@adadapted/react-native-sdk 3.1.6 → 3.1.8
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 +18 -1
- package/android/.settings/org.eclipse.buildship.core.prefs +4 -4
- package/android/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkModule.kt +1 -1
- package/lib/commonjs/api/adadaptedApiRequests.mock.js +0 -20
- package/lib/commonjs/api/adadaptedApiRequests.mock.js.map +1 -1
- package/lib/commonjs/api/adadaptedApiTypes.js +0 -5
- package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
- package/lib/commonjs/components/AdZone.js +10 -40
- package/lib/commonjs/components/AdZone.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/api/adadaptedApiRequests.mock.js +0 -20
- package/lib/module/api/adadaptedApiRequests.mock.js.map +1 -1
- package/lib/module/api/adadaptedApiTypes.js +0 -5
- package/lib/module/api/adadaptedApiTypes.js.map +1 -1
- package/lib/module/components/AdZone.js +10 -39
- package/lib/module/components/AdZone.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/api/adadaptedApiTypes.d.ts +0 -47
- package/lib/typescript/src/components/AdZone.d.ts +0 -4
- package/lib/typescript/src/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/api/adadaptedApiRequests.mock.ts +0 -20
- package/src/api/adadaptedApiTypes.ts +0 -48
- package/src/components/AdZone.tsx +13 -56
- package/src/index.tsx +1 -1
- package/lib/commonjs/components/AdPopup.js +0 -352
- package/lib/commonjs/components/AdPopup.js.map +0 -1
- package/lib/commonjs/components/AdPopup.test.js +0 -60
- package/lib/commonjs/components/AdPopup.test.js.map +0 -1
- package/lib/module/components/AdPopup.js +0 -339
- package/lib/module/components/AdPopup.js.map +0 -1
- package/lib/module/components/AdPopup.test.js +0 -50
- package/lib/module/components/AdPopup.test.js.map +0 -1
- package/lib/typescript/src/components/AdPopup.d.ts +0 -75
- package/lib/typescript/src/components/AdPopup.test.d.ts +0 -1
- package/src/components/AdPopup.test.tsx +0 -60
- package/src/components/AdPopup.tsx +0 -471
package/android/.project
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<projectDescription>
|
|
3
|
-
<name>
|
|
3
|
+
<name>adadaptedreactnativesdk</name>
|
|
4
4
|
<comment>Project android_ created by Buildship.</comment>
|
|
5
5
|
<projects>
|
|
6
6
|
</projects>
|
|
7
7
|
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
8
13
|
<buildCommand>
|
|
9
14
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
10
15
|
<arguments>
|
|
@@ -12,6 +17,18 @@
|
|
|
12
17
|
</buildCommand>
|
|
13
18
|
</buildSpec>
|
|
14
19
|
<natures>
|
|
20
|
+
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
15
21
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
16
22
|
</natures>
|
|
23
|
+
<filteredResources>
|
|
24
|
+
<filter>
|
|
25
|
+
<id>0</id>
|
|
26
|
+
<name></name>
|
|
27
|
+
<type>30</type>
|
|
28
|
+
<matcher>
|
|
29
|
+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
|
30
|
+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
|
31
|
+
</matcher>
|
|
32
|
+
</filter>
|
|
33
|
+
</filteredResources>
|
|
17
34
|
</projectDescription>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
arguments
|
|
1
|
+
arguments=--init-script /var/folders/vw/1yz06gyj201f5y15zm_xv9gr0000gn/T/d146c9752a26f79b52047fb6dc6ed385d064e120494f96f08ca63a317c41f94c.gradle --init-script /var/folders/vw/1yz06gyj201f5y15zm_xv9gr0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
|
|
2
2
|
auto.sync=false
|
|
3
3
|
build.scans.enabled=false
|
|
4
|
-
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(
|
|
5
|
-
connection.project.dir
|
|
4
|
+
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.4.2))
|
|
5
|
+
connection.project.dir=../example/android
|
|
6
6
|
eclipse.preferences.version=1
|
|
7
7
|
gradle.user.home=
|
|
8
|
-
java.home=/Library/Java/JavaVirtualMachines/
|
|
8
|
+
java.home=/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
|
|
9
9
|
jvm.arguments=
|
|
10
10
|
offline.mode=false
|
|
11
11
|
override.workspace.settings=true
|
|
@@ -100,7 +100,7 @@ class AdadaptedReactNativeSdkModule(val _reactContext: ReactApplicationContext)
|
|
|
100
100
|
finalDeviceData.put("deviceTimezone", TimeZone.getDefault().getID());
|
|
101
101
|
finalDeviceData.put("isAdTrackingEnabled", adTrackingEnabled);
|
|
102
102
|
|
|
103
|
-
promise.resolve(JSONObject(finalDeviceData).toString());
|
|
103
|
+
promise.resolve(JSONObject(finalDeviceData as Map<*, *>?).toString());
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
fun logGaidException() {
|
|
@@ -215,16 +215,6 @@ const AD_SESSION_DATA = {
|
|
|
215
215
|
product_sku: "",
|
|
216
216
|
product_title: "Sample Product"
|
|
217
217
|
}]
|
|
218
|
-
},
|
|
219
|
-
popup: {
|
|
220
|
-
title_text: "",
|
|
221
|
-
background_color: "",
|
|
222
|
-
text_color: "",
|
|
223
|
-
alt_close_btn: "",
|
|
224
|
-
type: "",
|
|
225
|
-
hide_banner: false,
|
|
226
|
-
hide_close_btn: false,
|
|
227
|
-
hide_browser_nav: false
|
|
228
218
|
}
|
|
229
219
|
}]
|
|
230
220
|
}
|
|
@@ -267,16 +257,6 @@ const REFRESHED_AD_SESSION_DATA = {
|
|
|
267
257
|
product_sku: "",
|
|
268
258
|
product_title: "Sample Product"
|
|
269
259
|
}]
|
|
270
|
-
},
|
|
271
|
-
popup: {
|
|
272
|
-
title_text: "",
|
|
273
|
-
background_color: "",
|
|
274
|
-
text_color: "",
|
|
275
|
-
alt_close_btn: "",
|
|
276
|
-
type: "",
|
|
277
|
-
hide_banner: false,
|
|
278
|
-
hide_close_btn: false,
|
|
279
|
-
hide_browser_nav: false
|
|
280
260
|
}
|
|
281
261
|
}]
|
|
282
262
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["adadaptedApiRequests.mock.ts"],"names":["initializeSession","Promise","resolve","data","AD_SESSION_DATA","then","undefined","config","headers","status","statusText","refreshSessionData","REFRESHED_AD_SESSION_DATA","reportAdEvent","results","getKeywordIntercepts","KEYWORD_INTERCEPT_DATA","reportInterceptEvent","reportListManagerEvents","reportPayloadContentStatus","retrievePayloadContent","payloads","payload_id","detailed_list_items","product_title","product_barcode","product_sku","product_image","product_discount","product_brand","product_category","session_id","will_serve_ads","active_campaigns","session_expires_at","polling_interval_ms","zones","id","port_height","port_width","land_height","land_width","ads","ad_id","impression_id","refresh_time","hide_after_interaction","type","creative_url","tracking_html","action_type","AdActionType","CONTENT","action_path","payload","popup","title_text","background_color","text_color","alt_close_btn","hide_banner","hide_close_btn","hide_browser_nav","search_id","min_match_length","terms","term_id","term","replacement","priority"],"mappings":";;;;;;;;;;;;;;AAIA;;AAJA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACO,SAASA,iBAAT,GAEL;AACE,SAAO,IAAIC,OAAJ,CAAuDC,OAAD,IAAa;AACtEA,IAAAA,OAAO,CAAC;AACJC,MAAAA,IAAI,EAAEC,eADF;AAEJC,MAAAA,IAAI,EAAEC,SAFF;AAGJC,MAAAA,MAAM,EAAE,EAHJ;AAIJC,MAAAA,OAAO,E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AAGIC,IAAAA,WAAW,EAAE,SAHjB;AAIIC,IAAAA,QAAQ,EAAE;AAJd,GAPG,EAaH;AACIH,IAAAA,OAAO,EAAE,gBADb;AAEIC,IAAAA,IAAI,EAAE,QAFV;AAGIC,IAAAA,WAAW,EAAE,eAHjB;AAIIC,IAAAA,QAAQ,EAAE;AAJd,GAbG,EAmBH;AACIH,IAAAA,OAAO,EAAE,gBADb;AAEIC,IAAAA,IAAI,EAAE,QAFV;AAGIC,IAAAA,WAAW,EAAE,wBAHjB;AAIIC,IAAAA,QAAQ,EAAE;AAJd,GAnBG;AAHuC,CAAlD","sourcesContent":["/**\n * Contains all API request mocks for the Rewards API.\n */\nimport { AxiosResponse } from \"axios\";\nimport {\n AdActionType,\n AdSession,\n InitializeSessionResponse,\n KeywordIntercepts,\n KeywordInterceptsResponse,\n RefreshSessionDataResponse,\n ReportAdEventResponse,\n ReportInterceptEventResponse,\n RetrievePayloadItemDataResponse,\n} from \"./adadaptedApiTypes\";\n\n/**\n * Mocks the API call for initializing a session.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function initializeSession(): Promise<\n AxiosResponse<InitializeSessionResponse>\n> {\n return new Promise<AxiosResponse<InitializeSessionResponse>>((resolve) => {\n resolve({\n data: AD_SESSION_DATA,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for refreshing session data.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function refreshSessionData(): Promise<\n AxiosResponse<RefreshSessionDataResponse>\n> {\n return new Promise<AxiosResponse<RefreshSessionDataResponse>>((resolve) => {\n resolve({\n data: REFRESHED_AD_SESSION_DATA,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for reporting an ad event.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function reportAdEvent(): Promise<AxiosResponse<ReportAdEventResponse>> {\n return new Promise<AxiosResponse<ReportAdEventResponse>>((resolve) => {\n resolve({\n data: {\n results: [\"Ok\"],\n },\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for getting keyword intercepts.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function getKeywordIntercepts(): Promise<\n AxiosResponse<KeywordInterceptsResponse>\n> {\n return new Promise<AxiosResponse<KeywordInterceptsResponse>>((resolve) => {\n resolve({\n data: KEYWORD_INTERCEPT_DATA,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for reporting an ad event.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function reportInterceptEvent(): Promise<\n AxiosResponse<ReportInterceptEventResponse>\n> {\n return new Promise<AxiosResponse<ReportInterceptEventResponse>>(\n (resolve) => {\n resolve({\n data: {\n results: [\"Ok\"],\n },\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n }\n );\n}\n\n/**\n * Mocks the API call for reporting List Manager events.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function reportListManagerEvents(): Promise<AxiosResponse<void>> {\n return new Promise<AxiosResponse<void>>((resolve) => {\n resolve({\n data: undefined,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for reporting Payload content status.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function reportPayloadContentStatus(): Promise<AxiosResponse<void>> {\n return new Promise<AxiosResponse<void>>((resolve) => {\n resolve({\n data: undefined,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for reporting Payload content status.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function retrievePayloadContent(): Promise<\n AxiosResponse<RetrievePayloadItemDataResponse>\n> {\n return new Promise<AxiosResponse<RetrievePayloadItemDataResponse>>(\n (resolve) => {\n resolve({\n data: {\n payloads: [\n {\n payload_id: \"TEST_PAYLOAD_1\",\n detailed_list_items: [\n {\n product_title: \"Test Product 1\",\n product_barcode: \"\",\n product_sku: \"\",\n product_image: \"\",\n product_discount: \"\",\n product_brand: \"\",\n product_category: \"\",\n },\n ],\n },\n ],\n },\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n }\n );\n}\n\n/**\n * Mock data for an {@link AdSession} object.\n */\nconst AD_SESSION_DATA: AdSession = {\n session_id: \"TEST_SESSION_ID\",\n will_serve_ads: true,\n active_campaigns: true,\n session_expires_at: 1587684561,\n polling_interval_ms: 1000,\n zones: {\n 100838: {\n id: \"100838\",\n port_height: 250,\n port_width: 320,\n land_height: 250,\n land_width: 320,\n ads: [\n {\n ad_id: \"1815\",\n impression_id: \"100838::C4D792785EA1EC91\",\n refresh_time: 60,\n hide_after_interaction: false,\n type: \"html\",\n creative_url:\n \"https://testurl.com/a/NTLKNZKYMMI2NTM1;100838;1815?session_id=TEST_SESSION_ID&udid=00000000-0000-0000-0000-000000000000\",\n tracking_html: \"<html></html>\",\n action_type: AdActionType.CONTENT,\n action_path: \"\",\n payload: {\n detailed_list_items: [\n {\n product_barcode: \"0\",\n product_brand: \"Brand\",\n product_category: \"\",\n product_discount: \"\",\n product_image: \"\",\n product_sku: \"\",\n product_title: \"Sample Product\",\n },\n ],\n },\n popup: {\n title_text: \"\",\n background_color: \"\",\n text_color: \"\",\n alt_close_btn: \"\",\n type: \"\",\n hide_banner: false,\n hide_close_btn: false,\n hide_browser_nav: false,\n },\n },\n ],\n },\n },\n};\n\n/**\n * Mock data for an {@link AdSession} object.\n */\nconst REFRESHED_AD_SESSION_DATA: AdSession = {\n session_id: \"TEST_SESSION_ID\",\n will_serve_ads: true,\n active_campaigns: true,\n session_expires_at: 1587684561,\n polling_interval_ms: 1000,\n zones: {\n 100838: {\n id: \"100838\",\n port_height: 250,\n port_width: 320,\n land_height: 250,\n land_width: 320,\n ads: [\n {\n ad_id: \"1816\",\n impression_id: \"100838::C4D792785EA1EC91\",\n refresh_time: 30,\n hide_after_interaction: false,\n type: \"html\",\n creative_url:\n \"https://testurl.com/a/NTLKNZKYMMI2NTM1;100838;1815?session_id=TEST_SESSION_ID&udid=00000000-0000-0000-0000-000000000000\",\n tracking_html: \"<html></html>\",\n action_type: AdActionType.CONTENT,\n action_path: \"\",\n payload: {\n detailed_list_items: [\n {\n product_barcode: \"0\",\n product_brand: \"Brand\",\n product_category: \"\",\n product_discount: \"\",\n product_image: \"\",\n product_sku: \"\",\n product_title: \"Sample Product\",\n },\n ],\n },\n popup: {\n title_text: \"\",\n background_color: \"\",\n text_color: \"\",\n alt_close_btn: \"\",\n type: \"\",\n hide_banner: false,\n hide_close_btn: false,\n hide_browser_nav: false,\n },\n },\n ],\n },\n },\n};\n\n/**\n * Mock data for an {@link AdSession} object.\n */\nconst KEYWORD_INTERCEPT_DATA: KeywordIntercepts = {\n search_id: \"test-search-id\",\n min_match_length: 3,\n terms: [\n {\n term_id: \"test-term-id-1\",\n term: \"Milk\",\n replacement: \"Fairlife Milk\",\n priority: 1,\n },\n {\n term_id: \"test-term-id-2\",\n term: \"milk\",\n replacement: \"A2 Milk\",\n priority: 0,\n },\n {\n term_id: \"test-term-id-3\",\n term: \"CHEESE\",\n replacement: \"Kraft Singles\",\n priority: 0,\n },\n {\n term_id: \"test-term-id-4\",\n term: \"cOfFeE\",\n replacement: \"Folgers Instant Coffee\",\n priority: 0,\n },\n ],\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["adadaptedApiRequests.mock.ts"],"names":["initializeSession","Promise","resolve","data","AD_SESSION_DATA","then","undefined","config","headers","status","statusText","refreshSessionData","REFRESHED_AD_SESSION_DATA","reportAdEvent","results","getKeywordIntercepts","KEYWORD_INTERCEPT_DATA","reportInterceptEvent","reportListManagerEvents","reportPayloadContentStatus","retrievePayloadContent","payloads","payload_id","detailed_list_items","product_title","product_barcode","product_sku","product_image","product_discount","product_brand","product_category","session_id","will_serve_ads","active_campaigns","session_expires_at","polling_interval_ms","zones","id","port_height","port_width","land_height","land_width","ads","ad_id","impression_id","refresh_time","hide_after_interaction","type","creative_url","tracking_html","action_type","AdActionType","CONTENT","action_path","payload","search_id","min_match_length","terms","term_id","term","replacement","priority"],"mappings":";;;;;;;;;;;;;;AAIA;;AAJA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACO,SAASA,iBAAT,GAEL;AACE,SAAO,IAAIC,OAAJ,CAAuDC,OAAD,IAAa;AACtEA,IAAAA,OAAO,CAAC;AACJC,MAAAA,IAAI,EAAEC,eADF;AAEJC,MAAAA,IAAI,EAAEC,SAFF;AAGJC,MAAAA,MAAM,EAAE,EAHJ;AAIJC,MAAAA,OAAO,EAAE,EAJL;AAKJC,MAAAA,MAAM,EAAE,GALJ;AAMJC,MAAAA,UAAU,EAAE;AANR,KAAD,CAAP;AAQH,GATM,CAAP;AAUH;AAED;AACA;AACA;AACA;;;AACO,SAASC,kBAAT,GAEL;AACE,SAAO,IAAIV,OAAJ,CAAwDC,OAAD,IAAa;AACvEA,IAAAA,OAAO,CAAC;AACJC,MAAAA,IAAI,EAAES,yBADF;AAEJP,MAAAA,IAAI,EAAEC,SAFF;AAGJC,MAAAA,MAAM,EAAE,EAHJ;AAIJC,MAAAA,OAAO,EAAE,EAJL;AAKJC,MAAAA,MAAM,EAAE,GALJ;AAMJC,MAAAA,UAAU,EAAE;AANR,KAAD,CAAP;AAQH,GATM,CAAP;AAUH;AAED;AACA;AACA;AACA;;;AACO,SAASG,aAAT,GAAwE;AAC3E,SAAO,IAAIZ,OAAJ,CAAmDC,OAAD,IAAa;AAClEA,IAAAA,OAAO,CAAC;AACJC,MAAAA,IAAI,EAAE;AACFW,QAAAA,OAAO,EAAE,CAAC,IAAD;AADP,OADF;AAIJT,MAAAA,IAAI,EAAEC,SAJF;AAKJC,MAAAA,MAAM,EAAE,EALJ;AAMJC,MAAAA,OAA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EAAE,gBADb;AAEIC,IAAAA,IAAI,EAAE,QAFV;AAGIC,IAAAA,WAAW,EAAE,eAHjB;AAIIC,IAAAA,QAAQ,EAAE;AAJd,GAbG,EAmBH;AACIH,IAAAA,OAAO,EAAE,gBADb;AAEIC,IAAAA,IAAI,EAAE,QAFV;AAGIC,IAAAA,WAAW,EAAE,wBAHjB;AAIIC,IAAAA,QAAQ,EAAE;AAJd,GAnBG;AAHuC,CAAlD","sourcesContent":["/**\n * Contains all API request mocks for the Rewards API.\n */\nimport { AxiosResponse } from \"axios\";\nimport {\n AdActionType,\n AdSession,\n InitializeSessionResponse,\n KeywordIntercepts,\n KeywordInterceptsResponse,\n RefreshSessionDataResponse,\n ReportAdEventResponse,\n ReportInterceptEventResponse,\n RetrievePayloadItemDataResponse,\n} from \"./adadaptedApiTypes\";\n\n/**\n * Mocks the API call for initializing a session.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function initializeSession(): Promise<\n AxiosResponse<InitializeSessionResponse>\n> {\n return new Promise<AxiosResponse<InitializeSessionResponse>>((resolve) => {\n resolve({\n data: AD_SESSION_DATA,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for refreshing session data.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function refreshSessionData(): Promise<\n AxiosResponse<RefreshSessionDataResponse>\n> {\n return new Promise<AxiosResponse<RefreshSessionDataResponse>>((resolve) => {\n resolve({\n data: REFRESHED_AD_SESSION_DATA,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for reporting an ad event.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function reportAdEvent(): Promise<AxiosResponse<ReportAdEventResponse>> {\n return new Promise<AxiosResponse<ReportAdEventResponse>>((resolve) => {\n resolve({\n data: {\n results: [\"Ok\"],\n },\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for getting keyword intercepts.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function getKeywordIntercepts(): Promise<\n AxiosResponse<KeywordInterceptsResponse>\n> {\n return new Promise<AxiosResponse<KeywordInterceptsResponse>>((resolve) => {\n resolve({\n data: KEYWORD_INTERCEPT_DATA,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for reporting an ad event.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function reportInterceptEvent(): Promise<\n AxiosResponse<ReportInterceptEventResponse>\n> {\n return new Promise<AxiosResponse<ReportInterceptEventResponse>>(\n (resolve) => {\n resolve({\n data: {\n results: [\"Ok\"],\n },\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n }\n );\n}\n\n/**\n * Mocks the API call for reporting List Manager events.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function reportListManagerEvents(): Promise<AxiosResponse<void>> {\n return new Promise<AxiosResponse<void>>((resolve) => {\n resolve({\n data: undefined,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for reporting Payload content status.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function reportPayloadContentStatus(): Promise<AxiosResponse<void>> {\n return new Promise<AxiosResponse<void>>((resolve) => {\n resolve({\n data: undefined,\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n });\n}\n\n/**\n * Mocks the API call for reporting Payload content status.\n * @returns a promise of an {@link AxiosResponse} of the mocked data.\n */\nexport function retrievePayloadContent(): Promise<\n AxiosResponse<RetrievePayloadItemDataResponse>\n> {\n return new Promise<AxiosResponse<RetrievePayloadItemDataResponse>>(\n (resolve) => {\n resolve({\n data: {\n payloads: [\n {\n payload_id: \"TEST_PAYLOAD_1\",\n detailed_list_items: [\n {\n product_title: \"Test Product 1\",\n product_barcode: \"\",\n product_sku: \"\",\n product_image: \"\",\n product_discount: \"\",\n product_brand: \"\",\n product_category: \"\",\n },\n ],\n },\n ],\n },\n then: undefined,\n config: {},\n headers: {},\n status: 200,\n statusText: \"200\",\n });\n }\n );\n}\n\n/**\n * Mock data for an {@link AdSession} object.\n */\nconst AD_SESSION_DATA: AdSession = {\n session_id: \"TEST_SESSION_ID\",\n will_serve_ads: true,\n active_campaigns: true,\n session_expires_at: 1587684561,\n polling_interval_ms: 1000,\n zones: {\n 100838: {\n id: \"100838\",\n port_height: 250,\n port_width: 320,\n land_height: 250,\n land_width: 320,\n ads: [\n {\n ad_id: \"1815\",\n impression_id: \"100838::C4D792785EA1EC91\",\n refresh_time: 60,\n hide_after_interaction: false,\n type: \"html\",\n creative_url:\n \"https://testurl.com/a/NTLKNZKYMMI2NTM1;100838;1815?session_id=TEST_SESSION_ID&udid=00000000-0000-0000-0000-000000000000\",\n tracking_html: \"<html></html>\",\n action_type: AdActionType.CONTENT,\n action_path: \"\",\n payload: {\n detailed_list_items: [\n {\n product_barcode: \"0\",\n product_brand: \"Brand\",\n product_category: \"\",\n product_discount: \"\",\n product_image: \"\",\n product_sku: \"\",\n product_title: \"Sample Product\",\n },\n ],\n },\n },\n ],\n },\n },\n};\n\n/**\n * Mock data for an {@link AdSession} object.\n */\nconst REFRESHED_AD_SESSION_DATA: AdSession = {\n session_id: \"TEST_SESSION_ID\",\n will_serve_ads: true,\n active_campaigns: true,\n session_expires_at: 1587684561,\n polling_interval_ms: 1000,\n zones: {\n 100838: {\n id: \"100838\",\n port_height: 250,\n port_width: 320,\n land_height: 250,\n land_width: 320,\n ads: [\n {\n ad_id: \"1816\",\n impression_id: \"100838::C4D792785EA1EC91\",\n refresh_time: 30,\n hide_after_interaction: false,\n type: \"html\",\n creative_url:\n \"https://testurl.com/a/NTLKNZKYMMI2NTM1;100838;1815?session_id=TEST_SESSION_ID&udid=00000000-0000-0000-0000-000000000000\",\n tracking_html: \"<html></html>\",\n action_type: AdActionType.CONTENT,\n action_path: \"\",\n payload: {\n detailed_list_items: [\n {\n product_barcode: \"0\",\n product_brand: \"Brand\",\n product_category: \"\",\n product_discount: \"\",\n product_image: \"\",\n product_sku: \"\",\n product_title: \"Sample Product\",\n },\n ],\n },\n },\n ],\n },\n },\n};\n\n/**\n * Mock data for an {@link AdSession} object.\n */\nconst KEYWORD_INTERCEPT_DATA: KeywordIntercepts = {\n search_id: \"test-search-id\",\n min_match_length: 3,\n terms: [\n {\n term_id: \"test-term-id-1\",\n term: \"Milk\",\n replacement: \"Fairlife Milk\",\n priority: 1,\n },\n {\n term_id: \"test-term-id-2\",\n term: \"milk\",\n replacement: \"A2 Milk\",\n priority: 0,\n },\n {\n term_id: \"test-term-id-3\",\n term: \"CHEESE\",\n replacement: \"Kraft Singles\",\n priority: 0,\n },\n {\n term_id: \"test-term-id-4\",\n term: \"cOfFeE\",\n replacement: \"Folgers Instant Coffee\",\n priority: 0,\n },\n ],\n};\n"]}
|
|
@@ -32,10 +32,6 @@ exports.PayloadStatus = exports.ReportedEventType = exports.AdActionType = expor
|
|
|
32
32
|
* The definition of a Detailed List Item.
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* The definition of an Ad Popup.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
35
|
/**
|
|
40
36
|
* The definition of a Keyword Intercepts object.
|
|
41
37
|
*/
|
|
@@ -102,7 +98,6 @@ exports.AdActionType = AdActionType;
|
|
|
102
98
|
AdActionType["CONTENT"] = "c";
|
|
103
99
|
AdActionType["EXTERNAL"] = "e";
|
|
104
100
|
AdActionType["LINK"] = "l";
|
|
105
|
-
AdActionType["POPUP"] = "p";
|
|
106
101
|
AdActionType["APP"] = "a";
|
|
107
102
|
AdActionType["NONE"] = "n";
|
|
108
103
|
})(AdActionType || (exports.AdActionType = AdActionType = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["adadaptedApiTypes.ts"],"names":["ListManagerEventSource","ListManagerEventName","AdActionType","ReportedEventType","PayloadStatus"],"mappings":";;;;;;AAAA;AACA;AACA;;AACA;AACA;AACA;;AA4BA;AACA;AACA;;AA4BA;AACA;AACA;;AAiDA;AACA;AACA;;AAQA;AACA;AACA;;AAgCA;AACA;AACA;;AAoCA;AACA;AACA;;AAoCA;AACA;AACA;;AAkBA;AACA;AACA;;AAuBA;AACA;AACA;;AAoBA;AACA;AACA;;AA6BA;AACA;AACA;;AAoBA;AACA;AACA;;AAgBA;AACA;AACA;;AAYA;AACA;AACA;IACYA,sB;AAOZ;AACA;AACA;;;;WATYA,sB;AAAAA,EAAAA,sB;GAAAA,sB,sCAAAA,sB;;IAUAC,oB;AAeZ;AACA;AACA;;;;WAjBYA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;GAAAA,oB,oCAAAA,oB;;IAkBAC,Y;AA+BZ;AACA;AACA;;;;WAjCYA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;GAAAA,Y,4BAAAA,Y;;IAkCAC,iB;AA4BZ;AACA;AACA;;;;WA9BYA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;GAAAA,iB,iCAAAA,iB;;IA+BAC,a,EAWZ;AACA;AACA;;AACA;AACA;AACA;;;;WAhBYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a","sourcesContent":["// =============================================================================\n// API TYPE MODELS\n// =============================================================================\n/**\n * The definition of an ad session data object.\n */\nexport interface AdSession {\n /**\n * The session ID.\n */\n session_id: string;\n /**\n * If true, ads will be served.\n */\n will_serve_ads: boolean;\n /**\n * If true, there are active campaigns.\n */\n active_campaigns: boolean;\n /**\n * How often to refresh session/ad data?\n */\n polling_interval_ms: number;\n /**\n * The time at which the session will expire.\n */\n session_expires_at: number;\n /**\n * All ad zones.\n */\n zones: { [key: number]: Zone };\n}\n\n/**\n * The definition of a zone.\n */\nexport interface Zone {\n /**\n * The zone ID.\n */\n id: string;\n /**\n * ?\n */\n land_height: number;\n /**\n * ?\n */\n land_width: number;\n /**\n * ?\n */\n port_height: number;\n /**\n * ?\n */\n port_width: number;\n /**\n * The available ads.\n */\n ads: Ad[];\n}\n\n/**\n * The definition of an Ad.\n */\nexport interface Ad {\n /**\n * The ad ID.\n */\n ad_id: string;\n /**\n * The impression ID.\n */\n impression_id: string;\n /**\n * The type of ad this is.\n */\n type: string;\n /**\n * How often the ad refreshes? Swaps out for another?\n * Length of time in seconds.\n */\n refresh_time: number;\n /**\n * The URL for the ad image to display.\n */\n creative_url: string;\n /**\n * The tracking pixel to include in the zone view for this ad?\n */\n tracking_html: string;\n /**\n * ?\n */\n action_path: string;\n /**\n * ?\n */\n action_type: AdActionType;\n /**\n * If true, the ad will be hidden after interaction.\n */\n hide_after_interaction: boolean;\n /**\n * ?\n */\n payload: AdPayload;\n /**\n * ?\n */\n popup: AdPopup;\n}\n\n/**\n * The definition of an Ad Payload.\n */\nexport interface AdPayload {\n /**\n * The array of list items.\n */\n detailed_list_items: DetailedListItem[];\n}\n\n/**\n * The definition of an \"out of app\" data payload.\n */\nexport interface OutOfAppDataPayload {\n /**\n * The payload ID associated to the provided list items.\n */\n payload_id: string;\n /**\n * The payload message.\n */\n payload_message?: string;\n /**\n * The payload image.\n */\n payload_image?: string;\n /**\n * The campaign ID.\n */\n campaign_id?: string;\n /**\n * The app ID.\n */\n app_id?: string;\n /**\n * Expiration time in seconds.\n */\n expire_seconds?: number;\n /**\n * The array of list items.\n */\n detailed_list_items: DetailedListItem[];\n}\n\n/**\n * The definition of a Detailed List Item.\n */\nexport interface DetailedListItem {\n /**\n * The barcode of the product.\n */\n product_barcode: string;\n /**\n * The brand of the product.\n */\n product_brand: string;\n /**\n * The category of the product.\n */\n product_category: string;\n /**\n * The discount given for the product.\n */\n product_discount: string;\n /**\n * The image used for display of the product.\n */\n product_image: string;\n /**\n * The SKU of the product.\n */\n product_sku: string;\n /**\n * The name/title of the product.\n */\n product_title: string;\n /**\n * The tracking ID.\n */\n tracking_id?: string;\n}\n\n/**\n * The definition of an Ad Popup.\n */\nexport interface AdPopup {\n /**\n * ?\n */\n alt_close_btn: string;\n /**\n * ?\n */\n background_color: string;\n /**\n * ?\n */\n hide_banner: boolean;\n /**\n * ?\n */\n hide_browser_nav: boolean;\n /**\n * ?\n */\n hide_close_btn: boolean;\n /**\n * ?\n */\n text_color: string;\n /**\n * ?\n */\n title_text: string;\n /**\n * ?\n */\n type: string;\n}\n\n/**\n * The definition of a Keyword Intercepts object.\n */\nexport interface KeywordIntercepts {\n /**\n * The search ID.\n * Automatically assigned by the API.\n */\n search_id: string;\n /**\n * The minimum number of characters required to perform\n * a search against all available search terms.\n */\n min_match_length: number;\n /**\n * All available search terms.\n */\n terms: KeywordSearchTerm[];\n}\n\n/**\n * The definition of a Keyword Search Term.\n */\nexport interface KeywordSearchTerm {\n /**\n * The search term ID.\n */\n term_id: string;\n /**\n * The search term to validate a search string against.\n */\n term: string;\n /**\n * The display string a client can use to display in a list.\n */\n replacement: string;\n /**\n * The display priority of this item.\n * Compare this to other {@link KeywordSearchTerm} items to determine\n * the final priority order during display.\n * The lower the number, the higher the priority.\n */\n priority: number;\n}\n\n/**\n * The definition of a Reported Ad Event.\n */\nexport interface ReportedAdEvent {\n /**\n * The add ID.\n */\n ad_id: string;\n /**\n * The impression ID.\n */\n impression_id: string;\n /**\n * The event type to report\n */\n event_type: ReportedEventType;\n /**\n * The timestamp at which the event occurred.\n */\n created_at: number;\n}\n\n/**\n * The definition of a Reported Intercept Event.\n */\nexport interface ReportedInterceptEvent {\n /**\n * The intercept search ID.\n */\n search_id: string;\n /**\n * The term ID.\n */\n term_id: string;\n /**\n * The term.\n */\n term: string;\n /**\n * The user input provided that ultimately\n * resulted in the event triggering.\n */\n user_input: string;\n /**\n * The event type to report\n */\n event_type: ReportedEventType;\n /**\n * The timestamp at which the event occurred.\n */\n created_at: number;\n}\n\n/**\n * Interface defining the structure of an event to send when using List Manager.\n */\nexport interface ListManagerEvent {\n /**\n * The source of the list manager event.\n */\n event_source: ListManagerEventSource;\n /**\n * The timestamp this event occurred (unix time).\n */\n event_timestamp: number;\n /**\n * The event name.\n */\n event_name: ListManagerEventName;\n /**\n * The parameter the event is triggered for.\n */\n event_params: ListManagerEventParam;\n}\n\n/**\n * Interface defining the structure of a payload tracking event.\n */\nexport interface PayloadTrackingEvent {\n /**\n * The source of the list manager event.\n */\n payload_id: string;\n /**\n * The status to report.\n */\n status: PayloadStatus;\n /**\n * The timestamp this event occurred (unix time).\n */\n event_timestamp: number;\n}\n\n/**\n * Interface defining the structure of an Event Param for List Manager.\n */\nexport interface ListManagerEventParam {\n /**\n * The item name being reported.\n */\n item_name: string;\n /**\n * The list name being reported.\n */\n list_name?: string;\n}\n\n/**\n * Enumeration that defines the possible values for a List Manager Event Source.\n */\nexport enum ListManagerEventSource {\n /**\n * The event was triggered from the app.\n */\n APP = \"app\",\n}\n\n/**\n * Enumeration that defines the possible values for a List Manager Event Name.\n */\nexport enum ListManagerEventName {\n /**\n * The user added an item to their list.\n */\n ADDED_TO_LIST = \"user_added_to_list\",\n /**\n * The user crossed off an item from their list.\n */\n CROSSED_OFF_LIST = \"user_crossed_off_list\",\n /**\n * The user deleted an item from their list.\n */\n DELETED_FROM_LIST = \"user_deleted_from_list\",\n}\n\n/**\n * Enum defining the available ad action types.\n */\nexport enum AdActionType {\n /**\n * Used for Add To List.\n */\n CONTENT = \"c\",\n /**\n * Used for opening URLs in an external browser.\n */\n EXTERNAL = \"e\",\n /**\n * Used for opening URLs in a web view within the app.\n * Works the same as {@link AdActionType.POPUP}.\n * NOTE: This one should probably be deprecated with the new\n * platform redesign, since its not as obvious what it does.\n */\n LINK = \"l\",\n /**\n * Used for opening URLs in a web view within the app.\n * Works the same as {@link AdActionType.LINK}.\n */\n POPUP = \"p\",\n /**\n * Used for opening app store URLs in the app store.\n */\n APP = \"a\",\n /**\n * ?\n */\n NONE = \"n\",\n}\n\n/**\n * Enum defining the different types of events that can be reported.\n */\nexport enum ReportedEventType {\n /**\n * Occurs when an ad is displayed to the user.\n */\n IMPRESSION = \"impression\",\n /**\n * Occurs when the user interacts with an ad.\n */\n INTERACTION = \"interaction\",\n /**\n * Occurs when the user's search term did not\n * match an available keyword intercept term.\n */\n NOT_MATCHED = \"not_matched\",\n /**\n * Occurs when the user's search term has matched a keyword intercept term.\n */\n MATCHED = \"matched\",\n /**\n * Occurs when the user was presented a keyword intercept term.\n */\n PRESENTED = \"presented\",\n /**\n * Occurs when the user has selected a keyword intercept term.\n */\n SELECTED = \"selected\",\n}\n\n/**\n * Enumeration defining the possible payload acknowledgment status values.\n */\nexport enum PayloadStatus {\n /**\n * The delivered status.\n */\n DELIVERED = \"delivered\",\n /**\n * The rejected status.\n */\n REJECTED = \"rejected\",\n}\n\n// =============================================================================\n// REQUEST MODELS\n// =============================================================================\n/**\n * The base request inputs that most requests will use.\n */\nexport interface BaseRequestInputs {\n /**\n * The app ID provided by the client using the API.\n */\n app_id: string;\n /**\n * The unique device ID.\n */\n udid: string;\n /**\n * The current session ID.\n */\n session_id: string;\n}\n\n/**\n * Interface for the request of the Initialize Session API call.\n */\nexport interface InitializeSessionRequest {\n /**\n * The app ID provided by the client using the API.\n */\n app_id: string;\n /**\n * The unique device ID of the users device.\n */\n udid: string;\n /**\n * The bundle ID.\n */\n bundle_id?: string;\n /**\n * The bundle version.\n */\n bundle_version?: string;\n /**\n * The name of the device.\n */\n device_name?: string;\n /**\n * The unique device ID of the users device.\n */\n device_udid?: string;\n /**\n * The OS of the device.\n */\n device_os?: string;\n /**\n * The OS version of the device.\n */\n device_osv?: string;\n /**\n * The locale the device is currently set for.\n */\n device_locale?: string;\n /**\n * The timezone the device is currently set for.\n */\n device_timezone?: string;\n /**\n * The device carrier name.\n */\n device_carrier?: string;\n /**\n * The height of the devices screen in pixels.\n */\n device_height?: number;\n /**\n * The width of the devices screen in pixels.\n */\n device_width?: number;\n /**\n * The density of the devices screen.\n */\n device_density?: string;\n /**\n * If true, the device allows for ad retargeting.\n */\n allow_retargeting?: boolean;\n /**\n * ?\n */\n created_at?: number;\n /**\n * The AdAdapted SDK version number.\n */\n sdk_version?: string;\n /**\n * ?\n */\n params?: { [key: string]: string };\n}\n\n/**\n * Interface for the request of the Refresh Session Data API call.\n */\nexport interface RefreshSessionDataRequest {\n /**\n * The app ID provided by the client using the API.\n */\n aid: string;\n /**\n * The unique device ID.\n */\n uid: string;\n /**\n * The current session ID.\n */\n sid: string;\n}\n\n/**\n * Interface for the request that reports an ad event.\n */\nexport interface ReportAdEventRequest extends BaseRequestInputs {\n /**\n * Events to report.\n */\n events: ReportedAdEvent[];\n}\n\n/**\n * Interface for the request of the Refresh Session Data API call.\n */\nexport interface KeywordInterceptsRequest {\n /**\n * The app ID provided by the client using the API.\n */\n aid: string;\n /**\n * The unique device ID.\n */\n uid: string;\n /**\n * The current session ID.\n */\n sid: string;\n}\n\n/**\n * Interface for the request that reports an intercept event.\n */\nexport interface ReportInterceptEventRequest extends BaseRequestInputs {\n /**\n * Events to report.\n */\n events: ReportedInterceptEvent[];\n}\n\n/**\n * Interface for the request that reports List Manager data.\n */\nexport interface ReportListManagerDataRequest extends BaseRequestInputs {\n /**\n * The events to report.\n */\n events: ListManagerEvent[];\n}\n\n/**\n * Interface for the request that reports Payload tracking data.\n */\nexport interface ReportPayloadDataRequest extends BaseRequestInputs {\n /**\n * The payload tracking events.\n */\n tracking: PayloadTrackingEvent[];\n}\n\n/**\n * Interface for the request that gets Payload server data.\n */\nexport interface RetrievePayloadItemDataRequest extends BaseRequestInputs {}\n\n// =============================================================================\n// RESPONSE MODELS\n// =============================================================================\n/**\n * Interface for the response of the Campaign API request.\n */\nexport interface InitializeSessionResponse extends AdSession {}\n\n/**\n * Interface for the response of the Campaign API request.\n */\nexport interface RefreshSessionDataResponse extends AdSession {}\n\n/**\n * Interface for the response of the Report Ad Event API request.\n */\nexport interface ReportAdEventResponse {\n /**\n * Array that contains response strings of \"Ok\" or \"Failed\" based\n * on the same order of the events sent to the request.\n */\n results: string[];\n}\n\n/**\n * Interface for the response of the Keyword Intercepts API request.\n */\nexport interface KeywordInterceptsResponse extends KeywordIntercepts {}\n\n/**\n * Interface for the response of the Report Intercept Event API request.\n */\nexport interface ReportInterceptEventResponse {\n /**\n * Array that contains response strings of \"Ok\" or \"Failed\" based\n * on the same order of the events sent to the request.\n */\n results: string[];\n}\n\n/**\n * Interface for the response of the Retrieve Payload Item Data API request.\n */\nexport interface RetrievePayloadItemDataResponse {\n /**\n * Array containing all current payloads for the provided user.\n */\n payloads: OutOfAppDataPayload[];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["adadaptedApiTypes.ts"],"names":["ListManagerEventSource","ListManagerEventName","AdActionType","ReportedEventType","PayloadStatus"],"mappings":";;;;;;AAAA;AACA;AACA;;AACA;AACA;AACA;;AA4BA;AACA;AACA;;AA4BA;AACA;AACA;;AA6CA;AACA;AACA;;AAQA;AACA;AACA;;AAgCA;AACA;AACA;;AAoCA;AACA;AACA;;AAkBA;AACA;AACA;;AAuBA;AACA;AACA;;AAoBA;AACA;AACA;;AA6BA;AACA;AACA;;AAoBA;AACA;AACA;;AAgBA;AACA;AACA;;AAYA;AACA;AACA;IACYA,sB;AAOZ;AACA;AACA;;;;WATYA,sB;AAAAA,EAAAA,sB;GAAAA,sB,sCAAAA,sB;;IAUAC,oB;AAeZ;AACA;AACA;;;;WAjBYA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;GAAAA,oB,oCAAAA,oB;;IAkBAC,Y;AAyBZ;AACA;AACA;;;;WA3BYA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;GAAAA,Y,4BAAAA,Y;;IA4BAC,iB;AA4BZ;AACA;AACA;;;;WA9BYA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;GAAAA,iB,iCAAAA,iB;;IA+BAC,a,EAWZ;AACA;AACA;;AACA;AACA;AACA;;;;WAhBYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a","sourcesContent":["// =============================================================================\n// API TYPE MODELS\n// =============================================================================\n/**\n * The definition of an ad session data object.\n */\nexport interface AdSession {\n /**\n * The session ID.\n */\n session_id: string;\n /**\n * If true, ads will be served.\n */\n will_serve_ads: boolean;\n /**\n * If true, there are active campaigns.\n */\n active_campaigns: boolean;\n /**\n * How often to refresh session/ad data?\n */\n polling_interval_ms: number;\n /**\n * The time at which the session will expire.\n */\n session_expires_at: number;\n /**\n * All ad zones.\n */\n zones: { [key: number]: Zone };\n}\n\n/**\n * The definition of a zone.\n */\nexport interface Zone {\n /**\n * The zone ID.\n */\n id: string;\n /**\n * ?\n */\n land_height: number;\n /**\n * ?\n */\n land_width: number;\n /**\n * ?\n */\n port_height: number;\n /**\n * ?\n */\n port_width: number;\n /**\n * The available ads.\n */\n ads: Ad[];\n}\n\n/**\n * The definition of an Ad.\n */\nexport interface Ad {\n /**\n * The ad ID.\n */\n ad_id: string;\n /**\n * The impression ID.\n */\n impression_id: string;\n /**\n * The type of ad this is.\n */\n type: string;\n /**\n * How often the ad refreshes? Swaps out for another?\n * Length of time in seconds.\n */\n refresh_time: number;\n /**\n * The URL for the ad image to display.\n */\n creative_url: string;\n /**\n * The tracking pixel to include in the zone view for this ad?\n */\n tracking_html: string;\n /**\n * ?\n */\n action_path: string;\n /**\n * ?\n */\n action_type: AdActionType;\n /**\n * If true, the ad will be hidden after interaction.\n */\n hide_after_interaction: boolean;\n /**\n * ?\n */\n payload: AdPayload;\n}\n\n/**\n * The definition of an Ad Payload.\n */\nexport interface AdPayload {\n /**\n * The array of list items.\n */\n detailed_list_items: DetailedListItem[];\n}\n\n/**\n * The definition of an \"out of app\" data payload.\n */\nexport interface OutOfAppDataPayload {\n /**\n * The payload ID associated to the provided list items.\n */\n payload_id: string;\n /**\n * The payload message.\n */\n payload_message?: string;\n /**\n * The payload image.\n */\n payload_image?: string;\n /**\n * The campaign ID.\n */\n campaign_id?: string;\n /**\n * The app ID.\n */\n app_id?: string;\n /**\n * Expiration time in seconds.\n */\n expire_seconds?: number;\n /**\n * The array of list items.\n */\n detailed_list_items: DetailedListItem[];\n}\n\n/**\n * The definition of a Detailed List Item.\n */\nexport interface DetailedListItem {\n /**\n * The barcode of the product.\n */\n product_barcode: string;\n /**\n * The brand of the product.\n */\n product_brand: string;\n /**\n * The category of the product.\n */\n product_category: string;\n /**\n * The discount given for the product.\n */\n product_discount: string;\n /**\n * The image used for display of the product.\n */\n product_image: string;\n /**\n * The SKU of the product.\n */\n product_sku: string;\n /**\n * The name/title of the product.\n */\n product_title: string;\n /**\n * The tracking ID.\n */\n tracking_id?: string;\n}\n\n/**\n * The definition of a Keyword Intercepts object.\n */\nexport interface KeywordIntercepts {\n /**\n * The search ID.\n * Automatically assigned by the API.\n */\n search_id: string;\n /**\n * The minimum number of characters required to perform\n * a search against all available search terms.\n */\n min_match_length: number;\n /**\n * All available search terms.\n */\n terms: KeywordSearchTerm[];\n}\n\n/**\n * The definition of a Keyword Search Term.\n */\nexport interface KeywordSearchTerm {\n /**\n * The search term ID.\n */\n term_id: string;\n /**\n * The search term to validate a search string against.\n */\n term: string;\n /**\n * The display string a client can use to display in a list.\n */\n replacement: string;\n /**\n * The display priority of this item.\n * Compare this to other {@link KeywordSearchTerm} items to determine\n * the final priority order during display.\n * The lower the number, the higher the priority.\n */\n priority: number;\n}\n\n/**\n * The definition of a Reported Ad Event.\n */\nexport interface ReportedAdEvent {\n /**\n * The add ID.\n */\n ad_id: string;\n /**\n * The impression ID.\n */\n impression_id: string;\n /**\n * The event type to report\n */\n event_type: ReportedEventType;\n /**\n * The timestamp at which the event occurred.\n */\n created_at: number;\n}\n\n/**\n * The definition of a Reported Intercept Event.\n */\nexport interface ReportedInterceptEvent {\n /**\n * The intercept search ID.\n */\n search_id: string;\n /**\n * The term ID.\n */\n term_id: string;\n /**\n * The term.\n */\n term: string;\n /**\n * The user input provided that ultimately\n * resulted in the event triggering.\n */\n user_input: string;\n /**\n * The event type to report\n */\n event_type: ReportedEventType;\n /**\n * The timestamp at which the event occurred.\n */\n created_at: number;\n}\n\n/**\n * Interface defining the structure of an event to send when using List Manager.\n */\nexport interface ListManagerEvent {\n /**\n * The source of the list manager event.\n */\n event_source: ListManagerEventSource;\n /**\n * The timestamp this event occurred (unix time).\n */\n event_timestamp: number;\n /**\n * The event name.\n */\n event_name: ListManagerEventName;\n /**\n * The parameter the event is triggered for.\n */\n event_params: ListManagerEventParam;\n}\n\n/**\n * Interface defining the structure of a payload tracking event.\n */\nexport interface PayloadTrackingEvent {\n /**\n * The source of the list manager event.\n */\n payload_id: string;\n /**\n * The status to report.\n */\n status: PayloadStatus;\n /**\n * The timestamp this event occurred (unix time).\n */\n event_timestamp: number;\n}\n\n/**\n * Interface defining the structure of an Event Param for List Manager.\n */\nexport interface ListManagerEventParam {\n /**\n * The item name being reported.\n */\n item_name: string;\n /**\n * The list name being reported.\n */\n list_name?: string;\n}\n\n/**\n * Enumeration that defines the possible values for a List Manager Event Source.\n */\nexport enum ListManagerEventSource {\n /**\n * The event was triggered from the app.\n */\n APP = \"app\",\n}\n\n/**\n * Enumeration that defines the possible values for a List Manager Event Name.\n */\nexport enum ListManagerEventName {\n /**\n * The user added an item to their list.\n */\n ADDED_TO_LIST = \"user_added_to_list\",\n /**\n * The user crossed off an item from their list.\n */\n CROSSED_OFF_LIST = \"user_crossed_off_list\",\n /**\n * The user deleted an item from their list.\n */\n DELETED_FROM_LIST = \"user_deleted_from_list\",\n}\n\n/**\n * Enum defining the available ad action types.\n */\nexport enum AdActionType {\n /**\n * Used for Add To List.\n */\n CONTENT = \"c\",\n /**\n * Used for opening URLs in an external browser.\n */\n EXTERNAL = \"e\",\n /**\n * Used for opening URLs in a web view within the app.\n * NOTE: This one should probably be deprecated with the new\n * platform redesign, since its not as obvious what it does.\n */\n LINK = \"l\",\n /**\n * Used for opening app store URLs in the app store.\n */\n APP = \"a\",\n /**\n * ?\n */\n NONE = \"n\",\n}\n\n/**\n * Enum defining the different types of events that can be reported.\n */\nexport enum ReportedEventType {\n /**\n * Occurs when an ad is displayed to the user.\n */\n IMPRESSION = \"impression\",\n /**\n * Occurs when the user interacts with an ad.\n */\n INTERACTION = \"interaction\",\n /**\n * Occurs when the user's search term did not\n * match an available keyword intercept term.\n */\n NOT_MATCHED = \"not_matched\",\n /**\n * Occurs when the user's search term has matched a keyword intercept term.\n */\n MATCHED = \"matched\",\n /**\n * Occurs when the user was presented a keyword intercept term.\n */\n PRESENTED = \"presented\",\n /**\n * Occurs when the user has selected a keyword intercept term.\n */\n SELECTED = \"selected\",\n}\n\n/**\n * Enumeration defining the possible payload acknowledgment status values.\n */\nexport enum PayloadStatus {\n /**\n * The delivered status.\n */\n DELIVERED = \"delivered\",\n /**\n * The rejected status.\n */\n REJECTED = \"rejected\",\n}\n\n// =============================================================================\n// REQUEST MODELS\n// =============================================================================\n/**\n * The base request inputs that most requests will use.\n */\nexport interface BaseRequestInputs {\n /**\n * The app ID provided by the client using the API.\n */\n app_id: string;\n /**\n * The unique device ID.\n */\n udid: string;\n /**\n * The current session ID.\n */\n session_id: string;\n}\n\n/**\n * Interface for the request of the Initialize Session API call.\n */\nexport interface InitializeSessionRequest {\n /**\n * The app ID provided by the client using the API.\n */\n app_id: string;\n /**\n * The unique device ID of the users device.\n */\n udid: string;\n /**\n * The bundle ID.\n */\n bundle_id?: string;\n /**\n * The bundle version.\n */\n bundle_version?: string;\n /**\n * The name of the device.\n */\n device_name?: string;\n /**\n * The unique device ID of the users device.\n */\n device_udid?: string;\n /**\n * The OS of the device.\n */\n device_os?: string;\n /**\n * The OS version of the device.\n */\n device_osv?: string;\n /**\n * The locale the device is currently set for.\n */\n device_locale?: string;\n /**\n * The timezone the device is currently set for.\n */\n device_timezone?: string;\n /**\n * The device carrier name.\n */\n device_carrier?: string;\n /**\n * The height of the devices screen in pixels.\n */\n device_height?: number;\n /**\n * The width of the devices screen in pixels.\n */\n device_width?: number;\n /**\n * The density of the devices screen.\n */\n device_density?: string;\n /**\n * If true, the device allows for ad retargeting.\n */\n allow_retargeting?: boolean;\n /**\n * ?\n */\n created_at?: number;\n /**\n * The AdAdapted SDK version number.\n */\n sdk_version?: string;\n /**\n * ?\n */\n params?: { [key: string]: string };\n}\n\n/**\n * Interface for the request of the Refresh Session Data API call.\n */\nexport interface RefreshSessionDataRequest {\n /**\n * The app ID provided by the client using the API.\n */\n aid: string;\n /**\n * The unique device ID.\n */\n uid: string;\n /**\n * The current session ID.\n */\n sid: string;\n}\n\n/**\n * Interface for the request that reports an ad event.\n */\nexport interface ReportAdEventRequest extends BaseRequestInputs {\n /**\n * Events to report.\n */\n events: ReportedAdEvent[];\n}\n\n/**\n * Interface for the request of the Refresh Session Data API call.\n */\nexport interface KeywordInterceptsRequest {\n /**\n * The app ID provided by the client using the API.\n */\n aid: string;\n /**\n * The unique device ID.\n */\n uid: string;\n /**\n * The current session ID.\n */\n sid: string;\n}\n\n/**\n * Interface for the request that reports an intercept event.\n */\nexport interface ReportInterceptEventRequest extends BaseRequestInputs {\n /**\n * Events to report.\n */\n events: ReportedInterceptEvent[];\n}\n\n/**\n * Interface for the request that reports List Manager data.\n */\nexport interface ReportListManagerDataRequest extends BaseRequestInputs {\n /**\n * The events to report.\n */\n events: ListManagerEvent[];\n}\n\n/**\n * Interface for the request that reports Payload tracking data.\n */\nexport interface ReportPayloadDataRequest extends BaseRequestInputs {\n /**\n * The payload tracking events.\n */\n tracking: PayloadTrackingEvent[];\n}\n\n/**\n * Interface for the request that gets Payload server data.\n */\nexport interface RetrievePayloadItemDataRequest extends BaseRequestInputs {}\n\n// =============================================================================\n// RESPONSE MODELS\n// =============================================================================\n/**\n * Interface for the response of the Campaign API request.\n */\nexport interface InitializeSessionResponse extends AdSession {}\n\n/**\n * Interface for the response of the Campaign API request.\n */\nexport interface RefreshSessionDataResponse extends AdSession {}\n\n/**\n * Interface for the response of the Report Ad Event API request.\n */\nexport interface ReportAdEventResponse {\n /**\n * Array that contains response strings of \"Ok\" or \"Failed\" based\n * on the same order of the events sent to the request.\n */\n results: string[];\n}\n\n/**\n * Interface for the response of the Keyword Intercepts API request.\n */\nexport interface KeywordInterceptsResponse extends KeywordIntercepts {}\n\n/**\n * Interface for the response of the Report Intercept Event API request.\n */\nexport interface ReportInterceptEventResponse {\n /**\n * Array that contains response strings of \"Ok\" or \"Failed\" based\n * on the same order of the events sent to the request.\n */\n results: string[];\n}\n\n/**\n * Interface for the response of the Retrieve Payload Item Data API request.\n */\nexport interface RetrievePayloadItemDataResponse {\n /**\n * Array containing all current payloads for the provided user.\n */\n payloads: OutOfAppDataPayload[];\n}\n"]}
|
|
@@ -15,8 +15,6 @@ var _adadaptedApiTypes = require("../api/adadaptedApiTypes");
|
|
|
15
15
|
|
|
16
16
|
var _reactNativeWebview = require("react-native-webview");
|
|
17
17
|
|
|
18
|
-
var _AdPopup = require("./AdPopup");
|
|
19
|
-
|
|
20
18
|
var _util = require("../util");
|
|
21
19
|
|
|
22
20
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -45,7 +43,6 @@ class AdZone extends React.Component {
|
|
|
45
43
|
const startingAdIndex = Math.floor(Math.random() * this.props.adZoneData.ads.length);
|
|
46
44
|
this.state = {
|
|
47
45
|
adIndexShown: startingAdIndex,
|
|
48
|
-
isAdPopupOpen: false,
|
|
49
46
|
touchStartCoords: undefined
|
|
50
47
|
};
|
|
51
48
|
}
|
|
@@ -119,17 +116,6 @@ class AdZone extends React.Component {
|
|
|
119
116
|
});
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
|
-
}) : undefined, currentAd && currentAd.creative_url ? /*#__PURE__*/React.createElement(_AdPopup.AdPopup, {
|
|
123
|
-
ad: currentAd,
|
|
124
|
-
isOpen: this.state.isAdPopupOpen,
|
|
125
|
-
onClose: () => {
|
|
126
|
-
this.setState({
|
|
127
|
-
isAdPopupOpen: false
|
|
128
|
-
});
|
|
129
|
-
},
|
|
130
|
-
onAddToListItemClicked: item => {
|
|
131
|
-
(0, _util.safeInvoke)(this.props.onAddToListTriggered, [item]);
|
|
132
|
-
}
|
|
133
119
|
}) : undefined);
|
|
134
120
|
}
|
|
135
121
|
/**
|
|
@@ -143,11 +129,6 @@ class AdZone extends React.Component {
|
|
|
143
129
|
if (currentAd.action_type === _adadaptedApiTypes.AdActionType.EXTERNAL && currentAd.action_path) {
|
|
144
130
|
// Action Type: EXTERNAL
|
|
145
131
|
_reactNative.Linking.openURL(currentAd.action_path).then();
|
|
146
|
-
} else if ((currentAd.action_type === _adadaptedApiTypes.AdActionType.POPUP || currentAd.action_type === _adadaptedApiTypes.AdActionType.LINK) && currentAd.action_path) {
|
|
147
|
-
// Action Type: POPUP or LINK
|
|
148
|
-
this.setState({
|
|
149
|
-
isAdPopupOpen: true
|
|
150
|
-
});
|
|
151
132
|
} else if (currentAd.action_type === _adadaptedApiTypes.AdActionType.CONTENT && currentAd.payload && currentAd.payload.detailed_list_items) {
|
|
152
133
|
(0, _util.safeInvoke)(this.props.onAddToListTriggered, currentAd.payload.detailed_list_items);
|
|
153
134
|
}
|
|
@@ -204,29 +185,18 @@ class AdZone extends React.Component {
|
|
|
204
185
|
|
|
205
186
|
|
|
206
187
|
cycleDisplayedAd() {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
let nextAdIndex = 0;
|
|
188
|
+
// Start by determining the next ad index to display.
|
|
189
|
+
let nextAdIndex = 0;
|
|
210
190
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
this.setState({
|
|
216
|
-
adIndexShown: nextAdIndex
|
|
217
|
-
}, () => {
|
|
218
|
-
this.initializeAd();
|
|
219
|
-
});
|
|
220
|
-
} else {
|
|
221
|
-
// Create a new timer with a timer length of just 10 seconds.
|
|
222
|
-
// This will allow us to re-check if the popup is still open
|
|
223
|
-
// quicker and handle switching to the next ad sooner instead of
|
|
224
|
-
// just restarting the current timer. We do this, because we must
|
|
225
|
-
// maintain the current ad shown or the popup will cycle to the
|
|
226
|
-
// next ad while the user is actively engaged with it. Then when
|
|
227
|
-
// the user closes the popup, the ad will cycle to the next quickly.
|
|
228
|
-
this.createAdTimer(10000);
|
|
191
|
+
if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {
|
|
192
|
+
nextAdIndex = this.state.adIndexShown + 1;
|
|
229
193
|
}
|
|
194
|
+
|
|
195
|
+
this.setState({
|
|
196
|
+
adIndexShown: nextAdIndex
|
|
197
|
+
}, () => {
|
|
198
|
+
this.initializeAd();
|
|
199
|
+
});
|
|
230
200
|
}
|
|
231
201
|
/**
|
|
232
202
|
* Performs all ad initialization tasks when a new ad is being displayed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["AdZone.tsx"],"names":["AdZone","React","Component","constructor","props","context","startingAdIndex","Math","floor","random","adZoneData","ads","length","state","adIndexShown","isAdPopupOpen","touchStartCoords","undefined","componentDidMount","initializeAd","componentWillUnmount","cycleAdTimer","clearTimeout","render","styles","generateStyles","currentAd","finalMainViewStyle","mainView","creative_url","width","height","uri","webView","e","setState","x","nativeEvent","pageX","y","pageY","touchEndCoords","abs","xyDragDistanceAllowed","onAdZoneSelected","item","onAddToListTriggered","action_type","AdActionType","EXTERNAL","action_path","Linking","openURL","then","POPUP","LINK","CONTENT","payload","detailed_list_items","triggerReportAdEvent","ReportedEventType","INTERACTION","cycleDisplayedAd","eventType","currentTs","round","Date","getTime","adadaptedApiRequests","reportAdEvent","app_id","appId","session_id","sessionId","udid","events","ad_id","impression_id","event_type","created_at","deviceOs","apiEnv","createAdTimer","timerLength","setTimeout","nextAdIndex","refresh_time","IMPRESSION","StyleSheet","create"],"mappings":";;;;;;;AAIA;;AACA;;AACA;;AACA;;AAOA;;AAEA;;AACA;;;;;;;;AA4FA;AACA;AACA;AACO,MAAMA,MAAN,SAAqBC,KAAK,CAACC,SAA3B,CAAmD;AACtD;AACJ;AACA;AACA;;AAGI;AACJ;AACA;AACIC,EAAAA,WAAW,CAACC,KAAD,EAAeC,OAAf,EAA8B;AACrC,UAAMD,KAAN,EAAaC,OAAb,EADqC,CAGrC;;AAHqC;;AAIrC,UAAMC,eAAe,GAAGC,IAAI,CAACC,KAAL,CACpBD,IAAI,CAACE,MAAL,KAAgB,KAAKL,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0BC,MADtB,CAAxB;AAIA,SAAKC,KAAL,GAAa;AACTC,MAAAA,YAAY,EAAER,eADL;AAETS,MAAAA,aAAa,EAAE,KAFN;AAGTC,MAAAA,gBAAgB,EAAEC;AAHT,KAAb;AAKH;AAED;AACJ;AACA;;;AACWC,EAAAA,iBAAP,GAAiC;AAC7B,SAAKC,YAAL;AACH;AAED;AACJ;AACA;;;AACWC,EAAAA,oBAAP,GAAoC;AAChC,QAAI,KAAKC,YAAT,EAAuB;AACnBC,MAAAA,YAAY,CAAC,KAAKD,YAAN,CAAZ;AACH;AACJ;AAED;AACJ;AACA;;;AACWE,EAAAA,MAAP,GAA6B;AACzB;AACA;AACA,UAAMC,MAAM,GAAG,KAAKC,cAAL,EAAf;AACA,UAAMC,SAAyB,GAC3B,KAAKtB,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,KAAsDG,SAD1D;AAEA,UAAMU,kBAAkB,GAAGH,MAAM,CAACI,QAAlC;;AAEA,QAAI,CAACF,SAAD,IAAc,CAACA,SAAS,CAACG,YAA7B,EAA2C;AAC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B,QAAI,CAAC,KAAKjD,KAAL,CAAWE,aAAhB,EAA+B;AAC3B;AACA,UAAIsE,WAAW,GAAG,CAAlB;;AAEA,UACI,KAAKxE,KAAL,CAAWC,YAAX,GACA,KAAKV,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0BC,MAA1B,GAAmC,CAFvC,EAGE;AACEyE,QAAAA,WAAW,GAAG,KAAKxE,KAAL,CAAWC,YAAX,GAA0B,CAAxC;AACH;;AAED,WAAKqB,QAAL,CACI;AACIrB,QAAAA,YAAY,EAAEuE;AADlB,OADJ,EAII,MAAM;AACF,aAAKlE,YAAL;AACH,OANL;AAQH,KAnBD,MAmBO;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAK+D,aAAL,CAAmB,KAAnB;AACH;AACJ;AAED;AACJ;AACA;;;AACY/D,EAAAA,YAAR,GAA6B;AACzB;AACA,SAAK+D,aAAL,CACI,KAAK9E,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,EAAmDwE,YAAnD,GACI,IAFR,EAFyB,CAOzB;;AACA,SAAK3B,oBAAL,CACI,KAAKvD,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,CADJ,EAEI8C,qCAAkB2B,UAFtB;AAIH;AAED;AACJ;AACA;AACA;;;AACY9D,EAAAA,cAAR,GAAmC;AAC/B,WAAO+D,wBAAWC,MAAX,CAAkB;AACrB7D,MAAAA,QAAQ,EAAE;AACNE,QAAAA,KAAK,EAAE,MADD;AAENC,QAAAA,MAAM,EAAE;AAFF,OADW;AAKrBE,MAAAA,OAAO,EAAE;AACLH,QAAAA,KAAK,EAAE,MADF;AAELC,QAAAA,MAAM,EAAE;AAFH;AALY,KAAlB,CAAP;AAUH;;AArRqD","sourcesContent":["/**\n * Component for creating an {@link AdZone}.\n * @module\n */\nimport * as React from \"react\";\nimport { Linking, StyleSheet, View, ViewStyle } from \"react-native\";\nimport * as adadaptedApiRequests from \"../api/adadaptedApiRequests\";\nimport {\n Ad,\n AdActionType,\n DetailedListItem,\n ReportedEventType,\n Zone,\n} from \"../api/adadaptedApiTypes\";\nimport { WebView } from \"react-native-webview\";\nimport { ApiEnv, DeviceOS } from \"../index\";\nimport { AdPopup } from \"./AdPopup\";\nimport { safeInvoke } from \"../util\";\n\n/**\n * Props interface for {@link AdZone}.\n */\ninterface Props {\n /**\n * The app ID.\n */\n appId: string;\n /**\n * The session ID.\n */\n sessionId: string;\n /**\n * The UDID.\n */\n udid: string;\n /**\n * The touch sensitivity of the Ad Zone in both the X and Y directions.\n * This is used to determine the click/press sensitivity when the\n * Ad Zone is being touched by the user as a regular touch or while\n * scrolling the view. If the amount of touch \"drag\" distance in either\n * X or Y direction is less than this value, we will treat the action as\n * a click/press on the Ad Zone.\n */\n xyDragDistanceAllowed: number;\n /**\n * The device OS used for API requests.\n */\n deviceOs: DeviceOS;\n /**\n * The API environment to use when making an API request.\n */\n apiEnv: ApiEnv;\n /**\n * The ad zone data.\n */\n adZoneData: Zone;\n /**\n * Callback that gets triggered when an \"add to list\" item/items are clicked.\n * @param items - The array of items to \"add to list\".\n */\n onAddToListTriggered?(items: DetailedListItem[]): void;\n}\n\n/**\n * State interface for {@link AdZone}.\n */\ninterface State {\n /**\n * Tracks the current ad index being shown.\n */\n adIndexShown: number;\n /**\n * If true, the ad popup(if available) is open.\n */\n isAdPopupOpen: boolean;\n /**\n * Tracks the coordinates when the user started touching the Ad View.\n */\n touchStartCoords: TouchCoordinates | undefined;\n}\n\n/**\n * Interface for tracking \"touch\" coordinates.\n */\ninterface TouchCoordinates {\n /**\n * The X coordinate for the touch.\n */\n x: number;\n /**\n * The Y coordinate for the touch.\n */\n y: number;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n}\n\n/**\n * Creates the AdZone component.\n */\nexport class AdZone extends React.Component<Props, State> {\n /**\n * Timer used for cycling through ads in the zone\n * based on the ad \"refresh time\" for each ad.\n */\n private cycleAdTimer: ReturnType<typeof setTimeout> | undefined;\n\n /**\n * @inheritDoc\n */\n constructor(props: Props, context?: any) {\n super(props, context);\n\n // Generates a random number between 0 and (number of available ads - 1).\n const startingAdIndex = Math.floor(\n Math.random() * this.props.adZoneData.ads.length\n );\n\n this.state = {\n adIndexShown: startingAdIndex,\n isAdPopupOpen: false,\n touchStartCoords: undefined,\n };\n }\n\n /**\n * @inheritDoc\n */\n public componentDidMount(): void {\n this.initializeAd();\n }\n\n /**\n * @inheritDoc\n */\n public componentWillUnmount(): void {\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n }\n\n /**\n * @inheritDoc\n */\n public render(): JSX.Element {\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = this.generateStyles();\n const currentAd: Ad | undefined =\n this.props.adZoneData.ads[this.state.adIndexShown] || undefined;\n const finalMainViewStyle = styles.mainView;\n\n if (!currentAd || !currentAd.creative_url) {\n // If there is no ad to display, make the view take up no space.\n finalMainViewStyle.width = 0;\n finalMainViewStyle.height = 0;\n }\n\n return (\n <View style={finalMainViewStyle}>\n {currentAd && currentAd.creative_url ? (\n <WebView\n source={{\n uri: currentAd.creative_url,\n }}\n androidHardwareAccelerationDisabled={true}\n automaticallyAdjustContentInsets={false}\n style={styles.webView}\n onTouchStart={(e) => {\n this.setState({\n touchStartCoords: {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n },\n });\n }}\n onTouchEnd={(e) => {\n if (this.state.touchStartCoords) {\n const touchEndCoords: TouchCoordinates = {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n };\n\n if (\n Math.abs(\n this.state.touchStartCoords.x -\n touchEndCoords.x\n ) < this.props.xyDragDistanceAllowed &&\n Math.abs(\n this.state.touchStartCoords.y -\n touchEndCoords.y\n ) < this.props.xyDragDistanceAllowed\n ) {\n this.onAdZoneSelected(currentAd);\n }\n\n // Make sure to reset the start coords\n this.setState({\n touchStartCoords: undefined,\n });\n }\n }}\n />\n ) : undefined}\n {currentAd && currentAd.creative_url ? (\n <AdPopup\n ad={currentAd}\n isOpen={this.state.isAdPopupOpen}\n onClose={() => {\n this.setState({\n isAdPopupOpen: false,\n });\n }}\n onAddToListItemClicked={(item) => {\n safeInvoke(this.props.onAddToListTriggered, [item]);\n }}\n />\n ) : undefined}\n </View>\n );\n }\n\n /**\n * Triggers when the user selects the ad zone.\n * @param currentAd - The ad currently displayed.\n */\n private onAdZoneSelected(currentAd: Ad): void {\n // Determine the \"action type\" and perform that specific action.\n if (\n currentAd.action_type === AdActionType.EXTERNAL &&\n currentAd.action_path\n ) {\n // Action Type: EXTERNAL\n Linking.openURL(currentAd.action_path).then();\n } else if (\n (currentAd.action_type === AdActionType.POPUP ||\n currentAd.action_type === AdActionType.LINK) &&\n currentAd.action_path\n ) {\n // Action Type: POPUP or LINK\n this.setState({\n isAdPopupOpen: true,\n });\n } else if (\n currentAd.action_type === AdActionType.CONTENT &&\n currentAd.payload &&\n currentAd.payload.detailed_list_items\n ) {\n safeInvoke(\n this.props.onAddToListTriggered,\n currentAd.payload.detailed_list_items\n );\n }\n\n this.triggerReportAdEvent(currentAd, ReportedEventType.INTERACTION);\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n this.cycleDisplayedAd();\n }\n\n /**\n * Triggered when we need to report an ad event to the API.\n * @param currentAd - The ad to send an event for.\n * @param eventType - The event type for the reported event.\n */\n private triggerReportAdEvent(\n currentAd: Ad,\n eventType: ReportedEventType\n ): void {\n // The event timestamp has to be sent as a unix timestamp.\n const currentTs = Math.round(new Date().getTime() / 1000);\n\n // Log the taken action/event with the API.\n adadaptedApiRequests\n .reportAdEvent(\n {\n app_id: this.props.appId,\n session_id: this.props.sessionId,\n udid: this.props.udid,\n events: [\n {\n ad_id: currentAd.ad_id,\n impression_id: currentAd.impression_id,\n event_type: eventType,\n created_at: currentTs,\n },\n ],\n },\n this.props.deviceOs,\n this.props.apiEnv\n )\n .then(() => {\n // Do nothing with the response for now...\n });\n }\n\n /**\n * Generates a new timer for cycling to the next ad.\n * @param timerLength - The length of time(in milliseconds) to initialize\n * the timer with.\n */\n private createAdTimer(timerLength: number): void {\n if (this.props.adZoneData.ads.length > 0) {\n this.cycleAdTimer = setTimeout(() => {\n this.cycleDisplayedAd();\n }, timerLength);\n }\n }\n\n /**\n * Cycles to the next ad to display in the current available sequence of ads.\n */\n private cycleDisplayedAd(): void {\n if (!this.state.isAdPopupOpen) {\n // Start by determining the next ad index to display.\n let nextAdIndex = 0;\n\n if (\n this.state.adIndexShown <\n this.props.adZoneData.ads.length - 1\n ) {\n nextAdIndex = this.state.adIndexShown + 1;\n }\n\n this.setState(\n {\n adIndexShown: nextAdIndex,\n },\n () => {\n this.initializeAd();\n }\n );\n } else {\n // Create a new timer with a timer length of just 10 seconds.\n // This will allow us to re-check if the popup is still open\n // quicker and handle switching to the next ad sooner instead of\n // just restarting the current timer. We do this, because we must\n // maintain the current ad shown or the popup will cycle to the\n // next ad while the user is actively engaged with it. Then when\n // the user closes the popup, the ad will cycle to the next quickly.\n this.createAdTimer(10000);\n }\n }\n\n /**\n * Performs all ad initialization tasks when a new ad is being displayed.\n */\n private initializeAd(): void {\n // Create the new timer based on the new ad index.\n this.createAdTimer(\n this.props.adZoneData.ads[this.state.adIndexShown].refresh_time *\n 1000\n );\n\n // Trigger an impression event for the ad.\n this.triggerReportAdEvent(\n this.props.adZoneData.ads[this.state.adIndexShown],\n ReportedEventType.IMPRESSION\n );\n }\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n private generateStyles(): StyleDef {\n return StyleSheet.create({\n mainView: {\n width: \"100%\",\n height: \"100%\",\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n },\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["AdZone.tsx"],"names":["AdZone","React","Component","constructor","props","context","startingAdIndex","Math","floor","random","adZoneData","ads","length","state","adIndexShown","touchStartCoords","undefined","componentDidMount","initializeAd","componentWillUnmount","cycleAdTimer","clearTimeout","render","styles","generateStyles","currentAd","finalMainViewStyle","mainView","creative_url","width","height","uri","webView","e","setState","x","nativeEvent","pageX","y","pageY","touchEndCoords","abs","xyDragDistanceAllowed","onAdZoneSelected","action_type","AdActionType","EXTERNAL","action_path","Linking","openURL","then","CONTENT","payload","detailed_list_items","onAddToListTriggered","triggerReportAdEvent","ReportedEventType","INTERACTION","cycleDisplayedAd","eventType","currentTs","round","Date","getTime","adadaptedApiRequests","reportAdEvent","app_id","appId","session_id","sessionId","udid","events","ad_id","impression_id","event_type","created_at","deviceOs","apiEnv","createAdTimer","timerLength","setTimeout","nextAdIndex","refresh_time","IMPRESSION","StyleSheet","create"],"mappings":";;;;;;;AAIA;;AACA;;AACA;;AACA;;AAOA;;AAEA;;;;;;;;AAwFA;AACA;AACA;AACO,MAAMA,MAAN,SAAqBC,KAAK,CAACC,SAA3B,CAAmD;AACtD;AACJ;AACA;AACA;;AAGI;AACJ;AACA;AACIC,EAAAA,WAAW,CAACC,KAAD,EAAeC,OAAf,EAA8B;AACrC,UAAMD,KAAN,EAAaC,OAAb,EADqC,CAGrC;;AAHqC;;AAIrC,UAAMC,eAAe,GAAGC,IAAI,CAACC,KAAL,CACpBD,IAAI,CAACE,MAAL,KAAgB,KAAKL,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0BC,MADtB,CAAxB;AAIA,SAAKC,KAAL,GAAa;AACTC,MAAAA,YAAY,EAAER,eADL;AAETS,MAAAA,gBAAgB,EAAEC;AAFT,KAAb;AAIH;AAED;AACJ;AACA;;;AACWC,EAAAA,iBAAP,GAAiC;AAC7B,SAAKC,YAAL;AACH;AAED;AACJ;AACA;;;AACWC,EAAAA,oBAAP,GAAoC;AAChC,QAAI,KAAKC,YAAT,EAAuB;AACnBC,MAAAA,YAAY,CAAC,KAA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QAAL,CACI;AACIpB,MAAAA,YAAY,EAAEmE;AADlB,KADJ,EAII,MAAM;AACF,WAAK/D,YAAL;AACH,KANL;AAQH;AAED;AACJ;AACA;;;AACYA,EAAAA,YAAR,GAA6B;AACzB;AACA,SAAK4D,aAAL,CACI,KAAK1E,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,EAAmDoE,YAAnD,GACI,IAFR,EAFyB,CAOzB;;AACA,SAAK3B,oBAAL,CACI,KAAKnD,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,CADJ,EAEI0C,qCAAkB2B,UAFtB;AAIH;AAED;AACJ;AACA;AACA;;;AACY3D,EAAAA,cAAR,GAAmC;AAC/B,WAAO4D,wBAAWC,MAAX,CAAkB;AACrB1D,MAAAA,QAAQ,EAAE;AACNE,QAAAA,KAAK,EAAE,MADD;AAENC,QAAAA,MAAM,EAAE;AAFF,OADW;AAKrBE,MAAAA,OAAO,EAAE;AACLH,QAAAA,KAAK,EAAE,MADF;AAELC,QAAAA,MAAM,EAAE;AAFH;AALY,KAAlB,CAAP;AAUH;;AA/OqD","sourcesContent":["/**\n * Component for creating an {@link AdZone}.\n * @module\n */\nimport * as React from \"react\";\nimport { Linking, StyleSheet, View, ViewStyle } from \"react-native\";\nimport * as adadaptedApiRequests from \"../api/adadaptedApiRequests\";\nimport {\n Ad,\n AdActionType,\n DetailedListItem,\n ReportedEventType,\n Zone,\n} from \"../api/adadaptedApiTypes\";\nimport { WebView } from \"react-native-webview\";\nimport { ApiEnv, DeviceOS } from \"../index\";\nimport { safeInvoke } from \"../util\";\n\n/**\n * Props interface for {@link AdZone}.\n */\ninterface Props {\n /**\n * The app ID.\n */\n appId: string;\n /**\n * The session ID.\n */\n sessionId: string;\n /**\n * The UDID.\n */\n udid: string;\n /**\n * The touch sensitivity of the Ad Zone in both the X and Y directions.\n * This is used to determine the click/press sensitivity when the\n * Ad Zone is being touched by the user as a regular touch or while\n * scrolling the view. If the amount of touch \"drag\" distance in either\n * X or Y direction is less than this value, we will treat the action as\n * a click/press on the Ad Zone.\n */\n xyDragDistanceAllowed: number;\n /**\n * The device OS used for API requests.\n */\n deviceOs: DeviceOS;\n /**\n * The API environment to use when making an API request.\n */\n apiEnv: ApiEnv;\n /**\n * The ad zone data.\n */\n adZoneData: Zone;\n /**\n * Callback that gets triggered when an \"add to list\" item/items are clicked.\n * @param items - The array of items to \"add to list\".\n */\n onAddToListTriggered?(items: DetailedListItem[]): void;\n}\n\n/**\n * State interface for {@link AdZone}.\n */\ninterface State {\n /**\n * Tracks the current ad index being shown.\n */\n adIndexShown: number;\n /**\n * Tracks the coordinates when the user started touching the Ad View.\n */\n touchStartCoords: TouchCoordinates | undefined;\n}\n\n/**\n * Interface for tracking \"touch\" coordinates.\n */\ninterface TouchCoordinates {\n /**\n * The X coordinate for the touch.\n */\n x: number;\n /**\n * The Y coordinate for the touch.\n */\n y: number;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n}\n\n/**\n * Creates the AdZone component.\n */\nexport class AdZone extends React.Component<Props, State> {\n /**\n * Timer used for cycling through ads in the zone\n * based on the ad \"refresh time\" for each ad.\n */\n private cycleAdTimer: ReturnType<typeof setTimeout> | undefined;\n\n /**\n * @inheritDoc\n */\n constructor(props: Props, context?: any) {\n super(props, context);\n\n // Generates a random number between 0 and (number of available ads - 1).\n const startingAdIndex = Math.floor(\n Math.random() * this.props.adZoneData.ads.length\n );\n\n this.state = {\n adIndexShown: startingAdIndex,\n touchStartCoords: undefined,\n };\n }\n\n /**\n * @inheritDoc\n */\n public componentDidMount(): void {\n this.initializeAd();\n }\n\n /**\n * @inheritDoc\n */\n public componentWillUnmount(): void {\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n }\n\n /**\n * @inheritDoc\n */\n public render(): JSX.Element {\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = this.generateStyles();\n const currentAd: Ad | undefined =\n this.props.adZoneData.ads[this.state.adIndexShown] || undefined;\n const finalMainViewStyle = styles.mainView;\n\n if (!currentAd || !currentAd.creative_url) {\n // If there is no ad to display, make the view take up no space.\n finalMainViewStyle.width = 0;\n finalMainViewStyle.height = 0;\n }\n\n return (\n <View style={finalMainViewStyle}>\n {currentAd && currentAd.creative_url ? (\n <WebView\n source={{\n uri: currentAd.creative_url,\n }}\n androidHardwareAccelerationDisabled={true}\n automaticallyAdjustContentInsets={false}\n style={styles.webView}\n onTouchStart={(e) => {\n this.setState({\n touchStartCoords: {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n },\n });\n }}\n onTouchEnd={(e) => {\n if (this.state.touchStartCoords) {\n const touchEndCoords: TouchCoordinates = {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n };\n\n if (\n Math.abs(\n this.state.touchStartCoords.x -\n touchEndCoords.x\n ) < this.props.xyDragDistanceAllowed &&\n Math.abs(\n this.state.touchStartCoords.y -\n touchEndCoords.y\n ) < this.props.xyDragDistanceAllowed\n ) {\n this.onAdZoneSelected(currentAd);\n }\n\n // Make sure to reset the start coords\n this.setState({\n touchStartCoords: undefined,\n });\n }\n }}\n />\n ) : undefined}\n </View>\n );\n }\n\n /**\n * Triggers when the user selects the ad zone.\n * @param currentAd - The ad currently displayed.\n */\n private onAdZoneSelected(currentAd: Ad): void {\n // Determine the \"action type\" and perform that specific action.\n if (\n currentAd.action_type === AdActionType.EXTERNAL &&\n currentAd.action_path\n ) {\n // Action Type: EXTERNAL\n Linking.openURL(currentAd.action_path).then();\n } else if (\n currentAd.action_type === AdActionType.CONTENT &&\n currentAd.payload &&\n currentAd.payload.detailed_list_items\n ) {\n safeInvoke(\n this.props.onAddToListTriggered,\n currentAd.payload.detailed_list_items\n );\n }\n\n this.triggerReportAdEvent(currentAd, ReportedEventType.INTERACTION);\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n this.cycleDisplayedAd();\n }\n\n /**\n * Triggered when we need to report an ad event to the API.\n * @param currentAd - The ad to send an event for.\n * @param eventType - The event type for the reported event.\n */\n private triggerReportAdEvent(\n currentAd: Ad,\n eventType: ReportedEventType\n ): void {\n // The event timestamp has to be sent as a unix timestamp.\n const currentTs = Math.round(new Date().getTime() / 1000);\n\n // Log the taken action/event with the API.\n adadaptedApiRequests\n .reportAdEvent(\n {\n app_id: this.props.appId,\n session_id: this.props.sessionId,\n udid: this.props.udid,\n events: [\n {\n ad_id: currentAd.ad_id,\n impression_id: currentAd.impression_id,\n event_type: eventType,\n created_at: currentTs,\n },\n ],\n },\n this.props.deviceOs,\n this.props.apiEnv\n )\n .then(() => {\n // Do nothing with the response for now...\n });\n }\n\n /**\n * Generates a new timer for cycling to the next ad.\n * @param timerLength - The length of time(in milliseconds) to initialize\n * the timer with.\n */\n private createAdTimer(timerLength: number): void {\n if (this.props.adZoneData.ads.length > 0) {\n this.cycleAdTimer = setTimeout(() => {\n this.cycleDisplayedAd();\n }, timerLength);\n }\n }\n\n /**\n * Cycles to the next ad to display in the current available sequence of ads.\n */\n private cycleDisplayedAd(): void {\n // Start by determining the next ad index to display.\n let nextAdIndex = 0;\n\n if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {\n nextAdIndex = this.state.adIndexShown + 1;\n }\n\n this.setState(\n {\n adIndexShown: nextAdIndex,\n },\n () => {\n this.initializeAd();\n }\n );\n }\n\n /**\n * Performs all ad initialization tasks when a new ad is being displayed.\n */\n private initializeAd(): void {\n // Create the new timer based on the new ad index.\n this.createAdTimer(\n this.props.adZoneData.ads[this.state.adIndexShown].refresh_time *\n 1000\n );\n\n // Trigger an impression event for the ad.\n this.triggerReportAdEvent(\n this.props.adZoneData.ads[this.state.adIndexShown],\n ReportedEventType.IMPRESSION\n );\n }\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n private generateStyles(): StyleDef {\n return StyleSheet.create({\n mainView: {\n width: \"100%\",\n height: \"100%\",\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n },\n });\n }\n}\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -157,7 +157,7 @@ class AdadaptedReactNativeSdk {
|
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* If provided, triggers when an "add to list" item is
|
|
160
|
-
* clicked in an ad zone
|
|
160
|
+
* clicked in an ad zone.
|
|
161
161
|
* @param items - The array of items to "add to list".
|
|
162
162
|
* @param isExternalPayload - If true, the items are from an external payload.
|
|
163
163
|
*/
|