From a7e82b2d9bca367271e983bd88a1bea938520171 Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Thu, 19 Jan 2017 14:52:54 -0800 Subject: [PATCH] Add 'from' to telemetry events --- .../editor/editorWalkThrough.ts | 2 +- .../electron-browser/walkThroughPart.ts | 15 +++++++++++++-- .../walkThrough/node/walkThroughInput.ts | 19 ++++++++----------- .../electron-browser/welcomePage.ts | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/vs/workbench/parts/walkThrough/electron-browser/editor/editorWalkThrough.ts b/src/vs/workbench/parts/walkThrough/electron-browser/editor/editorWalkThrough.ts index b3b1080fddc..6b760bf53d9 100644 --- a/src/vs/workbench/parts/walkThrough/electron-browser/editor/editorWalkThrough.ts +++ b/src/vs/workbench/parts/walkThrough/electron-browser/editor/editorWalkThrough.ts @@ -31,7 +31,7 @@ export class EditorWalkThroughAction extends Action { public run(): TPromise { const uri = URI.parse(require.toUrl('./editorWalkThrough.md')) .with({ scheme: WALK_THROUGH_SCHEME }); - const input = this.instantiationService.createInstance(WalkThroughInput, localize('editorWalkThrough.title', "Editor Walk-Through"), '', uri, null); + const input = this.instantiationService.createInstance(WalkThroughInput, localize('editorWalkThrough.title', "Editor Walk-Through"), '', uri, /* telemetryFrom */ null, /* onReady */ null); return this.editorService.openEditor(input, { pinned: true }, Position.ONE) .then(() => void (0)); } diff --git a/src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts b/src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts index adf88703626..da21a0b14d3 100644 --- a/src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts +++ b/src/vs/workbench/parts/walkThrough/electron-browser/walkThroughPart.ts @@ -81,18 +81,29 @@ export class WalkThroughPart extends BaseEditor { scrollTarget.scrollIntoView(); } } else { - this.openerService.open(URI.parse(node.href)); + const uri = this.addFrom(URI.parse(node.href)); + this.openerService.open(uri); } event.preventDefault(); } else if (node instanceof HTMLButtonElement) { const href = node.getAttribute('data-href'); if (href) { - this.openerService.open(URI.parse(href)); + const uri = this.addFrom(URI.parse(href)); + this.openerService.open(uri); } } }); } + private addFrom(uri: URI) { + if (uri.scheme !== 'command') { + return uri; + } + const query = uri.query ? JSON.parse(uri.query) : {}; + query.from = (this.input).getTelemetryFrom(); + return uri.with({ query: JSON.stringify(query) }); + } + layout({ width, height }: Dimension): void { $(this.content).style({ height: `${height}px`, width: `${width}px` }); this.contentDisposables.forEach(disposable => { diff --git a/src/vs/workbench/parts/walkThrough/node/walkThroughInput.ts b/src/vs/workbench/parts/walkThrough/node/walkThroughInput.ts index 8d35fe629c0..f9e3d9cd923 100644 --- a/src/vs/workbench/parts/walkThrough/node/walkThroughInput.ts +++ b/src/vs/workbench/parts/walkThrough/node/walkThroughInput.ts @@ -43,23 +43,16 @@ export class WalkThroughInput extends EditorInput { static ID: string = 'workbench.editors.walkThroughInput'; private promise: TPromise; - private resource: URI; - - private name: string; - private description: string; constructor( - name: string, - description: string, - resource: URI, + private name: string, + private description: string, + private resource: URI, + private telemetryFrom: string, public readonly onReady: (container: HTMLElement) => void, @ITextModelResolverService private textModelResolverService: ITextModelResolverService ) { super(); - - this.name = name; - this.description = description; - this.resource = resource; } getResource(): URI { @@ -78,6 +71,10 @@ export class WalkThroughInput extends EditorInput { return this.description; } + getTelemetryFrom(): string { + return this.telemetryFrom || 'walkThrough'; + } + getTelemetryDescriptor(): { [key: string]: any; } { const descriptor = super.getTelemetryDescriptor(); descriptor['resource'] = telemetryURIDescriptor(this.resource); diff --git a/src/vs/workbench/parts/welcomePage/electron-browser/welcomePage.ts b/src/vs/workbench/parts/welcomePage/electron-browser/welcomePage.ts index 6ebb5cbde79..d00df9156cf 100644 --- a/src/vs/workbench/parts/welcomePage/electron-browser/welcomePage.ts +++ b/src/vs/workbench/parts/welcomePage/electron-browser/welcomePage.ts @@ -86,7 +86,7 @@ class WelcomePage { const recentlyOpened = this.windowService.getRecentlyOpen(); const uri = URI.parse(require.toUrl('./welcomePage.html')) .with({ scheme: WALK_THROUGH_SCHEME }); - const input = this.instantiationService.createInstance(WalkThroughInput, localize('welcome.title', "Welcome"), '', uri, container => this.onReady(container, recentlyOpened)); + const input = this.instantiationService.createInstance(WalkThroughInput, localize('welcome.title', "Welcome"), '', uri, 'welcomePage', container => this.onReady(container, recentlyOpened)); this.editorService.openEditor(input, { pinned: true }, Position.ONE) .then(null, onUnexpectedError); } -- GitLab