- 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]>
64 lines
2.2 KiB
TypeScript
64 lines
2.2 KiB
TypeScript
import type { Field } from 'payload'
|
|
|
|
/**
|
|
* Panel fields that let an EDITOR configure a form's analytics event — the GTM
|
|
* `dataLayer` push fired on successful submit — without any code change. Add
|
|
* them to the Forms collection via the plugin's `formOverrides`:
|
|
*
|
|
* ipalKit({
|
|
* forms: {
|
|
* formOverrides: {
|
|
* fields: ({ defaultFields }) => [...defaultFields, ...buildFormAnalyticsFields()],
|
|
* },
|
|
* },
|
|
* })
|
|
*
|
|
* The front reads this config and emits the event automatically via
|
|
* `formAnalyticsOnSuccess` (see forms.md) — so adding a tracked form, or
|
|
* changing its event name/params, is panel-only. The GTM side (the Lead/Pixel
|
|
* tag, its trigger and consent gate) stays in GTM, which is itself a no-code
|
|
* panel for tags.
|
|
*/
|
|
export function buildFormAnalyticsFields(): Field[] {
|
|
return [
|
|
{
|
|
name: 'analytics',
|
|
type: 'group',
|
|
admin: {
|
|
description: {
|
|
en: 'Sent to Google Tag Manager after a successful submission.',
|
|
pl: 'Wysyłane do Google Tag Manager po udanym wysłaniu formularza.',
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'event',
|
|
type: 'text',
|
|
admin: {
|
|
description: { en: 'Leave empty to send nothing.', pl: 'Zostaw puste, aby nic nie wysyłać.' },
|
|
},
|
|
defaultValue: 'form_submit',
|
|
label: { en: 'Event name', pl: 'Nazwa zdarzenia' },
|
|
},
|
|
{
|
|
name: 'params',
|
|
type: 'array',
|
|
admin: {
|
|
description: {
|
|
en: 'A value starting with $ is taken from a form field, e.g. $topic.',
|
|
pl: 'Wartość zaczynająca się od $ pochodzi z pola formularza, np. $topic.',
|
|
},
|
|
},
|
|
fields: [
|
|
{ name: 'key', type: 'text', label: { en: 'Key', pl: 'Klucz' }, required: true },
|
|
{ name: 'value', type: 'text', label: { en: 'Value', pl: 'Wartość' }, required: true },
|
|
],
|
|
label: { en: 'Event parameters', pl: 'Parametry zdarzenia' },
|
|
labels: { plural: { en: 'Parameters', pl: 'Parametry' }, singular: { en: 'Parameter', pl: 'Parametr' } },
|
|
},
|
|
],
|
|
label: { en: 'Analytics event', pl: 'Zdarzenie analityki' },
|
|
},
|
|
]
|
|
}
|