Skip to content

Commit

Permalink
feat(audoedit): update billing categories (#6591)
Browse files Browse the repository at this point in the history
- Addressing the feedback from [this review
comment](#6430 (comment))
by marking `discarded` events as `billable`.
  • Loading branch information
valerybugakov authored Jan 10, 2025
1 parent 496f539 commit ddb6e7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ describe('AutoeditAnalyticsLogger', () => {
expect(discardedEventPayload).toMatchInlineSnapshot(`
{
"billingMetadata": {
"category": "core",
"category": "billable",
"product": "cody",
},
"interactionID": undefined,
Expand Down
19 changes: 13 additions & 6 deletions vscode/src/autoedits/analytics-logger/analytics-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ type AutoeditEventAction =
| 'error'
| `invalidTransitionTo${Capitalize<Phase>}`

const AUTOEDIT_EVENT_BILLING_CATEGORY: Partial<Record<AutoeditEventAction, BillingCategory>> = {
accepted: 'core',
discarded: 'billable',
suggested: 'billable',
}

/**
* Specialized string type for referencing error messages in our rate-limiting map.
*/
Expand Down Expand Up @@ -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,
Expand All @@ -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,
},
}),
},
})
}
Expand Down

0 comments on commit ddb6e7c

Please sign in to comment.