-
Notifications
You must be signed in to change notification settings - Fork 12.9k
send begin/end notifications when installing types packages #12551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,7 +198,7 @@ namespace ts.server { | |
private socket: NodeSocket; | ||
private projectService: ProjectService; | ||
private throttledOperations: ThrottledOperations; | ||
private telemetrySender: EventSender; | ||
private eventSender: EventSender; | ||
|
||
constructor( | ||
private readonly telemetryEnabled: boolean, | ||
|
@@ -231,7 +231,7 @@ namespace ts.server { | |
} | ||
|
||
setTelemetrySender(telemetrySender: EventSender) { | ||
this.telemetrySender = telemetrySender; | ||
this.eventSender = telemetrySender; | ||
} | ||
|
||
attach(projectService: ProjectService) { | ||
|
@@ -291,12 +291,30 @@ namespace ts.server { | |
}); | ||
} | ||
|
||
private handleMessage(response: SetTypings | InvalidateCachedTypings | TypingsInstallEvent) { | ||
private handleMessage(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes) { | ||
if (this.logger.hasLevel(LogLevel.verbose)) { | ||
this.logger.info(`Received response: ${JSON.stringify(response)}`); | ||
} | ||
if (response.kind === EventInstall) { | ||
if (this.telemetrySender) { | ||
|
||
if (response.kind === EventBeginInstallTypes) { | ||
if (!this.eventSender) { | ||
return; | ||
} | ||
const body: protocol.BeginInstallTypesEventBody = { | ||
eventId: response.eventId, | ||
packages: response.packagesToInstall, | ||
}; | ||
const eventName: protocol.BeginInstallTypesEventName = "beginInstallTypes"; | ||
this.eventSender.event(body, eventName); | ||
|
||
return; | ||
} | ||
|
||
if (response.kind === EventEndInstallTypes) { | ||
if (!this.eventSender) { | ||
return; | ||
} | ||
if (this.telemetryEnabled) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we still need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reasoning behind this was: these events are semantically different. one is intended to be consumed only in the editor, another - send by VSCode on our behalf. In theory the latter one can be sent by just grabbing the payload and sending it as is treating its content as opaque. Yes, in this case VSCode can reconstruct telemetry event from the content of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think that keeping both makes sense since they are used for different purposes. |
||
const body: protocol.TypingsInstalledTelemetryEventBody = { | ||
telemetryEventName: "typingsInstalled", | ||
payload: { | ||
|
@@ -306,10 +324,19 @@ namespace ts.server { | |
} | ||
}; | ||
const eventName: protocol.TelemetryEventName = "telemetry"; | ||
this.telemetrySender.event(body, eventName); | ||
this.eventSender.event(body, eventName); | ||
} | ||
|
||
const body: protocol.EndInstallTypesEventBody = { | ||
eventId: response.eventId, | ||
packages: response.packagesToInstall, | ||
success: response.installSuccess, | ||
}; | ||
const eventName: protocol.EndInstallTypesEventName = "endInstallTypes"; | ||
this.eventSender.event(body, eventName); | ||
return; | ||
} | ||
|
||
this.projectService.updateTypingsForProject(response); | ||
if (response.kind == ActionSet && this.socket) { | ||
this.sendEvent(0, "setTypings", response); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing
typingsInstallerVersion
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this event should be consumed only by editor so this information is unnecessary.