@primarix/easy-consent
Version:
A lightweight consent management solution for Google Analytics and related services. This is a beta version and should be used with caution.
59 lines (56 loc) • 1.6 kB
text/typescript
type Mode = "denied" | "granted";
interface Config {
ad_storage: Mode;
analytics_storage: Mode;
functionality_storage: Mode;
personalization_storage: Mode;
ad_user_data: Mode;
ad_personalization: Mode;
security_storage: Mode;
}
type PartialConfig = Partial<Config>;
type Options = keyof Config;
type ConsentEventKey = Options | 'all';
type ConsentEventMode = Mode | 'accept-all' | 'reject-all';
interface ConsentUpdateEventDetail {
key: ConsentEventKey;
mode: ConsentEventMode;
state: Config;
timestamp: string;
}
interface ConsentUpdateEvent extends CustomEvent {
detail: ConsentUpdateEventDetail;
}
declare global {
interface Window {
dataLayer: any[];
gtag: (...args: any[]) => void;
}
}
declare global {
interface WindowEventMap {
'consent-updated': ConsentUpdateEvent;
}
}
declare class EasyConsent {
private id;
isNewUser: boolean;
state: Config;
private head;
private analytics_lib;
private init_consent;
private init_GA;
private consentConfigDuration;
private getCookie;
private setCookie;
constructor(id: string);
private pageView;
private dispatchCustomEvent;
update(key: Options, mode: Mode): void;
acceptAll(): void;
rejectAll(): void;
isAllConsented(): boolean;
isAllDenied(): boolean;
updateMultiple(new_state: PartialConfig): void;
}
export { type Config, type ConsentEventKey, type ConsentEventMode, type ConsentUpdateEvent, type ConsentUpdateEventDetail, EasyConsent, type Mode, type Options, type PartialConfig };