mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
[web] Subscription event segmentation GitOrigin-RevId: fdc25ac7bc7320ed82617b7c27c12a17eb31d723
23 lines
746 B
TypeScript
23 lines
746 B
TypeScript
import { PaidSubscription } from '@ol-types/subscription/dashboard/subscription'
|
|
import isInFreeTrial from './is-in-free-trial'
|
|
|
|
/**
|
|
* The shared segmentation for `subscription-page-*` analytics events, so that
|
|
* every event fired from the subscription dashboard can be compared against the
|
|
* `subscription-page-view` event recorded server side.
|
|
*/
|
|
export default function getSubscriptionEventSegmentation(
|
|
subscription?: PaidSubscription
|
|
) {
|
|
return {
|
|
plan_code: subscription?.planCode,
|
|
billing_cycle: subscription?.plan
|
|
? subscription.plan.annual
|
|
? 'annual'
|
|
: 'monthly'
|
|
: undefined,
|
|
is_trial: isInFreeTrial(subscription?.payment?.trialEndsAt),
|
|
currency: subscription?.payment?.currency,
|
|
}
|
|
}
|