mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #25404 from overleaf/mf-send-subscription-analytics-events
[web] Send analytics events and user properties when user start subscription using Stripe GitOrigin-RevId: 9028397a5cb256df506e14beb1705191c9ae3f7f
This commit is contained in:
@@ -66,6 +66,7 @@ async function _sendSubscriptionResumedEvent(userId, eventData) {
|
||||
{
|
||||
plan_code: planCode,
|
||||
subscriptionId,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
AnalyticsManager.setUserPropertyForUserInBackground(
|
||||
@@ -87,6 +88,7 @@ async function _sendSubscriptionPausedEvent(userId, eventData) {
|
||||
pause_length: pauseLength,
|
||||
plan_code: planCode,
|
||||
subscriptionId,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
AnalyticsManager.setUserPropertyForUserInBackground(
|
||||
@@ -108,6 +110,7 @@ async function _sendSubscriptionStartedEvent(userId, eventData) {
|
||||
is_trial: isTrial,
|
||||
has_ai_add_on: hasAiAddOn,
|
||||
subscriptionId,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
AnalyticsManager.setUserPropertyForUserInBackground(
|
||||
@@ -154,6 +157,7 @@ async function _sendSubscriptionUpdatedEvent(userId, eventData) {
|
||||
is_trial: isTrial,
|
||||
has_ai_add_on: hasAiAddOn,
|
||||
subscriptionId,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
AnalyticsManager.setUserPropertyForUserInBackground(
|
||||
@@ -185,6 +189,7 @@ async function _sendSubscriptionCancelledEvent(userId, eventData) {
|
||||
is_trial: isTrial,
|
||||
has_ai_add_on: hasAiAddOn,
|
||||
subscriptionId,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
AnalyticsManager.setUserPropertyForUserInBackground(
|
||||
@@ -211,6 +216,7 @@ async function _sendSubscriptionExpiredEvent(userId, eventData) {
|
||||
is_trial: isTrial,
|
||||
has_ai_add_on: hasAiAddOn,
|
||||
subscriptionId,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
AnalyticsManager.setUserPropertyForUserInBackground(
|
||||
@@ -242,6 +248,7 @@ async function _sendSubscriptionRenewedEvent(userId, eventData) {
|
||||
is_trial: isTrial,
|
||||
has_ai_add_on: hasAiAddOn,
|
||||
subscriptionId,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
AnalyticsManager.setUserPropertyForUserInBackground(
|
||||
@@ -272,6 +279,7 @@ async function _sendSubscriptionReactivatedEvent(userId, eventData) {
|
||||
quantity,
|
||||
has_ai_add_on: hasAiAddOn,
|
||||
subscriptionId,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
AnalyticsManager.setUserPropertyForUserInBackground(
|
||||
@@ -318,6 +326,7 @@ async function _sendInvoicePaidEvent(userId, eventData) {
|
||||
taxInCents,
|
||||
country,
|
||||
collectionMethod,
|
||||
payment_provider: 'recurly',
|
||||
...subscriptionIds,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -62,6 +62,7 @@ describe('RecurlyEventHandler', function () {
|
||||
is_trial: true,
|
||||
has_ai_add_on: false,
|
||||
subscriptionId: this.eventData.subscription.uuid,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
sinon.assert.calledWith(
|
||||
@@ -116,6 +117,7 @@ describe('RecurlyEventHandler', function () {
|
||||
is_trial: false,
|
||||
has_ai_add_on: false,
|
||||
subscriptionId: this.eventData.subscription.uuid,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
sinon.assert.calledWith(
|
||||
@@ -149,6 +151,7 @@ describe('RecurlyEventHandler', function () {
|
||||
is_trial: true,
|
||||
has_ai_add_on: false,
|
||||
subscriptionId: this.eventData.subscription.uuid,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
sinon.assert.calledWith(
|
||||
@@ -187,6 +190,7 @@ describe('RecurlyEventHandler', function () {
|
||||
is_trial: true,
|
||||
has_ai_add_on: false,
|
||||
subscriptionId: this.eventData.subscription.uuid,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
sinon.assert.calledWith(
|
||||
@@ -219,6 +223,7 @@ describe('RecurlyEventHandler', function () {
|
||||
is_trial: true,
|
||||
has_ai_add_on: false,
|
||||
subscriptionId: this.eventData.subscription.uuid,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
sinon.assert.calledWith(
|
||||
@@ -256,6 +261,7 @@ describe('RecurlyEventHandler', function () {
|
||||
is_trial: true,
|
||||
has_ai_add_on: false,
|
||||
subscriptionId: this.eventData.subscription.uuid,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -274,6 +280,7 @@ describe('RecurlyEventHandler', function () {
|
||||
quantity: 1,
|
||||
has_ai_add_on: false,
|
||||
subscriptionId: this.eventData.subscription.uuid,
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -313,6 +320,7 @@ describe('RecurlyEventHandler', function () {
|
||||
collectionMethod: invoice.collection_method,
|
||||
subscriptionId1: invoice.subscription_ids[0],
|
||||
subscriptionId2: invoice.subscription_ids[1],
|
||||
payment_provider: 'recurly',
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import Stripe from 'stripe'
|
||||
|
||||
type StripeWebhookEventType =
|
||||
| 'customer.subscription.created'
|
||||
| 'customer.subscription.updated'
|
||||
@@ -6,8 +8,7 @@ type StripeWebhookEventType =
|
||||
export type CustomerSubscriptionWebhookEvent = {
|
||||
type: StripeWebhookEventType
|
||||
data: {
|
||||
object: {
|
||||
id: string
|
||||
object: Stripe.Subscription & {
|
||||
metadata: {
|
||||
adminUserId?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user