@adadapted/react-native-sdk 3.3.0 → 3.5.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 (87) hide show
  1. package/android/bin/build.gradle +9 -8
  2. package/android/bin/gradle.properties +1 -1
  3. package/android/build.gradle +17 -80
  4. package/android/gradle.properties +2 -2
  5. package/android/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkModule.kt +39 -54
  6. package/ios/AdadaptedReactNativeSdk.m +1 -1
  7. package/lib/commonjs/api/adadaptedApiRequests.js +12 -12
  8. package/lib/commonjs/api/adadaptedApiRequests.js.map +1 -1
  9. package/lib/commonjs/api/adadaptedApiRequests.mock.js.map +1 -1
  10. package/lib/commonjs/api/adadaptedApiTypes.js +5 -10
  11. package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
  12. package/lib/commonjs/componentTypes/AdZone.js +11 -0
  13. package/lib/commonjs/componentTypes/AdZone.js.map +1 -0
  14. package/lib/commonjs/componentTypes/Device.js +22 -0
  15. package/lib/commonjs/componentTypes/Device.js.map +1 -0
  16. package/lib/commonjs/componentTypes/Environment.js +34 -0
  17. package/lib/commonjs/componentTypes/Environment.js.map +1 -0
  18. package/lib/commonjs/components/AdZone.js +76 -85
  19. package/lib/commonjs/components/AdZone.js.map +1 -1
  20. package/lib/commonjs/components/ReportAdButton.js +9 -7
  21. package/lib/commonjs/components/ReportAdButton.js.map +1 -1
  22. package/lib/commonjs/index.js +108 -132
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/package.json +1 -0
  25. package/lib/commonjs/types.js.map +1 -1
  26. package/lib/commonjs/util.js +1 -4
  27. package/lib/commonjs/util.js.map +1 -1
  28. package/lib/module/api/adadaptedApiRequests.js +11 -9
  29. package/lib/module/api/adadaptedApiRequests.js.map +1 -1
  30. package/lib/module/api/adadaptedApiRequests.mock.js +2 -0
  31. package/lib/module/api/adadaptedApiRequests.mock.js.map +1 -1
  32. package/lib/module/api/adadaptedApiTypes.js +16 -0
  33. package/lib/module/api/adadaptedApiTypes.js.map +1 -1
  34. package/lib/module/componentTypes/AdZone.js +7 -0
  35. package/lib/module/componentTypes/AdZone.js.map +1 -0
  36. package/lib/module/componentTypes/Device.js +18 -0
  37. package/lib/module/componentTypes/Device.js.map +1 -0
  38. package/lib/module/componentTypes/Environment.js +30 -0
  39. package/lib/module/componentTypes/Environment.js.map +1 -0
  40. package/lib/module/components/AdZone.js +70 -80
  41. package/lib/module/components/AdZone.js.map +1 -1
  42. package/lib/module/components/ReportAdButton.js +9 -5
  43. package/lib/module/components/ReportAdButton.js.map +1 -1
  44. package/lib/module/index.js +102 -130
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/module/package.json +1 -0
  47. package/lib/module/types.js +2 -0
  48. package/lib/module/types.js.map +1 -1
  49. package/lib/module/util.js +5 -5
  50. package/lib/module/util.js.map +1 -1
  51. package/lib/typescript/src/api/adadaptedApiRequests.d.ts +10 -9
  52. package/lib/typescript/src/api/adadaptedApiRequests.d.ts.map +1 -1
  53. package/lib/typescript/src/api/adadaptedApiTypes.d.ts +11 -0
  54. package/lib/typescript/src/api/adadaptedApiTypes.d.ts.map +1 -1
  55. package/lib/typescript/src/componentTypes/AdZone.d.ts +95 -0
  56. package/lib/typescript/src/componentTypes/AdZone.d.ts.map +1 -0
  57. package/lib/typescript/src/componentTypes/Device.d.ts +80 -0
  58. package/lib/typescript/src/componentTypes/Device.d.ts.map +1 -0
  59. package/lib/typescript/src/componentTypes/Environment.d.ts +57 -0
  60. package/lib/typescript/src/componentTypes/Environment.d.ts.map +1 -0
  61. package/lib/typescript/src/components/AdZone.d.ts +5 -54
  62. package/lib/typescript/src/components/AdZone.d.ts.map +1 -1
  63. package/lib/typescript/src/components/ReportAdButton.d.ts +2 -2
  64. package/lib/typescript/src/components/ReportAdButton.d.ts.map +1 -1
  65. package/lib/typescript/src/index.d.ts +34 -139
  66. package/lib/typescript/src/index.d.ts.map +1 -1
  67. package/package.json +10 -14
  68. package/src/api/adadaptedApiRequests.ts +25 -24
  69. package/src/api/adadaptedApiTypes.ts +11 -0
  70. package/src/componentTypes/AdZone.ts +97 -0
  71. package/src/componentTypes/Device.ts +79 -0
  72. package/src/componentTypes/Environment.ts +58 -0
  73. package/src/components/AdZone.tsx +82 -144
  74. package/src/components/ReportAdButton.tsx +1 -1
  75. package/src/index.tsx +168 -255
  76. package/lib/typescript/example/index.d.ts +0 -2
  77. package/lib/typescript/example/index.d.ts.map +0 -1
  78. package/lib/typescript/example/src/App.d.ts +0 -29
  79. package/lib/typescript/example/src/App.d.ts.map +0 -1
  80. package/lib/typescript/example/src/OffScreenAdZone.d.ts +0 -38
  81. package/lib/typescript/example/src/OffScreenAdZone.d.ts.map +0 -1
  82. package/lib/typescript/example/src/StandardAdZone.d.ts +0 -38
  83. package/lib/typescript/example/src/StandardAdZone.d.ts.map +0 -1
  84. package/lib/typescript/index.d.ts +0 -2
  85. package/lib/typescript/index.d.ts.map +0 -1
  86. package/lib/typescript/jest.setup.d.ts +0 -6
  87. package/lib/typescript/jest.setup.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adadapted/react-native-sdk",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "The AdAdapted react-native SDK.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -51,12 +51,12 @@
