Skip to content

Commit 7cf393e

Browse files
committed
Revert "feat: add cloud gtm injection (#8311)"
This reverts commit 788f508.
1 parent 2bf1629 commit 7cf393e

File tree

9 files changed

+2
-276
lines changed

9 files changed

+2
-276
lines changed

global.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ interface Window {
3030
badge?: string
3131
}
3232
}
33-
dataLayer?: Array<Record<string, unknown>>
3433
}
3534

3635
interface Navigator {

src/main.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ if (isCloud) {
3131
const { refreshRemoteConfig } =
3232
await import('@/platform/remoteConfig/refreshRemoteConfig')
3333
await refreshRemoteConfig({ useAuth: false })
34-
35-
const { initGtm } = await import('@/platform/telemetry/gtm')
36-
initGtm()
3734
}
3835

3936
const ComfyUIPreset = definePreset(Aura, {

src/platform/cloud/subscription/composables/useSubscription.test.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -206,45 +206,6 @@ describe('useSubscription', () => {
206206
)
207207
})
208208

209-
it('pushes purchase event after a pending subscription completes', async () => {
210-
window.dataLayer = []
211-
localStorage.setItem(
212-
'pending_subscription_purchase',
213-
JSON.stringify({
214-
tierKey: 'creator',
215-
billingCycle: 'monthly',
216-
timestamp: Date.now()
217-
})
218-
)
219-
220-
vi.mocked(global.fetch).mockResolvedValue({
221-
ok: true,
222-
json: async () => ({
223-
is_active: true,
224-
subscription_id: 'sub_123',
225-
subscription_tier: 'CREATOR',
226-
subscription_duration: 'MONTHLY'
227-
})
228-
} as Response)
229-
230-
mockIsLoggedIn.value = true
231-
const { fetchStatus } = useSubscription()
232-
233-
await fetchStatus()
234-
235-
expect(window.dataLayer).toHaveLength(1)
236-
expect(window.dataLayer?.[0]).toMatchObject({
237-
event: 'purchase',
238-
transaction_id: 'sub_123',
239-
currency: 'USD',
240-
item_id: 'monthly_creator',
241-
item_variant: 'monthly',
242-
item_category: 'subscription',
243-
quantity: 1
244-
})
245-
expect(localStorage.getItem('pending_subscription_purchase')).toBeNull()
246-
})
247-
248209
it('should handle fetch errors gracefully', async () => {
249210
vi.mocked(global.fetch).mockResolvedValue({
250211
ok: false,

src/platform/cloud/subscription/composables/useSubscription.ts

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,12 @@ import { getComfyApiBaseUrl, getComfyPlatformBaseUrl } from '@/config/comfyApi'
88
import { t } from '@/i18n'
99
import { isCloud } from '@/platform/distribution/types'
1010
import { useTelemetry } from '@/platform/telemetry'
11-
import { pushDataLayerEvent } from '@/platform/telemetry/gtm'
1211
import {
1312
FirebaseAuthStoreError,
1413
useFirebaseAuthStore
1514
} from '@/stores/firebaseAuthStore'
1615
import { useDialogService } from '@/services/dialogService'
17-
import {
18-
getTierPrice,
19-
TIER_TO_KEY
20-
} from '@/platform/cloud/subscription/constants/tierPricing'
21-
import {
22-
clearPendingSubscriptionPurchase,
23-
getPendingSubscriptionPurchase
24-
} from '@/platform/cloud/subscription/utils/subscriptionPurchaseTracker'
16+
import { TIER_TO_KEY } from '@/platform/cloud/subscription/constants/tierPricing'
2517
import type { operations } from '@/types/comfyRegistryTypes'
2618
import { useSubscriptionCancellationWatcher } from './useSubscriptionCancellationWatcher'
2719

@@ -101,42 +93,7 @@ function useSubscriptionInternal() {
10193
: baseName
10294
})
10395

104-
function buildApiUrl(path: string): string {
105-
return `${getComfyApiBaseUrl()}${path}`
106-
}
107-
108-
function trackSubscriptionPurchase(
109-
status: CloudSubscriptionStatusResponse | null
110-
): void {
111-
if (!status?.is_active || !status.subscription_id) return
112-
113-
const pendingPurchase = getPendingSubscriptionPurchase()
114-
if (!pendingPurchase) return
115-
116-
const { tierKey, billingCycle } = pendingPurchase
117-
const isYearly = billingCycle === 'yearly'
118-
const baseName = t(`subscription.tiers.${tierKey}.name`)
119-
const planName = isYearly
120-
? t('subscription.tierNameYearly', { name: baseName })
121-
: baseName
122-
const unitPrice = getTierPrice(tierKey, isYearly)
123-
const value = isYearly && tierKey !== 'founder' ? unitPrice * 12 : unitPrice
124-
125-
pushDataLayerEvent({
126-
event: 'purchase',
127-
transaction_id: status.subscription_id,
128-
value,
129-
currency: 'USD',
130-
item_id: `${billingCycle}_${tierKey}`,
131-
item_name: planName,
132-
item_category: 'subscription',
133-
item_variant: billingCycle,
134-
price: value,
135-
quantity: 1
136-
})
137-
138-
clearPendingSubscriptionPurchase()
139-
}
96+
const buildApiUrl = (path: string) => `${getComfyApiBaseUrl()}${path}`
14097

14198
const fetchStatus = wrapWithErrorHandlingAsync(
14299
fetchSubscriptionStatus,
@@ -237,12 +194,6 @@ function useSubscriptionInternal() {
237194

238195
const statusData = await response.json()
239196
subscriptionStatus.value = statusData
240-
241-
try {
242-
await trackSubscriptionPurchase(statusData)
243-
} catch (error) {
244-
console.error('Failed to track subscription purchase', error)
245-
}
246197
return statusData
247198
}
248199

src/platform/cloud/subscription/utils/subscriptionCheckoutUtil.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
useFirebaseAuthStore
77
} from '@/stores/firebaseAuthStore'
88
import type { TierKey } from '@/platform/cloud/subscription/constants/tierPricing'
9-
import { startSubscriptionPurchaseTracking } from '@/platform/cloud/subscription/utils/subscriptionPurchaseTracker'
109
import type { BillingCycle } from './subscriptionTierRank'
1110

1211
type CheckoutTier = TierKey | `${TierKey}-yearly`
@@ -79,7 +78,6 @@ export async function performSubscriptionCheckout(
7978
const data = await response.json()
8079

8180
if (data.checkout_url) {
82-
startSubscriptionPurchaseTracking(tierKey, currentBillingCycle)
8381
if (openInNewTab) {
8482
window.open(data.checkout_url, '_blank')
8583
} else {

src/platform/cloud/subscription/utils/subscriptionPurchaseTracker.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/platform/telemetry/gtm.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/router.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type { RouteLocationNormalized } from 'vue-router'
99

1010
import { useFeatureFlags } from '@/composables/useFeatureFlags'
1111
import { isCloud } from '@/platform/distribution/types'
12-
import { pushDataLayerEvent } from '@/platform/telemetry/gtm'
1312
import { useDialogService } from '@/services/dialogService'
1413
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
1514
import { useUserStore } from '@/stores/userStore'
@@ -37,16 +36,6 @@ function getBasePath(): string {
3736

3837
const basePath = getBasePath()
3938

40-
function pushPageView(): void {
41-
if (!isCloud || typeof window === 'undefined') return
42-
43-
pushDataLayerEvent({
44-
event: 'page_view',
45-
page_location: window.location.href,
46-
page_title: document.title
47-
})
48-
}
49-
5039
const router = createRouter({
5140
history: isFileProtocol
5241
? createWebHashHistory()
@@ -104,10 +93,6 @@ installPreservedQueryTracker(router, [
10493
}
10594
])
10695

107-
router.afterEach(() => {
108-
pushPageView()
109-
})
110-
11196
if (isCloud) {
11297
const { flags } = useFeatureFlags()
11398
const PUBLIC_ROUTE_NAMES = new Set([

src/stores/firebaseAuthStore.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { t } from '@/i18n'
2626
import { WORKSPACE_STORAGE_KEYS } from '@/platform/auth/workspace/workspaceConstants'
2727
import { isCloud } from '@/platform/distribution/types'
2828
import { useTelemetry } from '@/platform/telemetry'
29-
import { pushDataLayerEvent as pushDataLayerEventBase } from '@/platform/telemetry/gtm'
3029
import { useDialogService } from '@/services/dialogService'
3130
import { useApiKeyAuthStore } from '@/stores/apiKeyAuthStore'
3231
import type { AuthHeader } from '@/types/authTypes'
@@ -82,42 +81,6 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
8281

8382
const buildApiUrl = (path: string) => `${getComfyApiBaseUrl()}${path}`
8483

85-
function pushDataLayerEvent(event: Record<string, unknown>): void {
86-
if (!isCloud || typeof window === 'undefined') return
87-
88-
try {
89-
pushDataLayerEventBase(event)
90-
} catch (error) {
91-
console.warn('Failed to push data layer event', error)
92-
}
93-
}
94-
95-
async function hashSha256(value: string): Promise<string | undefined> {
96-
if (typeof crypto === 'undefined' || !crypto.subtle) return
97-
if (typeof TextEncoder === 'undefined') return
98-
const data = new TextEncoder().encode(value)
99-
const hash = await crypto.subtle.digest('SHA-256', data)
100-
return Array.from(new Uint8Array(hash))
101-
.map((b) => b.toString(16).padStart(2, '0'))
102-
.join('')
103-
}
104-
105-
async function trackSignUp(method: 'email' | 'google' | 'github') {
106-
if (!isCloud || typeof window === 'undefined') return
107-
108-
try {
109-
const userId = currentUser.value?.uid
110-
const hashedUserId = userId ? await hashSha256(userId) : undefined
111-
pushDataLayerEvent({
112-
event: 'sign_up',
113-
method,
114-
...(hashedUserId ? { user_id: hashedUserId } : {})
115-
})
116-
} catch (error) {
117-
console.warn('Failed to track sign up', error)
118-
}
119-
}
120-
12184
// Providers
12285
const googleProvider = new GoogleAuthProvider()
12386
googleProvider.addScope('email')
@@ -384,7 +347,6 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
384347
method: 'email',
385348
is_new_user: true
386349
})
387-
await trackSignUp('email')
388350
}
389351

390352
return result
@@ -403,9 +365,6 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
403365
method: 'google',
404366
is_new_user: isNewUser
405367
})
406-
if (isNewUser) {
407-
await trackSignUp('google')
408-
}
409368
}
410369

411370
return result
@@ -424,9 +383,6 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
424383
method: 'github',
425384
is_new_user: isNewUser
426385
})
427-
if (isNewUser) {
428-
await trackSignUp('github')
429-
}
430386
}
431387

432388
return result

0 commit comments

Comments
 (0)