@adadapted/react-native-sdk 3.4.0 → 3.5.1

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 (75) hide show
  1. package/adadapted-react-native-sdk.podspec +1 -1
  2. package/lib/commonjs/api/adadaptedApiRequests.js +10 -11
  3. package/lib/commonjs/api/adadaptedApiRequests.js.map +1 -1
  4. package/lib/commonjs/api/adadaptedApiTypes.js +57 -0
  5. package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
  6. package/lib/commonjs/componentTypes/AdZone.js +11 -0
  7. package/lib/commonjs/componentTypes/AdZone.js.map +1 -0
  8. package/lib/commonjs/componentTypes/Device.js +28 -0
  9. package/lib/commonjs/componentTypes/Device.js.map +1 -0
  10. package/lib/commonjs/componentTypes/Environment.js +61 -0
  11. package/lib/commonjs/componentTypes/Environment.js.map +1 -0
  12. package/lib/commonjs/components/AdZone.js +12 -17
  13. package/lib/commonjs/components/AdZone.js.map +1 -1
  14. package/lib/commonjs/components/ReportAdButton.js +1 -2
  15. package/lib/commonjs/components/ReportAdButton.js.map +1 -1
  16. package/lib/commonjs/index.js +97 -118
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/util.js +0 -1
  19. package/lib/commonjs/util.js.map +1 -1
  20. package/lib/module/api/adadaptedApiRequests.js +9 -9
  21. package/lib/module/api/adadaptedApiRequests.js.map +1 -1
  22. package/lib/module/api/adadaptedApiTypes.js +57 -0
  23. package/lib/module/api/adadaptedApiTypes.js.map +1 -1
  24. package/lib/module/componentTypes/AdZone.js +7 -0
  25. package/lib/module/componentTypes/AdZone.js.map +1 -0
  26. package/lib/module/componentTypes/Device.js +24 -0
  27. package/lib/module/componentTypes/Device.js.map +1 -0
  28. package/lib/module/componentTypes/Environment.js +57 -0
  29. package/lib/module/componentTypes/Environment.js.map +1 -0
  30. package/lib/module/components/AdZone.js +11 -15
  31. package/lib/module/components/AdZone.js.map +1 -1
  32. package/lib/module/index.js +92 -122
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/module/util.js +0 -1
  35. package/lib/module/util.js.map +1 -1
  36. package/lib/typescript/index.d.ts +2 -0
  37. package/lib/typescript/index.d.ts.map +1 -0
  38. package/lib/typescript/jest.setup.d.ts +6 -0
  39. package/lib/typescript/jest.setup.d.ts.map +1 -0
  40. package/lib/typescript/src/api/adadaptedApiRequests.d.ts +10 -9
  41. package/lib/typescript/src/api/adadaptedApiRequests.d.ts.map +1 -1
  42. package/lib/typescript/src/api/adadaptedApiTypes.d.ts +11 -4
  43. package/lib/typescript/src/api/adadaptedApiTypes.d.ts.map +1 -1
  44. package/lib/typescript/src/componentTypes/AdZone.d.ts +95 -0
  45. package/lib/typescript/src/componentTypes/AdZone.d.ts.map +1 -0
  46. package/lib/typescript/src/componentTypes/Device.d.ts +80 -0
  47. package/lib/typescript/src/componentTypes/Device.d.ts.map +1 -0
  48. package/lib/typescript/src/componentTypes/Environment.d.ts +57 -0
  49. package/lib/typescript/src/componentTypes/Environment.d.ts.map +1 -0
  50. package/lib/typescript/src/components/AdZone.d.ts +2 -55
  51. package/lib/typescript/src/components/AdZone.d.ts.map +1 -1
  52. package/lib/typescript/src/index.d.ts +38 -142
  53. package/lib/typescript/src/index.d.ts.map +1 -1
  54. package/lib/typescript/src/types.d.ts.map +1 -1
  55. package/package.json +43 -34
  56. package/src/api/adadaptedApiRequests.mock.ts +2 -2
  57. package/src/api/adadaptedApiRequests.ts +27 -26
  58. package/src/api/adadaptedApiTypes.ts +11 -5
  59. package/src/componentTypes/AdZone.ts +97 -0
  60. package/src/componentTypes/Device.ts +79 -0
  61. package/src/componentTypes/Environment.ts +58 -0
  62. package/src/components/AdZone.tsx +42 -120
  63. package/src/index.tsx +189 -287
  64. package/src/types.tsx +6 -5
  65. package/src/util.ts +6 -7
  66. package/android/.project +0 -34
  67. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  68. package/android/bin/.project +0 -34
  69. package/android/bin/.settings/org.eclipse.buildship.core.prefs +0 -13
  70. package/android/bin/build.gradle +0 -132
  71. package/android/bin/gradle.properties +0 -4
  72. package/android/bin/src/main/AndroidManifest.xml +0 -4
  73. package/android/bin/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkModule.kt +0 -115
  74. package/android/bin/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkPackage.kt +0 -20
  75. package/lib/module/package.json +0 -1
