@adadapted/react-native-sdk 3.1.12 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/android/.project +1 -1
  2. package/android/.settings/org.eclipse.buildship.core.prefs +2 -2
  3. package/android/bin/build.gradle +6 -5
  4. package/android/bin/gradle.properties +4 -4
  5. package/android/build.gradle +6 -5
  6. package/android/gradle.properties +3 -3
  7. package/android/src/main/AndroidManifest.xml +1 -3
  8. package/lib/commonjs/api/adadaptedApiRequests.js.map +1 -1
  9. package/lib/commonjs/api/adadaptedApiRequests.mock.js +25 -8
  10. package/lib/commonjs/api/adadaptedApiRequests.mock.js.map +1 -1
  11. package/lib/commonjs/api/adadaptedApiTypes.js +72 -26
  12. package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
  13. package/lib/commonjs/components/AdZone.js +200 -129
  14. package/lib/commonjs/components/AdZone.js.map +1 -1
  15. package/lib/commonjs/components/ReportAdButton.js +38 -0
  16. package/lib/commonjs/components/ReportAdButton.js.map +1 -0
  17. package/lib/commonjs/images/ReportIcon.png +0 -0
  18. package/lib/commonjs/index.js +162 -78
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/types.js +4 -0
  21. package/lib/commonjs/types.js.map +1 -1
  22. package/lib/commonjs/util.js +13 -0
  23. package/lib/commonjs/util.js.map +1 -1
  24. package/lib/module/api/adadaptedApiRequests.js.map +1 -1
  25. package/lib/module/api/adadaptedApiRequests.mock.js +25 -9
  26. package/lib/module/api/adadaptedApiRequests.mock.js.map +1 -1
  27. package/lib/module/api/adadaptedApiTypes.js +70 -24
  28. package/lib/module/api/adadaptedApiTypes.js.map +1 -1
  29. package/lib/module/components/AdZone.js +192 -128
  30. package/lib/module/components/AdZone.js.map +1 -1
  31. package/lib/module/components/ReportAdButton.js +30 -0
  32. package/lib/module/components/ReportAdButton.js.map +1 -0
  33. package/lib/module/images/ReportIcon.png +0 -0
  34. package/lib/module/index.js +162 -77
  35. package/lib/module/index.js.map +1 -1
  36. package/lib/module/types.js +1 -1
  37. package/lib/module/types.js.map +1 -1
  38. package/lib/module/util.js +14 -2
  39. package/lib/module/util.js.map +1 -1
  40. package/lib/typescript/example/index.d.ts +1 -0
  41. package/lib/typescript/example/index.d.ts.map +1 -0
  42. package/lib/typescript/example/src/App.d.ts +15 -62
  43. package/lib/typescript/example/src/App.d.ts.map +1 -0
  44. package/lib/typescript/example/src/OffScreenAdZone.d.ts +38 -0
  45. package/lib/typescript/example/src/OffScreenAdZone.d.ts.map +1 -0
  46. package/lib/typescript/example/src/StandardAdZone.d.ts +38 -0
  47. package/lib/typescript/example/src/StandardAdZone.d.ts.map +1 -0
  48. package/lib/typescript/index.d.ts +2 -0
  49. package/lib/typescript/index.d.ts.map +1 -0
  50. package/lib/typescript/jest.setup.d.ts +2 -1
  51. package/lib/typescript/jest.setup.d.ts.map +1 -0
  52. package/lib/typescript/src/api/adadaptedApiRequests.d.ts +1 -0
  53. package/lib/typescript/src/api/adadaptedApiRequests.d.ts.map +1 -0
  54. package/lib/typescript/src/api/adadaptedApiRequests.mock.d.ts +1 -0
  55. package/lib/typescript/src/api/adadaptedApiRequests.mock.d.ts.map +1 -0
  56. package/lib/typescript/src/api/adadaptedApiTypes.d.ts +9 -0
  57. package/lib/typescript/src/api/adadaptedApiTypes.d.ts.map +1 -0
  58. package/lib/typescript/src/components/AdZone.d.ts +9 -80
  59. package/lib/typescript/src/components/AdZone.d.ts.map +1 -0
  60. package/lib/typescript/src/components/ReportAdButton.d.ts +19 -0
  61. package/lib/typescript/src/components/ReportAdButton.d.ts.map +1 -0
  62. package/lib/typescript/src/index.d.ts +39 -1
  63. package/lib/typescript/src/index.d.ts.map +1 -0
  64. package/lib/typescript/src/types.d.ts +3 -2
  65. package/lib/typescript/src/types.d.ts.map +1 -0
  66. package/lib/typescript/src/util.d.ts +13 -0
  67. package/lib/typescript/src/util.d.ts.map +1 -0
  68. package/package.json +155 -155
  69. package/src/api/adadaptedApiRequests.mock.ts +25 -9
  70. package/src/api/adadaptedApiTypes.ts +8 -0
  71. package/src/components/AdZone.tsx +222 -173
  72. package/src/components/ReportAdButton.tsx +46 -0
  73. package/src/images/ReportIcon.png +0 -0
  74. package/src/index.tsx +160 -56
  75. package/src/util.ts +13 -0
