Merge pull request #36496 from overleaf/oa-annual-events

[web] Subscription event segmentation

GitOrigin-RevId: fdc25ac7bc7320ed82617b7c27c12a17eb31d723
This commit is contained in:
Olzhas Askar
2026-09-17 11:59:20 +00:00
committed by Copybot
parent ba4e6ef8ed
commit 6053781e57
14 changed files with 305 additions and 47 deletions
@@ -29,7 +29,11 @@ async function sendRecurlyAnalyticsEvent(event, eventData) {
await _sendSubscriptionStartedEvent(userId, eventData)
break
case 'updated_subscription_notification':
await _sendSubscriptionUpdatedEvent(userId, eventData)
await _sendSubscriptionUpdatedEvent(
userId,
eventData,
subscription?.planCode
)
break
case 'canceled_subscription_notification':
await _sendSubscriptionCancelledEvent(userId, eventData)
@@ -146,7 +150,11 @@ async function _sendSubscriptionStartedEvent(userId, eventData) {
}
}
async function _sendSubscriptionUpdatedEvent(userId, eventData) {
async function _sendSubscriptionUpdatedEvent(
userId,
eventData,
planCodeBeforeSync
) {
const { planCode, quantity, state, isTrial, hasAiAddOn, subscriptionId } =
_getSubscriptionData(eventData)
AnalyticsManager.recordEventForUserInBackground(
@@ -154,6 +162,10 @@ async function _sendSubscriptionUpdatedEvent(userId, eventData) {
'subscription-updated',
{
plan_code: planCode,
// Mongo sync might already have happened,
// we only want to record when it haven't yet.
previous_plan_code:
planCodeBeforeSync !== planCode ? planCodeBeforeSync : undefined,
quantity,
is_trial: isTrial,
has_ai_add_on: hasAiAddOn,