Merge pull request #23177 from overleaf/rh-pause-tracking

Add tracking for subscription-pause-scheduled event

GitOrigin-RevId: 802899e53d22f2be49f2d20adb45a4a47d0f6beb
This commit is contained in:
roo hutton
2025-01-30 09:59:22 +00:00
committed by Copybot
parent 4858efd06f
commit 347cade55f
3 changed files with 16 additions and 0 deletions
@@ -198,6 +198,20 @@ async function pauseSubscription(req, res, next) {
)
try {
await SubscriptionHandler.promises.pauseSubscription(user, pauseCycles)
const { subscription } =
await LimitationsManager.promises.userHasSubscription(user)
AnalyticsManager.recordEventForUserInBackground(
user._id,
'subscription-pause-scheduled',
{
pause_length: pauseCycles,
plan_code: subscription?.planCode,
subscriptionId: subscription?.id,
}
)
return res.sendStatus(200)
} catch (err) {
if (err instanceof Error) {
@@ -66,6 +66,7 @@ export default function PauseSubscriptionModal() {
const newUrl = new URL(location.toString())
newUrl.searchParams.set('flash', 'paused')
window.history.replaceState(null, '', newUrl)
location.reload()
} catch (err) {
debugConsole.error('error pausing subscription', err)
@@ -172,6 +172,7 @@ describe('SubscriptionController', function () {
'./Errors': SubscriptionErrors,
'../Analytics/AnalyticsManager': (this.AnalyticsManager = {
recordEventForUser: sinon.stub(),
recordEventForUserInBackground: sinon.stub(),
recordEventForSession: sinon.stub(),
setUserPropertyForUser: sinon.stub(),
}),