import type { Field } from 'payload' import type { AdminText } from '../../../modules/admin-i18n/index.js' import { validateAnalyticsId } from '../../../modules/analytics/idFormats.js' /** * Analytics / marketing tag IDs. All are PUBLIC (exposed client-side), so no * read restriction. Google tags (GA4/GTM) use Consent Mode; the rest load only * after the matching consent category is granted (see modules/analytics). */ const GOOGLE: AdminText = { en: "Follows the visitor's choice in the cookie banner (Google Consent Mode).", pl: 'Uwzględnia wybór odwiedzającego w banerze cookies (Google Consent Mode).', } const AFTER_MARKETING: AdminText = { en: 'Loads after the visitor accepts marketing cookies.', pl: 'Wczytuje się po zaakceptowaniu przez odwiedzającego cookies marketingowych.', } const AFTER_ANALYTICS: AdminText = { en: 'Loads after the visitor accepts analytics cookies.', pl: 'Wczytuje się po zaakceptowaniu przez odwiedzającego cookies analitycznych.', } export const analyticsFields: Field[] = [ { name: 'ga4MeasurementId', type: 'text', admin: { description: GOOGLE, placeholder: 'G-XXXXXXXXXX' }, label: { en: 'Google Analytics 4 ID', pl: 'ID Google Analytics 4' }, validate: validateAnalyticsId('ga4MeasurementId', 'G-XXXXXXXXXX'), }, { name: 'gtmContainerId', type: 'text', admin: { description: GOOGLE, placeholder: 'GTM-XXXXXXX' }, label: { en: 'Google Tag Manager ID', pl: 'ID Google Tag Manager' }, validate: validateAnalyticsId('gtmContainerId', 'GTM-XXXXXXX'), }, { name: 'metaPixelId', type: 'text', admin: { description: AFTER_MARKETING, placeholder: '1234567890123456' }, label: { en: 'Meta Pixel ID', pl: 'ID Meta Pixel' }, validate: validateAnalyticsId('metaPixelId', '1234567890123456'), }, { name: 'clarityProjectId', type: 'text', admin: { description: AFTER_ANALYTICS, placeholder: 'abcdefghij' }, label: { en: 'Microsoft Clarity ID', pl: 'ID Microsoft Clarity' }, validate: validateAnalyticsId('clarityProjectId', 'abcdefghij'), }, { name: 'linkedInPartnerId', type: 'text', admin: { description: AFTER_MARKETING, placeholder: '1234567' }, label: { en: 'LinkedIn Insight Tag ID', pl: 'ID LinkedIn Insight Tag' }, validate: validateAnalyticsId('linkedInPartnerId', '1234567'), }, { name: 'tiktokPixelId', type: 'text', admin: { description: AFTER_MARKETING, placeholder: 'CXXXXXXXXXXXXXXXXXXX' }, label: { en: 'TikTok Pixel ID', pl: 'ID TikTok Pixel' }, validate: validateAnalyticsId('tiktokPixelId', 'CXXXXXXXXXXXXXXXXXXX'), }, ]