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.

803 B
Raw Blame
import type { DeploymentEdition } from '@dify/contracts/api/console/system-features/types.gen'

type CloudAnalyticsRequest = {
  cookieYesSiteKey: string | undefined
  deploymentEdition: DeploymentEdition
  isProd: boolean
  requestHost: string | null
  webPrefix: string | undefined
}

export function isCloudAnalyticsRequest({
  cookieYesSiteKey,
  deploymentEdition,
  isProd,
  requestHost,
  webPrefix,
}: CloudAnalyticsRequest) {
  if (
    deploymentEdition !== 'CLOUD' ||
    !isProd ||
    !cookieYesSiteKey?.trim() ||
    !requestHost ||
    !webPrefix
  )
    return false

  try {
    const expectedHost = new URL(webPrefix).host.toLowerCase()
    const currentHost = requestHost.split(',')[0]?.trim().toLowerCase()
    return currentHost === expectedHost
  } catch {
    return false
  }
}