Allow integrations in discovery mode
Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -4,6 +4,10 @@ All notable changes to the `@probo/cookie-banner` SDK will be documented in this
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Grant all Google Consent Mode types when the banner config is unavailable (discovery mode), so GTM-managed tags can fire and be detected instead of staying blocked by the eager deny-all bootstrap
|
||||||
|
|
||||||
## [0.10.0] - 2026-06-19
|
## [0.10.0] - 2026-06-19
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -98,6 +98,12 @@ export class CookieBannerClient {
|
|||||||
try {
|
try {
|
||||||
config = await fetchJSON<BannerConfig>(configUrl);
|
config = await fetchJSON<BannerConfig>(configUrl);
|
||||||
} catch {
|
} catch {
|
||||||
|
// Discovery mode: no published banner config, but detectors still run
|
||||||
|
// so admins can inventory trackers. Grant GCM so GTM-managed tags can
|
||||||
|
// fire; otherwise bootstrap's deny-all would hide them from discovery.
|
||||||
|
for (const integration of this.integrations) {
|
||||||
|
integration.grantAll();
|
||||||
|
}
|
||||||
this.startDetector();
|
this.startDetector();
|
||||||
if (this.observer) {
|
if (this.observer) {
|
||||||
this.observer.disconnect();
|
this.observer.disconnect();
|
||||||
|
|||||||
@@ -45,17 +45,32 @@ export class GoogleConsentModeIntegration implements ConsentIntegration {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly ALL_TYPES = [
|
||||||
|
"ad_storage",
|
||||||
|
"ad_user_data",
|
||||||
|
"ad_personalization",
|
||||||
|
"analytics_storage",
|
||||||
|
"functionality_storage",
|
||||||
|
"personalization_storage",
|
||||||
|
"security_storage",
|
||||||
|
] as const;
|
||||||
|
|
||||||
bootstrap(): void {
|
bootstrap(): void {
|
||||||
const consentFn = this.getConsentFn();
|
const consentFn = this.getConsentFn();
|
||||||
consentFn("consent", "default", {
|
const defaults: Record<string, string> = {};
|
||||||
ad_storage: "denied",
|
for (const type of GoogleConsentModeIntegration.ALL_TYPES) {
|
||||||
ad_user_data: "denied",
|
defaults[type] = "denied";
|
||||||
ad_personalization: "denied",
|
}
|
||||||
analytics_storage: "denied",
|
consentFn("consent", "default", defaults);
|
||||||
functionality_storage: "denied",
|
}
|
||||||
personalization_storage: "denied",
|
|
||||||
security_storage: "denied",
|
grantAll(): void {
|
||||||
});
|
const consentFn = this.getConsentFn();
|
||||||
|
const update: Record<string, string> = {};
|
||||||
|
for (const type of GoogleConsentModeIntegration.ALL_TYPES) {
|
||||||
|
update[type] = "granted";
|
||||||
|
}
|
||||||
|
consentFn("consent", "update", update);
|
||||||
}
|
}
|
||||||
|
|
||||||
setDefaults(categories: Category[]): void {
|
setDefaults(categories: Category[]): void {
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ export interface ConsentIntegration {
|
|||||||
/** Called eagerly before config fetch to deny all tracking by default. */
|
/** Called eagerly before config fetch to deny all tracking by default. */
|
||||||
bootstrap(): void;
|
bootstrap(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the banner config is unavailable (discovery mode).
|
||||||
|
* Grants all consent types so trackers can fire and be detected.
|
||||||
|
*/
|
||||||
|
grantAll(): void;
|
||||||
|
|
||||||
/** Called once after config is loaded, before any consent is applied. */
|
/** Called once after config is loaded, before any consent is applied. */
|
||||||
setDefaults(categories: Category[]): void;
|
setDefaults(categories: Category[]): void;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user