From ddb6e7c6cc5339bdcead66f56c1d41df95304159 Mon Sep 17 00:00:00 2001 From: Valery Bugakov Date: Fri, 10 Jan 2025 23:40:49 +0800 Subject: [PATCH] feat(audoedit): update billing categories (#6591) - Addressing the feedback from [this review comment](https://github.com/sourcegraph/cody/pull/6430#discussion_r1901015283) by marking `discarded` events as `billable`. --- .../analytics-logger/analytics-logger.test.ts | 2 +- .../analytics-logger/analytics-logger.ts | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/vscode/src/autoedits/analytics-logger/analytics-logger.test.ts b/vscode/src/autoedits/analytics-logger/analytics-logger.test.ts index 5e472c1ed534..74dcb5b792ed 100644 --- a/vscode/src/autoedits/analytics-logger/analytics-logger.test.ts +++ b/vscode/src/autoedits/analytics-logger/analytics-logger.test.ts @@ -314,7 +314,7 @@ describe('AutoeditAnalyticsLogger', () => { expect(discardedEventPayload).toMatchInlineSnapshot(` { "billingMetadata": { - "category": "core", + "category": "billable", "product": "cody", }, "interactionID": undefined, diff --git a/vscode/src/autoedits/analytics-logger/analytics-logger.ts b/vscode/src/autoedits/analytics-logger/analytics-logger.ts index af4b7fd5b65d..fde639452338 100644 --- a/vscode/src/autoedits/analytics-logger/analytics-logger.ts +++ b/vscode/src/autoedits/analytics-logger/analytics-logger.ts @@ -367,6 +367,12 @@ type AutoeditEventAction = | 'error' | `invalidTransitionTo${Capitalize}` +const AUTOEDIT_EVENT_BILLING_CATEGORY: Partial> = { + accepted: 'core', + discarded: 'billable', + suggested: 'billable', +} + /** * Specialized string type for referencing error messages in our rate-limiting map. */ @@ -697,6 +703,7 @@ export class AutoeditAnalyticsLogger { state.suggestionLoggedAt = getTimeNowInMillis() const { metadata, privateMetadata } = splitSafeMetadata(payload) + const billingCategory = AUTOEDIT_EVENT_BILLING_CATEGORY[action] this.writeAutoeditEvent({ action, @@ -710,12 +717,12 @@ export class AutoeditAnalyticsLogger { recordsPrivateMetadataTranscript: 'prediction' in privateMetadata ? 1 : 0, }, privateMetadata, - billingMetadata: { - product: 'cody', - // TODO: double check with the analytics team - // whether we should be categorizing the different completion event types. - category: action === 'suggested' ? 'billable' : 'core', - }, + ...(billingCategory && { + billingMetadata: { + product: 'cody', + category: billingCategory, + }, + }), }, }) }