23 lines
919 B
TypeScript
23 lines
919 B
TypeScript
import type { BasePayload } from 'payload'
|
|
|
|
import type { AnalyticsConfig } from './types.js'
|
|
|
|
import { getSiteIntegrations } from '../payload/index.js'
|
|
|
|
/**
|
|
* Reads the public analytics / marketing tag IDs from SiteIntegrations,
|
|
* server-side. All are public (exposed client-side), so safe to pass to the
|
|
* <Analytics> component. Does NOT expose any secret from SiteIntegrations.
|
|
*/
|
|
export async function getAnalyticsConfig(payload: BasePayload): Promise<AnalyticsConfig> {
|
|
const integrations = await getSiteIntegrations<AnalyticsConfig>(payload)
|
|
return {
|
|
clarityProjectId: integrations.clarityProjectId ?? null,
|
|
ga4MeasurementId: integrations.ga4MeasurementId ?? null,
|
|
gtmContainerId: integrations.gtmContainerId ?? null,
|
|
linkedInPartnerId: integrations.linkedInPartnerId ?? null,
|
|
metaPixelId: integrations.metaPixelId ?? null,
|
|
tiktokPixelId: integrations.tiktokPixelId ?? null,
|
|
}
|
|
}
|