51
51
  "homepage": "https://gitlab.com/adadapted/adadapted-react-native-sdk#readme",
52
52
  "dependencies": {
53
53
  "@react-native-community/eslint-config": "^3.2.0",
54
- "axios": "1.4.0",
54
+ "axios": "^1.7.9",
55
55
  "react-native-base64": "0.2.1",
56
56
  "type-zoo": "3.4.1"
57
57
  },
58
58
  "peerDependencies": {
59
- "react": "*",
59
+ "react": ">=18",
60
60
  "react-native": "*",
61
61
  "react-native-webview": "*"
62
62
  },
@@ -66,14 +66,13 @@
66
66
  "@babel/preset-env": "7.22.5",
67
67
  "@babel/preset-react": "7.22.5",
68
68
  "@babel/preset-typescript": "7.22.5",
69
+ "@react-native/typescript-config": "0.74.88",
69
70
  "@types/jest": "29.5.2",
70
- "@types/react": "18.2.12",
71
- "@types/react-dom": "18.2.6",
72
- "@types/react-native": "0.72.2",
71
+ "@types/react": "18.3.1",
73
72
  "@types/react-native-base64": "0.2.0",
74
73
  "@typescript-eslint/eslint-plugin": "^5.62.0",
75
74
  "@typescript-eslint/parser": "5.60.0",
76
- "eslint": "^8.44.0",
75
+ "eslint": "^8.19.0",
77
76
  "eslint-config-standard-with-typescript": "^36.0.0",
78
77
  "eslint-plugin-import": "^2.27.5",
79
78
  "eslint-plugin-jest": "27.2.2",
@@ -82,16 +81,13 @@
82
81
  "eslint-plugin-prefer-arrow": "1.2.3",
83
82
  "eslint-plugin-promise": "^6.1.1",
