mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 13:49:09 +03:00
Adds client-side PostHog tracking to run in parallel with server-side telemetry across studio, docs, and www. This enables session replays and resolves a race condition where page views arrive before group assignments resulting in attribution errors. Changes: - Created PostHog client wrapper with consent-aware initialization in common package - Integrated PostHog client calls into existing telemetry functions to send events to both PostHog (client) and backend (server) - Updated CSP to allow connections to PostHog endpoints - Added environment variable support for all apps - PostHog client accepts consent as a parameter and respects user preferences - Events can be distinguished in PostHog by $lib property (posthog-js vs posthog-node) - PostHog URL configured based on environment (staging/local uses ph.supabase.green) - Maintains full backward compatibility with existing telemetry system Resolves GROWTH-438 Resolves GROWTH-271
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
// Ignore barrel file rule here since it's just exporting more constants
|
|
// eslint-disable-next-line barrel-files/avoid-re-export-all
|
|
export * from './infrastructure'
|
|
|
|
export const IS_PLATFORM = process.env.NEXT_PUBLIC_IS_PLATFORM === 'true'
|
|
|
|
export const API_URL = (() => {
|
|
if (process.env.NODE_ENV === 'test') return 'http://localhost:3000/api'
|
|
// If running in platform, use API_URL from the env var
|
|
if (IS_PLATFORM) return process.env.NEXT_PUBLIC_API_URL!
|
|
// If running in browser, let it add the host
|
|
if (typeof window !== 'undefined') return '/api'
|
|
// If running self-hosted Vercel preview, use VERCEL_URL
|
|
if (!!process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}/api`
|
|
// If running on self-hosted, use NEXT_PUBLIC_SITE_URL
|
|
if (!!process.env.NEXT_PUBLIC_SITE_URL) return `${process.env.NEXT_PUBLIC_SITE_URL}/api`
|
|
return '/api'
|
|
})()
|
|
|
|
export const PG_META_URL = IS_PLATFORM
|
|
? process.env.PLATFORM_PG_META_URL
|
|
: process.env.STUDIO_PG_META_URL
|
|
export const BASE_PATH = process.env.NEXT_PUBLIC_BASE_PATH ?? ''
|
|
|
|
/**
|
|
* @deprecated use DATETIME_FORMAT
|
|
*/
|
|
export const DATE_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ'
|
|
|
|
// should be used for all dayjs formattings shown to the user. Includes timezone info.
|
|
export const DATETIME_FORMAT = 'DD MMM YYYY, HH:mm:ss (ZZ)'
|
|
|
|
export const GOTRUE_ERRORS = {
|
|
UNVERIFIED_GITHUB_USER: 'Error sending confirmation mail',
|
|
}
|
|
|
|
export const STRIPE_PUBLIC_KEY =
|
|
process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY || 'pk_test_XVwg5IZH3I9Gti98hZw6KRzd00v5858heG'
|
|
|
|
export const POSTHOG_URL =
|
|
process.env.NEXT_PUBLIC_ENVIRONMENT === 'staging' ||
|
|
process.env.NEXT_PUBLIC_ENVIRONMENT === 'local'
|
|
? 'https://ph.supabase.green'
|
|
: 'https://ph.supabase.com'
|
|
|
|
export const USAGE_APPROACHING_THRESHOLD = 0.75
|
|
|
|
export const OPT_IN_TAGS = {
|
|
AI_SQL: 'AI_SQL_GENERATOR_OPT_IN',
|
|
AI_DATA: 'AI_DATA_GENERATOR_OPT_IN',
|
|
AI_LOG: 'AI_LOG_GENERATOR_OPT_IN',
|
|
}
|
|
|
|
export const GB = 1024 * 1024 * 1024
|
|
export const MB = 1024 * 1024
|
|
export const KB = 1024
|