Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/vs/workbench/services/chat/common/chatEntitlementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ function isAnonymous(configurationService: IConfigurationService, entitlement: C
return true;
}

function logChatEntitlements(state: IChatEntitlementContextState, configurationService: IConfigurationService, telemetryService: ITelemetryService): void {
telemetryService.publicLog2<ChatEntitlementEvent, ChatEntitlementClassification>('chatEntitlements', {
chatHidden: Boolean(state.hidden),
chatDisabled: Boolean(state.disabled),
chatEntitlement: state.entitlement,
chatRegistered: Boolean(state.registered),
chatAnonymous: isAnonymous(configurationService, state.entitlement, state)
});
}

export class ChatEntitlementService extends Disposable implements IChatEntitlementService {

declare _serviceBrand: undefined;
Expand All @@ -228,14 +238,16 @@ export class ChatEntitlementService extends Disposable implements IChatEntitleme
@IProductService productService: IProductService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IConfigurationService private readonly configurationService: IConfigurationService
@IConfigurationService private readonly configurationService: IConfigurationService,
@ITelemetryService private readonly telemetryService: ITelemetryService
) {
super();

this.chatQuotaExceededContextKey = ChatEntitlementContextKeys.chatQuotaExceeded.bindTo(this.contextKeyService);
this.completionsQuotaExceededContextKey = ChatEntitlementContextKeys.completionsQuotaExceeded.bindTo(this.contextKeyService);

this.anonymousContextKey = ChatEntitlementContextKeys.chatAnonymous.bindTo(this.contextKeyService);
this.anonymousContextKey.set(this.anonymous);

this.onDidChangeEntitlement = Event.map(
Event.filter(
Expand Down Expand Up @@ -372,6 +384,10 @@ export class ChatEntitlementService extends Disposable implements IChatEntitleme
anonymousUsage = newAnonymousUsage;
this.anonymousContextKey.set(newAnonymousUsage);

if (this.context?.hasValue) {
logChatEntitlements(this.context.value.state, this.configurationService, this.telemetryService);
}

this._onDidChangeAnonymous.fire();
}
};
Expand Down Expand Up @@ -1278,13 +1294,7 @@ export class ChatEntitlementContext extends Disposable {
this.registeredContext.set(!!state.registered);

this.logService.trace(`[chat entitlement context] updateContext(): ${JSON.stringify(state)}`);
this.telemetryService.publicLog2<ChatEntitlementEvent, ChatEntitlementClassification>('chatEntitlements', {
chatHidden: Boolean(state.hidden),
chatDisabled: Boolean(state.disabled),
chatEntitlement: state.entitlement,
chatRegistered: Boolean(state.registered),
chatAnonymous: isAnonymous(this.configurationService, state.entitlement, state)
});
logChatEntitlements(state, this.configurationService, this.telemetryService);

this._onDidChange.fire();
}
Expand Down
Loading