Skip to content

Commit

Permalink
chore(metrics): add metrics to identify who attempte to upgrade organ…
Browse files Browse the repository at this point in the history
…ization (#10432)
  • Loading branch information
tianrunhe authored Oct 30, 2024
1 parent 1b36b18 commit 62b610a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Stripe from 'stripe'
import {analytics} from '../../../utils/analytics/analytics'
import {getUserId} from '../../../utils/authorization'
import standardError from '../../../utils/standardError'
import {getStripeManager} from '../../../utils/stripe'
Expand Down Expand Up @@ -50,6 +51,7 @@ const createStripeSubscription: MutationResolvers['createStripeSubscription'] =
const paymentIntent = latestInvoice.payment_intent as Stripe.PaymentIntent
const clientSecret = paymentIntent.client_secret

analytics.organizationUpgradeAttempted(viewer, orgId)
const data = {stripeSubscriptionClientSecret: clientSecret}
return data
}
Expand Down
5 changes: 5 additions & 0 deletions packages/server/utils/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export type AnalyticsEvent =
| 'Notification Email Sent'
// org
| 'Upgrade CTA Clicked'
| 'Organization Upgrade Attempted'
| 'Organization Upgraded'
| 'Downgrade Clicked'
| 'Downgrade Continue Clicked'
Expand Down Expand Up @@ -506,6 +507,10 @@ class Analytics {
this.track(user, 'Upgrade CTA Clicked', {upgradeCTALocation})
}

organizationUpgradeAttempted = (user: AnalyticsUser, orgId: string) => {
this.track(user, 'Organization Upgrade Attempted', {orgId})
}

organizationUpgraded = (
user: AnalyticsUser,
upgradeEventProperties: OrgTierChangeEventProperties
Expand Down

0 comments on commit 62b610a

Please sign in to comment.