package/src/index.tsx CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  import * as adadaptedApiRequests from "./api/adadaptedApiRequests";
13
13
  import {
14
14
  AdSession,
15
- AdZoneDetailedListItemInfo,
15
+ DetailedListItem,
16
16
  KeywordIntercepts,
17
17
  KeywordSearchTerm,
18
18
  ListManagerEvent,
@@ -29,74 +29,8 @@ import { AdZone } from "./components/AdZone";
29
29
  import { safeInvoke } from "./util";
30
30
  import packageJson from "../package.json";
31
31
  import base64 from "react-native-base64";
32
-
33
- /**
34
- * Enum representing possible device operating systems.
35
- */
36
- export enum DeviceOS {
37
- /**
38
- * Represents the Android operating system.
39
- */
40
- ANDROID = "android",
41
- /**
42
- * Represents the iOS operating system.
43
- */
44
- IOS = "ios",
45
- }
46
-
47
- /**
48
- * Enum defining the different API environments.
49
- */
50
- export enum ApiEnv {
51
- /**
52
- * The production API environment.
53
- */
54
- Prod = "https://ads.adadapted.com",
55
- /**
56
- * The development API environment.
57
- */
58
- Dev = "https://sandbox.adadapted.com",
59
- /**
60
- * Used only for unit testing/mock data.
61
- */
62
- Mock = "MOCK_DATA",
63
- }
64
-
65
- /**
66
- * Enum defining the different API environments for List Manager.
67
- */
68
- export enum ListManagerApiEnv {
69
- /**
70
- * The production API environment.
71
- */
72
- Prod = "https://ec.adadapted.com",
73
- /**
74
- * The development API environment.
75
- */
76
- Dev = "https://sandec.adadapted.com",
77
- /**
78
- * Used only for unit testing/mocking data.
79
- */
80
- Mock = "MOCK_DATA",
81
- }
82
-
83
- /**
84
- * Enum defining the different API environments for the Payload Server.
85
- */
86
- export enum PayloadApiEnv {
87
- /**
88
- * The production API environment.
89
- */
90
- Prod = "https://payload.adadapted.com",
91
- /**
92
- * The development API environment.
93
- */
94
- Dev = "https://sandpayload.adadapted.com",
95
- /**
96
- * Used only for unit testing/mocking data.
97
- */
98
- Mock = "MOCK_DATA",
99
- }
32
+ import { DeviceTypes } from "./componentTypes/Device";
33
+ import { EnvironmentTypes } from "./componentTypes/Environment";
100
34
 
101
35
  /**
102
36
  * Interface defining inputs to the {@link Sdk.initialize: AdadaptedReactNativeSdk} method.
@@ -110,7 +44,7 @@ export interface InitializeProps {
110
44
  * The API environment.
111
45
  * If undefined, defaults to production.
112
46
  */
113
- apiEnv?: ApiEnv;
47
+ apiEnv?: EnvironmentTypes.ApiEnv;
114
48
  /**
115
49
  * Optional custom advertiserId to replace IDFA - ios only.
116
50
  */
@@ -131,81 +65,19 @@ export interface InitializeProps {
131
65
  onAdZonesRefreshed?(): void;
132
66
  /**
133
67
  * Callback that gets triggered when an "add to list" item/items are clicked.
134
- * @param detail - details about the list items to add to cart.
68
+ * @param items - The array of items to "add to list".
135
69
  */
136
- onAddToListTriggered?(detail: AdZoneDetailedListItemInfo): void;
70
+ onAddToListTriggered?(items: DetailedListItem[]): void;
137
71
  /**
138
72
  * Callback that gets triggered when an "add to list"
139
73
  * occurs by means of an "out of app" data payload.
140
- * @param detail - Details about payloads clients must go through.
74
+ * @param payloads - All payloads the client must go through.
141
75
  */
142
76
  onOutOfAppPayloadAvailable?(payloads: OutOfAppDataPayload[]): void;
143
77
  /**
144
- * Ad zones that contain off-screen ads.
78
+ * Ad zone ids that contain off-screen ads.
145
79
  */
146
- offScreenAdZone?: [number];
147
- }
148
-
149
- /**
150
- * Interface defining properties of a user's Device.
151
- */
152
- export interface DeviceInfo {
153
- /**
154
- * The unique device ID.
155
- */
156
- udid: string;
157
- /**
158
- * The device name.
159
- */
160
- deviceName: string;
161
- /**
162
- * The operating system name.
163
- */
164
- systemName: string;
165
- /**
166
- * The operating system version.
167
- */
168
- systemVersion: string;
169
- /**
170
- * The device model.
171
- */
172
- deviceModel: string;
173
- /**
174
- * The device screen width.
175
- */
176
- deviceWidth: string;
177
- /**
178
- * The device screen height.
179
- */
180
- deviceHeight: string;
181
- /**
182
- * The device screen density.
183
- */
184
- deviceScreenDensity: string;
185
- /**
186
- * The current device local.
187
- */
188
- deviceLocale: string;
189
- /**
190
- * The device carrier name.
191
- */
192
- deviceCarrier: string;
193
- /**
194
- * The bundle ID.
195
- */
196
- bundleId: string;
197
- /**
198
- * The bundle version.
199
- */
200
- bundleVersion: string;
201
- /**
202
- * The current device timezone.
203
- */
204
- deviceTimezone: string;
205
- /**
206
- * If true, ad tracking is enabled for the device.
207
- */
208
- isAdTrackingEnabled: boolean;
80
+ offScreenAdZoneIds?: [number];
209
81
  }
210
82
 
211
83
  /**
@@ -241,19 +113,19 @@ export class AdadaptedReactNativeSdk {
241
113
  /**
242
114
  * The API environment to use when making API calls.
243
115
  */
244
- private apiEnv: ApiEnv;
116
+ private apiEnv: EnvironmentTypes.ApiEnv;
245
117
  /**
246
118
  * The API environment to use when making API calls for List Manager.
247
119
  */
248
- private listManagerApiEnv: ListManagerApiEnv;
120
+ private listManagerApiEnv: EnvironmentTypes.ListManagerApiEnv;
249
121
  /**
250
122
  * The API environment to use when making API calls for the Payload server.
251
123
  */
252
- private payloadApiEnv: PayloadApiEnv;
124
+ private payloadApiEnv: EnvironmentTypes.PayloadApiEnv;
253
125
  /**
254
126
  * The device operating system.
255
127
  */
256
- private deviceOs: DeviceOS | undefined;
128
+ private deviceOs: DeviceTypes.DeviceOS | undefined;
257
129
  /**
258
130
  * The session ID used for the API to properly identify a user.
259
131
  */
@@ -261,7 +133,7 @@ export class AdadaptedReactNativeSdk {
261
133
  /**
262
134
  * All device data gathered when "initialize" is called.
263
135
  */
264
- private deviceInfo: DeviceInfo | undefined;
136
+ private deviceInfo: DeviceTypes.DeviceInfo | undefined;
265
137
  /**
266
138
  * All current Session/Ad info.
267
139
  * This info can be refreshed based on the set interval.
@@ -275,6 +147,10 @@ export class AdadaptedReactNativeSdk {
275
147
  * The available off-screen ad zones.
276
148
  */
277
149
  private offScreenAdZones: AdZoneInfo[] = [];
150
+ /**
151
+ * The zone ids of the availible off-screen ad zones.
152
+ */
153
+ private offScreenAdZoneIds: number[] = [];
278
154
  /**
279
155
  * The touch sensitivity of the Ad Zone in both the X and Y directions.
280
156
  * This is used to determine the click/press sensitivity when the
@@ -309,12 +185,12 @@ export class AdadaptedReactNativeSdk {
309
185
  /**
310
186
  * If provided, triggers when an "add to list" item is
311
187
  * clicked in an ad zone.
312
- * @param detail - The array of items to "add to list".
188
+ * @param items - The array of items to "add to list".
313
189
  * @param isExternalPayload - If true, the items are from an external payload.
314
190
  */
315
191
  private onAddToListTriggered: (
316
- detail: AdZoneDetailedListItemInfo,
317
- isExternalPayload?: boolean
192
+ items: DetailedListItem[],
193
+ isExternalPayload?: boolean,
318
194
  ) => void | undefined;
319
195
  /**
320
196
  * If provided, triggers when an "add to list"
@@ -322,7 +198,7 @@ export class AdadaptedReactNativeSdk {
322
198
  * @param payloads - All payloads the client must go through.
323
199
  */
324
200
  private onOutOfAppPayloadAvailable: (
325
- payloads: OutOfAppDataPayload[]
201
+ payloads: OutOfAppDataPayload[],
326
202
  ) => void | undefined;
327
203
  /**
328
204
  * Deeplink event listener.
@@ -333,9 +209,19 @@ export class AdadaptedReactNativeSdk {
333
209
  */
334
210
  private AppStateOnEventListener: EmitterSubscription | undefined;
335
211
  /**
336
- * Ad zones that contain off-screen ads.
212
+ * The current adzone visibility status.
213
+ */
214
+ private isAdZoneVisible: boolean = true;
215
+ /**
216
+ * The ad context object.
337
217
  */
338
- private offScreenAdZone: [number] | undefined;
218
+ private adContext:
219
+ | {
220
+ contextIds: string[];
221
+ zoneIds: string[];
222
+ }
223
+ | undefined;
224
+
339
225
  /**
340
226
  * Gets the Session ID.
341
227
  * @returns the Session ID.
@@ -348,7 +234,7 @@ export class AdadaptedReactNativeSdk {
348
234
  * Gets the Device Info object.
349
235
  * @returns the Device Info object.
350
236
  */
351
- public getDeviceInfo(): DeviceInfo | undefined {
237
+ public getDeviceInfo(): DeviceTypes.DeviceInfo | undefined {
352
238
  return this.deviceInfo;
353
239
  }
354
240
 
@@ -368,13 +254,35 @@ export class AdadaptedReactNativeSdk {
368
254
  return this.offScreenAdZones;
369
255
  }
370
256
 
257
+ /**
258
+ * Sets an ad context to replace an ad zone's ads with contextual ads for recipes.
259
+ * @param adContext - Object containing the contextual term and the associted ad zone.
260
+ * @param adContext.contextIds - An array of contextual ad ids.
261
+ * @param adContext.zoneIds - An array of zone ids for applying contextual ads.
262
+ */
263
+ public setAdContext(adContext: {
264
+ contextIds: string[];
265
+ zoneIds: string[];
266
+ }): void {
267
+ this.adContext = adContext;
268
+ this.onRefreshAdZones(true);
269
+ }
270
+
271
+ /**
272
+ * Clear the contextual ads from ad zones to return standard ads to the ad zones.
273
+ */
274
+ public clearAdContext(): void {
275
+ this.adContext = undefined;
276
+ this.onRefreshAdZones(true);
277
+ }
278
+
371
279
  /**
372
280
  * @inheritDoc
373
281
  */
374
282
  constructor() {
375
- this.apiEnv = ApiEnv.Prod;
376
- this.listManagerApiEnv = ListManagerApiEnv.Prod;
377
- this.payloadApiEnv = PayloadApiEnv.Prod;
283
+ this.apiEnv = EnvironmentTypes.ApiEnv.Prod;
284
+ this.listManagerApiEnv = EnvironmentTypes.ListManagerApiEnv.Prod;
285
+ this.payloadApiEnv = EnvironmentTypes.PayloadApiEnv.Prod;
378
286
  this.onAdZonesRefreshed = () => {
379
287
  // Defaulting to empty method.
380
288
  };
@@ -401,111 +309,92 @@ export class AdadaptedReactNativeSdk {
401
309
  NativeModules.AdadaptedReactNativeSdk.getDeviceInfo().then(
402
310
  (response: string) => {
403
311
  resolve(response);
404
- }
312
+ },
405
313
  );
406
314
  });
407
315
  }
408
316
 
317
+ private adZoneTemplate(
318
+ adZones: { [key: number]: Zone },
319
+ zoneId: string,
320
+ offScreenAdZone: boolean,
321
+ ): AdZoneInfo {
322
+ return {
323
+ zoneId: adZones[Number(zoneId)].id,
324
+ adZone: (
325
+ <AdZone
326
+ key={zoneId}
327
+ appId={this.appId}
328
+ sessionId={this.sessionId!}
329
+ udid={this.deviceInfo!.udid}
330
+ deviceOs={this.deviceOs!}
331
+ apiEnv={this.apiEnv}
332
+ xyDragDistanceAllowed={
333
+ this.xyAdZoneDragDistanceAllowed || 25
334
+ }
335
+ adZoneData={adZones[Number(zoneId)]}
336
+ onAddToListTriggered={(items) => {
337
+ safeInvoke(this.onAddToListTriggered, items);
338
+ }}
339
+ isAdZoneVisible={this.isAdZoneVisible}
340
+ offScreenAdZone={offScreenAdZone ? true : false}
341
+ isContextualAd={this.adContext ? true : false}
342
+ />
343
+ ),
344
+ };
345
+ }
346
+
409
347
  /**
410
348
  * Creates all Ad Zone Info objects based on provided Ad Zones.
411
349
  * @param adZones - The object of available zones.
350
+ * @param offScreenAdZone - True if an ad zone first renders out of view.
412
351
  * @returns the array of Ad Zone Info objects.
413
352
  */
414
- private generateAdZones(adZones: { [key: number]: Zone }): AdZoneInfo[] {
353
+ private generateAdZones(
354
+ adZones: { [key: number]: Zone },
355
+ offScreenAdZone: boolean = false,
356
+ ): AdZoneInfo[] {
415
357
  const adZoneInfoList: AdZoneInfo[] = [];
416
-
417
- for (const adZoneId in adZones) {
418
- if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
419
- adZoneInfoList.push({
420
- zoneId: adZones[adZoneId].id,
421
- adZone: (
422
- <AdZone
423
- key={adZoneId}
424
- appId={this.appId}
425
- sessionId={this.sessionId!}
426
- udid={this.deviceInfo!.udid}
427
- deviceOs={this.deviceOs!}
428
- apiEnv={this.apiEnv}
429
- xyDragDistanceAllowed={
430
- this.xyAdZoneDragDistanceAllowed || 25
431
- }
432
- adZoneData={adZones[adZoneId]}
433
- onAddToListTriggered={(details) => {
434
- safeInvoke(this.onAddToListTriggered, {
435
- zoneId: adZoneId,
436
- items: details,
437
- });
438
- }}
439
- isAdZoneVisible={true}
440
- offScreenAdZone={false}
441
- />
442
- ),
443
- });
358
+ const offScreenAdZoneList: AdZoneInfo[] = [];
359
+
360
+ if (offScreenAdZone) {
361
+ for (const adZoneId in adZones) {
362
+ if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
363
+ if (this.offScreenAdZoneIds.includes(Number(adZoneId))) {
364
+ offScreenAdZoneList.push(
365
+ this.adZoneTemplate(adZones, adZoneId, true),
366
+ );
367
+ }
368
+ }
444
369
  }
445
- }
446
- return adZoneInfoList;
447
- }
448
-
449
- /**
450
- * Creates all off-screen Ad Zone Info objects based on provided off-screen Ad Zones.
451
- * @param adZones - The object of available zones.
452
- * @returns the array of off-screen Ad Zone Info objects.
453
- */
454
- private generateOffScreenAdZones(adZones: {
455
- [key: number]: Zone;
456
- }): AdZoneInfo[] {
457
- const adZoneInfoList: AdZoneInfo[] = [];
458
-
459
- for (const adZoneId in adZones) {
460
- if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
461
- if (
462
- this.offScreenAdZone &&
463
- this.offScreenAdZone.length > 0 &&
464
- this.offScreenAdZone.includes(Number(adZoneId))
465
- ) {
466
- adZoneInfoList.push({
467
- zoneId: adZones[adZoneId].id,
468
- adZone: (
469
- <AdZone
470
- key={adZoneId}
471
- appId={this.appId}
472
- sessionId={this.sessionId!}
473
- udid={this.deviceInfo!.udid}
474
- deviceOs={this.deviceOs!}
475
- apiEnv={this.apiEnv}
476
- xyDragDistanceAllowed={
477
- this.xyAdZoneDragDistanceAllowed || 25
478
- }
479
- adZoneData={adZones[adZoneId]}
480
- onAddToListTriggered={(items) => {
481
- safeInvoke(this.onAddToListTriggered, {
482
- zoneId: adZoneId,
483
- items,
484
- });
485
- }}
486
- isAdZoneVisible={false}
487
- offScreenAdZone={true}
488
- />
489
- ),
490
- });
370
+ } else {
371
+ for (const adZoneId in adZones) {
372
+ if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
373
+ adZoneInfoList.push(
374
+ this.adZoneTemplate(adZones, adZoneId, false),
375
+ );
491
376
  }
492
377
  }
493
378
  }
494
- return adZoneInfoList;
379
+
380
+ return offScreenAdZone ? offScreenAdZoneList : adZoneInfoList;
495
381
  }
496
382
 
497
383
  /**
498
384
  * Triggered when session data is initialized or refreshed. Creates
499
385
  * a timer based on the session data refresh value.
386
+ * @param immediateRefresh - If true the ad zones are refreshed bypassing the timer.
500
387
  */
501
- private onRefreshAdZones(): void {
388
+ private onRefreshAdZones(immediateRefresh: boolean = false): void {
502
389
  // Get the amount of time we will wait until a refresh occurs.
503
390
  // We are setting a minimum refresh time of 5 minutes, so if a
504
391
  // value provided by the API is lower, we don't refresh too often.
505
- const timerMs =
506
- this.sessionInfo!.polling_interval_ms >= 300000
507
- ? this.sessionInfo!.polling_interval_ms
508
- : 300000;
392
+ // If there are contextual ads, we refresh immediately to reload the ad zone.
393
+ const timerMs = immediateRefresh
394
+ ? 0
395
+ : this.sessionInfo!.polling_interval_ms >= 300000
396
+ ? this.sessionInfo!.polling_interval_ms
397
+ : 300000;
509
398
 
510
399
  this.refreshAdZonesTimer = setTimeout(() => {
511
400
  adadaptedApiRequests
@@ -514,16 +403,23 @@ export class AdadaptedReactNativeSdk {
514
403
  aid: this.appId,
515
404
  sid: this.sessionId!,
516
405
  uid: this.deviceInfo!.udid,
406
+ sdkVersion: packageJson.version,
407
+ adContext: this.adContext,
517
408
  },
518
409
  this.deviceOs!,
519
- this.apiEnv
410
+ this.apiEnv,
520
411
  )
521
412
  .then((response) => {
522
413
  this.sessionInfo = response.data;
414
+
415
+ if (this.offScreenAdZones.length > 0) {
416
+ this.offScreenAdZones = this.generateAdZones(
417
+ response.data.zones,
418
+ true,
419
+ );
420
+ }
421
+
523
422
  this.adZones = this.generateAdZones(response.data.zones);
524
- this.offScreenAdZones = this.generateOffScreenAdZones(
525
- response.data.zones
526
- );
527
423
 
528
424
  // Call the user defined callback indicating
529
425
  // the session data has been refreshed.
@@ -555,7 +451,7 @@ export class AdadaptedReactNativeSdk {
555
451
  uid: this.deviceInfo!.udid,
556
452
  },
557
453
  this.deviceOs!,
558
- this.apiEnv
454
+ this.apiEnv,
559
455
  )
560
456
  .then((response) => {
561
457
  this.keywordIntercepts = response.data;
@@ -568,7 +464,7 @@ export class AdadaptedReactNativeSdk {
568
464
  * @returns the term if it was found based on the provided term ID.
569
465
  */
570
466
  private getKeywordInterceptTerm(
571
- termId: string
467
+ termId: string,
572
468
  ): KeywordSearchTerm | undefined {
573
469
  let term: KeywordSearchTerm | undefined;
574
470
 
@@ -603,7 +499,7 @@ export class AdadaptedReactNativeSdk {
603
499
  eventSource: ListManagerEventSource,
604
500
  eventName: ListManagerEventName,
605
501
  itemNames: string[],
606
- listName?: string
502
+ listName?: string,
607
503
  ): ReportListManagerDataRequest {
608
504
  const eventList: ListManagerEvent[] = [];
609
505
 
@@ -638,7 +534,7 @@ export class AdadaptedReactNativeSdk {
638
534
 
639
535
  if (dataIndex !== -1) {
640
536
  const encodedData: string = event.url.substr(
641
- `${dataIndex}${searchStr.length}`
537
+ `${dataIndex}${searchStr.length}`,
642
538
  );
643
539
  const payloadData = JSON.parse(base64.decode(encodedData));
644
540
  const payloadId = payloadData.payload_id;
@@ -691,7 +587,7 @@ export class AdadaptedReactNativeSdk {
691
587
  session_id: this.sessionId!,
692
588
  udid: this.deviceInfo!.udid,
693
589
  },
694
- this.payloadApiEnv
590
+ this.payloadApiEnv,
695
591
  )
696
592
  .then((response) => {
697
593
  const finalItemList: OutOfAppDataPayload[] = [];
@@ -753,19 +649,20 @@ export class AdadaptedReactNativeSdk {
753
649
  if (props.apiEnv) {
754
650
  this.apiEnv = props.apiEnv;
755
651
  } else {
756
- this.apiEnv = ApiEnv.Prod;
652
+ this.apiEnv = EnvironmentTypes.ApiEnv.Prod;
757
653
  }
758
654
 
759
655
  // Base the List Manager API environment off what
760
656
  // the user provides for the props.apiEnv value.
761
657
  if (props.apiEnv) {
762
- if (props.apiEnv === ApiEnv.Prod) {
763
- this.listManagerApiEnv = ListManagerApiEnv.Prod;
658
+ if (props.apiEnv === EnvironmentTypes.ApiEnv.Prod) {
659
+ this.listManagerApiEnv =
660
+ EnvironmentTypes.ListManagerApiEnv.Prod;
764
661
  } else {
765
- this.listManagerApiEnv = ListManagerApiEnv.Dev;
662
+ this.listManagerApiEnv = EnvironmentTypes.ListManagerApiEnv.Dev;
766
663
  }
767
664
  } else {
768
- this.listManagerApiEnv = ListManagerApiEnv.Prod;
665
+ this.listManagerApiEnv = EnvironmentTypes.ListManagerApiEnv.Prod;
769
666
  }
770
667
 
771
668
  // The ad zone touch drag sensitivity setting.
@@ -792,21 +689,22 @@ export class AdadaptedReactNativeSdk {
792
689
  }
793
690
 
794
691
  // If provided set any off-screen ad zones.
795
- if (props.offScreenAdZone) {
796
- this.offScreenAdZone = props.offScreenAdZone;
692
+ if ((props.offScreenAdZoneIds ?? []).length > 0) {
693
+ this.offScreenAdZoneIds = props.offScreenAdZoneIds ?? [];
797
694
  }
798
695
 
799
696
  return new Promise<void>((resolve, reject) => {
800
697
  this.getDeviceInformation()
801
698
  .then((deviceInfoObj) => {
802
- const deviceInfo = JSON.parse(deviceInfoObj) as DeviceInfo;
699
+ const deviceInfo = JSON.parse(
700
+ deviceInfoObj,
701
+ ) as DeviceTypes.DeviceInfo;
803
702
  this.deviceInfo = deviceInfo;
804
- this.deviceOs =
805
- deviceInfo.systemName === "ios"
806
- ? DeviceOS.IOS
807
- : DeviceOS.ANDROID;
703
+ this.deviceOs = deviceInfo.systemName.includes("ios")
704
+ ? DeviceTypes.DeviceOS.IOS
705
+ : DeviceTypes.DeviceOS.ANDROID;
808
706
  // Pass custom advertiserId - ios only
809
- if (Platform.OS === "ios") {
707
+ if (Platform.OS.includes("ios")) {
810
708
  if (!(props.advertiserId === undefined)) {
811
709
  deviceInfo.udid = props.advertiserId;
812
710
  }
@@ -821,11 +719,11 @@ export class AdadaptedReactNativeSdk {
821
719
  sdk_version: packageJson.version,
822
720
  device_width: parseInt(
823
721
  deviceInfo.deviceWidth,
824
- 10
722
+ 10,
825
723
  ),
826
724
  device_height: parseInt(
827
725
  deviceInfo.deviceHeight,
828
- 10
726
+ 10,
829
727
  ),
830
728
  device_density: deviceInfo.deviceScreenDensity,
831
729
  device_carrier: deviceInfo.deviceCarrier,
@@ -840,21 +738,25 @@ export class AdadaptedReactNativeSdk {
840
738
  deviceInfo.isAdTrackingEnabled,
841
739
  },
842
740
  this.deviceOs,
843
- this.apiEnv
741
+ this.apiEnv,
844
742
  )
845
743
  .then((response) => {
846
744
  NativeModules.AdadaptedReactNativeSdk.storeCurrentSessionId(
847
- response.data.session_id
745
+ response.data.session_id,
848
746
  );
849
747
  this.sessionId = response.data.session_id;
850
748
  this.sessionInfo = response.data;
749
+
851
750
  this.adZones = this.generateAdZones(
852
- response.data.zones
751
+ response.data.zones,
853
752
  );
854
- this.offScreenAdZones =
855
- this.generateOffScreenAdZones(
856
- response.data.zones
753
+
754
+ if ((props.offScreenAdZoneIds ?? []).length > 0) {
755
+ this.offScreenAdZones = this.generateAdZones(
756
+ response.data.zones,
757
+ true,
857
758
  );
759
+ }
858
760
 
859
761
  // Start the session data refresh timer.
860
762
  this.onRefreshAdZones();
@@ -883,7 +785,7 @@ export class AdadaptedReactNativeSdk {
883
785
  this.deepLinkOnEventListener =
884
786
  Linking.addEventListener(
885
787
  "url",
886
- this.handleDeepLink
788
+ this.handleDeepLink,
887
789
  );
888
790
 
889
791
  // // Initialize an event listener to intercept App state changes.
@@ -919,11 +821,11 @@ export class AdadaptedReactNativeSdk {
919
821
 
920
822
  if (!this.deviceInfo) {
921
823
  console.error(
922
- "AdAdapted SDK has not been initialized with device info."
824
+ "AdAdapted SDK has not been initialized with device info.",
923
825
  );
924
826
  } else if (!this.sessionId) {
925
827
  console.error(
926
- "AdAdapted SDK has not been initialized with session id."
828
+ "AdAdapted SDK has not been initialized with session id.",
927
829
  );
928
830
  } else if (!this.keywordIntercepts) {
929
831
  console.error("No available keyword intercepts.");
@@ -961,10 +863,10 @@ export class AdadaptedReactNativeSdk {
961
863
 
962
864
  // Sort the final results by priority.
963
865
  finalResultListStartsWith.sort((a, b) =>
964
- a.priority > b.priority ? 1 : -1
866
+ a.priority > b.priority ? 1 : -1,
965
867
  );
966
868
  finalResultListContains.sort((a, b) =>
967
- a.priority > b.priority ? 1 : -1
869
+ a.priority > b.priority ? 1 : -1,
968
870
  );
969
871
 
970
872
  // If there are no events to report at this point,
@@ -991,7 +893,7 @@ export class AdadaptedReactNativeSdk {
991
893
  events: finalEventsList,
992
894
  },
993
895
  this.deviceOs!,
994
- this.apiEnv
896
+ this.apiEnv,
995
897
  )
996
898
  .then(() => {
997
899
  // Do nothing with the response for now...
@@ -1018,11 +920,11 @@ export class AdadaptedReactNativeSdk {
1018
920
 
1019
921
  if (!this.deviceInfo) {
1020
922
  console.error(
1021
- "AdAdapted SDK has not been initialized with device info."
923
+ "AdAdapted SDK has not been initialized with device info.",
1022
924
  );
1023
925
  } else if (!this.sessionId) {
1024
926
  console.error(
1025
- "AdAdapted SDK has not been initialized with session id."
927
+ "AdAdapted SDK has not been initialized with session id.",
1026
928
  );
1027
929
  } else if (!this.keywordIntercepts) {
1028
930
  console.error("No available keyword intercepts.");
@@ -1047,7 +949,7 @@ export class AdadaptedReactNativeSdk {
1047
949
  ],
1048
950
  },
1049
951
  this.deviceOs!,
1050
- this.apiEnv
952
+ this.apiEnv,
1051
953
  )
1052
954
  .then(() => {
1053
955
  // Do nothing with the response for now...
@@ -1077,11 +979,11 @@ export class AdadaptedReactNativeSdk {
1077
979
 
1078
980
  if (!this.deviceInfo) {
1079
981
  console.error(
1080
- "AdAdapted SDK has not been initialized with device info."
982
+ "AdAdapted SDK has not been initialized with device info.",
1081
983
  );
1082
984
  } else if (!this.sessionId) {
1083
985
  console.error(
1084
- "AdAdapted SDK has not been initialized with session id."
986
+ "AdAdapted SDK has not been initialized with session id.",
1085
987
  );
1086
988
  } else if (!this.keywordIntercepts) {
1087
989
  console.error("No available keyword intercepts.");
@@ -1111,7 +1013,7 @@ export class AdadaptedReactNativeSdk {
1111
1013
  events: termEvents,
1112
1014
  },
1113
1015
  this.deviceOs!,
1114
- this.apiEnv
1016
+ this.apiEnv,
1115
1017
  )
1116
1018
  .then(() => {
1117
1019
  // Do nothing with the response for now...
@@ -1127,20 +1029,20 @@ export class AdadaptedReactNativeSdk {
1127
1029
  */
1128
1030
  public reportItemsAddedToList(
1129
1031
  itemNames: string[],
1130
- listName?: string
1032
+ listName?: string,
1131
1033
  ): void {
1132
1034
  const requestData = this.getListManagerApiRequestData(
1133
1035
  ListManagerEventSource.APP,
1134
1036
  ListManagerEventName.ADDED_TO_LIST,
1135
1037
  itemNames,
1136
- listName
1038
+ listName,
1137
1039
  );
1138
1040
 
1139
1041
  adadaptedApiRequests
1140
1042
  .reportListManagerEvents(
1141
1043
  requestData,
1142
1044
  this.deviceOs!,
1143
- this.listManagerApiEnv
1045
+ this.listManagerApiEnv,
1144
1046
  )
1145
1047
  .then()
1146
1048
  .catch(() => {
@@ -1156,20 +1058,20 @@ export class AdadaptedReactNativeSdk {
1156
1058
  */
1157
1059
  public reportItemsCrossedOffList(
1158
1060
  itemNames: string[],
1159
- listName?: string
1061
+ listName?: string,
1160
1062
  ): void {
1161
1063
  const requestData = this.getListManagerApiRequestData(
1162
1064
  ListManagerEventSource.APP,
1163
1065
  ListManagerEventName.CROSSED_OFF_LIST,
1164
1066
  itemNames,
1165
- listName
1067
+ listName,
1166
1068
  );
1167
1069
 
1168
1070
  adadaptedApiRequests
1169
1071
  .reportListManagerEvents(
1170
1072
  requestData,
1171
1073
  this.deviceOs!,
1172
- this.listManagerApiEnv
1074
+ this.listManagerApiEnv,
1173
1075
  )
1174
1076
  .then()
1175
1077
  .catch(() => {
@@ -1185,20 +1087,20 @@ export class AdadaptedReactNativeSdk {
1185
1087
  */
1186
1088
  public reportItemsDeletedFromList(
1187
1089
  itemNames: string[],
1188
- listName?: string
1090
+ listName?: string,
1189
1091
  ): void {
1190
1092
  const requestData = this.getListManagerApiRequestData(
1191
1093
  ListManagerEventSource.APP,
1192
1094
  ListManagerEventName.DELETED_FROM_LIST,
1193
1095
  itemNames,
1194
- listName
1096
+ listName,
1195
1097
  );
1196
1098
 
1197
1099
  adadaptedApiRequests
1198
1100
  .reportListManagerEvents(
1199
1101
  requestData,
1200
1102
  this.deviceOs!,
1201
- this.listManagerApiEnv
1103
+ this.listManagerApiEnv,
1202
1104
  )
1203
1105
  .then()
1204
1106
  .catch(() => {
@@ -1226,7 +1128,7 @@ export class AdadaptedReactNativeSdk {
1226
1128
  },
1227
1129
  ],
1228
1130
  },
1229
- this.payloadApiEnv
1131
+ this.payloadApiEnv,
1230
1132
  )
1231
1133
  .then()
1232
1134
  .catch(() => {
@@ -1254,7 +1156,7 @@ export class AdadaptedReactNativeSdk {
1254
1156
  },
1255
1157
  ],
1256
1158
  },
1257
- this.payloadApiEnv
1159
+ this.payloadApiEnv,
1258
1160
  )
1259
1161
  .then()
1260
1162
  .catch(() => {