From a688ae6ef540524282fa14d34898eca17c1efafe Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Wed, 25 Jan 2017 09:09:19 -0800 Subject: [PATCH] Telemetry for http/s links (fixes #19080) --- .../electron-browser/walkThroughPart.ts | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts b/src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts index e81774a6955..3422b16b78e 100644 --- a/src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts +++ b/src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts @@ -96,22 +96,25 @@ export class WalkThroughPart extends BaseEditor { let baseElement = window.document.getElementsByTagName('base')[0] || window.location; if (baseElement && node.href.indexOf(baseElement.href) >= 0 && node.hash) { let scrollTarget = this.content.querySelector(node.hash); + this.telemetryService.publicLog('revealInDocument', { + hash: node.hash, + broken: !scrollTarget, + from: this.input instanceof WalkThroughInput ? this.input.getTelemetryFrom() : undefined + }); if (scrollTarget) { const targetTop = scrollTarget.getBoundingClientRect().top; const containerTop = this.content.getBoundingClientRect().top; this.scrollbar.updateState({ scrollTop: targetTop - containerTop }); } } else { - const uri = this.addFrom(URI.parse(node.href)); - this.openerService.open(uri); + this.open(URI.parse(node.href)); } event.preventDefault(); break; } else if (node instanceof HTMLButtonElement) { const href = node.getAttribute('data-href'); if (href) { - const uri = this.addFrom(URI.parse(href)); - this.openerService.open(uri); + this.open(URI.parse(href)); } break; } else if (node === event.currentTarget) { @@ -121,12 +124,22 @@ export class WalkThroughPart extends BaseEditor { }); } + private open(uri: URI) { + if (uri.scheme === 'http' || uri.scheme === 'https') { + this.telemetryService.publicLog('openExternal', { + uri: uri.toString(true), + from: this.input instanceof WalkThroughInput ? this.input.getTelemetryFrom() : undefined + }); + } + this.openerService.open(this.addFrom(uri)); + } + private addFrom(uri: URI) { - if (uri.scheme !== 'command') { + if (uri.scheme !== 'command' || !(this.input instanceof WalkThroughInput)) { return uri; } const query = uri.query ? JSON.parse(uri.query) : {}; - query.from = (this.input).getTelemetryFrom(); + query.from = this.input.getTelemetryFrom(); return uri.with({ query: JSON.stringify(query) }); }