Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/sparrowadmin-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Sparrow-admin-Stg
on:
push:
branches:
- release/2.36.0
- release/2.38.0
workflow_dispatch:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sparrow-admin-app",
"private": true,
"version": "2.36.0",
"version": "2.38.0",
"type": "module",
"scripts": {
"dev": "vite --host",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/pages/TrialFlow/TrialFlow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/pages/UserTrialFlow/UserTrialFlow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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') {
Expand Down
45 changes: 27 additions & 18 deletions src/utils/posthogConfig.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
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) {
posthog.init(POSTHOG_API_KEY, {
api_host: 'https://us.i.posthog.com',

person_profiles: 'always',
})

isInitialized = true
capture_exceptions: true,
});

return true
}
isInitialized = true;

return false
}
return true;
}
return false;
};

export const captureEvent = (
eventName: string,
export const captureEvent = (eventName: string, properties?: Record<string, any>) => {
if (!isInitialized) {
initPostHog();
}
posthog.capture(eventName, properties);
};

export const captureException = (
error: Error | unknown,
properties?: Record<string, any>,
) => {
posthog.capture(eventName, properties)
}
): void => {
if (!isInitialized) {
initPostHog();
}
posthog.captureException(error, properties);
};

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
export const posthogClient = posthog;
Loading