@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.
Files changed (77) hide show
  1. package/README.md +23 -7
  2. package/lib/commonjs/ConsentManager.js +4 -1
  3. package/lib/commonjs/ConsentManager.js.map +1 -1
  4. package/lib/commonjs/constants.js +6 -5
  5. package/lib/commonjs/constants.js.map +1 -1
  6. package/lib/commonjs/index.js +3 -2
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/commonjs/services/consent.js +16 -2
  9. package/lib/commonjs/services/consent.js.map +1 -1
  10. package/lib/commonjs/utils/API.js +4 -3
  11. package/lib/commonjs/utils/API.js.map +1 -1
  12. package/lib/module/ConsentManager.js +4 -1
  13. package/lib/module/ConsentManager.js.map +1 -1
  14. package/lib/module/constants.js +6 -5
  15. package/lib/module/constants.js.map +1 -1
  16. package/lib/module/index.js +3 -2
  17. package/lib/module/index.js.map +1 -1
  18. package/lib/module/services/consent.js +16 -2
  19. package/lib/module/services/consent.js.map +1 -1
  20. package/lib/module/utils/API.js +4 -3
  21. package/lib/module/utils/API.js.map +1 -1
  22. package/lib/typescript/lib/commonjs/ConsentManager.d.ts +1 -1
  23. package/lib/typescript/lib/commonjs/ConsentManager.d.ts.map +1 -1
  24. package/lib/typescript/lib/commonjs/services/consent.d.ts.map +1 -1
  25. package/lib/typescript/lib/commonjs/utils/API.d.ts +1 -1
  26. package/lib/typescript/lib/commonjs/utils/API.d.ts.map +1 -1
  27. package/lib/typescript/lib/module/ConsentManager.d.ts +1 -1
  28. package/lib/typescript/lib/module/ConsentManager.d.ts.map +1 -1
  29. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  30. package/lib/typescript/lib/module/services/consent.d.ts.map +1 -1
  31. package/lib/typescript/lib/module/utils/API.d.ts +1 -1
  32. package/lib/typescript/lib/module/utils/API.d.ts.map +1 -1
  33. package/lib/typescript/src/ConsentManager.d.ts +1 -1
  34. package/lib/typescript/src/ConsentManager.d.ts.map +1 -1
  35. package/lib/typescript/src/constants.d.ts.map +1 -1
  36. package/lib/typescript/src/index.d.ts.map +1 -1
  37. package/lib/typescript/src/services/consent.d.ts +9 -0
  38. package/lib/typescript/src/services/consent.d.ts.map +1 -1
  39. package/lib/typescript/src/utils/API.d.ts +1 -1
  40. package/lib/typescript/src/utils/API.d.ts.map +1 -1
  41. package/lib/typescript/webdriverio-appium/common/commonCommands.d.ts +21 -0
  42. package/lib/typescript/webdriverio-appium/common/commonCommands.d.ts.map +1 -0
  43. package/lib/typescript/webdriverio-appium/config/wdio.conf.android.d.cts +3 -0
  44. package/lib/typescript/webdriverio-appium/config/wdio.conf.android.d.cts.map +1 -0
  45. package/lib/typescript/webdriverio-appium/config/wdio.conf.d.cts +21 -0
  46. package/lib/typescript/webdriverio-appium/config/wdio.conf.d.cts.map +1 -0
  47. package/lib/typescript/webdriverio-appium/config/wdio.conf.ios.d.cts +3 -0
  48. package/lib/typescript/webdriverio-appium/config/wdio.conf.ios.d.cts.map +1 -0
  49. package/lib/typescript/webdriverio-appium/test/android/six-drawer.d.ts +2 -0
  50. package/lib/typescript/webdriverio-appium/test/android/six-drawer.d.ts.map +1 -0
  51. package/lib/typescript/webdriverio-appium/test/ios/one.d.ts +2 -0
  52. package/lib/typescript/webdriverio-appium/test/ios/one.d.ts.map +1 -0
  53. package/lib/typescript/webdriverio-appium/test/ios/six.d.ts +2 -0
  54. package/lib/typescript/webdriverio-appium/test/ios/six.d.ts.map +1 -0
  55. package/lib/typescript/webdriverio-appium/test/ios/three.d.ts +2 -0
  56. package/lib/typescript/webdriverio-appium/test/ios/three.d.ts.map +1 -0
  57. package/lib/typescript/webdriverio-appium/test/ios/two-iab.d.ts +2 -0
  58. package/lib/typescript/webdriverio-appium/test/ios/two-iab.d.ts.map +1 -0
  59. package/lib/typescript/webdriverio-appium/test/ios/two.d.ts +2 -0
  60. package/lib/typescript/webdriverio-appium/test/ios/two.d.ts.map +1 -0
  61. package/lib/typescript/webdriverio-appium/test/one.d.ts +2 -0
  62. package/lib/typescript/webdriverio-appium/test/one.d.ts.map +1 -0
  63. package/lib/typescript/webdriverio-appium/test/six-iab.d.ts +2 -0
  64. package/lib/typescript/webdriverio-appium/test/six-iab.d.ts.map +1 -0
  65. package/lib/typescript/webdriverio-appium/test/three.d.ts +2 -0
  66. package/lib/typescript/webdriverio-appium/test/three.d.ts.map +1 -0
  67. package/lib/typescript/webdriverio-appium/test/two-iab.d.ts +2 -0
  68. package/lib/typescript/webdriverio-appium/test/two-iab.d.ts.map +1 -0
  69. package/lib/typescript/webdriverio-appium/test/two.d.ts +2 -0
  70. package/lib/typescript/webdriverio-appium/test/two.d.ts.map +1 -0
  71. package/package.json +8 -8
  72. package/src/ConsentManager.ts +4 -1
  73. package/src/constants.ts +7 -5
  74. package/src/index.tsx +2 -1
  75. package/src/services/consent.ts +31 -3
  76. package/src/types/index.d.ts +1 -0
  77. 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>(
@@ -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 = createConsentPayload(cmp, consent);
138
- return API.post(`${CONSENT_URI}/record`, createConsentPayload(cmp, consent))
139
- .then(() => payload.consented ?? cmp.consent)
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
@@ -31,4 +31,5 @@ export interface OsanoProps {
31
31
  onLangLoadSuccess?: () => void;
32
32
  onLangLoadFailure?: () => void;
33
33
  overrides?: OsanoOverrides;
34
+ extUsrData?: string
34
35
  }
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
  };