@@ -1,208 +1,272 @@
1
- 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; }
2
1
  /**
3
2
  * Component for creating an {@link AdZone}.
4
3
  * @module
5
4
  */
6
5
  import * as React from "react";
7
- import { Linking, StyleSheet, View } from "react-native";
6
+ import { DeviceEventEmitter, Linking, StyleSheet, View } from "react-native";
8
7
  import * as adadaptedApiRequests from "../api/adadaptedApiRequests";
9
8
  import { AdActionType, ReportedEventType } from "../api/adadaptedApiTypes";
10
9
  import { WebView } from "react-native-webview";
11
10
  import { safeInvoke } from "../util";
11
+ import { useEffect, useState } from "react";
12
+ import { ReportAdButton } from "./ReportAdButton";
12
13
 
13
14
  /**
14
15
  * Props interface for {@link AdZone}.
15
16
  */
16
17
 
18
+ /**
19
+ * Interface for tracking "touch" coordinates.
20
+ */
21
+
22
+ /**
23
+ * Defines the style typing for the component.
24
+ */
25
+
26
+ /**
27
+ * Timer used for cycling through ads in the zone
28
+ * based on the ad "refresh time" for each ad.
29
+ */
30
+ let cycleAdTimer;
31
+
17
32
  /**
18
33
  * Creates the AdZone component.
34
+ * @param props - properties passed to AdZone.
35
+ * @returns an AdZone JSX Element.
19
36
  */