84
83
  "eslint-plugin-react": "^7.32.2",
84
+ "eslint-plugin-react-hooks": "^5.1.0",
85
85
  "eslint-plugin-react-native": "^4.0.0",
86
- "jest": "29.5.0",
86
+ "jest": "^29.6.3",
87
87
  "prettier": "2.8.8",
88
- "react": "18.2.0",
89
- "react-native": "0.72.0",
90
- "react-native-builder-bob": "^0.23.2",
91
- "react-native-webview": "13.2.2",
92
- "react-router-native": "6.14.0",
88
+ "react-native-builder-bob": "0.33.3",
93
89
  "ts-jest": "29.1.0",
94
- "typescript": "^5.0.4"
90
+ "typescript": "5.0.4"
95
91
  },
96
92
  "jest": {
97
93
  "preset": "react-native",
@@ -19,7 +19,8 @@ import {
19
19
  } from "./adadaptedApiTypes";
20
20
  import axios, { AxiosResponse } from "axios";
21
21
  import * as adadaptedApiRequestMocks from "./adadaptedApiRequests.mock";
22
- import { ApiEnv, DeviceOS, ListManagerApiEnv, PayloadApiEnv } from "../index";
22
+ import { DeviceTypes } from "../componentTypes/Device";
23
+ import { EnvironmentTypes } from "../componentTypes/Environment";
23
24
 
24
25
  /**
25
26
  * Makes an API request to initialize the session for the AdAdapted API.
@@ -30,10 +31,10 @@ import { ApiEnv, DeviceOS, ListManagerApiEnv, PayloadApiEnv } from "../index";
30
31
  */
31
32
  export function initializeSession(
32
33
  requestData: InitializeSessionRequest,
33
- deviceOS: DeviceOS,
34
- apiEnv: ApiEnv
34
+ deviceOS: DeviceTypes.DeviceOS,
35
+ apiEnv: EnvironmentTypes.ApiEnv
35
36
  ): Promise<AxiosResponse<InitializeSessionResponse>> {
36
- return apiEnv === ApiEnv.Mock
37
+ return apiEnv === EnvironmentTypes.ApiEnv.Mock
37
38
  ? adadaptedApiRequestMocks.initializeSession()
38
39
  : axios(`${apiEnv}/v/0.9.5/${deviceOS}/sessions/initialize`, {
39
40
  method: "POST",
@@ -54,13 +55,13 @@ export function initializeSession(
54
55
  */
55
56
  export function refreshSessionData(
56
57
  requestData: RefreshSessionDataRequest,
57
- deviceOS: DeviceOS,
58
- apiEnv: ApiEnv
58
+ deviceOS: DeviceTypes.DeviceOS,
59
+ apiEnv: EnvironmentTypes.ApiEnv
59
60
  ): Promise<AxiosResponse<RefreshSessionDataResponse>> {
60
- return apiEnv === ApiEnv.Mock
61
+ return apiEnv === EnvironmentTypes.ApiEnv.Mock
61
62
  ? adadaptedApiRequestMocks.refreshSessionData()
62
63
  : axios(
63
- `${apiEnv}/v/0.9.5/${deviceOS}/ads/retrieve?aid=${requestData.aid}&sid=${requestData.sid}&uid=${requestData.uid}`,
64
+ `${apiEnv}/v/0.9.5/${deviceOS}/ads/retrieve?aid=${requestData.aid}&sid=${requestData.sid}&uid=${requestData.uid}&sdk=${requestData.sdkVersion}&contextID=${requestData.adContext?.contextIds}&zoneID=${requestData.adContext?.zoneIds}`,
64
65
  {
65
66
  method: "GET",
66
67
  headers: {
@@ -80,10 +81,10 @@ export function refreshSessionData(
80
81
  */
81
82
  export function reportAdEvent(
82
83
  requestData: ReportAdEventRequest,
83
- deviceOS: DeviceOS,
84
- apiEnv: ApiEnv
84
+ deviceOS: DeviceTypes.DeviceOS,
85
+ apiEnv: EnvironmentTypes.ApiEnv
85
86
  ): Promise<AxiosResponse<ReportAdEventResponse>> {
86
- return apiEnv === ApiEnv.Mock
87
+ return apiEnv === EnvironmentTypes.ApiEnv.Mock
87
88
  ? adadaptedApiRequestMocks.reportAdEvent()
88
89
  : axios(`${apiEnv}/v/0.9.5/${deviceOS}/ads/events`, {
89
90
  method: "POST",
@@ -104,10 +105,10 @@ export function reportAdEvent(
104
105
  */
105
106
  export function getKeywordIntercepts(
106
107
  requestData: KeywordInterceptsRequest,
107
- deviceOS: DeviceOS,
108
- apiEnv: ApiEnv
108
+ deviceOS: DeviceTypes.DeviceOS,
109
+ apiEnv: EnvironmentTypes.ApiEnv
109
110
  ): Promise<AxiosResponse<KeywordInterceptsResponse>> {
110
- return apiEnv === ApiEnv.Mock
111
+ return apiEnv === EnvironmentTypes.ApiEnv.Mock
111
112
  ? adadaptedApiRequestMocks.getKeywordIntercepts()
112
113
  : axios(
113
114
  `${apiEnv}/v/0.9.5/${deviceOS}/intercepts/retrieve?aid=${requestData.aid}&sid=${requestData.sid}&uid=${requestData.uid}`,
@@ -130,10 +131,10 @@ export function getKeywordIntercepts(
130
131
  */
131
132
  export function reportInterceptEvent(
132
133
  requestData: ReportInterceptEventRequest,
133
- deviceOS: DeviceOS,
134
- apiEnv: ApiEnv
134
+ deviceOS: DeviceTypes.DeviceOS,
135
+ apiEnv: EnvironmentTypes.ApiEnv
135
136
  ): Promise<AxiosResponse<ReportInterceptEventResponse>> {
136
- return apiEnv === ApiEnv.Mock
137
+ return apiEnv === EnvironmentTypes.ApiEnv.Mock
137
138
  ? adadaptedApiRequestMocks.reportInterceptEvent()
138
139
  : axios(`${apiEnv}/v/0.9.5/${deviceOS}/intercepts/events`, {
139
140
  method: "POST",
@@ -154,10 +155,10 @@ export function reportInterceptEvent(
154
155
  */
155
156
  export function reportListManagerEvents(
156
157
  requestData: ReportListManagerDataRequest,
157
- deviceOS: DeviceOS,
158
- apiEnv: ListManagerApiEnv
158
+ deviceOS: DeviceTypes.DeviceOS,
159
+ apiEnv: EnvironmentTypes.ListManagerApiEnv
159
160
  ): Promise<AxiosResponse<void>> {
160
- return apiEnv === ListManagerApiEnv.Mock
161
+ return apiEnv === EnvironmentTypes.ListManagerApiEnv.Mock
161
162
  ? adadaptedApiRequestMocks.reportListManagerEvents()
162
163
  : axios(`${apiEnv}/v/1/${deviceOS}/events`, {
163
164
  method: "POST",
@@ -178,9 +179,9 @@ export function reportListManagerEvents(
178
179
  */
179
180
  export function reportPayloadContentStatus(
180
181
  requestData: ReportPayloadDataRequest,
181
- apiEnv: PayloadApiEnv
182
+ apiEnv: EnvironmentTypes.PayloadApiEnv
182
183
  ): Promise<AxiosResponse<void>> {
183
- return apiEnv === PayloadApiEnv.Mock
184
+ return apiEnv === EnvironmentTypes.PayloadApiEnv.Mock
184
185
  ? adadaptedApiRequestMocks.reportPayloadContentStatus()
185
186
  : axios(`${apiEnv}/v/1/tracking`, {
186
187
  method: "POST",
@@ -200,9 +201,9 @@ export function reportPayloadContentStatus(
200
201
  */
201
202
  export function retrievePayloadContent(
202
203
  requestData: RetrievePayloadItemDataRequest,
203
- apiEnv: PayloadApiEnv
204
+ apiEnv: EnvironmentTypes.PayloadApiEnv
204
205
  ): Promise<AxiosResponse<RetrievePayloadItemDataResponse>> {
205
- return apiEnv === PayloadApiEnv.Mock
206
+ return apiEnv === EnvironmentTypes.PayloadApiEnv.Mock
206
207
  ? adadaptedApiRequestMocks.retrievePayloadContent()
207
208
  : axios(`${apiEnv}/v/1/pickup`, {
208
209
  method: "POST",
@@ -566,6 +566,17 @@ export interface RefreshSessionDataRequest {
566
566
  * The current session ID.
567
567
  */
568
568
  sid: string;
569
+ /**
570
+ * The current sdk version.
571
+ */
572
+ sdkVersion: string;
573
+ /**
574
+ * The context IDs and associated zone IDs.
575
+ */
576
+ adContext?: {
577
+ contextIds: string[] | undefined;
578
+ zoneIds: string[];
579
+ };
569
580
  }
570
581
 
571
582
  /**
@@ -0,0 +1,97 @@
1
+ import { ViewStyle } from "react-native/types";
2
+ import { Zone, DetailedListItem } from "src/api/adadaptedApiTypes";
3
+ import { DeviceTypes } from "./Device";
4
+ import { EnvironmentTypes } from "./Environment";
5
+
6
+ /**
7
+ * Namespace for AdZone types.
8
+ */
9
+ export namespace AdZoneTypes {
10
+ /**
11
+ * Props interface for an ad zone.
12
+ */
13
+ export interface Props {
14
+ /**
15
+ * The app ID.
16
+ */
17
+ appId: string;
18
+ /**
19
+ * The session ID.
20
+ */
21
+ sessionId: string;
22
+ /**
23
+ * The UDID.
24
+ */
25
+ udid: string;
26
+ /**
27
+ * The touch sensitivity of the Ad Zone in both the X and Y directions.
28
+ * This is used to determine the click/press sensitivity when the
29
+ * Ad Zone is being touched by the user as a regular touch or while
30
+ * scrolling the view. If the amount of touch "drag" distance in either
31
+ * X or Y direction is less than this value, we will treat the action as
32
+ * a click/press on the Ad Zone.
33
+ */
34
+ xyDragDistanceAllowed: number;
35
+ /**
36
+ * The device OS used for API requests.
37
+ */
38
+ deviceOs: DeviceTypes.DeviceOS;
39
+ /**
40
+ * The API environment to use when making an API request.
41
+ */
42
+ apiEnv: EnvironmentTypes.ApiEnv;
43
+ /**
44
+ * The ad zone data.
45
+ */
46
+ adZoneData: Zone;
47
+ /**
48
+ * Callback that gets triggered when an "add to list" item/items are clicked.
49
+ * @param items - The array of items to "add to list".
50
+ */
51
+ onAddToListTriggered?(items: DetailedListItem[]): void;
52
+ /**
53
+ * An ad zone that is not visible on screen for the initial render.
54
+ */
55
+ offScreenAdZone: boolean;
56
+ /**
57
+ * Track the ad zone visibility in parent component. (for off-screen ads)
58
+ */
59
+ isAdZoneVisible?: boolean;
60
+ /**
61
+ * Flag to determine if the ad is contextual.
62
+ */
63
+ isContextualAd?: boolean;
64
+ }
65
+
66
+ /**
67
+ * Interface for tracking "touch" coordinates.
68
+ */
69
+ export interface TouchCoordinates {
70
+ /**
71
+ * The X coordinate for the touch.
72
+ */
73
+ x: number;
74
+ /**
75
+ * The Y coordinate for the touch.
76
+ */
77
+ y: number;
78
+ }
79
+
80
+ /**
81
+ * Defines the style typing for the component.
82
+ */
83
+ export interface StyleDef {
84
+ /**
85
+ * Styles for the main View element.
86
+ */
87
+ mainView: ViewStyle;
88
+ /**
89
+ * Styles for the WebView element.
90
+ */
91
+ webView: ViewStyle;
92
+ /**
93
+ * Styles for the ReportAdButton.
94
+ */
95
+ reportAd: ViewStyle;
96
+ }
97
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Namespace for Device types.
3
+ */
4
+ export namespace DeviceTypes {
5
+ /**
6
+ * Enum representing possible device operating systems.
7
+ */
8
+ export enum DeviceOS {
9
+ /**
10
+ * Represents the Android operating system.
11
+ */
12
+ ANDROID = "android",
13
+ /**
14
+ * Represents the iOS operating system.
15
+ */
16
+ IOS = "ios",
17
+ }
18
+ /**
19
+ * Interface defining properties of a user's Device.
20
+ */
21
+ export interface DeviceInfo {
22
+ /**
23
+ * The unique device ID.
24
+ */
25
+ udid: string;
26
+ /**
27
+ * The device name.
28
+ */
29
+ deviceName: string;
30
+ /**
31
+ * The operating system name.
32
+ */
33
+ systemName: string;
34
+ /**
35
+ * The operating system version.
36
+ */
37
+ systemVersion: string;
38
+ /**
39
+ * The device model.
40
+ */
41
+ deviceModel: string;
42
+ /**
43
+ * The device screen width.
44
+ */
45
+ deviceWidth: string;
46
+ /**
47
+ * The device screen height.
48
+ */
49
+ deviceHeight: string;
50
+ /**
51
+ * The device screen density.
52
+ */
53
+ deviceScreenDensity: string;
54
+ /**
55
+ * The current device local.
56
+ */
57
+ deviceLocale: string;
58
+ /**
59
+ * The device carrier name.
60
+ */
61
+ deviceCarrier: string;
62
+ /**
63
+ * The bundle ID.
64
+ */
65
+ bundleId: string;
66
+ /**
67
+ * The bundle version.
68
+ */
69
+ bundleVersion: string;
70
+ /**
71
+ * The current device timezone.
72
+ */
73
+ deviceTimezone: string;
74
+ /**
75
+ * If true, ad tracking is enabled for the device.
76
+ */
77
+ isAdTrackingEnabled: boolean;
78
+ }
79
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Namespace for environment types.
3
+ */
4
+ export namespace EnvironmentTypes {
5
+ /**
6
+ * Enum defining the different API environments.
7
+ */
8
+ export enum ApiEnv {
9
+ /**
10
+ * The production API environment.
11
+ */
12
+ Prod = "https://ads.adadapted.com",
13
+ /**
14
+ * The development API environment.
15
+ */
16
+ Dev = "https://sandbox.adadapted.com",
17
+ /**
18
+ * Used only for unit testing/mock data.
19
+ */
20
+ Mock = "MOCK_DATA",
21
+ }
22
+
23
+ /**
24
+ * Enum defining the different API environments for List Manager.
25
+ */
26
+ export enum ListManagerApiEnv {
27
+ /**
28
+ * The production API environment.
29
+ */
30
+ Prod = "https://ec.adadapted.com",
31
+ /**
32
+ * The development API environment.
33
+ */
34
+ Dev = "https://sandec.adadapted.com",
35
+ /**
36
+ * Used only for unit testing/mocking data.
37
+ */
38
+ Mock = "MOCK_DATA",
39
+ }
40
+
41
+ /**
42
+ * Enum defining the different API environments for the Payload Server.
43
+ */
44
+ export enum PayloadApiEnv {
45
+ /**
46
+ * The production API environment.
47
+ */
48
+ Prod = "https://payload.adadapted.com",
49
+ /**
50
+ * The development API environment.
51
+ */
52
+ Dev = "https://sandpayload.adadapted.com",
53
+ /**
54
+ * Used only for unit testing/mocking data.
55
+ */
56
+ Mock = "MOCK_DATA",
57
+ }
58
+ }