Skip to content

Commit 50cec75

Browse files
docs: expand README for preferences, globalcmp and new api
1 parent 3d5bd02 commit 50cec75

File tree

1 file changed

+81
-15
lines changed

1 file changed

+81
-15
lines changed

README.md

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The following attributes should be replaced with your organization's details:
5757
| `config.accountId` | Number | Value associates the property with your organization's Sourcepoint account. Retrieved by contacting your Sourcepoint Account Manager or via the **My Account** page in the Sourcepoint portal. |
5858
| `config.propertyId` | Number | ID for property found in the Sourcepoint portal |
5959
| `config.propertyName` | String | Name of property found in the Sourcepoint portal |
60-
| `config.campaigns` | Object | Campaigns launched on the property through the Sourcepoint portal. Accepts `gdpr: {}` and/or `usnat: {}`. See table below for information on each campaign type. |
60+
| `config.campaigns` | Object | Campaigns launched on the property through the Sourcepoint portal. Accepts `gdpr: {}`, `usnat: {}`, `preferences: {}` and `globalcmp: {}`. See table below for information on each campaign type. |
6161
6262
Refer to the table below regarding the different campaigns that can be implemented:
6363
@@ -99,8 +99,71 @@ consentManager.current?.loadMessage();
9999
100100
```ts
101101
consentManager.current?.onFinished(() => {
102-
consentManager.current?.getUserData().then(setUserData);
103-
});
102+
consentManager.current?.getUserData().then(setUserData);
103+
});
104+
```
105+
106+
#### `SPUserData`
107+
108+
Is structured by campaign type.
109+
```ts
110+
type SPUserData = {
111+
gdpr?: GDPRConsent;
112+
usnat?: USNatConsent;
113+
preferences?: PreferencesConsent;
114+
globalcmp?: GlobalCMPConsent;
115+
};
116+
```
117+
118+
`GDPRConsent`:
119+
```ts
120+
type GDPRConsent = {
121+
applies: boolean;
122+
uuid?: string;
123+
expirationDate?: string;
124+
createdDate?: string;
125+
euconsent?: string;
126+
vendorGrants: { [key: string]: GDPRVendorGrant };
127+
statuses?: GDPRConsentStatus;
128+
tcfData?: { [key: string]: string };
129+
};
130+
```
131+
132+
`USNatConsent`:
133+
```ts
134+
type USNatConsent = {
135+
applies: boolean;
136+
uuid?: string;
137+
expirationDate?: string;
138+
createdDate?: string;
139+
consentSections: Array<ConsentSection>;
140+
statuses?: USNatConsentStatus;
141+
vendors: Array<Consentable>;
142+
categories: Array<Consentable>;
143+
gppData?: { [key: string]: string };
144+
};
145+
```
146+
147+
`PreferencesConsent`:
148+
```ts
149+
type PreferencesConsent = {
150+
dateCreated: string;
151+
uuid?: string;
152+
status: PreferencesStatus[];
153+
rejectedStatus: PreferencesStatus[];
154+
}
155+
```
156+
157+
`GlobalCMPConsent`:
158+
```ts
159+
type GlobalCMPConsent = {
160+
applies: boolean;
161+
uuid?: string;
162+
expirationDate?: string;
163+
createdDate?: string;
164+
vendors: Array<Consentable>;
165+
categories: Array<Consentable>;
166+
}
104167
```
105168
106169
## React example
@@ -115,40 +178,43 @@ import { SPConsentManager, SPCampaignEnvironment } from '@sourcepoint/react-nati
115178

116179
export default function App() {
117180
const [userData, setUserData] = useState<SPUserData>({});
118-
const consentManager = useRef<SPConsentManager | null>();
181+
const consentManager = useRef<SPConsentManager | null>(null);
119182

120183
useEffect(() => {
121184
// setup
122185
consentManager.current = new SPConsentManager();
123186
consentManager.current?.build(
124-
22,
125-
16893,
126-
"mobile.multicampaign.demo",
127-
{
187+
22, // account id
188+
16893, // property id
189+
"mobile.multicampaign.demo", // property name
190+
{ // campaigns used by your property
191+
// add only the campaigns your property uses
128192
gdpr: {},
129-
// usnat: {} // uncomment this if you have a usnat campaign set up
193+
// usnat: {},
194+
// preferences: {},
195+
// globalcmp: {}
130196
}
131197
);
132198

133199
// configure callbacks
134200
consentManager.current?.onSPUIReady(() => {
135-
console.log("Consent UI is ready to be displayed")
201+
console.log("Consent UI is ready and will be presented.")
136202
});
137203
consentManager.current?.onSPUIFinished(() => {
138-
console.log("Consent UI is finished")
204+
console.log("Consent UI is finished and will be dismissed.")
139205
});
140206
consentManager.current?.onFinished(() => {
141207
consentManager.current?.getUserData().then(setUserData);
142208
});
143-
consentManager.current?.onAction((action) => {
144-
console.log(`User took action ${action}`)
209+
consentManager.current?.onAction(({ actionType }) =>
210+
console.log(`User took action ${actionType}`)
145211
});
146-
consentManager.current?.onError(console.error);
212+
consentManager.current?.onError(console.error)
147213

148214
consentManager.current?.loadMessage();
149215

150216
return () => {
151-
consentManager.current?.dispose();
217+
consentManager.current = null;
152218
};
153219
}, []);
154220
return (

0 commit comments

Comments
 (0)