20
- export class AdZone extends React.Component {
21
- /**
22
- * Timer used for cycling through ads in the zone
23
- * based on the ad "refresh time" for each ad.
24
- */
37
+ export function AdZone(props) {
38
+ // Generates a random number between 0 and (number of available ads - 1).
39
+ const startingAdIndex = Math.floor(Math.random() * props.adZoneData.ads.length);
25
40
 
26
41
  /**
27
- * @inheritDoc
42
+ * Tracks the current ad index being shown.
28
43
  */
29
- constructor(props, context) {
30
- super(props, context);
31
-
32
- // Generates a random number between 0 and (number of available ads - 1).
33
- _defineProperty(this, "cycleAdTimer", void 0);
34
- const startingAdIndex = Math.floor(Math.random() * this.props.adZoneData.ads.length);
35
- this.state = {
36
- adIndexShown: startingAdIndex,
37
- touchStartCoords: undefined
38
- };
39
- }
40
-
44
+ const [adIndexShown, setAdIndexShown] = useState(startingAdIndex);
41
45
  /**
42
- * @inheritDoc
46
+ * Tracks the coordinates when the user started touching the Ad View.
43
47
  */
44
- componentDidMount() {
45
- this.initializeAd();
46
- }
47
-
48
+ const [touchStartCoords, setTouchStartCoords] = useState({
49
+ x: 0,
50
+ y: 0
51
+ });
48
52
  /**
49
- * @inheritDoc
53
+ * Track ad visibility (for off-screen ads).
50
54
  */
51
- componentWillUnmount() {
52
- if (this.cycleAdTimer) {
53
- clearTimeout(this.cycleAdTimer);
55
+ const [isAdVisible, setIsAdVisibile] = useState(props.isAdZoneVisible);
56
+
57
+ // Setup device listeners.
58
+ useEffect(() => {
59
+ DeviceEventEmitter.addListener("visibility-event", event => {
60
+ setIsAdVisibile(event);
61
+ });
62
+ DeviceEventEmitter.addListener("acknowledge", itemName => {
63
+ acknowledge(itemName);
64
+ });
65
+ if (props.offScreenAdZone && isAdVisible) {
66
+ sendAdImpression();
67
+ } else if (!props.offScreenAdZone) {
68
+ sendAdImpression();
54
69
  }
55
- }
70
+ return () => {
71
+ clearTimeout(cycleAdTimer);
72
+ DeviceEventEmitter.removeAllListeners("visibility-event");
73
+ DeviceEventEmitter.removeAllListeners("acknowledge");
74
+ };
75
+ // eslint-disable-next-line react-hooks/exhaustive-deps
76
+ }, []);
77
+
78
+ // Send impression on ad cycle.
79
+ useEffect(() => {
80
+ startAdTimer();
81
+ if (props.offScreenAdZone && isAdVisible) {
82
+ sendAdImpression();
83
+ } else if (!props.offScreenAdZone) {
84
+ sendAdImpression();
85
+ }
86
+ // eslint-disable-next-line react-hooks/exhaustive-deps
87
+ }, [adIndexShown]);
88
+
89
+ // Send impression based on visibility change. (for off-screen ads)
90
+ useEffect(() => {
91
+ if (props.offScreenAdZone && isAdVisible) {
92
+ sendAdImpression();
93
+ } else if (!props.offScreenAdZone) {
94
+ sendAdImpression();
95
+ }
96
+ // eslint-disable-next-line react-hooks/exhaustive-deps
97
+ }, [isAdVisible]);
56
98
 
57
99
  /**
58
- * @inheritDoc
100
+ * Generates all component related styles.
101
+ * @returns the styles needed for the component.
59
102
  */
60
- render() {
61
- // Generate the styles each render in case the ad is updated with
62
- // new settings that need to be reflected in the styles of the view.
63
- const styles = this.generateStyles();
64
- const currentAd = this.props.adZoneData.ads[this.state.adIndexShown] || undefined;
65
- const finalMainViewStyle = styles.mainView;
66
- if (!currentAd || !currentAd.creative_url) {
67
- // If there is no ad to display, make the view take up no space.
68
- finalMainViewStyle.width = 0;
69
- finalMainViewStyle.height = 0;
70
- }
71
- return /*#__PURE__*/React.createElement(View, {
72
- style: finalMainViewStyle
73
- }, currentAd && currentAd.creative_url ? /*#__PURE__*/React.createElement(WebView, {
74
- source: {
75
- uri: currentAd.creative_url
103
+ function generateStyles() {
104
+ return StyleSheet.create({
105
+ mainView: {
106
+ width: "100%",
107
+ height: "100%"
76
108
  },
77
- androidLayerType: "hardware",
78
- automaticallyAdjustContentInsets: false,
79
- style: styles.webView,
80
- onTouchStart: e => {
81
- this.setState({
82
- touchStartCoords: {
83
- x: e.nativeEvent.pageX,
84
- y: e.nativeEvent.pageY
85
- }
86
- });
109
+ webView: {
110
+ width: "100%",
111
+ height: "100%"
87
112
  },
88
- onTouchEnd: e => {
89
- if (this.state.touchStartCoords) {
90
- const touchEndCoords = {
91
- x: e.nativeEvent.pageX,
92
- y: e.nativeEvent.pageY
93
- };
94
- if (Math.abs(this.state.touchStartCoords.x - touchEndCoords.x) < this.props.xyDragDistanceAllowed && Math.abs(this.state.touchStartCoords.y - touchEndCoords.y) < this.props.xyDragDistanceAllowed) {
95
- this.onAdZoneSelected(currentAd);
96
- }
97
-
98
- // Make sure to reset the start coords
99
- this.setState({
100
- touchStartCoords: undefined
101
- });
102
- }
113
+ reportAd: {
114
+ position: "absolute",
115
+ top: 10,
116
+ right: 10
103
117
  }
104
- }) : undefined);
118
+ });
119
+ }
120
+
121
+ // Generate the styles each render in case the ad is updated with
122
+ // new settings that need to be reflected in the styles of the view.
123
+ const styles = generateStyles();
124
+ const currentAd = props.adZoneData.ads[adIndexShown] || undefined;
125
+ const finalMainViewStyle = styles.mainView;
126
+ if (!currentAd || !currentAd.creative_url) {
127
+ // If there is no ad to display, make the view take up no space.
128
+ finalMainViewStyle.width = 0;
129
+ finalMainViewStyle.height = 0;
105
130
  }
106
131
 
107
132
  /**
108
133
  * Triggers when the user selects the ad zone.
109
- * @param currentAd - The ad currently displayed.
134
+ * @param currentlyDisplayedAd - The ad currently displayed.
110
135
  */
111
- onAdZoneSelected(currentAd) {
136
+ function onAdZoneSelected(currentlyDisplayedAd) {
112
137
  // Determine the "action type" and perform that specific action.
113
- if (currentAd.action_type === AdActionType.EXTERNAL && currentAd.action_path) {
138
+ if (currentlyDisplayedAd.action_type === AdActionType.EXTERNAL && currentlyDisplayedAd.action_path) {
114
139
  // Action Type: EXTERNAL
115
- Linking.openURL(currentAd.action_path).then();
116
- } else if (currentAd.action_type === AdActionType.CONTENT && currentAd.payload && currentAd.payload.detailed_list_items) {
117
- safeInvoke(this.props.onAddToListTriggered, currentAd.payload.detailed_list_items);
140
+ Linking.openURL(currentlyDisplayedAd.action_path).then();
141
+ } else if (currentlyDisplayedAd.action_type === AdActionType.CONTENT && currentlyDisplayedAd.payload && currentlyDisplayedAd.payload.detailed_list_items) {
142
+ safeInvoke(props.onAddToListTriggered, currentlyDisplayedAd.payload.detailed_list_items);
118
143
  }
119
- this.triggerReportAdEvent(currentAd, ReportedEventType.INTERACTION);
120
- if (this.cycleAdTimer) {
121
- clearTimeout(this.cycleAdTimer);
144
+ cycleDisplayedAd();
145
+ }
146
+
147
+ /**
148
+ * Call to acknowledge ATL item(s) added to user list.
149
+ * @param itemName - Detailed list item title from ad that was clicked.
150
+ */
151
+ function acknowledge(itemName) {
152
+ if (props.adZoneData.ads) {
153
+ props.adZoneData.ads.forEach(ad => {
154
+ if (ad.action_type === "c") {
155
+ ad.payload.detailed_list_items.forEach(item => {
156
+ if (item.product_title === itemName) {
157
+ triggerReportAdEvent(ad, ReportedEventType.INTERACTION);
158
+ }
159
+ });
160
+ }
161
+ });
122
162
  }
123
- this.cycleDisplayedAd();
124
163
  }
125
164
 
126
165
  /**
127
166
  * Triggered when we need to report an ad event to the API.
128
- * @param currentAd - The ad to send an event for.
167
+ * @param ad - The ad to send an event for.
129
168
  * @param eventType - The event type for the reported event.
130
169
  */
131
- triggerReportAdEvent(currentAd, eventType) {
170
+ function triggerReportAdEvent(ad, eventType) {
132
171
  // The event timestamp has to be sent as a unix timestamp.
133
172
  const currentTs = Math.round(new Date().getTime() / 1000);
134
173
 
135
174
  // Log the taken action/event with the API.
136
175
  adadaptedApiRequests.reportAdEvent({
137
- app_id: this.props.appId,
138
- session_id: this.props.sessionId,
139
- udid: this.props.udid,
176
+ app_id: props.appId,
177
+ session_id: props.sessionId,
178
+ udid: props.udid,
140
179
  events: [{
141
- ad_id: currentAd.ad_id,
142
- impression_id: currentAd.impression_id,
180
+ ad_id: ad.ad_id,
181
+ impression_id: ad.impression_id,
143
182
  event_type: eventType,
144
183
  created_at: currentTs
145
184
  }]
146
- }, this.props.deviceOs, this.props.apiEnv).then(() => {
185
+ }, props.deviceOs, props.apiEnv).then(() => {
147
186
  // Do nothing with the response for now...
148
187
  });
149
188
  }
150
189
 
151
190
  /**
152
191
  * Generates a new timer for cycling to the next ad.
153
- * @param timerLength - The length of time(in milliseconds) to initialize
154
- * the timer with.
155
192
  */
156
- createAdTimer(timerLength) {
157
- if (this.props.adZoneData.ads.length > 0) {
158
- this.cycleAdTimer = setTimeout(() => {
159
- this.cycleDisplayedAd();
160
- }, timerLength);
193
+ function startAdTimer() {
194
+ clearTimeout(cycleAdTimer);
195
+ if (props.adZoneData.ads.length > 0) {
196
+ const refreshTime = props.adZoneData.ads[adIndexShown].refresh_time * 1000;
197
+ cycleAdTimer = setTimeout(cycleDisplayedAd, refreshTime);
161
198
  }
162
199
  }
163
200
 
164
201
  /**
165
202
  * Cycles to the next ad to display in the current available sequence of ads.
166
203
  */
167
- cycleDisplayedAd() {
204
+ function cycleDisplayedAd() {
168
205
  // Start by determining the next ad index to display.
169
206
  let nextAdIndex = 0;
170
- if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {
171
- nextAdIndex = this.state.adIndexShown + 1;
207
+ const lastAd = props.adZoneData.ads[adIndexShown];
208
+ if (adIndexShown < props.adZoneData.ads.length - 1) {
209
+ nextAdIndex = adIndexShown + 1;
172
210
  }
173
- this.setState({
174
- adIndexShown: nextAdIndex
175
- }, () => {
176
- this.initializeAd();
177
- });
211
+ if (nextAdIndex !== adIndexShown && lastAd.impression_tracked) {
212
+ // Reset ad impression tracking status.
213
+ lastAd.impression_tracked = false;
214
+ } else {
215
+ // Send invisible ad impression if ad was not visible before end of timer cycle.
216
+ triggerReportAdEvent(lastAd, ReportedEventType.INVISIBLE_IMPRESSION);
217
+ }
218
+ setAdIndexShown(nextAdIndex);
178
219
  }
179
220
 
180
221
  /**
181
- * Performs all ad initialization tasks when a new ad is being displayed.
222
+ * Send ad tracking impression.
182
223
  */
183
- initializeAd() {
184
- // Create the new timer based on the new ad index.
185
- this.createAdTimer(this.props.adZoneData.ads[this.state.adIndexShown].refresh_time * 1000);
186
-
187
- // Trigger an impression event for the ad.
188
- this.triggerReportAdEvent(this.props.adZoneData.ads[this.state.adIndexShown], ReportedEventType.IMPRESSION);
224
+ function sendAdImpression() {
225
+ const ad = props.adZoneData.ads[adIndexShown];
226
+ if (!ad.impression_tracked) {
227
+ triggerReportAdEvent(ad, ReportedEventType.IMPRESSION);
228
+ ad.impression_tracked = true;
229
+ }
189
230
  }
190
231
 
191
- /**
192
- * Generates all component related styles.
193
- * @returns the styles needed for the component.
194
- */
195
- generateStyles() {
196
- return StyleSheet.create({
197
- mainView: {
198
- width: "100%",
199
- height: "100%"
200
- },
201
- webView: {
202
- width: "100%",
203
- height: "100%"
232
+ // Returned JSX.
233
+ return /*#__PURE__*/React.createElement(View, {
234
+ style: finalMainViewStyle
235
+ }, currentAd && currentAd.creative_url ? /*#__PURE__*/React.createElement(WebView, {
236
+ source: {
237
+ uri: currentAd.creative_url
238
+ },
239
+ androidLayerType: "hardware",
240
+ automaticallyAdjustContentInsets: false,
241
+ style: styles.webView,
242
+ onTouchStart: e => {
243
+ setTouchStartCoords({
244
+ x: e.nativeEvent.pageX,
245
+ y: e.nativeEvent.pageY
246
+ });
247
+ },
248
+ onTouchEnd: e => {
249
+ if (touchStartCoords) {
250
+ const touchEndCoords = {
251
+ x: e.nativeEvent.pageX,
252
+ y: e.nativeEvent.pageY
253
+ };
254
+ if (Math.abs(touchStartCoords.x - touchEndCoords.x) < props.xyDragDistanceAllowed && Math.abs(touchStartCoords.y - touchEndCoords.y) < props.xyDragDistanceAllowed) {
255
+ onAdZoneSelected(currentAd);
256
+ }
257
+
258
+ // Make sure to reset the start coords
259
+ setTouchStartCoords({
260
+ x: 0,
261
+ y: 0
262
+ });
204
263
  }
205
- });
206
- }
264
+ }
265
+ }) : undefined, /*#__PURE__*/React.createElement(View, {
266
+ style: styles.reportAd
267
+ }, /*#__PURE__*/React.createElement(ReportAdButton, {
268
+ adId: currentAd.ad_id,
269
+ udid: props.udid
270
+ })));
207
271
  }
208
272
  //# sourceMappingURL=AdZone.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","Linking","StyleSheet","View","adadaptedApiRequests","AdActionType","ReportedEventType","WebView","safeInvoke","AdZone","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","EXTERNAL","action_path","openURL","then","CONTENT","payload","detailed_list_items","onAddToListTriggered","triggerReportAdEvent","INTERACTION","cycleDisplayedAd","eventType","currentTs","round","Date","getTime","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","create"],"sources":["AdZone.tsx"],"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 androidLayerType=\"hardware\"\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"],"mappings":";AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,OAAO,EAAEC,UAAU,EAAEC,IAAI,QAAmB,cAAc;AACnE,OAAO,KAAKC,oBAAoB,MAAM,6BAA6B;AACnE,SAEIC,YAAY,EAEZC,iBAAiB,QAEd,0BAA0B;AACjC,SAASC,OAAO,QAAQ,sBAAsB;AAE9C,SAASC,UAAU,QAAQ,SAAS;;AAEpC;AACA;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E;MACZ;IACJ,CAAC,CAAC;EACN;AACJ"}
1
+ {"version":3,"names":["React","DeviceEventEmitter","Linking","StyleSheet","View","adadaptedApiRequests","AdActionType","ReportedEventType","WebView","safeInvoke","useEffect","useState","ReportAdButton","cycleAdTimer","AdZone","props","startingAdIndex","Math","floor","random","adZoneData","ads","length","adIndexShown","setAdIndexShown","touchStartCoords","setTouchStartCoords","x","y","isAdVisible","setIsAdVisibile","isAdZoneVisible","addListener","event","itemName","acknowledge","offScreenAdZone","sendAdImpression","clearTimeout","removeAllListeners","startAdTimer","generateStyles","create","mainView","width","height","webView","reportAd","position","top","right","styles","currentAd","undefined","finalMainViewStyle","creative_url","onAdZoneSelected","currentlyDisplayedAd","action_type","EXTERNAL","action_path","openURL","then","CONTENT","payload","detailed_list_items","onAddToListTriggered","cycleDisplayedAd","forEach","ad","item","product_title","triggerReportAdEvent","INTERACTION","eventType","currentTs","round","Date","getTime","reportAdEvent","app_id","appId","session_id","sessionId","udid","events","ad_id","impression_id","event_type","created_at","deviceOs","apiEnv","refreshTime","refresh_time","setTimeout","nextAdIndex","lastAd","impression_tracked","INVISIBLE_IMPRESSION","IMPRESSION","createElement","style","source","uri","androidLayerType","automaticallyAdjustContentInsets","onTouchStart","e","nativeEvent","pageX","pageY","onTouchEnd","touchEndCoords","abs","xyDragDistanceAllowed","adId"],"sourceRoot":"../../../src","sources":["components/AdZone.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACIC,kBAAkB,EAClBC,OAAO,EACPC,UAAU,EACVC,IAAI,QAED,cAAc;AACrB,OAAO,KAAKC,oBAAoB,MAAM,6BAA6B;AACnE,SAEIC,YAAY,EAEZC,iBAAiB,QAEd,0BAA0B;AACjC,SAASC,OAAO,QAAQ,sBAAsB;AAE9C,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,cAAc,QAAQ,kB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,CAAC,GAAGqF,cAAc,CAACrF,CACxC,CAAC,GAAGZ,KAAK,CAACmG,qBAAqB,IAC/BjG,IAAI,CAACgG,GAAG,CACJxF,gBAAgB,CAACG,CAAC,GAAGoF,cAAc,CAACpF,CACxC,CAAC,GAAGb,KAAK,CAACmG,qBAAqB,EACjC;UACE1D,gBAAgB,CAACJ,SAAS,CAAC;QAC/B;;QAEA;QACA1B,mBAAmB,CAAC;UAAEC,CAAC,EAAE,CAAC;UAAEC,CAAC,EAAE;QAAE,CAAC,CAAC;MACvC;IACJ;EAAE,CACL,CAAC,GACFyB,SAAS,eACbrD,KAAA,CAAAoG,aAAA,CAAChG,IAAI;IAACiG,KAAK,EAAElD,MAAM,CAACJ;EAAS,gBACzB/C,KAAA,CAAAoG,aAAA,CAACxF,cAAc;IAACuG,IAAI,EAAE/D,SAAS,CAACkC,KAAM;IAACF,IAAI,EAAErE,KAAK,CAACqE;EAAK,CAAE,CACxD,CACJ,CAAC;AAEf"}
@@ -0,0 +1,30 @@
1
+ import React, { useEffect } from "react";
2
+ import { Image, Linking, StyleSheet, TouchableOpacity } from "react-native";
3
+ /**
4
+ * Creates the ReportAdButton component.
5
+ * @param props The component's props.
6
+ * @returns a reportSdButton JSX Element.
7
+ */
8
+ export function ReportAdButton(props) {
9
+ const reportAdUrlBase = new URL("https://feedback.add-it.io/");
10
+ const styles = StyleSheet.create({
11
+ buttonStyle: {
12
+ width: 14,
13
+ height: 14
14
+ }
15
+ });
16
+ useEffect(() => {
17
+ reportAdUrlBase.searchParams.append("aid", props.adId);
18
+ reportAdUrlBase.searchParams.append("uid", props.udid);
19
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20
+ }, [props]);
21
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
22
+ style: styles.buttonStyle,
23
+ onPress: () => {
24
+ Linking.openURL(reportAdUrlBase.toString());
25
+ }
26
+ }, /*#__PURE__*/React.createElement(Image, {
27
+ source: require("../images/ReportIcon.png")
28
+ }));
29
+ }
30
+ //# sourceMappingURL=ReportAdButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","Image","Linking","StyleSheet","TouchableOpacity","ReportAdButton","props","reportAdUrlBase","URL","styles","create","buttonStyle","width","height","searchParams","append","adId","udid","createElement","style","onPress","openURL","toString","source","require"],"sourceRoot":"../../../src","sources":["components/ReportAdButton.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,KAAK,EAAEC,OAAO,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ,cAAc;AAa3E;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,KAAY,EAAe;EACtD,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAC,6BAA6B,CAAC;EAE9D,MAAMC,MAAM,GAAGN,UAAU,CAACO,MAAM,CAAC;IAC7BC,WAAW,EAAE;MACTC,KAAK,EAAE,EAAE;MACTC,MAAM,EAAE;IACZ;EACJ,CAAC,CAAC;EAEFb,SAAS,CAAC,MAAM;IACZO,eAAe,CAACO,YAAY,CAACC,MAAM,CAAC,KAAK,EAAET,KAAK,CAACU,IAAI,CAAC;IACtDT,eAAe,CAACO,YAAY,CAACC,MAAM,CAAC,KAAK,EAAET,KAAK,CAACW,IAAI,CAAC;IACtD;EACJ,CAAC,EAAE,CAACX,KAAK,CAAC,CAAC;EAEX,oBACIP,KAAA,CAAAmB,aAAA,CAACd,gBAAgB;IACbe,KAAK,EAAEV,MAAM,CAACE,WAAY;IAC1BS,OAAO,EAAEA,CAAA,KAAM;MACXlB,OAAO,CAACmB,OAAO,CAACd,eAAe,CAACe,QAAQ,CAAC,CAAC,CAAC;IAC/C;EAAE,gBAEFvB,KAAA,CAAAmB,aAAA,CAACjB,KAAK;IAACsB,MAAM,EAAEC,OAAO,CAAC,0BAA0B;EAAE,CAAE,CACvC,CAAC;AAE3B"}
Binary file