mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-11 16:10:05 +00:00
refactor: create userIdentityBus to decouple auth and telemetry
- Create src/platform/telemetry/userIdentityBus.ts with event hooks - MixpanelTelemetryProvider subscribes to userIdentityHook instead of importing useCurrentUser - firebaseAuthStore emits authEventHook instead of calling useTelemetry - telemetry/index.ts subscribes to authEventHook for tracking Part of Phase 1 circular dependency fixes. Amp-Thread-ID: https://ampcode.com/threads/T-019bfe05-7da5-736f-bff0-34743c003b34 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -25,7 +25,7 @@ import { getComfyApiBaseUrl } from '@/config/comfyApi'
|
||||
import { t } from '@/i18n'
|
||||
import { WORKSPACE_STORAGE_KEYS } from '@/platform/auth/workspace/workspaceConstants'
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
import { useTelemetry } from '@/platform/telemetry'
|
||||
import { authEventHook } from '@/platform/telemetry/userIdentityBus'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useApiKeyAuthStore } from '@/stores/apiKeyAuthStore'
|
||||
import type { AuthHeader } from '@/types/authTypes'
|
||||
@@ -323,9 +323,10 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
|
||||
)
|
||||
|
||||
if (isCloud) {
|
||||
useTelemetry()?.trackAuth({
|
||||
void authEventHook.trigger({
|
||||
event: 'login',
|
||||
method: 'email',
|
||||
is_new_user: false
|
||||
isNewUser: false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -343,9 +344,10 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
|
||||
)
|
||||
|
||||
if (isCloud) {
|
||||
useTelemetry()?.trackAuth({
|
||||
void authEventHook.trigger({
|
||||
event: 'register',
|
||||
method: 'email',
|
||||
is_new_user: true
|
||||
isNewUser: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -361,9 +363,10 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
|
||||
if (isCloud) {
|
||||
const additionalUserInfo = getAdditionalUserInfo(result)
|
||||
const isNewUser = additionalUserInfo?.isNewUser ?? false
|
||||
useTelemetry()?.trackAuth({
|
||||
void authEventHook.trigger({
|
||||
event: isNewUser ? 'register' : 'login',
|
||||
method: 'google',
|
||||
is_new_user: isNewUser
|
||||
isNewUser
|
||||
})
|
||||
}
|
||||
|
||||
@@ -379,9 +382,10 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
|
||||
if (isCloud) {
|
||||
const additionalUserInfo = getAdditionalUserInfo(result)
|
||||
const isNewUser = additionalUserInfo?.isNewUser ?? false
|
||||
useTelemetry()?.trackAuth({
|
||||
void authEventHook.trigger({
|
||||
event: isNewUser ? 'register' : 'login',
|
||||
method: 'github',
|
||||
is_new_user: isNewUser
|
||||
isNewUser
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user