Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit b9506e8

Browse files
authored
Log hover events only when tooltip is displayed (mimic logic from sou… (#57)
* Log hover events only when tooltip is displayed (mimic logic from sourcegraph.com) * Prevent leaks
1 parent e1ddf50 commit b9506e8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/components/BlobAnnotator.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export class BlobAnnotator extends React.Component<Props, State> {
272272
.map(data => ({ target: data.target, ctx: { ...this.props, position: data.loc! } }))
273273
.switchMap(({ target, ctx }) => {
274274
const tooltip = this.getTooltip(target, ctx)
275-
tooltip.subscribe(() => eventLogger.logHover(this.getEventLoggerProps()))
275+
this.subscriptions.add(tooltip.subscribe(this.logTelemetryOnTooltip))
276276
const tooltipWithJ2D: Observable<TooltipData> = tooltip
277277
.zip(this.getDefinition(ctx))
278278
.map(([tooltip, defUrl]) => ({ ...tooltip, defUrl: defUrl || undefined }))
@@ -349,6 +349,18 @@ export class BlobAnnotator extends React.Component<Props, State> {
349349
)
350350
}
351351

352+
private logTelemetryOnTooltip = (data: TooltipData) => {
353+
// If another tooltip is visible for the diff, ignore this mouseover.
354+
if (isTooltipVisible(this.props, !this.props.isBase) || isOtherFileTooltipVisible(this.props)) {
355+
return
356+
}
357+
// Only log an event if there is no fixed tooltip docked, we have a
358+
// target element, and we have tooltip contents
359+
if (!this.state.fixedTooltip && data.target && data.contents) {
360+
eventLogger.logHover(this.getEventLoggerProps())
361+
}
362+
}
363+
352364
private diffSpec = () => {
353365
const spec: MaybeDiffSpec = {
354366
isDelta: this.isDelta,

0 commit comments

Comments
 (0)