Built-in statistics (cookieless, consent-gated visitor history); per-page meta descriptions, NoSnippet
Stats: ipalKit({ stats: true }) adds the stats-visits collection, POST /api/ipal/hit, the
/admin/stats view (30-day visits chart, top/entry pages, referrers, devices), a dashboard card
and a nav link. <PageStats> (or <SiteProviders stats>) sends one beacon per page view. Without
consent nothing is stored on the device and no IP is kept: page views are joined by a hash with
an in-memory salt replaced daily. With analytics consent an ipal_vid cookie links visits across
days (server re-checks the consent cookie and policy version; withdrawal deletes the cookie).
Bots, logged-in panel users and prefetches aren't counted. Retention 90 days.
@payloadcms/next added to peerDependencies (DefaultTemplate). Docs: stats.md with privacy text.
Also in this release: meta.description auto-filled from page blocks, <NoSnippet>,
MetaDescriptionCheck in the SEO tab, data-nosnippet on banner/language switcher, GA4 CSP
wildcards, consent version passed to Analytics' default consent.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
305c564d13
commit
4ec27d9ef0
@@ -17,6 +17,7 @@ import { buildLocalizationConfig, validateI18nConfig } from './modules/i18n/inde
|
||||
import { buildSystemPagesFields } from './modules/pages/index.js'
|
||||
import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo/index.js'
|
||||
import { buildIndexNowHook } from './modules/seo/indexNow.js'
|
||||
import { buildStatsCollection, buildStatsEndpoint } from './modules/stats/index.js'
|
||||
|
||||
/**
|
||||
* IPAL (Intecion Payload Advanced Library) plugin for Payload CMS 3.
|
||||
@@ -232,6 +233,38 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
config.endpoints = [...(config.endpoints ?? []), buildConsentLogEndpoint(logOptions)]
|
||||
}
|
||||
|
||||
// --- built-in statistics: cookieless visits + consented history (opt-in) ---
|
||||
if (options.stats) {
|
||||
const statsOptions = options.stats === true ? {} : options.stats
|
||||
const adminRoute = options.adminRoute ?? '/admin'
|
||||
const viewProps = { adminRoute, ...(statsOptions.timeZone ? { timeZone: statsOptions.timeZone } : {}) }
|
||||
config.collections = [...(config.collections ?? []), buildStatsCollection()]
|
||||
config.endpoints = [...(config.endpoints ?? []), buildStatsEndpoint(statsOptions)]
|
||||
config.admin = {
|
||||
...(config.admin ?? {}),
|
||||
components: {
|
||||
...(config.admin?.components ?? {}),
|
||||
afterNavLinks: [
|
||||
...(config.admin?.components?.afterNavLinks ?? []),
|
||||
{ path: '@intecion/ipal-kit/admin#StatsNavLink', serverProps: { adminRoute } },
|
||||
],
|
||||
beforeDashboard: [
|
||||
...(config.admin?.components?.beforeDashboard ?? []),
|
||||
...(statsOptions.dashboard === false
|
||||
? []
|
||||
: [{ path: '@intecion/ipal-kit/admin#StatsWidget', serverProps: viewProps }]),
|
||||
],
|
||||
views: {
|
||||
...(config.admin?.components?.views ?? {}),
|
||||
ipalStats: {
|
||||
Component: { path: '@intecion/ipal-kit/admin#StatsView', serverProps: viewProps },
|
||||
path: '/stats',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// --- IndexNow: submit published URLs (opt-in) ---
|
||||
if (options.indexNow) {
|
||||
const pagesSlug = options.pages?.slug ?? 'pages'
|
||||
|
||||
Reference in New Issue
Block a user