@adadapted/react-native-sdk 3.1.8 → 3.1.10
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/android/.project +1 -1
- package/android/.settings/org.eclipse.buildship.core.prefs +2 -2
- package/android/bin/.project +34 -0
- package/android/bin/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/bin/build.gradle +130 -0
- package/android/bin/gradle.properties +4 -0
- package/android/bin/src/main/AndroidManifest.xml +4 -0
- package/android/bin/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkModule.kt +115 -0
- package/android/bin/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkPackage.kt +20 -0
- package/android/build.gradle +1 -1
- package/lib/commonjs/api/adadaptedApiRequests.js +10 -24
- package/lib/commonjs/api/adadaptedApiRequests.js.map +1 -1
- package/lib/commonjs/api/adadaptedApiRequests.mock.js +11 -21
- package/lib/commonjs/api/adadaptedApiRequests.mock.js.map +1 -1
- package/lib/commonjs/api/adadaptedApiTypes.js +1 -30
- package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
- package/lib/commonjs/components/AdZone.js +22 -48
- package/lib/commonjs/components/AdZone.js.map +1 -1
- package/lib/commonjs/index.js +127 -182
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/util.js +4 -2
- package/lib/commonjs/util.js.map +1 -1
- package/lib/module/api/adadaptedApiRequests.js +9 -8
- package/lib/module/api/adadaptedApiRequests.js.map +1 -1
- package/lib/module/api/adadaptedApiRequests.mock.js +12 -11
- package/lib/module/api/adadaptedApiRequests.mock.js.map +1 -1
- package/lib/module/api/adadaptedApiTypes.js +6 -11
- package/lib/module/api/adadaptedApiTypes.js.map +1 -1
- package/lib/module/components/AdZone.js +21 -36
- package/lib/module/components/AdZone.js.map +1 -1
- package/lib/module/index.js +130 -159
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/util.js +4 -1
- package/lib/module/util.js.map +1 -1
- package/lib/typescript/src/index.d.ts +8 -0
- package/package.json +12 -13
- package/src/components/AdZone.tsx +1 -1
- package/src/index.tsx +26 -5
package/lib/commonjs/index.js
CHANGED
|
@@ -3,32 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.PayloadApiEnv = exports.ListManagerApiEnv = exports.DeviceOS = exports.ApiEnv = exports.AdadaptedReactNativeSdk = void 0;
|
|
8
7
|
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
9
|
var adadaptedApiRequests = _interopRequireWildcard(require("./api/adadaptedApiRequests"));
|
|
13
|
-
|
|
14
10
|
var _adadaptedApiTypes = require("./api/adadaptedApiTypes");
|
|
15
|
-
|
|
16
11
|
var _AdZone = require("./components/AdZone");
|
|
17
|
-
|
|
18
12
|
var _util = require("./util");
|
|
19
|
-
|
|
20
13
|
var _package = _interopRequireDefault(require("../package.json"));
|
|
21
|
-
|
|
22
14
|
var _reactNativeBase = _interopRequireDefault(require("react-native-base64"));
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
30
18
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
-
|
|
32
19
|
/**
|
|
33
20
|
* Enum representing possible device operating systems.
|
|
34
21
|
*/
|
|
@@ -36,53 +23,41 @@ let DeviceOS;
|
|
|
36
23
|
/**
|
|
37
24
|
* Enum defining the different API environments.
|
|
38
25
|
*/
|
|
39
|
-
|
|
40
26
|
exports.DeviceOS = DeviceOS;
|
|
41
|
-
|
|
42
27
|
(function (DeviceOS) {
|
|
43
28
|
DeviceOS["ANDROID"] = "android";
|
|
44
29
|
DeviceOS["IOS"] = "ios";
|
|
45
30
|
})(DeviceOS || (exports.DeviceOS = DeviceOS = {}));
|
|
46
|
-
|
|
47
31
|
let ApiEnv;
|
|
48
32
|
/**
|
|
49
33
|
* Enum defining the different API environments for List Manager.
|
|
50
34
|
*/
|
|
51
|
-
|
|
52
35
|
exports.ApiEnv = ApiEnv;
|
|
53
|
-
|
|
54
36
|
(function (ApiEnv) {
|
|
55
37
|
ApiEnv["Prod"] = "https://ads.adadapted.com";
|
|
56
38
|
ApiEnv["Dev"] = "https://sandbox.adadapted.com";
|
|
57
39
|
ApiEnv["Mock"] = "MOCK_DATA";
|
|
58
40
|
})(ApiEnv || (exports.ApiEnv = ApiEnv = {}));
|
|
59
|
-
|
|
60
41
|
let ListManagerApiEnv;
|
|
61
42
|
/**
|
|
62
43
|
* Enum defining the different API environments for the Payload Server.
|
|
63
44
|
*/
|
|
64
|
-
|
|
65
45
|
exports.ListManagerApiEnv = ListManagerApiEnv;
|
|
66
|
-
|
|
67
46
|
(function (ListManagerApiEnv) {
|
|
68
47
|
ListManagerApiEnv["Prod"] = "https://ec.adadapted.com";
|
|
69
48
|
ListManagerApiEnv["Dev"] = "https://sandec.adadapted.com";
|
|
70
49
|
ListManagerApiEnv["Mock"] = "MOCK_DATA";
|
|
71
50
|
})(ListManagerApiEnv || (exports.ListManagerApiEnv = ListManagerApiEnv = {}));
|
|
72
|
-
|
|
73
51
|
let PayloadApiEnv;
|
|
74
52
|
/**
|
|
75
53
|
* Interface defining inputs to the {@link Sdk.initialize} method.
|
|
76
54
|
*/
|
|
77
|
-
|
|
78
55
|
exports.PayloadApiEnv = PayloadApiEnv;
|
|
79
|
-
|
|
80
56
|
(function (PayloadApiEnv) {
|
|
81
57
|
PayloadApiEnv["Prod"] = "https://payload.adadapted.com";
|
|
82
58
|
PayloadApiEnv["Dev"] = "https://sandpayload.adadapted.com";
|
|
83
59
|
PayloadApiEnv["Mock"] = "MOCK_DATA";
|
|
84
60
|
})(PayloadApiEnv || (exports.PayloadApiEnv = PayloadApiEnv = {}));
|
|
85
|
-
|
|
86
61
|
/**
|
|
87
62
|
* Class that acts as the AdAdapted SDK for react-native.
|
|
88
63
|
*/
|
|
@@ -168,6 +143,14 @@ class AdadaptedReactNativeSdk {
|
|
|
168
143
|
* @param payloads - All payloads the client must go through.
|
|
169
144
|
*/
|
|
170
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Deeplink event listener.
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* AppState event listener.
|
|
152
|
+
*/
|
|
153
|
+
|
|
171
154
|
/**
|
|
172
155
|
* Gets the Session ID.
|
|
173
156
|
* @returns the Session ID.
|
|
@@ -175,87 +158,68 @@ class AdadaptedReactNativeSdk {
|
|
|
175
158
|
getSessionId() {
|
|
176
159
|
return this.sessionId;
|
|
177
160
|
}
|
|
161
|
+
|
|
178
162
|
/**
|
|
179
163
|
* Gets the Device Info object.
|
|
180
164
|
* @returns the Device Info object.
|
|
181
165
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
166
|
getDeviceInfo() {
|
|
185
167
|
return this.deviceInfo;
|
|
186
168
|
}
|
|
169
|
+
|
|
187
170
|
/**
|
|
188
171
|
* Gets the list of available Ad Zones.
|
|
189
172
|
* @returns all available ad zones.
|
|
190
173
|
*/
|
|
191
|
-
|
|
192
|
-
|
|
193
174
|
getAdZones() {
|
|
194
175
|
return this.adZones;
|
|
195
176
|
}
|
|
177
|
+
|
|
196
178
|
/**
|
|
197
179
|
* @inheritDoc
|
|
198
180
|
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
181
|
constructor() {
|
|
202
182
|
_defineProperty(this, "appId", "");
|
|
203
|
-
|
|
204
183
|
_defineProperty(this, "apiEnv", void 0);
|
|
205
|
-
|
|
206
184
|
_defineProperty(this, "listManagerApiEnv", void 0);
|
|
207
|
-
|
|
208
185
|
_defineProperty(this, "payloadApiEnv", void 0);
|
|
209
|
-
|
|
210
186
|
_defineProperty(this, "deviceOs", void 0);
|
|
211
|
-
|
|
212
187
|
_defineProperty(this, "sessionId", void 0);
|
|
213
|
-
|
|
214
188
|
_defineProperty(this, "deviceInfo", void 0);
|
|
215
|
-
|
|
216
189
|
_defineProperty(this, "sessionInfo", void 0);
|
|
217
|
-
|
|
218
190
|
_defineProperty(this, "adZones", void 0);
|
|
219
|
-
|
|
220
191
|
_defineProperty(this, "xyAdZoneDragDistanceAllowed", void 0);
|
|
221
|
-
|
|
222
192
|
_defineProperty(this, "onAdZonesRefreshed", void 0);
|
|
223
|
-
|
|
224
193
|
_defineProperty(this, "refreshAdZonesTimer", void 0);
|
|
225
|
-
|
|
226
194
|
_defineProperty(this, "keywordInterceptSearchValue", void 0);
|
|
227
|
-
|
|
228
195
|
_defineProperty(this, "keywordIntercepts", void 0);
|
|
229
|
-
|
|
230
196
|
_defineProperty(this, "onAddToListTriggered", void 0);
|
|
231
|
-
|
|
232
197
|
_defineProperty(this, "onOutOfAppPayloadAvailable", void 0);
|
|
233
|
-
|
|
198
|
+
_defineProperty(this, "deepLinkOnEventListener", void 0);
|
|
199
|
+
_defineProperty(this, "AppStateOnEventListener", void 0);
|
|
234
200
|
this.apiEnv = ApiEnv.Prod;
|
|
235
201
|
this.listManagerApiEnv = ListManagerApiEnv.Prod;
|
|
236
202
|
this.payloadApiEnv = PayloadApiEnv.Prod;
|
|
237
|
-
|
|
238
|
-
|
|
203
|
+
this.onAdZonesRefreshed = () => {
|
|
204
|
+
// Defaulting to empty method.
|
|
239
205
|
};
|
|
240
|
-
|
|
241
|
-
|
|
206
|
+
this.onAddToListTriggered = () => {
|
|
207
|
+
// Defaulting to empty method.
|
|
242
208
|
};
|
|
243
|
-
|
|
244
|
-
|
|
209
|
+
this.onOutOfAppPayloadAvailable = () => {
|
|
210
|
+
// Defaulting to empty method.
|
|
245
211
|
};
|
|
246
|
-
|
|
247
212
|
this.keywordInterceptSearchValue = "";
|
|
248
213
|
this.initialize = this.initialize.bind(this);
|
|
249
214
|
this.unmount = this.unmount.bind(this);
|
|
250
215
|
this.handleAppStateChange = this.handleAppStateChange.bind(this);
|
|
251
216
|
this.handleDeepLink = this.handleDeepLink.bind(this);
|
|
252
217
|
}
|
|
218
|
+
|
|
253
219
|
/**
|
|
254
220
|
* Gets the users device info.
|
|
255
221
|
* @returns a Promise of void.
|
|
256
222
|
*/
|
|
257
|
-
|
|
258
|
-
|
|
259
223
|
getDeviceInformation() {
|
|
260
224
|
return new Promise(resolve => {
|
|
261
225
|
_reactNative.NativeModules.AdadaptedReactNativeSdk.getDeviceInfo().then(response => {
|
|
@@ -263,16 +227,14 @@ class AdadaptedReactNativeSdk {
|
|
|
263
227
|
});
|
|
264
228
|
});
|
|
265
229
|
}
|
|
230
|
+
|
|
266
231
|
/**
|
|
267
232
|
* Creates all Ad Zone Info objects based on provided Ad Zones.
|
|
268
233
|
* @param adZones - The object of available zones.
|
|
269
234
|
* @returns the array of Ad Zone Info objects.
|
|
270
235
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
236
|
generateAdZones(adZones) {
|
|
274
237
|
const adZoneInfoList = [];
|
|
275
|
-
|
|
276
238
|
for (const adZoneId in adZones) {
|
|
277
239
|
if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
|
|
278
240
|
adZoneInfoList.push({
|
|
@@ -293,15 +255,13 @@ class AdadaptedReactNativeSdk {
|
|
|
293
255
|
});
|
|
294
256
|
}
|
|
295
257
|
}
|
|
296
|
-
|
|
297
258
|
return adZoneInfoList;
|
|
298
259
|
}
|
|
260
|
+
|
|
299
261
|
/**
|
|
300
262
|
* Triggered when session data is initialized or refreshed. Creates
|
|
301
263
|
* a timer based on the session data refresh value.
|
|
302
264
|
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
265
|
onRefreshAdZones() {
|
|
306
266
|
// Get the amount of time we will wait until a refresh occurs.
|
|
307
267
|
// We are setting a minimum refresh time of 5 minutes, so if a
|
|
@@ -314,26 +274,28 @@ class AdadaptedReactNativeSdk {
|
|
|
314
274
|
uid: this.deviceInfo.udid
|
|
315
275
|
}, this.deviceOs, this.apiEnv).then(response => {
|
|
316
276
|
this.sessionInfo = response.data;
|
|
317
|
-
this.adZones = this.generateAdZones(response.data.zones);
|
|
318
|
-
// the session data has been refreshed.
|
|
277
|
+
this.adZones = this.generateAdZones(response.data.zones);
|
|
319
278
|
|
|
320
|
-
|
|
279
|
+
// Call the user defined callback indicating
|
|
280
|
+
// the session data has been refreshed.
|
|
281
|
+
this.onAdZonesRefreshed();
|
|
321
282
|
|
|
283
|
+
// Start the timer again based on the new session data.
|
|
322
284
|
this.onRefreshAdZones();
|
|
323
285
|
}).catch(err => {
|
|
324
|
-
console.error(err);
|
|
325
|
-
// attempt to refresh the session data.
|
|
286
|
+
console.error(err);
|
|
326
287
|
|
|
288
|
+
// Start the timer again so we can make another
|
|
289
|
+
// attempt to refresh the session data.
|
|
327
290
|
this.onRefreshAdZones();
|
|
328
291
|
});
|
|
329
292
|
}, timerMs);
|
|
330
293
|
}
|
|
294
|
+
|
|
331
295
|
/**
|
|
332
296
|
* Trigger an API request to get all possible
|
|
333
297
|
* keyword intercepts for the session.
|
|
334
298
|
*/
|
|
335
|
-
|
|
336
|
-
|
|
337
299
|
getKeywordIntercepts() {
|
|
338
300
|
adadaptedApiRequests.getKeywordIntercepts({
|
|
339
301
|
aid: this.appId,
|
|
@@ -344,16 +306,14 @@ class AdadaptedReactNativeSdk {
|
|
|
344
306
|
this.performKeywordSearch("mil");
|
|
345
307
|
});
|
|
346
308
|
}
|
|
309
|
+
|
|
347
310
|
/**
|
|
348
311
|
* Gets the Keyword Intercept Term based on the provided term ID.
|
|
349
312
|
* @param termId - The term ID to get the term object for.
|
|
350
313
|
* @returns the term if it was found based on the provided term ID.
|
|
351
314
|
*/
|
|
352
|
-
|
|
353
|
-
|
|
354
315
|
getKeywordInterceptTerm(termId) {
|
|
355
316
|
let term;
|
|
356
|
-
|
|
357
317
|
if (this.keywordIntercepts && termId) {
|
|
358
318
|
for (const termObj of this.keywordIntercepts.terms) {
|
|
359
319
|
if (termObj.term_id === termId) {
|
|
@@ -361,18 +321,17 @@ class AdadaptedReactNativeSdk {
|
|
|
361
321
|
}
|
|
362
322
|
}
|
|
363
323
|
}
|
|
364
|
-
|
|
365
324
|
return term;
|
|
366
325
|
}
|
|
326
|
+
|
|
367
327
|
/**
|
|
368
328
|
* Gets the current unix timestamp.
|
|
369
329
|
* @returns the current unix timestamp.
|
|
370
330
|
*/
|
|
371
|
-
|
|
372
|
-
|
|
373
331
|
getCurrentUnixTimestamp() {
|
|
374
332
|
return Math.round(new Date().getTime() / 1000);
|
|
375
333
|
}
|
|
334
|
+
|
|
376
335
|
/**
|
|
377
336
|
* Gets all data needed to make a List Manager API request.
|
|
378
337
|
* @param eventSource - The event source.
|
|
@@ -381,11 +340,8 @@ class AdadaptedReactNativeSdk {
|
|
|
381
340
|
* @param listName - The list associated to the items, if any.
|
|
382
341
|
* @returns the data required for the request.
|
|
383
342
|
*/
|
|
384
|
-
|
|
385
|
-
|
|
386
343
|
getListManagerApiRequestData(eventSource, eventName, itemNames, listName) {
|
|
387
344
|
const eventList = [];
|
|
388
|
-
|
|
389
345
|
for (const itemName of itemNames) {
|
|
390
346
|
eventList.push({
|
|
391
347
|
event_source: eventSource,
|
|
@@ -397,7 +353,6 @@ class AdadaptedReactNativeSdk {
|
|
|
397
353
|
}
|
|
398
354
|
});
|
|
399
355
|
}
|
|
400
|
-
|
|
401
356
|
return {
|
|
402
357
|
session_id: this.sessionId,
|
|
403
358
|
app_id: this.appId,
|
|
@@ -405,26 +360,22 @@ class AdadaptedReactNativeSdk {
|
|
|
405
360
|
events: eventList
|
|
406
361
|
};
|
|
407
362
|
}
|
|
363
|
+
|
|
408
364
|
/**
|
|
409
365
|
* Takes the deep link URL and extracts out the payload items data to
|
|
410
366
|
* send to the client for adding to a user's list.
|
|
411
367
|
* @param event - The event containing URL related info.
|
|
412
368
|
*/
|
|
413
|
-
|
|
414
|
-
|
|
415
369
|
handleDeepLink(event) {
|
|
416
370
|
const searchStr = "data=";
|
|
417
371
|
const dataIndex = event["url"].indexOf(searchStr);
|
|
418
|
-
|
|
419
372
|
if (dataIndex !== -1) {
|
|
420
373
|
const encodedData = event.url.substr(dataIndex + searchStr.length);
|
|
421
374
|
const payloadData = JSON.parse(_reactNativeBase.default.decode(encodedData));
|
|
422
375
|
const payloadId = payloadData["payload_id"];
|
|
423
376
|
const itemDataList = payloadData["detailed_list_items"];
|
|
424
|
-
|
|
425
377
|
if (itemDataList && itemDataList.length > 0) {
|
|
426
378
|
const finalItemList = [];
|
|
427
|
-
|
|
428
379
|
for (const itemData of itemDataList) {
|
|
429
380
|
finalItemList.push({
|
|
430
381
|
payload_id: payloadId,
|
|
@@ -438,29 +389,27 @@ class AdadaptedReactNativeSdk {
|
|
|
438
389
|
product_sku: itemData["product_sku"]
|
|
439
390
|
}]
|
|
440
391
|
});
|
|
441
|
-
}
|
|
442
|
-
|
|
392
|
+
}
|
|
443
393
|
|
|
394
|
+
// Send the items to the client, so they can add them to the list.
|
|
444
395
|
(0, _util.safeInvoke)(this.onOutOfAppPayloadAvailable, finalItemList);
|
|
445
396
|
}
|
|
446
397
|
}
|
|
447
398
|
}
|
|
399
|
+
|
|
448
400
|
/**
|
|
449
401
|
* Triggered when the state of the app changes.
|
|
450
402
|
* @param state - The current state of the app.
|
|
451
403
|
*/
|
|
452
|
-
|
|
453
|
-
|
|
454
404
|
handleAppStateChange(state) {
|
|
455
405
|
if (state === "active") {
|
|
456
406
|
this.getPayloadItemData();
|
|
457
407
|
}
|
|
458
408
|
}
|
|
409
|
+
|
|
459
410
|
/**
|
|
460
411
|
* Gets all available Payload server item data for the user.
|
|
461
412
|
*/
|
|
462
|
-
|
|
463
|
-
|
|
464
413
|
getPayloadItemData() {
|
|
465
414
|
adadaptedApiRequests.retrievePayloadContent({
|
|
466
415
|
app_id: this.appId,
|
|
@@ -468,7 +417,6 @@ class AdadaptedReactNativeSdk {
|
|
|
468
417
|
udid: this.deviceInfo.udid
|
|
469
418
|
}, this.payloadApiEnv).then(response => {
|
|
470
419
|
const finalItemList = [];
|
|
471
|
-
|
|
472
420
|
for (const payload of response.data.payloads) {
|
|
473
421
|
for (const itemData of payload.detailed_list_items) {
|
|
474
422
|
finalItemList.push({
|
|
@@ -484,33 +432,34 @@ class AdadaptedReactNativeSdk {
|
|
|
484
432
|
}]
|
|
485
433
|
});
|
|
486
434
|
}
|
|
487
|
-
}
|
|
488
|
-
|
|
435
|
+
}
|
|
489
436
|
|
|
437
|
+
// Send the items to the client, so they can add them to the list.
|
|
490
438
|
(0, _util.safeInvoke)(this.onOutOfAppPayloadAvailable, finalItemList);
|
|
491
|
-
}).catch(() => {
|
|
439
|
+
}).catch(() => {
|
|
440
|
+
// Do nothing.
|
|
492
441
|
});
|
|
493
442
|
}
|
|
443
|
+
|
|
494
444
|
/**
|
|
495
445
|
* Initializes the session for the AdAdapted API and sets up the SDK.
|
|
496
446
|
* @param props - The props used to initialize the SDK.
|
|
497
447
|
* @returns a Promise of void.
|
|
498
448
|
*/
|
|
499
|
-
|
|
500
|
-
|
|
501
449
|
initialize(props) {
|
|
502
450
|
// Set the app ID.
|
|
503
|
-
this.appId = props.appId;
|
|
504
|
-
// If the apiEnv value is not provided, production will be used as default.
|
|
451
|
+
this.appId = props.appId;
|
|
505
452
|
|
|
453
|
+
// Set the API environment based on the provided override value.
|
|
454
|
+
// If the apiEnv value is not provided, production will be used as default.
|
|
506
455
|
if (props.apiEnv) {
|
|
507
456
|
this.apiEnv = props.apiEnv;
|
|
508
457
|
} else {
|
|
509
458
|
this.apiEnv = ApiEnv.Prod;
|
|
510
|
-
}
|
|
511
|
-
// the user provides for the props.apiEnv value.
|
|
512
|
-
|
|
459
|
+
}
|
|
513
460
|
|
|
461
|
+
// Base the List Manager API environment off what
|
|
462
|
+
// the user provides for the props.apiEnv value.
|
|
514
463
|
if (props.apiEnv) {
|
|
515
464
|
if (props.apiEnv === ApiEnv.Prod) {
|
|
516
465
|
this.listManagerApiEnv = ListManagerApiEnv.Prod;
|
|
@@ -519,44 +468,42 @@ class AdadaptedReactNativeSdk {
|
|
|
519
468
|
}
|
|
520
469
|
} else {
|
|
521
470
|
this.listManagerApiEnv = ListManagerApiEnv.Prod;
|
|
522
|
-
}
|
|
523
|
-
|
|
471
|
+
}
|
|
524
472
|
|
|
473
|
+
// The ad zone touch drag sensitivity setting.
|
|
525
474
|
if (props.xyDragDistanceAllowed) {
|
|
526
475
|
this.xyAdZoneDragDistanceAllowed = props.xyDragDistanceAllowed;
|
|
527
|
-
}
|
|
528
|
-
// globally for use when the method needs to be triggered.
|
|
529
|
-
|
|
476
|
+
}
|
|
530
477
|
|
|
478
|
+
// If the callback for onAdZonesRefreshed was provided, set it
|
|
479
|
+
// globally for use when the method needs to be triggered.
|
|
531
480
|
if (props.onAdZonesRefreshed) {
|
|
532
481
|
this.onAdZonesRefreshed = props.onAdZonesRefreshed;
|
|
533
|
-
}
|
|
534
|
-
// globally for use when the method needs to be triggered.
|
|
535
|
-
|
|
482
|
+
}
|
|
536
483
|
|
|
484
|
+
// If the callback for onAddToListTriggered was provided, set it
|
|
485
|
+
// globally for use when the method needs to be triggered.
|
|
537
486
|
if (props.onAddToListTriggered) {
|
|
538
487
|
this.onAddToListTriggered = props.onAddToListTriggered;
|
|
539
|
-
}
|
|
540
|
-
// globally for use when the method needs to be triggered.
|
|
541
|
-
|
|
488
|
+
}
|
|
542
489
|
|
|
490
|
+
// If the callback for onOutOfAppPayloadAvailable was provided, set it
|
|
491
|
+
// globally for use when the method needs to be triggered.
|
|
543
492
|
if (props.onOutOfAppPayloadAvailable) {
|
|
544
493
|
this.onOutOfAppPayloadAvailable = props.onOutOfAppPayloadAvailable;
|
|
545
494
|
}
|
|
546
|
-
|
|
547
495
|
return new Promise((resolve, reject) => {
|
|
548
496
|
this.getDeviceInformation().then(deviceInfoObj => {
|
|
549
497
|
const deviceInfo = JSON.parse(deviceInfoObj);
|
|
550
498
|
this.deviceInfo = deviceInfo;
|
|
551
|
-
this.deviceOs = deviceInfo.systemName === "ios" ? DeviceOS.IOS : DeviceOS.ANDROID;
|
|
552
|
-
|
|
499
|
+
this.deviceOs = deviceInfo.systemName === "ios" ? DeviceOS.IOS : DeviceOS.ANDROID;
|
|
500
|
+
// Pass custom advertiserId - ios only
|
|
553
501
|
if (_reactNative.Platform.OS === "ios") {
|
|
554
502
|
if (!(props.advertiserId === undefined)) {
|
|
555
503
|
deviceInfo.udid = props.advertiserId;
|
|
556
504
|
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
505
|
+
}
|
|
506
|
+
// Pass device info along with API call
|
|
560
507
|
adadaptedApiRequests.initializeSession({
|
|
561
508
|
app_id: this.appId,
|
|
562
509
|
udid: deviceInfo.udid,
|
|
@@ -576,17 +523,19 @@ class AdadaptedReactNativeSdk {
|
|
|
576
523
|
allow_retargeting: deviceInfo.isAdTrackingEnabled
|
|
577
524
|
}, this.deviceOs, this.apiEnv).then(response => {
|
|
578
525
|
_reactNative.NativeModules.AdadaptedReactNativeSdk.storeCurrentSessionId(response.data.session_id);
|
|
579
|
-
|
|
580
526
|
this.sessionId = response.data.session_id;
|
|
581
527
|
this.sessionInfo = response.data;
|
|
582
|
-
this.adZones = this.generateAdZones(response.data.zones);
|
|
528
|
+
this.adZones = this.generateAdZones(response.data.zones);
|
|
529
|
+
|
|
530
|
+
// Start the session data refresh timer.
|
|
531
|
+
this.onRefreshAdZones();
|
|
583
532
|
|
|
584
|
-
|
|
533
|
+
// Get all possible keyword intercept values.
|
|
585
534
|
// We don't need to wait for this to complete
|
|
586
535
|
// prior to resolving initialization of the SDK.
|
|
536
|
+
this.getKeywordIntercepts();
|
|
587
537
|
|
|
588
|
-
|
|
589
|
-
|
|
538
|
+
// Intercept an initial deep link here, if needed.
|
|
590
539
|
_reactNative.Linking.getInitialURL().then(url => {
|
|
591
540
|
if (url) {
|
|
592
541
|
// Pass in as an object so it mimics the "url"
|
|
@@ -595,17 +544,19 @@ class AdadaptedReactNativeSdk {
|
|
|
595
544
|
url
|
|
596
545
|
});
|
|
597
546
|
}
|
|
598
|
-
});
|
|
599
|
-
// the user has any outstanding items to be added to list.
|
|
600
|
-
|
|
547
|
+
});
|
|
601
548
|
|
|
602
|
-
|
|
549
|
+
// Make the initial call to the Payload data server to see if
|
|
550
|
+
// the user has any outstanding items to be added to list.
|
|
551
|
+
this.getPayloadItemData();
|
|
603
552
|
|
|
604
|
-
|
|
553
|
+
// Initialize an event listener to intercept deep links while the app is running.
|
|
605
554
|
|
|
555
|
+
this.deepLinkOnEventListener = _reactNative.Linking.addEventListener("url", this.handleDeepLink);
|
|
606
556
|
|
|
607
|
-
|
|
557
|
+
// Initialize an event listener to intercept App state changes.
|
|
608
558
|
|
|
559
|
+
this.AppStateOnEventListener = _reactNative.AppState.addEventListener("change", this.handleAppStateChange);
|
|
609
560
|
resolve();
|
|
610
561
|
}).catch(err => {
|
|
611
562
|
reject(err);
|
|
@@ -615,19 +566,17 @@ class AdadaptedReactNativeSdk {
|
|
|
615
566
|
});
|
|
616
567
|
});
|
|
617
568
|
}
|
|
569
|
+
|
|
618
570
|
/**
|
|
619
571
|
* Searches through available ad keywords based on provided search term.
|
|
620
572
|
* @param searchTerm - The search term used to match against
|
|
621
573
|
* available keyword intercepts.
|
|
622
574
|
* @returns all keyword intercept terms that matched the search term.
|
|
623
575
|
*/
|
|
624
|
-
|
|
625
|
-
|
|
626
576
|
performKeywordSearch(searchTerm) {
|
|
627
577
|
const finalResultListStartsWith = [];
|
|
628
578
|
const finalResultListContains = [];
|
|
629
579
|
this.keywordInterceptSearchValue = searchTerm;
|
|
630
|
-
|
|
631
580
|
if (!this.deviceInfo || !this.sessionId) {
|
|
632
581
|
console.error("AdAdapted SDK has not been initialized.");
|
|
633
582
|
} else if (!this.keywordIntercepts) {
|
|
@@ -635,8 +584,9 @@ class AdadaptedReactNativeSdk {
|
|
|
635
584
|
} else if (searchTerm && searchTerm.trim() && searchTerm.trim().length >= this.keywordIntercepts.min_match_length) {
|
|
636
585
|
searchTerm = searchTerm.trim();
|
|
637
586
|
const finalEventsList = [];
|
|
638
|
-
const currentTs = this.getCurrentUnixTimestamp();
|
|
587
|
+
const currentTs = this.getCurrentUnixTimestamp();
|
|
639
588
|
|
|
589
|
+
// Search for matching terms.
|
|
640
590
|
for (const termObj of this.keywordIntercepts.terms) {
|
|
641
591
|
if (termObj.term.toLowerCase().startsWith(searchTerm.toLowerCase())) {
|
|
642
592
|
// If the term starts with the search term,
|
|
@@ -651,13 +601,14 @@ class AdadaptedReactNativeSdk {
|
|
|
651
601
|
created_at: currentTs
|
|
652
602
|
});
|
|
653
603
|
}
|
|
654
|
-
}
|
|
655
|
-
|
|
604
|
+
}
|
|
656
605
|
|
|
606
|
+
// Sort the final results by priority.
|
|
657
607
|
finalResultListStartsWith.sort((a, b) => a.priority > b.priority ? 1 : -1);
|
|
658
|
-
finalResultListContains.sort((a, b) => a.priority > b.priority ? 1 : -1);
|
|
659
|
-
// we need to report the "not_matched" event.
|
|
608
|
+
finalResultListContains.sort((a, b) => a.priority > b.priority ? 1 : -1);
|
|
660
609
|
|
|
610
|
+
// If there are no events to report at this point,
|
|
611
|
+
// we need to report the "not_matched" event.
|
|
661
612
|
if (finalEventsList.length === 0) {
|
|
662
613
|
finalEventsList.push({
|
|
663
614
|
term_id: "",
|
|
@@ -667,26 +618,28 @@ class AdadaptedReactNativeSdk {
|
|
|
667
618
|
event_type: _adadaptedApiTypes.ReportedEventType.NOT_MATCHED,
|
|
668
619
|
created_at: currentTs
|
|
669
620
|
});
|
|
670
|
-
}
|
|
671
|
-
// all terms that matched the users search.
|
|
672
|
-
|
|
621
|
+
}
|
|
673
622
|
|
|
623
|
+
// Send up the "matched" event for the keyword search for
|
|
624
|
+
// all terms that matched the users search.
|
|
674
625
|
adadaptedApiRequests.reportInterceptEvent({
|
|
675
626
|
app_id: this.appId,
|
|
676
627
|
udid: this.deviceInfo.udid,
|
|
677
628
|
session_id: this.sessionId,
|
|
678
629
|
events: finalEventsList
|
|
679
|
-
}, this.deviceOs, this.apiEnv).then(() => {
|
|
630
|
+
}, this.deviceOs, this.apiEnv).then(() => {
|
|
631
|
+
// Do nothing with the response for now...
|
|
680
632
|
});
|
|
681
|
-
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// The returned list will keep all terms found by matching the
|
|
682
636
|
// beginning of the term string at the beginning of the list. All
|
|
683
637
|
// terms found that didn't match the beginning of the string, but
|
|
684
638
|
// still contained the search term will be concatenated to the end
|
|
685
639
|
// of the list.
|
|
686
|
-
|
|
687
|
-
|
|
688
640
|
return finalResultListStartsWith.concat(finalResultListContains);
|
|
689
641
|
}
|
|
642
|
+
|
|
690
643
|
/**
|
|
691
644
|
* Client must trigger this method when a Keyword Intercept Term has
|
|
692
645
|
* been "selected" by the user.
|
|
@@ -694,11 +647,8 @@ class AdadaptedReactNativeSdk {
|
|
|
694
647
|
* accuracy in client reports.
|
|
695
648
|
* @param termId - The term ID to trigger the event for.
|
|
696
649
|
*/
|
|
697
|
-
|
|
698
|
-
|
|
699
650
|
reportKeywordInterceptTermSelected(termId) {
|
|
700
651
|
const termObj = this.getKeywordInterceptTerm(termId);
|
|
701
|
-
|
|
702
652
|
if (!this.deviceInfo || !this.sessionId) {
|
|
703
653
|
console.error("AdAdapted SDK has not been initialized.");
|
|
704
654
|
} else if (!this.keywordIntercepts) {
|
|
@@ -718,10 +668,12 @@ class AdadaptedReactNativeSdk {
|
|
|
718
668
|
event_type: _adadaptedApiTypes.ReportedEventType.SELECTED,
|
|
719
669
|
created_at: this.getCurrentUnixTimestamp()
|
|
720
670
|
}]
|
|
721
|
-
}, this.deviceOs, this.apiEnv).then(() => {
|
|
671
|
+
}, this.deviceOs, this.apiEnv).then(() => {
|
|
672
|
+
// Do nothing with the response for now...
|
|
722
673
|
});
|
|
723
674
|
}
|
|
724
675
|
}
|
|
676
|
+
|
|
725
677
|
/**
|
|
726
678
|
* Client must trigger this method when a Keyword Intercept Term has
|
|
727
679
|
* been "presented" to the user. All terms that satisfy a search don't
|
|
@@ -731,19 +683,14 @@ class AdadaptedReactNativeSdk {
|
|
|
731
683
|
* accuracy in client reports.
|
|
732
684
|
* @param termIds - The term IDs list to trigger the event for.
|
|
733
685
|
*/
|
|
734
|
-
|
|
735
|
-
|
|
736
686
|
reportKeywordInterceptTermsPresented(termIds) {
|
|
737
687
|
const termObjs = [];
|
|
738
|
-
|
|
739
688
|
for (const termId of termIds) {
|
|
740
689
|
const termObj = this.getKeywordInterceptTerm(termId);
|
|
741
|
-
|
|
742
690
|
if (termObj) {
|
|
743
691
|
termObjs.push(termObj);
|
|
744
692
|
}
|
|
745
693
|
}
|
|
746
|
-
|
|
747
694
|
if (!this.deviceInfo || !this.sessionId) {
|
|
748
695
|
console.error("AdAdapted SDK has not been initialized.");
|
|
749
696
|
} else if (!this.keywordIntercepts) {
|
|
@@ -753,7 +700,6 @@ class AdadaptedReactNativeSdk {
|
|
|
753
700
|
} else {
|
|
754
701
|
const termEvents = [];
|
|
755
702
|
const currentTs = this.getCurrentUnixTimestamp();
|
|
756
|
-
|
|
757
703
|
for (const termObj of termObjs) {
|
|
758
704
|
termEvents.push({
|
|
759
705
|
term_id: termObj.term_id,
|
|
@@ -764,62 +710,61 @@ class AdadaptedReactNativeSdk {
|
|
|
764
710
|
created_at: currentTs
|
|
765
711
|
});
|
|
766
712
|
}
|
|
767
|
-
|
|
768
713
|
adadaptedApiRequests.reportInterceptEvent({
|
|
769
714
|
app_id: this.appId,
|
|
770
715
|
udid: this.deviceInfo.udid,
|
|
771
716
|
session_id: this.sessionId,
|
|
772
717
|
events: termEvents
|
|
773
|
-
}, this.deviceOs, this.apiEnv).then(() => {
|
|
718
|
+
}, this.deviceOs, this.apiEnv).then(() => {
|
|
719
|
+
// Do nothing with the response for now...
|
|
774
720
|
});
|
|
775
721
|
}
|
|
776
722
|
}
|
|
723
|
+
|
|
777
724
|
/**
|
|
778
725
|
* Client must trigger this method when any items
|
|
779
726
|
* are added to a list for reports we provide to the client.
|
|
780
727
|
* @param itemNames - The items to report.
|
|
781
728
|
* @param listName - The list to associate the items with, if any.
|
|
782
729
|
*/
|
|
783
|
-
|
|
784
|
-
|
|
785
730
|
reportItemsAddedToList(itemNames, listName) {
|
|
786
731
|
const requestData = this.getListManagerApiRequestData(_adadaptedApiTypes.ListManagerEventSource.APP, _adadaptedApiTypes.ListManagerEventName.ADDED_TO_LIST, itemNames, listName);
|
|
787
|
-
adadaptedApiRequests.reportListManagerEvents(requestData, this.deviceOs, this.listManagerApiEnv).then().catch(() => {
|
|
732
|
+
adadaptedApiRequests.reportListManagerEvents(requestData, this.deviceOs, this.listManagerApiEnv).then().catch(() => {
|
|
733
|
+
// Do nothing.
|
|
788
734
|
});
|
|
789
735
|
}
|
|
736
|
+
|
|
790
737
|
/**
|
|
791
738
|
* Client must trigger this method when any items
|
|
792
739
|
* are crossed off a list for reports we provide to the client.
|
|
793
740
|
* @param itemNames - The items to report.
|
|
794
741
|
* @param listName - The list the items are associated with, if any.
|
|
795
742
|
*/
|
|
796
|
-
|
|
797
|
-
|
|
798
743
|
reportItemsCrossedOffList(itemNames, listName) {
|
|
799
744
|
const requestData = this.getListManagerApiRequestData(_adadaptedApiTypes.ListManagerEventSource.APP, _adadaptedApiTypes.ListManagerEventName.CROSSED_OFF_LIST, itemNames, listName);
|
|
800
|
-
adadaptedApiRequests.reportListManagerEvents(requestData, this.deviceOs, this.listManagerApiEnv).then().catch(() => {
|
|
745
|
+
adadaptedApiRequests.reportListManagerEvents(requestData, this.deviceOs, this.listManagerApiEnv).then().catch(() => {
|
|
746
|
+
// Do nothing.
|
|
801
747
|
});
|
|
802
748
|
}
|
|
749
|
+
|
|
803
750
|
/**
|
|
804
751
|
* Client must trigger this method when any items
|
|
805
752
|
* are deleted from a list for reports we provide to the client.
|
|
806
753
|
* @param itemNames - The items to report.
|
|
807
754
|
* @param listName - The list the items are associated with, if any.
|
|
808
755
|
*/
|
|
809
|
-
|
|
810
|
-
|
|
811
756
|
reportItemsDeletedFromList(itemNames, listName) {
|
|
812
757
|
const requestData = this.getListManagerApiRequestData(_adadaptedApiTypes.ListManagerEventSource.APP, _adadaptedApiTypes.ListManagerEventName.DELETED_FROM_LIST, itemNames, listName);
|
|
813
|
-
adadaptedApiRequests.reportListManagerEvents(requestData, this.deviceOs, this.listManagerApiEnv).then().catch(() => {
|
|
758
|
+
adadaptedApiRequests.reportListManagerEvents(requestData, this.deviceOs, this.listManagerApiEnv).then().catch(() => {
|
|
759
|
+
// Do nothing.
|
|
814
760
|
});
|
|
815
761
|
}
|
|
762
|
+
|
|
816
763
|
/**
|
|
817
764
|
* Client must trigger this method when any items
|
|
818
765
|
* are deleted from a list for reports we provide to the client.
|
|
819
766
|
* @param payloadId - The payload ID that we want to acknowledge.
|
|
820
767
|
*/
|
|
821
|
-
|
|
822
|
-
|
|
823
768
|
markPayloadContentAcknowledged(payloadId) {
|
|
824
769
|
adadaptedApiRequests.reportPayloadContentStatus({
|
|
825
770
|
app_id: this.appId,
|
|
@@ -830,16 +775,16 @@ class AdadaptedReactNativeSdk {
|
|
|
830
775
|
status: _adadaptedApiTypes.PayloadStatus.DELIVERED,
|
|
831
776
|
event_timestamp: this.getCurrentUnixTimestamp()
|
|
832
777
|
}]
|
|
833
|
-
}, this.payloadApiEnv).then().catch(() => {
|
|
778
|
+
}, this.payloadApiEnv).then().catch(() => {
|
|
779
|
+
// Do nothing.
|
|
834
780
|
});
|
|
835
781
|
}
|
|
782
|
+
|
|
836
783
|
/**
|
|
837
784
|
* Client must trigger this method when any items
|
|
838
785
|
* are deleted from a list for reports we provide to the client.
|
|
839
786
|
* @param payloadId - The payload ID that we want to acknowledge.
|
|
840
787
|
*/
|
|
841
|
-
|
|
842
|
-
|
|
843
788
|
markPayloadContentRejected(payloadId) {
|
|
844
789
|
adadaptedApiRequests.reportPayloadContentStatus({
|
|
845
790
|
app_id: this.appId,
|
|
@@ -850,27 +795,27 @@ class AdadaptedReactNativeSdk {
|
|
|
850
795
|
status: _adadaptedApiTypes.PayloadStatus.REJECTED,
|
|
851
796
|
event_timestamp: this.getCurrentUnixTimestamp()
|
|
852
797
|
}]
|
|
853
|
-
}, this.payloadApiEnv).then().catch(() => {
|
|
798
|
+
}, this.payloadApiEnv).then().catch(() => {
|
|
799
|
+
// Do nothing.
|
|
854
800
|
});
|
|
855
801
|
}
|
|
802
|
+
|
|
856
803
|
/**
|
|
857
804
|
* Performs all clean up tasks for the SDK. Call this method when
|
|
858
805
|
* the component that references this SDK will "unmount", otherwise you
|
|
859
806
|
* can experience memory leaks.
|
|
860
807
|
*/
|
|
861
|
-
|
|
862
|
-
|
|
863
808
|
unmount() {
|
|
864
809
|
if (this.refreshAdZonesTimer) {
|
|
865
810
|
clearTimeout(this.refreshAdZonesTimer);
|
|
866
811
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
812
|
+
if (this.deepLinkOnEventListener) {
|
|
813
|
+
this.deepLinkOnEventListener.remove();
|
|
814
|
+
}
|
|
815
|
+
if (this.AppStateOnEventListener) {
|
|
816
|
+
this.AppStateOnEventListener.remove();
|
|
817
|
+
}
|
|
871
818
|
}
|
|
872
|
-
|
|
873
819
|
}
|
|
874
|
-
|
|
875
820
|
exports.AdadaptedReactNativeSdk = AdadaptedReactNativeSdk;
|
|
876
821
|
//# sourceMappingURL=index.js.map
|