Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

716 B
Raw Blame
export type WebAppEventProperties = {
  webapp_run: {
    app_mode: string
  }
}

export type WebAppEventName = keyof WebAppEventProperties

export type WebAppEventTracker = <EventName extends WebAppEventName>(
  eventName: EventName,
  properties: WebAppEventProperties[EventName],
) => void

let activeTracker: WebAppEventTracker | null = null

export function registerWebAppEventTracker(tracker: WebAppEventTracker) {
  activeTracker = tracker

  return () => {
    if (activeTracker === tracker) activeTracker = null
  }
}

export function trackWebAppEvent<EventName extends WebAppEventName>(
  eventName: EventName,
  properties: WebAppEventProperties[EventName],
) {
  activeTracker?.(eventName, properties)
}