@osano/osano-cmp-react-native 0.6.0 → 0.8.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/README.md +23 -7
- package/lib/commonjs/ConsentManager.js +4 -1
- package/lib/commonjs/ConsentManager.js.map +1 -1
- package/lib/commonjs/constants.js +6 -5
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/index.js +3 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/services/consent.js +16 -2
- package/lib/commonjs/services/consent.js.map +1 -1
- package/lib/commonjs/utils/API.js +4 -3
- package/lib/commonjs/utils/API.js.map +1 -1
- package/lib/module/ConsentManager.js +4 -1
- package/lib/module/ConsentManager.js.map +1 -1
- package/lib/module/constants.js +6 -5
- package/lib/module/constants.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/consent.js +16 -2
- package/lib/module/services/consent.js.map +1 -1
- package/lib/module/utils/API.js +4 -3
- package/lib/module/utils/API.js.map +1 -1
- package/lib/typescript/lib/commonjs/ConsentManager.d.ts +1 -1
- package/lib/typescript/lib/commonjs/ConsentManager.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/services/consent.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/utils/API.d.ts +1 -1
- package/lib/typescript/lib/commonjs/utils/API.d.ts.map +1 -1
- package/lib/typescript/lib/module/ConsentManager.d.ts +1 -1
- package/lib/typescript/lib/module/ConsentManager.d.ts.map +1 -1
- package/lib/typescript/lib/module/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/services/consent.d.ts.map +1 -1
- package/lib/typescript/lib/module/utils/API.d.ts +1 -1
- package/lib/typescript/lib/module/utils/API.d.ts.map +1 -1
- package/lib/typescript/src/ConsentManager.d.ts +1 -1
- package/lib/typescript/src/ConsentManager.d.ts.map +1 -1
- package/lib/typescript/src/constants.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/services/consent.d.ts +9 -0
- package/lib/typescript/src/services/consent.d.ts.map +1 -1
- package/lib/typescript/src/utils/API.d.ts +1 -1
- package/lib/typescript/src/utils/API.d.ts.map +1 -1
- package/lib/typescript/webdriverio-appium/common/commonCommands.d.ts +21 -0
- package/lib/typescript/webdriverio-appium/common/commonCommands.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/config/wdio.conf.android.d.cts +3 -0
- package/lib/typescript/webdriverio-appium/config/wdio.conf.android.d.cts.map +1 -0
- package/lib/typescript/webdriverio-appium/config/wdio.conf.d.cts +21 -0
- package/lib/typescript/webdriverio-appium/config/wdio.conf.d.cts.map +1 -0
- package/lib/typescript/webdriverio-appium/config/wdio.conf.ios.d.cts +3 -0
- package/lib/typescript/webdriverio-appium/config/wdio.conf.ios.d.cts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/android/six-drawer.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/android/six-drawer.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/ios/one.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/ios/one.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/ios/six.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/ios/six.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/ios/three.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/ios/three.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/ios/two-iab.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/ios/two-iab.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/ios/two.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/ios/two.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/one.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/one.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/six-iab.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/six-iab.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/three.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/three.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/two-iab.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/two-iab.d.ts.map +1 -0
- package/lib/typescript/webdriverio-appium/test/two.d.ts +2 -0
- package/lib/typescript/webdriverio-appium/test/two.d.ts.map +1 -0
- package/package.json +8 -8
- package/src/ConsentManager.ts +4 -1
- package/src/constants.ts +7 -5
- package/src/index.tsx +2 -1
- package/src/services/consent.ts +31 -3
- package/src/types/index.d.ts +1 -0
- package/src/utils/API.ts +3 -1
package/src/index.tsx
CHANGED
|
@@ -45,10 +45,11 @@ export const Osano: React.FunctionComponent<
|
|
|
45
45
|
onLangLoadFailure,
|
|
46
46
|
onLangLoadSuccess,
|
|
47
47
|
overrides,
|
|
48
|
+
extUsrData
|
|
48
49
|
} = props;
|
|
49
50
|
const { flavor, iabEnabled } = overrides || {};
|
|
50
51
|
const consentManager = useRef<ConsentManager>(
|
|
51
|
-
new ConsentManager(overrides)
|
|
52
|
+
new ConsentManager(overrides, extUsrData)
|
|
52
53
|
);
|
|
53
54
|
|
|
54
55
|
const [_state, store] = useThunkReducer<OsanoState, OsanoAction>(
|
package/src/services/consent.ts
CHANGED
|
@@ -30,6 +30,16 @@ export type ConsentPayload = {
|
|
|
30
30
|
extUsrData?: string;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
export type ConsentRecordPayload = {
|
|
34
|
+
osnoCustomerId: string;
|
|
35
|
+
osnoConfigId: string;
|
|
36
|
+
consented?: string;
|
|
37
|
+
consentingDomain: string;
|
|
38
|
+
consentingPlatform: string;
|
|
39
|
+
userConsentId: string;
|
|
40
|
+
extUsrData?: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
33
43
|
function createConsentPayload(
|
|
34
44
|
cmp: ConsentManager,
|
|
35
45
|
consent?: ConsentCategoryType[],
|
|
@@ -47,6 +57,24 @@ function createConsentPayload(
|
|
|
47
57
|
) as ConsentPayload;
|
|
48
58
|
}
|
|
49
59
|
|
|
60
|
+
function createConsentRecordPayload(
|
|
61
|
+
cmp: ConsentManager,
|
|
62
|
+
consent?: ConsentCategoryType[],
|
|
63
|
+
): ConsentRecordPayload{
|
|
64
|
+
const consentedCategories = consent ?? cmp.consent
|
|
65
|
+
return Object.fromEntries(
|
|
66
|
+
Object.entries({
|
|
67
|
+
osnoCustomerId: cmp.customerId,
|
|
68
|
+
osnoConfigId: cmp.configId,
|
|
69
|
+
consented: consentedCategories.join(','),
|
|
70
|
+
consentingDomain: cmp.consentingDomain,
|
|
71
|
+
consentingPlatform: `${Platform.OS}.react-native`,
|
|
72
|
+
userConsentId: cmp.deviceId,
|
|
73
|
+
extUsrData: cmp.extUsrData,
|
|
74
|
+
}).filter(([, value]) => value !== undefined),
|
|
75
|
+
) as ConsentRecordPayload;
|
|
76
|
+
}
|
|
77
|
+
|
|
50
78
|
const STORAGE_KEY = 'osano_consentmanager';
|
|
51
79
|
|
|
52
80
|
const storeConsent = async (
|
|
@@ -134,9 +162,9 @@ export const recordConsent = (
|
|
|
134
162
|
cmp: ConsentManager,
|
|
135
163
|
consent?: ConsentCategoryType[],
|
|
136
164
|
) => {
|
|
137
|
-
const payload =
|
|
138
|
-
return API.post(`${CONSENT_URI}/record`,
|
|
139
|
-
.then(() =>
|
|
165
|
+
const payload = createConsentRecordPayload(cmp, consent);
|
|
166
|
+
return API.post(`${CONSENT_URI}/record`, payload, {referrer: cmp.consentingDomain})
|
|
167
|
+
.then(() => consent ?? cmp.consent)
|
|
140
168
|
.then((consentCategories) => storeConsent(cmp, consentCategories))
|
|
141
169
|
.catch((error) => {
|
|
142
170
|
// Cannot record consent
|
package/src/types/index.d.ts
CHANGED
package/src/utils/API.ts
CHANGED
|
@@ -3,6 +3,7 @@ const makeFetch = (
|
|
|
3
3
|
path: string,
|
|
4
4
|
params = {},
|
|
5
5
|
returnHeaders = false,
|
|
6
|
+
headers = {},
|
|
6
7
|
): Promise<unknown | { json: object; headers: Headers }> => {
|
|
7
8
|
const url = new URL(path);
|
|
8
9
|
if (method.toLowerCase() === 'get') {
|
|
@@ -22,6 +23,7 @@ const makeFetch = (
|
|
|
22
23
|
mode: 'cors',
|
|
23
24
|
referrer: 'no-referrer',
|
|
24
25
|
body: method !== 'GET' ? JSON.stringify(params) : undefined,
|
|
26
|
+
...headers
|
|
25
27
|
}).then((response) => {
|
|
26
28
|
if (response.status === 204 || response.type === 'opaque') {
|
|
27
29
|
return '';
|
|
@@ -44,5 +46,5 @@ export default {
|
|
|
44
46
|
typeof queryObj !== 'boolean' ? queryObj : undefined,
|
|
45
47
|
typeof queryObj === 'boolean',
|
|
46
48
|
),
|
|
47
|
-
post: (path: string, params?: object) => makeFetch('POST', path, params),
|
|
49
|
+
post: (path: string, params?: object, headers?: object) => makeFetch('POST', path, params, false, headers),
|
|
48
50
|
};
|