提交 a7e82b2d 编写于 作者: C Christof Marti

Add 'from' to telemetry events

上级 851ed825
......@@ -31,7 +31,7 @@ export class EditorWalkThroughAction extends Action {
public run(): TPromise<void> {
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));
}
......
......@@ -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 = (<WalkThroughInput>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 => {
......
......@@ -43,23 +43,16 @@ export class WalkThroughInput extends EditorInput {
static ID: string = 'workbench.editors.walkThroughInput';
private promise: TPromise<WalkThroughModel>;
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);
......
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册