mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
feat: fire subscription_success telemetry on subscription activation
Wire trackMonthlySubscriptionSucceeded() into both subscription detection paths so GTM receives a client-side subscription_success event for ad platform conversion tags (LinkedIn, Meta): - Legacy flow: SubscriptionRequiredDialogContent watcher - Workspace flow: billingOperationStore.handleSuccess() Uses subscription_success (not purchase) to avoid double-counting with the server-side GA4 Measurement Protocol purchase event and the existing Google Ads Purchase conversion tag in GTM.
This commit is contained in:
@@ -236,6 +236,7 @@ watch(
|
||||
() => isActiveSubscription.value,
|
||||
(isActive) => {
|
||||
if (isActive && showCustomPricingTable.value) {
|
||||
telemetry?.trackMonthlySubscriptionSucceeded()
|
||||
emit('close', true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,14 @@ vi.mock('@/stores/dialogStore', () => ({
|
||||
})
|
||||
}))
|
||||
|
||||
const mockTrackMonthlySubscriptionSucceeded = vi.fn()
|
||||
|
||||
vi.mock('@/platform/telemetry', () => ({
|
||||
useTelemetry: () => ({
|
||||
trackMonthlySubscriptionSucceeded: mockTrackMonthlySubscriptionSucceeded
|
||||
})
|
||||
}))
|
||||
|
||||
import { workspaceApi } from '@/platform/workspace/api/workspaceApi'
|
||||
|
||||
import { useBillingOperationStore } from './billingOperationStore'
|
||||
@@ -159,6 +167,37 @@ describe('billingOperationStore', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('fires purchase telemetry on subscription success', async () => {
|
||||
vi.mocked(workspaceApi.getBillingOpStatus).mockResolvedValue({
|
||||
id: 'op-1',
|
||||
status: 'succeeded',
|
||||
started_at: new Date().toISOString(),
|
||||
completed_at: new Date().toISOString()
|
||||
})
|
||||
|
||||
const store = useBillingOperationStore()
|
||||
store.startOperation('op-1', 'subscription')
|
||||
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
|
||||
expect(mockTrackMonthlySubscriptionSucceeded).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('does not fire purchase telemetry on topup success', async () => {
|
||||
vi.mocked(workspaceApi.getBillingOpStatus).mockResolvedValue({
|
||||
id: 'op-1',
|
||||
status: 'succeeded',
|
||||
started_at: new Date().toISOString()
|
||||
})
|
||||
|
||||
const store = useBillingOperationStore()
|
||||
store.startOperation('op-1', 'topup')
|
||||
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
|
||||
expect(mockTrackMonthlySubscriptionSucceeded).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('shows topup success message for topup operations', async () => {
|
||||
vi.mocked(workspaceApi.getBillingOpStatus).mockResolvedValue({
|
||||
id: 'op-1',
|
||||
|
||||
@@ -4,6 +4,7 @@ import { computed, ref } from 'vue'
|
||||
|
||||
import { useBillingContext } from '@/composables/billing/useBillingContext'
|
||||
import { t } from '@/i18n'
|
||||
import { useTelemetry } from '@/platform/telemetry'
|
||||
import { useToastStore } from '@/platform/updates/common/toastStore'
|
||||
import { workspaceApi } from '@/platform/workspace/api/workspaceApi'
|
||||
import { useSettingsDialog } from '@/platform/settings/composables/useSettingsDialog'
|
||||
@@ -133,6 +134,10 @@ export const useBillingOperationStore = defineStore('billingOperation', () => {
|
||||
updateOperationStatus(opId, 'succeeded', null)
|
||||
cleanup(opId)
|
||||
|
||||
if (operation.type === 'subscription') {
|
||||
useTelemetry()?.trackMonthlySubscriptionSucceeded()
|
||||
}
|
||||
|
||||
const billingContext = useBillingContext()
|
||||
await Promise.all([
|
||||
billingContext.fetchStatus(),
|
||||
|
||||
Reference in New Issue
Block a user