Share consent

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-18 18:41:52 +04:00
parent 0f32037e70
commit 10e35c6afc

View File

@@ -87,11 +87,15 @@ export class ConsentManager {
}
}
let instance: ConsentManager | null = null;
const GLOBAL_KEY = "__proboConsentManager";
export function getConsent(): ConsentManager {
if (!instance) {
instance = new ConsentManager();
const g = typeof globalThis !== "undefined"
? (globalThis as unknown as Record<string, unknown>)
: (window as unknown as Record<string, unknown>);
if (!g[GLOBAL_KEY]) {
g[GLOBAL_KEY] = new ConsentManager();
}
return instance;
return g[GLOBAL_KEY] as ConsentManager;
}