Gap fixes: top-level searchSettings, public shouldLoadGoogle, consent/stats collection overrides
- ipalKit({ searchSettings }): switches off / reshapes Site Settings → Search & AI
without `seo`; read as options.searchSettings ?? options.seo?.searchSettings.
- shouldLoadGoogle moved to a pure module (analytics/shouldLoadGoogle.ts) and
exported from @intecion/ipal-kit and /client.
- consentLog.collectionOverrides and stats.collectionOverrides (object merges
access/admin/hooks key by key, function takes over), via the new exported
applyCollectionOverride / CollectionOverride. The stats view and dashboard
chart now follow the stats-visits read access, so overrides narrow them too.
All additive; defaults unchanged. Docs: AGENT.md, ipal-reference, consent,
stats, seo, analytics, ipal-setup.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4911da7112
commit
5a07c42f76
@@ -7,6 +7,7 @@ import { useConsentContext } from '../consent/client.js'
|
||||
import { gtag } from '../consent/googleConsent.js'
|
||||
import { CONSENT_COOKIE, DEFAULT_CONSENT, parseConsent, setDefaultConsent } from '../consent/index.js'
|
||||
import { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from './pixels.js'
|
||||
import { shouldLoadGoogle } from './shouldLoadGoogle.js'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -69,24 +70,6 @@ export type AnalyticsProps = {
|
||||
deferTimeoutMs?: number
|
||||
} & AnalyticsConfig
|
||||
|
||||
/**
|
||||
* Whether the Google tag may load now. Pure, so the consent rule is testable
|
||||
* without a DOM: 'basic' waits for an analytics or marketing grant, 'advanced'
|
||||
* relies on the Consent Mode default and loads as soon as `ready`.
|
||||
*/
|
||||
export function shouldLoadGoogle({
|
||||
consentMode,
|
||||
ready,
|
||||
state,
|
||||
}: {
|
||||
consentMode: 'advanced' | 'basic'
|
||||
ready: boolean
|
||||
state: { analytics?: boolean; marketing?: boolean }
|
||||
}): boolean {
|
||||
if (!ready) {return false}
|
||||
return consentMode === 'advanced' || Boolean(state.analytics || state.marketing)
|
||||
}
|
||||
|
||||
const INTERACTION_EVENTS = ['scroll', 'pointerdown', 'touchstart', 'keydown'] as const
|
||||
|
||||
/** True once third-party tags may load (immediately, or per `defer` rules). */
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Pure consent gate for the Google tag — no React, no DOM, safe on the server
|
||||
* and in the client bundle. <Analytics> uses it; export it to apply the same
|
||||
* rule to your own Google-dependent code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Whether the Google tag may load now. Pure, so the consent rule is testable
|
||||
* without a DOM: 'basic' waits for an analytics or marketing grant, 'advanced'
|
||||
* relies on the Consent Mode default and loads as soon as `ready`.
|
||||
*/
|
||||
export function shouldLoadGoogle({
|
||||
consentMode,
|
||||
ready,
|
||||
state,
|
||||
}: {
|
||||
consentMode: 'advanced' | 'basic'
|
||||
ready: boolean
|
||||
state: { analytics?: boolean; marketing?: boolean }
|
||||
}): boolean {
|
||||
if (!ready) {return false}
|
||||
return consentMode === 'advanced' || Boolean(state.analytics || state.marketing)
|
||||
}
|
||||
Reference in New Issue
Block a user