Files
ipal-kit/src/globals/SiteIntegrations/fields/analytics.ts
T
Radosław SmolińskiandClaude Opus 5.5 6b46bc0c14 Admin panel in English and Polish, reworded per docs/dev/admin-ux.md
- admin-i18n module: AdminText { en, pl }, component texts under the ipal
  namespace (project translations win), en + pl admin languages when the
  project sets none (project's supportedLanguages wins)
- every plugin label, description, option, tab and group as { en, pl };
  explicit labels instead of auto-labels; sentence case; glossary terms
- visible renames (slugs, names, data unchanged): Cookie banner, Form
  messages, Privacy group, Search engines, Maintenance, Spam protection,
  E-mail sending, stats nav link Overview (hidden without access)
- Polish visitor defaults by page locale: cookie banner, form messages,
  validators, lightbox, accessibility widget; {field} uses the label
- fixes: e-mail status banner used Turnstile wording; developer words and
  env var names out of editor messages; stats numbers/dates in the admin
  language; test e-mail no longer says ipal-kit
- test/adminUx.test.ts: length limits, en + pl present, no developer words

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 15:46:25 +01:00

70 lines
2.6 KiB
TypeScript

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'),
},
]