@ht-sdks/consent-manager 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commonjs/__tests__/consent-manager/dialog.test.js +33 -0
- package/commonjs/__tests__/consent-manager-builder/analytics.test.js +53 -46
- package/commonjs/__tests__/consent-manager-builder/index.todo.js +48 -87
- package/commonjs/__tests__/consent-manager-builder/preferences.test.js +34 -27
- package/commonjs/__tests__/index.test.js +12 -12
- package/commonjs/consent-manager/banner.js +35 -19
- package/commonjs/consent-manager/buttons.js +5 -5
- package/commonjs/consent-manager/cancel-dialog.js +26 -10
- package/commonjs/consent-manager/categories.js +2 -2
- package/commonjs/consent-manager/container.js +2 -3
- package/commonjs/consent-manager/dialog.js +39 -23
- package/commonjs/consent-manager/font-styles.js +2 -2
- package/commonjs/consent-manager/index.js +41 -25
- package/commonjs/consent-manager/preference-dialog.js +36 -20
- package/commonjs/consent-manager-builder/analytics.js +3 -5
- package/commonjs/consent-manager-builder/index.js +30 -30
- package/commonjs/consent-manager-builder/preferences.js +22 -16
- package/commonjs/index.js +5 -4
- package/commonjs/standalone.js +25 -11
- package/esm/__tests__/consent-manager/dialog.test.js +28 -0
- package/esm/__tests__/consent-manager-builder/analytics.test.js +41 -34
- package/esm/__tests__/consent-manager-builder/index.todo.js +34 -73
- package/esm/__tests__/consent-manager-builder/preferences.test.js +30 -23
- package/esm/consent-manager/banner.js +5 -3
- package/esm/consent-manager/buttons.js +4 -4
- package/esm/consent-manager/cancel-dialog.js +4 -2
- package/esm/consent-manager/categories.js +2 -2
- package/esm/consent-manager/container.js +1 -1
- package/esm/consent-manager/dialog.js +7 -5
- package/esm/consent-manager/font-styles.js +2 -2
- package/esm/consent-manager/index.js +19 -17
- package/esm/consent-manager/preference-dialog.js +7 -5
- package/esm/consent-manager-builder/analytics.js +2 -4
- package/esm/consent-manager-builder/index.js +26 -26
- package/esm/consent-manager-builder/preferences.js +17 -11
- package/esm/index.js +4 -3
- package/esm/standalone.js +3 -3
- package/esm/types.js +1 -0
- package/package.json +62 -67
- package/src/__tests__/consent-manager/dialog.test.tsx +42 -0
- package/src/__tests__/consent-manager-builder/analytics.test.ts +40 -33
- package/src/__tests__/consent-manager-builder/index.todo.js +52 -95
- package/src/__tests__/consent-manager-builder/preferences.test.ts +31 -21
- package/src/consent-manager/banner.tsx +11 -11
- package/src/consent-manager/buttons.tsx +26 -10
- package/src/consent-manager/cancel-dialog.tsx +1 -1
- package/src/consent-manager/categories.ts +2 -2
- package/src/consent-manager/container.tsx +14 -17
- package/src/consent-manager/dialog.tsx +4 -4
- package/src/consent-manager/font-styles.tsx +12 -2
- package/src/consent-manager/index.tsx +27 -29
- package/src/consent-manager/preference-dialog.tsx +13 -11
- package/src/consent-manager-builder/analytics.ts +5 -5
- package/src/consent-manager-builder/index.tsx +28 -28
- package/src/consent-manager-builder/preferences.ts +20 -14
- package/src/index.ts +8 -4
- package/src/standalone.tsx +1 -1
- package/src/types.ts +8 -2
- package/standalone/consent-manager.js +5 -10
- package/standalone/consent-manager.js.map +1 -1
- package/types/consent-manager/banner.d.ts +1 -1
- package/types/consent-manager/buttons.d.ts +6 -7
- package/types/consent-manager/cancel-dialog.d.ts +1 -1
- package/types/consent-manager/index.d.ts +3 -3
- package/types/consent-manager/preference-dialog.d.ts +1 -1
- package/types/consent-manager-builder/analytics.d.ts +1 -1
- package/types/consent-manager-builder/index.d.ts +7 -8
- package/types/consent-manager-builder/preferences.d.ts +4 -6
- package/types/index.d.ts +1 -1
- package/types/types.d.ts +14 -10
- package/commonjs/__tests__/consent-manager-builder/fetch-destinations.test.js +0 -155
- package/commonjs/consent-manager-builder/fetch-destinations.js +0 -104
- package/esm/__tests__/consent-manager-builder/fetch-destinations.test.js +0 -150
- package/esm/consent-manager-builder/fetch-destinations.js +0 -98
- package/src/__tests__/consent-manager-builder/fetch-destinations.test.ts +0 -89
- package/src/consent-manager-builder/fetch-destinations.ts +0 -50
- package/types/consent-manager-builder/fetch-destinations.d.ts +0 -2
- package/types/src/__tests__/consent-manager-builder/analytics.test.d.ts +0 -1
- package/types/src/__tests__/consent-manager-builder/fetch-destinations.test.d.ts +0 -1
- package/types/src/__tests__/consent-manager-builder/preferences.test.d.ts +0 -1
- package/types/src/__tests__/index.test.d.ts +0 -1
- package/types/src/consent-manager/banner.d.ts +0 -21
- package/types/src/consent-manager/buttons.d.ts +0 -13
- package/types/src/consent-manager/cancel-dialog.d.ts +0 -19
- package/types/src/consent-manager/categories.d.ts +0 -3
- package/types/src/consent-manager/container.d.ts +0 -35
- package/types/src/consent-manager/dialog.d.ts +0 -29
- package/types/src/consent-manager/font-styles.d.ts +0 -2
- package/types/src/consent-manager/index.d.ts +0 -35
- package/types/src/consent-manager/preference-dialog.d.ts +0 -32
- package/types/src/consent-manager-builder/analytics.d.ts +0 -14
- package/types/src/consent-manager-builder/fetch-destinations.d.ts +0 -2
- package/types/src/consent-manager-builder/index.d.ts +0 -126
- package/types/src/consent-manager-builder/preferences.d.ts +0 -26
- package/types/src/index.d.ts +0 -7
- package/types/src/standalone.d.ts +0 -5
- package/types/src/types.d.ts +0 -130
- /package/types/__tests__/{consent-manager-builder/fetch-destinations.test.d.ts → consent-manager/dialog.test.d.ts} +0 -0
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
|
-
import { Destination, CategoryPreferences, CustomCategories, DefaultDestinationBehavior, HtEventsBrowserOptions } from '../types';
|
|
3
|
-
import { CookieAttributes } from 'js-cookie';
|
|
4
|
-
interface Props {
|
|
5
|
-
/** Your Hightouch Write key for your website */
|
|
6
|
-
writeKey: string;
|
|
7
|
-
/** Options to pass to Hightouch Events Browser SDK */
|
|
8
|
-
options?: HtEventsBrowserOptions;
|
|
9
|
-
cookieDomain?: string;
|
|
10
|
-
cookieName?: string;
|
|
11
|
-
cookieAttributes?: CookieAttributes;
|
|
12
|
-
/**
|
|
13
|
-
* Number of days until the preferences cookie should expire
|
|
14
|
-
*/
|
|
15
|
-
cookieExpires?: number;
|
|
16
|
-
/**
|
|
17
|
-
* An initial selection of Preferences
|
|
18
|
-
*/
|
|
19
|
-
initialPreferences?: CategoryPreferences;
|
|
20
|
-
/**
|
|
21
|
-
* Provide a function to define whether or not consent should be required
|
|
22
|
-
*/
|
|
23
|
-
shouldRequireConsent?: () => Promise<boolean> | boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Render props for the Consent Manager builder
|
|
26
|
-
*/
|
|
27
|
-
children: (props: RenderProps) => React.ReactElement;
|
|
28
|
-
/**
|
|
29
|
-
* Allows for customizing how to show different categories of consent.
|
|
30
|
-
*/
|
|
31
|
-
mapCustomPreferences?: (destinations: Destination[], preferences: CategoryPreferences) => {
|
|
32
|
-
destinationPreferences: CategoryPreferences;
|
|
33
|
-
customPreferences: CategoryPreferences;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Allows for adding custom consent categories by mapping a custom category to Hightouch integrations
|
|
37
|
-
*/
|
|
38
|
-
customCategories?: CustomCategories;
|
|
39
|
-
/**
|
|
40
|
-
* Specified default behavior for when new destinations are detected on the source(s) of this consent manager.
|
|
41
|
-
*/
|
|
42
|
-
defaultDestinationBehavior?: DefaultDestinationBehavior;
|
|
43
|
-
/**
|
|
44
|
-
* A callback for dealing with errors in the Consent Manager
|
|
45
|
-
*/
|
|
46
|
-
onError?: (err: Error) => void | Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* CDN to fetch list of integrations from
|
|
49
|
-
*/
|
|
50
|
-
cdnHost?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Default true
|
|
53
|
-
* Reload the page if the trackers have already been initialized so that
|
|
54
|
-
* the user's new preferences can take effect.
|
|
55
|
-
*/
|
|
56
|
-
shouldReload?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Default false
|
|
59
|
-
* Disable htevents.load for local testing.
|
|
60
|
-
*/
|
|
61
|
-
devMode?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Default false
|
|
64
|
-
* Use default categories set by Consent Manager instead of destinations
|
|
65
|
-
*/
|
|
66
|
-
useDefaultCategories?: boolean;
|
|
67
|
-
}
|
|
68
|
-
interface RenderProps {
|
|
69
|
-
destinations: Destination[];
|
|
70
|
-
newDestinations: Destination[];
|
|
71
|
-
preferences: CategoryPreferences;
|
|
72
|
-
destinationPreferences: CategoryPreferences;
|
|
73
|
-
isConsentRequired: boolean;
|
|
74
|
-
customCategories?: CustomCategories;
|
|
75
|
-
havePreferencesChanged: boolean;
|
|
76
|
-
workspaceAddedNewDestinations: boolean;
|
|
77
|
-
setPreferences: (newPreferences: CategoryPreferences) => void;
|
|
78
|
-
resetPreferences: () => void;
|
|
79
|
-
saveConsent: (newPreferences?: CategoryPreferences | boolean, shouldReload?: boolean, devMode?: boolean) => void;
|
|
80
|
-
}
|
|
81
|
-
interface State {
|
|
82
|
-
isLoading: boolean;
|
|
83
|
-
destinations: Destination[];
|
|
84
|
-
newDestinations: Destination[];
|
|
85
|
-
preferences?: CategoryPreferences;
|
|
86
|
-
destinationPreferences?: CategoryPreferences;
|
|
87
|
-
isConsentRequired: boolean;
|
|
88
|
-
havePreferencesChanged: boolean;
|
|
89
|
-
workspaceAddedNewDestinations: boolean;
|
|
90
|
-
}
|
|
91
|
-
export default class ConsentManagerBuilder extends Component<Props, State> {
|
|
92
|
-
static displayName: string;
|
|
93
|
-
static defaultProps: {
|
|
94
|
-
options: undefined;
|
|
95
|
-
onError: undefined;
|
|
96
|
-
shouldRequireConsent: () => boolean;
|
|
97
|
-
initialPreferences: {};
|
|
98
|
-
cdnHost: string;
|
|
99
|
-
shouldReload: boolean;
|
|
100
|
-
devMode: boolean;
|
|
101
|
-
useDefaultCategories: boolean;
|
|
102
|
-
};
|
|
103
|
-
state: {
|
|
104
|
-
isLoading: boolean;
|
|
105
|
-
destinations: never[];
|
|
106
|
-
newDestinations: never[];
|
|
107
|
-
preferences: {};
|
|
108
|
-
destinationPreferences: {};
|
|
109
|
-
isConsentRequired: boolean;
|
|
110
|
-
havePreferencesChanged: boolean;
|
|
111
|
-
workspaceAddedNewDestinations: boolean;
|
|
112
|
-
useDefaultCategories: boolean;
|
|
113
|
-
};
|
|
114
|
-
render(): import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, any> | null) | (new (props: any) => Component<any, any, any>)> | null;
|
|
115
|
-
componentDidMount(): Promise<void>;
|
|
116
|
-
initialise: () => Promise<void>;
|
|
117
|
-
handleSetPreferences: (newPreferences: CategoryPreferences) => void;
|
|
118
|
-
handleResetPreferences: () => void;
|
|
119
|
-
handleSaveConsent: (newPreferences: CategoryPreferences | undefined, shouldReload: boolean, devMode?: boolean | undefined) => void;
|
|
120
|
-
mergePreferences: (args: {
|
|
121
|
-
destinations: Destination[];
|
|
122
|
-
existingPreferences?: CategoryPreferences | undefined;
|
|
123
|
-
newPreferences?: CategoryPreferences | undefined;
|
|
124
|
-
}) => CategoryPreferences;
|
|
125
|
-
}
|
|
126
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { CookieAttributes } from 'js-cookie';
|
|
3
|
-
import { Preferences } from '../types';
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
export declare const DEFAULT_COOKIE_NAME = "ht-cm-preferences";
|
|
6
|
-
export interface PreferencesManager {
|
|
7
|
-
loadPreferences(cookieName?: string): Preferences;
|
|
8
|
-
onPreferencesSaved(listener: (prefs: Preferences) => void): void;
|
|
9
|
-
savePreferences(prefs: SavePreferences): void;
|
|
10
|
-
}
|
|
11
|
-
export declare function loadPreferences(cookieName?: string): Preferences;
|
|
12
|
-
declare type SavePreferences = Preferences & {
|
|
13
|
-
cookieDomain?: string;
|
|
14
|
-
cookieName?: string;
|
|
15
|
-
cookieExpires?: number;
|
|
16
|
-
cookieAttributes?: CookieAttributes;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Subscribes to consent preferences changing over time and returns
|
|
20
|
-
* a cleanup function that can be invoked to remove the instantiated listener.
|
|
21
|
-
*
|
|
22
|
-
* @param listener a function to be invoked when ConsentPreferences are saved
|
|
23
|
-
*/
|
|
24
|
-
export declare function onPreferencesSaved(listener: (prefs: Preferences) => void): () => EventEmitter;
|
|
25
|
-
export declare function savePreferences({ destinationPreferences, customPreferences, cookieDomain, cookieName, cookieExpires, cookieAttributes }: SavePreferences): void;
|
|
26
|
-
export {};
|
package/types/src/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import CMB from './consent-manager-builder';
|
|
2
|
-
import CM from './consent-manager';
|
|
3
|
-
export { openDialog as openConsentManager } from './consent-manager/container';
|
|
4
|
-
export { loadPreferences, savePreferences, onPreferencesSaved } from './consent-manager-builder/preferences';
|
|
5
|
-
export declare const ConsentManagerBuilder: typeof CMB;
|
|
6
|
-
export declare const ConsentManager: typeof CM;
|
|
7
|
-
export declare function doNotTrack(): boolean | null;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import inEU from '@segment/in-eu';
|
|
2
|
-
import { openConsentManager, doNotTrack } from '.';
|
|
3
|
-
import * as preferences from './consent-manager-builder/preferences';
|
|
4
|
-
export declare const version: string | undefined;
|
|
5
|
-
export { openConsentManager, doNotTrack, inEU, preferences };
|
package/types/src/types.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { CloseBehaviorFunction } from './consent-manager/container';
|
|
3
|
-
import { PreferencesManager } from './consent-manager-builder/preferences';
|
|
4
|
-
import { CookieAttributes } from 'js-cookie';
|
|
5
|
-
export declare type HtEventsBrowserOptions = {
|
|
6
|
-
integrations?: Record<string, boolean>;
|
|
7
|
-
apiHost?: string;
|
|
8
|
-
protocol?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare type HtEventsBrowser = {
|
|
11
|
-
initialized: boolean;
|
|
12
|
-
load: (writeKey: string, options?: HtEventsBrowserOptions) => void;
|
|
13
|
-
track: (event: string, properties: Record<string, any>, options?: any, callback?: any) => void;
|
|
14
|
-
addSourceMiddleware: (middleware: Middleware) => void;
|
|
15
|
-
};
|
|
16
|
-
export declare type Middleware = (input: MiddlewareInput) => void;
|
|
17
|
-
interface MiddlewareInput {
|
|
18
|
-
payload: {
|
|
19
|
-
obj: Record<string, any>;
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
};
|
|
22
|
-
integrations?: Record<string, boolean>;
|
|
23
|
-
next: (payload: MiddlewareInput['payload']) => void;
|
|
24
|
-
}
|
|
25
|
-
export declare type WindowWithHtEvents = Window & typeof globalThis & {
|
|
26
|
-
htevents?: HtEventsBrowser;
|
|
27
|
-
};
|
|
28
|
-
export declare type WindowWithConsentManagerConfig = Window & typeof globalThis & {
|
|
29
|
-
consentManagerConfig?: (args: StandaloneConsentManagerParams) => ConsentManagerInput | ConsentManagerInput;
|
|
30
|
-
};
|
|
31
|
-
export declare type ConsentManagerInput = ConsentManagerProps & {
|
|
32
|
-
container: string;
|
|
33
|
-
};
|
|
34
|
-
export declare type DefaultDestinationBehavior = 'enable' | 'disable' | 'imply' | 'ask';
|
|
35
|
-
export declare type CloseBehavior = 'accept' | 'deny' | 'dismiss';
|
|
36
|
-
interface StandaloneConsentManagerParams {
|
|
37
|
-
React: unknown;
|
|
38
|
-
version?: string;
|
|
39
|
-
openConsentManager: () => void;
|
|
40
|
-
doNotTrack: () => boolean | null;
|
|
41
|
-
inEU: () => boolean;
|
|
42
|
-
preferences: PreferencesManager;
|
|
43
|
-
inRegions: (regions: string[]) => () => boolean;
|
|
44
|
-
}
|
|
45
|
-
export interface Preferences {
|
|
46
|
-
destinationPreferences?: CategoryPreferences;
|
|
47
|
-
customPreferences?: CategoryPreferences;
|
|
48
|
-
}
|
|
49
|
-
export interface Destination {
|
|
50
|
-
id: string;
|
|
51
|
-
name: string;
|
|
52
|
-
creationName: string;
|
|
53
|
-
description: string;
|
|
54
|
-
website: string;
|
|
55
|
-
category: string;
|
|
56
|
-
}
|
|
57
|
-
export interface CategoryPreferences {
|
|
58
|
-
functional?: boolean | null | undefined;
|
|
59
|
-
marketingAndAnalytics?: boolean | null | undefined;
|
|
60
|
-
advertising?: boolean | null | undefined;
|
|
61
|
-
[category: string]: boolean | null | undefined | string;
|
|
62
|
-
}
|
|
63
|
-
export interface CustomCategories {
|
|
64
|
-
[key: string]: CustomCategory;
|
|
65
|
-
}
|
|
66
|
-
interface CustomCategory {
|
|
67
|
-
integrations?: string[];
|
|
68
|
-
purpose: string;
|
|
69
|
-
}
|
|
70
|
-
export interface PreferencesCategories {
|
|
71
|
-
key: string;
|
|
72
|
-
name?: string;
|
|
73
|
-
description?: string;
|
|
74
|
-
example?: string;
|
|
75
|
-
}
|
|
76
|
-
export interface PreferenceDialogTemplate {
|
|
77
|
-
headings?: {
|
|
78
|
-
allowValue?: string;
|
|
79
|
-
categoryValue?: string;
|
|
80
|
-
purposeValue?: string;
|
|
81
|
-
toolsValue?: string;
|
|
82
|
-
};
|
|
83
|
-
checkboxes?: {
|
|
84
|
-
noValue?: string;
|
|
85
|
-
yesValue?: string;
|
|
86
|
-
};
|
|
87
|
-
actionButtons?: {
|
|
88
|
-
saveValue?: string;
|
|
89
|
-
cancelValue?: string;
|
|
90
|
-
};
|
|
91
|
-
cancelDialogButtons?: {
|
|
92
|
-
cancelValue?: string;
|
|
93
|
-
backValue?: string;
|
|
94
|
-
};
|
|
95
|
-
categories?: PreferencesCategories[];
|
|
96
|
-
}
|
|
97
|
-
export interface ConsentManagerProps {
|
|
98
|
-
writeKey: string;
|
|
99
|
-
options?: HtEventsBrowserOptions;
|
|
100
|
-
shouldRequireConsent?: () => Promise<boolean> | boolean;
|
|
101
|
-
implyConsentOnInteraction?: boolean;
|
|
102
|
-
cookieDomain?: string;
|
|
103
|
-
cookieName?: string;
|
|
104
|
-
cookieAttributes?: CookieAttributes;
|
|
105
|
-
cookieExpires?: number;
|
|
106
|
-
bannerContent?: React.ReactNode;
|
|
107
|
-
bannerSubContent?: string;
|
|
108
|
-
bannerActionsBlock?: ((props: ActionsBlockProps) => React.ReactElement) | true;
|
|
109
|
-
bannerTextColor?: string;
|
|
110
|
-
bannerBackgroundColor?: string;
|
|
111
|
-
bannerHideCloseButton: boolean;
|
|
112
|
-
bannerAsModal?: boolean;
|
|
113
|
-
preferencesDialogTitle?: React.ReactNode;
|
|
114
|
-
preferencesDialogContent?: React.ReactNode;
|
|
115
|
-
onError?: (error: Error | undefined) => void;
|
|
116
|
-
cancelDialogTitle?: React.ReactNode;
|
|
117
|
-
cancelDialogContent?: React.ReactNode;
|
|
118
|
-
closeBehavior?: CloseBehavior | CloseBehaviorFunction;
|
|
119
|
-
initialPreferences?: CategoryPreferences;
|
|
120
|
-
customCategories?: CustomCategories;
|
|
121
|
-
defaultDestinationBehavior?: DefaultDestinationBehavior;
|
|
122
|
-
cdnHost?: string;
|
|
123
|
-
preferencesDialogTemplate?: PreferenceDialogTemplate;
|
|
124
|
-
}
|
|
125
|
-
export interface ActionsBlockProps {
|
|
126
|
-
acceptAll: () => void;
|
|
127
|
-
denyAll: () => void;
|
|
128
|
-
changePreferences: () => void;
|
|
129
|
-
}
|
|
130
|
-
export {};
|
|
File without changes
|