mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 09:00:05 +00:00
Implement setting telemetry
This commit is contained in:
@@ -4,9 +4,11 @@ import { compare, valid } from 'semver'
|
||||
import { ref } from 'vue'
|
||||
|
||||
import type { SettingParams } from '@/platform/settings/types'
|
||||
import { useTelemetry } from '@/platform/telemetry'
|
||||
import type { Settings } from '@/schemas/apiSchema'
|
||||
import { api } from '@/scripts/api'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
import type { TreeNode } from '@/types/treeExplorerTypes'
|
||||
|
||||
export const getSettingInfo = (setting: SettingParams) => {
|
||||
@@ -73,6 +75,37 @@ export const useSettingStore = defineStore('setting', () => {
|
||||
onChange(settingsById.value[key], newValue, oldValue)
|
||||
settingValues.value[key] = newValue
|
||||
await api.storeSetting(key, newValue)
|
||||
|
||||
try {
|
||||
const dialogStore = useDialogStore()
|
||||
if (dialogStore.isDialogOpen('global-settings')) {
|
||||
const telemetry = useTelemetry()
|
||||
const param = settingsById.value[key]
|
||||
const { category, subCategory } = getSettingInfo(
|
||||
param ??
|
||||
({
|
||||
id: String(key)
|
||||
} as unknown as SettingParams)
|
||||
)
|
||||
|
||||
const inputType = (() => {
|
||||
const type = param?.type
|
||||
if (!type) return undefined
|
||||
return typeof type === 'function' ? 'custom' : String(type)
|
||||
})()
|
||||
|
||||
telemetry?.trackSettingChanged({
|
||||
setting_id: String(key),
|
||||
input_type: inputType,
|
||||
category,
|
||||
sub_category: subCategory,
|
||||
previous_value: oldValue,
|
||||
new_value: newValue
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to track setting change', err)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import { app } from '@/scripts/app'
|
||||
import { useNodeDefStore } from '@/stores/nodeDefStore'
|
||||
import { NodeSourceType } from '@/types/nodeSource'
|
||||
import { reduceAllNodes } from '@/utils/graphTraversalUtil'
|
||||
import { normalizeSurveyResponses } from '../../utils/surveyNormalization'
|
||||
|
||||
import type {
|
||||
AuthMetadata,
|
||||
@@ -19,18 +18,20 @@ import type {
|
||||
NodeSearchResultMetadata,
|
||||
PageVisibilityMetadata,
|
||||
RunButtonProperties,
|
||||
SettingChangedMetadata,
|
||||
SurveyResponses,
|
||||
TabCountMetadata,
|
||||
TelemetryEventName,
|
||||
TelemetryEventProperties,
|
||||
TelemetryProvider,
|
||||
TemplateFilterMetadata,
|
||||
TemplateLibraryMetadata,
|
||||
TemplateLibraryClosedMetadata,
|
||||
TemplateLibraryMetadata,
|
||||
TemplateMetadata,
|
||||
WorkflowImportMetadata
|
||||
} from '../../types'
|
||||
import { TelemetryEvents } from '../../types'
|
||||
import { normalizeSurveyResponses } from '../../utils/surveyNormalization'
|
||||
|
||||
interface QueuedEvent {
|
||||
eventName: TelemetryEventName
|
||||
@@ -282,6 +283,10 @@ export class MixpanelTelemetryProvider implements TelemetryProvider {
|
||||
this.trackEvent(TelemetryEvents.EXECUTION_SUCCESS, metadata)
|
||||
}
|
||||
|
||||
trackSettingChanged(metadata: SettingChangedMetadata): void {
|
||||
this.trackEvent(TelemetryEvents.SETTING_CHANGED, metadata)
|
||||
}
|
||||
|
||||
getExecutionContext(): ExecutionContext {
|
||||
const workflowStore = useWorkflowStore()
|
||||
const templatesStore = useWorkflowTemplatesStore()
|
||||
|
||||
@@ -159,6 +159,18 @@ export interface TabCountMetadata {
|
||||
tab_count: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings change metadata
|
||||
*/
|
||||
export interface SettingChangedMetadata {
|
||||
setting_id: string
|
||||
input_type?: string
|
||||
category?: string
|
||||
sub_category?: string
|
||||
previous_value?: unknown
|
||||
new_value?: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
* Node search metadata
|
||||
*/
|
||||
@@ -239,6 +251,9 @@ export interface TelemetryProvider {
|
||||
trackWorkflowExecution(): void
|
||||
trackExecutionError(metadata: ExecutionErrorMetadata): void
|
||||
trackExecutionSuccess(metadata: ExecutionSuccessMetadata): void
|
||||
|
||||
// Settings events
|
||||
trackSettingChanged(metadata: SettingChangedMetadata): void
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,6 +308,9 @@ export const TelemetryEvents = {
|
||||
// Template Filter Analytics
|
||||
TEMPLATE_FILTER_CHANGED: 'app:template_filter_changed',
|
||||
|
||||
// Settings
|
||||
SETTING_CHANGED: 'app:setting_changed',
|
||||
|
||||
// Execution Lifecycle
|
||||
EXECUTION_START: 'execution_start',
|
||||
EXECUTION_ERROR: 'execution_error',
|
||||
@@ -322,3 +340,4 @@ export type TelemetryEventProperties =
|
||||
| NodeSearchMetadata
|
||||
| NodeSearchResultMetadata
|
||||
| TemplateFilterMetadata
|
||||
| SettingChangedMetadata
|
||||
|
||||
Reference in New Issue
Block a user