From a08075b61d02bfcd751e1661f29613c87ec4c64b Mon Sep 17 00:00:00 2001 From: LordNayan Date: Thu, 19 Mar 2026 08:57:44 +0530 Subject: [PATCH 1/3] feat: add subscription confirmed message[SPRW-3129] --- .../PaymentMethodSelectionPage.svelte | 7 +++++++ src/pages/TrialFlow/TrialFlow.svelte | 9 +++++++++ src/pages/UserTrialFlow/UserTrialFlow.svelte | 9 +++++++++ src/utils/posthogConfig.ts | 12 ++++++++++++ 4 files changed, 37 insertions(+) diff --git a/src/pages/Payment/PaymentInformation/PaymentMethodSelectionPage.svelte b/src/pages/Payment/PaymentInformation/PaymentMethodSelectionPage.svelte index ca0f454d..1917d269 100644 --- a/src/pages/Payment/PaymentInformation/PaymentMethodSelectionPage.svelte +++ b/src/pages/Payment/PaymentInformation/PaymentMethodSelectionPage.svelte @@ -119,6 +119,13 @@ onPaymentSuccess: (data) => { console.log('Payment success:', data); const { team } = data; + // PostHog event for subscription confirmation + captureEvent('subscription_confirmed', { + hubName: team?.name || '', + planName, + userCount, + nextBilling: team?.billing?.current_period_end, + }); setTimeout(() => { isProcessing = false; showProcessingModal = false; diff --git a/src/pages/TrialFlow/TrialFlow.svelte b/src/pages/TrialFlow/TrialFlow.svelte index 91e0a83e..97963e4a 100644 --- a/src/pages/TrialFlow/TrialFlow.svelte +++ b/src/pages/TrialFlow/TrialFlow.svelte @@ -13,6 +13,8 @@ import { API_BASE_URL } from '@/constants/environment'; import { notification } from '@/components/Toast'; import { navigate } from 'svelte-routing'; + import { captureEvent } from '@/utils/posthogConfig'; + let _viewModel = new TrialFlowViewModel(); let currentStep = 1; @@ -247,6 +249,13 @@ console.log('Payment success team:', team); let formatTeamData: { email: string; role: string }[] = []; let userCount = 1; + // PostHog event for subscription confirmation + captureEvent('subscription_confirmed', { + hubName: team?.name || '', + planName: 'Standard', + userCount: triggerPoint === 'finish' ? teamdata.length : 1, + nextBilling: team?.billing?.current_period_end, + }); setTimeout(async () => { if (triggerPoint === 'finish') { formatTeamData = teamdata diff --git a/src/pages/UserTrialFlow/UserTrialFlow.svelte b/src/pages/UserTrialFlow/UserTrialFlow.svelte index f851da8f..2ed39877 100644 --- a/src/pages/UserTrialFlow/UserTrialFlow.svelte +++ b/src/pages/UserTrialFlow/UserTrialFlow.svelte @@ -14,6 +14,8 @@ import { notification } from '@/components/Toast'; import DropdownNoSearch from '@/components/DropdownNoSearch/DropdownNoSearch.svelte'; import { navigate } from 'svelte-routing'; + import { captureEvent } from '@/utils/posthogConfig'; + let _viewModel = new TrialFlowViewModel(); let currentStep = 1; @@ -394,6 +396,13 @@ console.log('Payment success team:', team); let formatTeamData: { email: string; role: string }[] = []; let userCount = 1; + // PostHog event for subscription confirmation + captureEvent('subscription_confirmed', { + hubName: team?.name || '', + planName: planTier, + userCount: triggerPoint === 'finish' ? teamdata.length : 1, + nextBilling: team?.billing?.current_period_end, + }); if (invoice?.amount_paid === 0) { setTimeout(async () => { if (triggerPoint === 'finish') { diff --git a/src/utils/posthogConfig.ts b/src/utils/posthogConfig.ts index 0aaf7ee7..7add6bf0 100644 --- a/src/utils/posthogConfig.ts +++ b/src/utils/posthogConfig.ts @@ -9,6 +9,8 @@ export const initPostHog = () => { api_host: 'https://us.i.posthog.com', person_profiles: 'always', + + capture_exceptions: true, }) isInitialized = true @@ -27,6 +29,16 @@ export const captureEvent = ( posthog.capture(eventName, properties) } +export const captureException = ( + error: Error | unknown, + properties?: Record, +): void => { + if (!isInitialized) { + initPostHog(); + } + posthog.captureException(error, properties); +}; + export const identifyUser = (email: string): void => { if (!posthog) { console.error('PostHog is not initialized'); From d46bea11dacdb58a6697e952b657bdc6fdaa8e99 Mon Sep 17 00:00:00 2001 From: LordNayan Date: Wed, 25 Mar 2026 06:40:49 +0530 Subject: [PATCH 2/3] fix: init posthog on captureEvent --- src/utils/posthogConfig.ts | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/utils/posthogConfig.ts b/src/utils/posthogConfig.ts index 7add6bf0..608d2e78 100644 --- a/src/utils/posthogConfig.ts +++ b/src/utils/posthogConfig.ts @@ -1,7 +1,7 @@ -import posthog from 'posthog-js' -import { POSTHOG_API_KEY } from '@/constants/environment' +import posthog from 'posthog-js'; +import { POSTHOG_API_KEY } from '@/constants/environment'; -let isInitialized = false +let isInitialized = false; export const initPostHog = () => { if (!isInitialized) { @@ -11,23 +11,21 @@ export const initPostHog = () => { person_profiles: 'always', capture_exceptions: true, - }) + }); - isInitialized = true + isInitialized = true; - return true + return true; } + return false; +}; - return false -} - -export const captureEvent = ( - eventName: string, - - properties?: Record, -) => { - posthog.capture(eventName, properties) -} +export const captureEvent = (eventName: string, properties?: Record) => { + if (!isInitialized) { + initPostHog(); + } + posthog.capture(eventName, properties); +}; export const captureException = ( error: Error | unknown, @@ -40,11 +38,10 @@ export const captureException = ( }; export const identifyUser = (email: string): void => { - if (!posthog) { - console.error('PostHog is not initialized'); - return; + if (!isInitialized) { + initPostHog(); } posthog.identify(email); }; -export const posthogClient = posthog \ No newline at end of file +export const posthogClient = posthog; From aa92d9f2999ed7c04831d7504731323903065e53 Mon Sep 17 00:00:00 2001 From: LordNayan Date: Wed, 25 Mar 2026 11:20:24 +0530 Subject: [PATCH 3/3] build: version bump --- .github/workflows/sparrowadmin-staging.yml | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sparrowadmin-staging.yml b/.github/workflows/sparrowadmin-staging.yml index 4672c16a..2bea6cd8 100644 --- a/.github/workflows/sparrowadmin-staging.yml +++ b/.github/workflows/sparrowadmin-staging.yml @@ -2,7 +2,7 @@ name: Sparrow-admin-Stg on: push: branches: - - release/2.36.0 + - release/2.38.0 workflow_dispatch: jobs: diff --git a/package-lock.json b/package-lock.json index d4e126e1..605e223c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sparrow-admin-app", - "version": "2.36.0", + "version": "2.38.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sparrow-admin-app", - "version": "2.36.0", + "version": "2.38.0", "dependencies": { "@tailwindcss/vite": "^4.1.4", "@tanstack/svelte-table": "^8.21.3", diff --git a/package.json b/package.json index c2947d95..8c4c343c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sparrow-admin-app", "private": true, - "version": "2.36.0", + "version": "2.38.0", "type": "module", "scripts": { "dev": "vite --host",