@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
@@ -3,206 +3,277 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.AdZone = void 0;
6
+ exports.AdZone = AdZone;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var adadaptedApiRequests = _interopRequireWildcard(require("../api/adadaptedApiRequests"));
10
10
  var _adadaptedApiTypes = require("../api/adadaptedApiTypes");
11
11
  var _reactNativeWebview = require("react-native-webview");
12
12
  var _util = require("../util");
13
+ var _ReportAdButton = require("./ReportAdButton");
13
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
- 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; }
16
+ /**
17
+ * Component for creating an {@link AdZone}.
18
+ * @module
19
+ */
20
+
21
+ /**
22
+ * Props interface for {@link AdZone}.
23
+ */
24
+
25
+ /**
26
+ * Interface for tracking "touch" coordinates.
27
+ */
28
+
29
+ /**
30
+ * Defines the style typing for the component.
31
+ */
32
+
33
+ /**
34
+ * Timer used for cycling through ads in the zone
35
+ * based on the ad "refresh time" for each ad.
36
+ */
37
+ let cycleAdTimer;
38
+
16
39
  /**
17
40
  * Creates the AdZone component.
41
+ * @param props - properties passed to AdZone.
42
+ * @returns an AdZone JSX Element.
18
43
  */
19
- class AdZone extends React.Component {
20
- /**
21
- * Timer used for cycling through ads in the zone
22
- * based on the ad "refresh time" for each ad.
23
- */
44
+ function AdZone(props) {
45
+ // Generates a random number between 0 and (number of available ads - 1).
46
+ const startingAdIndex = Math.floor(Math.random() * props.adZoneData.ads.length);
24
47
 
25
48
  /**
26
- * @inheritDoc
49
+ * Tracks the current ad index being shown.
27
50
  */
28
- constructor(props, context) {
29
- super(props, context);
30
-
31
- // Generates a random number between 0 and (number of available ads - 1).
32
- _defineProperty(this, "cycleAdTimer", void 0);
33
- const startingAdIndex = Math.floor(Math.random() * this.props.adZoneData.ads.length);
34
- this.state = {
35
- adIndexShown: startingAdIndex,
36
- touchStartCoords: undefined
37
- };
38
- }
39
-
51
+ const [adIndexShown, setAdIndexShown] = (0, React.useState)(startingAdIndex);
40
52
  /**
41
- * @inheritDoc
53
+ * Tracks the coordinates when the user started touching the Ad View.
42
54
  */
43
- componentDidMount() {
44
- this.initializeAd();
45
- }
46
-
55
+ const [touchStartCoords, setTouchStartCoords] = (0, React.useState)({
56
+ x: 0,
57
+ y: 0
58
+ });
47
59
  /**
48
- * @inheritDoc
60
+ * Track ad visibility (for off-screen ads).
49
61
  */
50
- componentWillUnmount() {
51
- if (this.cycleAdTimer) {
52
- clearTimeout(this.cycleAdTimer);
62
+ const [isAdVisible, setIsAdVisibile] = (0, React.useState)(props.isAdZoneVisible);
63
+
64
+ // Setup device listeners.
65
+ (0, React.useEffect)(() => {
66
+ _reactNative.DeviceEventEmitter.addListener("visibility-event", event => {
67
+ setIsAdVisibile(event);
68
+ });
69
+ _reactNative.DeviceEventEmitter.addListener("acknowledge", itemName => {
70
+ acknowledge(itemName);
71
+ });
72
+ if (props.offScreenAdZone && isAdVisible) {
73
+ sendAdImpression();
74
+ } else if (!props.offScreenAdZone) {
75
+ sendAdImpression();
53
76
  }
54
- }
77
+ return () => {
78
+ clearTimeout(cycleAdTimer);
79
+ _reactNative.DeviceEventEmitter.removeAllListeners("visibility-event");
80
+ _reactNative.DeviceEventEmitter.removeAllListeners("acknowledge");
81
+ };
82
+ // eslint-disable-next-line react-hooks/exhaustive-deps
83
+ }, []);
84
+
85
+ // Send impression on ad cycle.
86
+ (0, React.useEffect)(() => {
87
+ startAdTimer();
88
+ if (props.offScreenAdZone && isAdVisible) {
89
+ sendAdImpression();
90
+ } else if (!props.offScreenAdZone) {
91
+ sendAdImpression();
92
+ }
93
+ // eslint-disable-next-line react-hooks/exhaustive-deps
94
+ }, [adIndexShown]);
95
+
96
+ // Send impression based on visibility change. (for off-screen ads)
97
+ (0, React.useEffect)(() => {
98
+ if (props.offScreenAdZone && isAdVisible) {
99
+ sendAdImpression();
100
+ } else if (!props.offScreenAdZone) {
101
+ sendAdImpression();
102
+ }
103
+ // eslint-disable-next-line react-hooks/exhaustive-deps
104
+ }, [isAdVisible]);
55
105
 
56
106
  /**
57
- * @inheritDoc
107
+ * Generates all component related styles.
108
+ * @returns the styles needed for the component.
58
109
  */
59
- render() {
60
- // Generate the styles each render in case the ad is updated with
61
- // new settings that need to be reflected in the styles of the view.
62
- const styles = this.generateStyles();
63
- const currentAd = this.props.adZoneData.ads[this.state.adIndexShown] || undefined;
64
- const finalMainViewStyle = styles.mainView;
65
- if (!currentAd || !currentAd.creative_url) {
66
- // If there is no ad to display, make the view take up no space.
67
- finalMainViewStyle.width = 0;
68
- finalMainViewStyle.height = 0;
69
- }
70
- return /*#__PURE__*/React.createElement(_reactNative.View, {
71
- style: finalMainViewStyle
72
- }, currentAd && currentAd.creative_url ? /*#__PURE__*/React.createElement(_reactNativeWebview.WebView, {
73
- source: {
74
- uri: currentAd.creative_url
110
+ function generateStyles() {
111
+ return _reactNative.StyleSheet.create({
112
+ mainView: {
113
+ width: "100%",
114
+ height: "100%"
75
115
  },
76
- androidLayerType: "hardware",
77
- automaticallyAdjustContentInsets: false,
78
- style: styles.webView,
79
- onTouchStart: e => {
80
- this.setState({
81
- touchStartCoords: {
82
- x: e.nativeEvent.pageX,
83
- y: e.nativeEvent.pageY
84
- }
85
- });
116
+ webView: {
117
+ width: "100%",
118
+ height: "100%"
86
119
  },
87
- onTouchEnd: e => {
88
- if (this.state.touchStartCoords) {
89
- const touchEndCoords = {
90
- x: e.nativeEvent.pageX,
91
- y: e.nativeEvent.pageY
92
- };
93
- if (Math.abs(this.state.touchStartCoords.x - touchEndCoords.x) < this.props.xyDragDistanceAllowed && Math.abs(this.state.touchStartCoords.y - touchEndCoords.y) < this.props.xyDragDistanceAllowed) {
94
- this.onAdZoneSelected(currentAd);
95
- }
96
-
97
- // Make sure to reset the start coords
98
- this.setState({
99
- touchStartCoords: undefined
100
- });
101
- }
120
+ reportAd: {
121
+ position: "absolute",
122
+ top: 10,
123
+ right: 10
102
124
  }
103
- }) : undefined);
125
+ });
126
+ }
127
+
128
+ // Generate the styles each render in case the ad is updated with
129
+ // new settings that need to be reflected in the styles of the view.
130
+ const styles = generateStyles();
131
+ const currentAd = props.adZoneData.ads[adIndexShown] || undefined;
132
+ const finalMainViewStyle = styles.mainView;
133
+ if (!currentAd || !currentAd.creative_url) {
134
+ // If there is no ad to display, make the view take up no space.
135
+ finalMainViewStyle.width = 0;
136
+ finalMainViewStyle.height = 0;
104
137
  }
105
138
 
106
139
  /**
107
140
  * Triggers when the user selects the ad zone.
108
- * @param currentAd - The ad currently displayed.
141
+ * @param currentlyDisplayedAd - The ad currently displayed.
109
142
  */
110
- onAdZoneSelected(currentAd) {
143
+ function onAdZoneSelected(currentlyDisplayedAd) {
111
144
  // Determine the "action type" and perform that specific action.
112
- if (currentAd.action_type === _adadaptedApiTypes.AdActionType.EXTERNAL && currentAd.action_path) {
145
+ if (currentlyDisplayedAd.action_type === _adadaptedApiTypes.AdActionType.EXTERNAL && currentlyDisplayedAd.action_path) {
113
146
  // Action Type: EXTERNAL
114
- _reactNative.Linking.openURL(currentAd.action_path).then();
115
- } else if (currentAd.action_type === _adadaptedApiTypes.AdActionType.CONTENT && currentAd.payload && currentAd.payload.detailed_list_items) {
116
- (0, _util.safeInvoke)(this.props.onAddToListTriggered, currentAd.payload.detailed_list_items);
147
+ _reactNative.Linking.openURL(currentlyDisplayedAd.action_path).then();
148
+ } else if (currentlyDisplayedAd.action_type === _adadaptedApiTypes.AdActionType.CONTENT && currentlyDisplayedAd.payload && currentlyDisplayedAd.payload.detailed_list_items) {
149
+ (0, _util.safeInvoke)(props.onAddToListTriggered, currentlyDisplayedAd.payload.detailed_list_items);
117
150
  }
118
- this.triggerReportAdEvent(currentAd, _adadaptedApiTypes.ReportedEventType.INTERACTION);
119
- if (this.cycleAdTimer) {
120
- clearTimeout(this.cycleAdTimer);
151
+ cycleDisplayedAd();
152
+ }
153
+
154
+ /**
155
+ * Call to acknowledge ATL item(s) added to user list.
156
+ * @param itemName - Detailed list item title from ad that was clicked.
157
+ */
158
+ function acknowledge(itemName) {
159
+ if (props.adZoneData.ads) {
160
+ props.adZoneData.ads.forEach(ad => {
161
+ if (ad.action_type === "c") {
162
+ ad.payload.detailed_list_items.forEach(item => {
163
+ if (item.product_title === itemName) {
164
+ triggerReportAdEvent(ad, _adadaptedApiTypes.ReportedEventType.INTERACTION);
165
+ }
166
+ });
167
+ }
168
+ });
121
169
  }
122
- this.cycleDisplayedAd();
123
170
  }
124
171
 
125
172
  /**
126
173
  * Triggered when we need to report an ad event to the API.
127
- * @param currentAd - The ad to send an event for.
174
+ * @param ad - The ad to send an event for.
128
175
  * @param eventType - The event type for the reported event.
129
176
  */
130
- triggerReportAdEvent(currentAd, eventType) {
177
+ function triggerReportAdEvent(ad, eventType) {
131
178
  // The event timestamp has to be sent as a unix timestamp.
132
179
  const currentTs = Math.round(new Date().getTime() / 1000);
133
180
 
134
181
  // Log the taken action/event with the API.
135
182
  adadaptedApiRequests.reportAdEvent({
136
- app_id: this.props.appId,
137
- session_id: this.props.sessionId,
138
- udid: this.props.udid,
183
+ app_id: props.appId,
184
+ session_id: props.sessionId,
185
+ udid: props.udid,
139
186
  events: [{
140
- ad_id: currentAd.ad_id,
141
- impression_id: currentAd.impression_id,
187
+ ad_id: ad.ad_id,
188
+ impression_id: ad.impression_id,
142
189
  event_type: eventType,
143
190
  created_at: currentTs
144
191
  }]
145
- }, this.props.deviceOs, this.props.apiEnv).then(() => {
192
+ }, props.deviceOs, props.apiEnv).then(() => {
146
193
  // Do nothing with the response for now...
147
194
  });
148
195
  }
149
196
 
150
197
  /**
151
198
  * Generates a new timer for cycling to the next ad.
152
- * @param timerLength - The length of time(in milliseconds) to initialize
153
- * the timer with.
154
199
  */
155
- createAdTimer(timerLength) {
156
- if (this.props.adZoneData.ads.length > 0) {
157
- this.cycleAdTimer = setTimeout(() => {
158
- this.cycleDisplayedAd();
159
- }, timerLength);
200
+ function startAdTimer() {
201
+ clearTimeout(cycleAdTimer);
202
+ if (props.adZoneData.ads.length > 0) {
203
+ const refreshTime = props.adZoneData.ads[adIndexShown].refresh_time * 1000;
204
+ cycleAdTimer = setTimeout(cycleDisplayedAd, refreshTime);
160
205
  }
161
206
  }
162
207
 
163
208
  /**
164
209
  * Cycles to the next ad to display in the current available sequence of ads.
165
210
  */
166
- cycleDisplayedAd() {
211
+ function cycleDisplayedAd() {
167
212
  // Start by determining the next ad index to display.
168
213
  let nextAdIndex = 0;
169
- if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {
170
- nextAdIndex = this.state.adIndexShown + 1;
214
+ const lastAd = props.adZoneData.ads[adIndexShown];
215
+ if (adIndexShown < props.adZoneData.ads.length - 1) {
216
+ nextAdIndex = adIndexShown + 1;
171
217
  }
172
- this.setState({
173
- adIndexShown: nextAdIndex
174
- }, () => {
175
- this.initializeAd();
176
- });
218
+ if (nextAdIndex !== adIndexShown && lastAd.impression_tracked) {
219
+ // Reset ad impression tracking status.
220
+ lastAd.impression_tracked = false;
221
+ } else {
222
+ // Send invisible ad impression if ad was not visible before end of timer cycle.
223
+ triggerReportAdEvent(lastAd, _adadaptedApiTypes.ReportedEventType.INVISIBLE_IMPRESSION);
224
+ }
225
+ setAdIndexShown(nextAdIndex);
177
226
  }
178
227
 
179
228
  /**
180
- * Performs all ad initialization tasks when a new ad is being displayed.
229
+ * Send ad tracking impression.
181
230
  */
182
- initializeAd() {
183
- // Create the new timer based on the new ad index.
184
- this.createAdTimer(this.props.adZoneData.ads[this.state.adIndexShown].refresh_time * 1000);
185
-
186
- // Trigger an impression event for the ad.
187
- this.triggerReportAdEvent(this.props.adZoneData.ads[this.state.adIndexShown], _adadaptedApiTypes.ReportedEventType.IMPRESSION);
231
+ function sendAdImpression() {
232
+ const ad = props.adZoneData.ads[adIndexShown];
233
+ if (!ad.impression_tracked) {
234
+ triggerReportAdEvent(ad, _adadaptedApiTypes.ReportedEventType.IMPRESSION);
235
+ ad.impression_tracked = true;
236
+ }
188
237
  }
189
238
 
190
- /**
191
- * Generates all component related styles.
192
- * @returns the styles needed for the component.
193
- */
194
- generateStyles() {
195
- return _reactNative.StyleSheet.create({
196
- mainView: {
197
- width: "100%",
198
- height: "100%"
199
- },
200
- webView: {
201
- width: "100%",
202
- height: "100%"
239
+ // Returned JSX.
240
+ return /*#__PURE__*/React.createElement(_reactNative.View, {
241
+ style: finalMainViewStyle
242
+ }, currentAd && currentAd.creative_url ? /*#__PURE__*/React.createElement(_reactNativeWebview.WebView, {
243
+ source: {
244
+ uri: currentAd.creative_url
245
+ },
246
+ androidLayerType: "hardware",
247
+ automaticallyAdjustContentInsets: false,
248
+ style: styles.webView,
249
+ onTouchStart: e => {
250
+ setTouchStartCoords({
251
+ x: e.nativeEvent.pageX,
252
+ y: e.nativeEvent.pageY
253
+ });
254
+ },
255
+ onTouchEnd: e => {
256
+ if (touchStartCoords) {
257
+ const touchEndCoords = {
258
+ x: e.nativeEvent.pageX,
259
+ y: e.nativeEvent.pageY
260
+ };
261
+ if (Math.abs(touchStartCoords.x - touchEndCoords.x) < props.xyDragDistanceAllowed && Math.abs(touchStartCoords.y - touchEndCoords.y) < props.xyDragDistanceAllowed) {
262
+ onAdZoneSelected(currentAd);
263
+ }
264
+
265
+ // Make sure to reset the start coords
266
+ setTouchStartCoords({
267
+ x: 0,
268
+ y: 0
269
+ });
203
270
  }
204
- });
205
- }
271
+ }
272
+ }) : undefined, /*#__PURE__*/React.createElement(_reactNative.View, {
273
+ style: styles.reportAd
274
+ }, /*#__PURE__*/React.createElement(_ReportAdButton.ReportAdButton, {
275
+ adId: currentAd.ad_id,
276
+ udid: props.udid
277
+ })));
206
278
  }
207
- exports.AdZone = AdZone;
208
279
  //# sourceMappingURL=AdZone.js.map
@@ -1 +1 @@
1
- {"version":3,"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","safeInvoke","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"],"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":";;;;;;AAIA;AACA;AACA;AACA;AAOA;AAEA;AAAqC;AAAA;AAAA;AAwFrC;AACA;AACA;AACO,MAAMA,MAAM,SAASC,KAAK,CAACC,SAAS,CAAe;EACtD;AACJ;AACA;AACA;;EAGI;AACJ;AACA;EACIC,WAAW,CAACC,KAAY,EAAEC,OAAa,EAAE;IACrC,KAAK,CAACD,KAAK,EAAEC,OAAO,CAAC;;IAErB;IAAA;IACA,MAAMC,eAAe,GAAGC,IAAI,CAACC,KAAK,CAC9BD,IAAI,CAACE,MAAM,EAAE,GAAG,IAAI,CAACL,KAAK,CAACM,UAAU,CAACC,GAAG,CAACC,MAAM,CACnD;IAED,IAAI,CAACC,KAAK,GAAG;MACTC,YAAY,EAAER,eAAe;MAC7BS,gBAAgB,EAAEC;IACtB,CAAC;EACL;;EAEA;AACJ;AACA;EACWC,iBAAiB,GAAS;IAC7B,IAAI,CAACC,YAAY,EA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G,CAAC;IAC7C;IAEA,IAAI,CAACoB,QAAQ,CACT;MACIpB,YAAY,EAAEoE;IAClB,CAAC,EACD,MAAM;MACF,IAAI,CAAChE,YAAY,EAAE;IACvB,CAAC,CACJ;EACL;;EAEA;AACJ;AACA;EACYA,YAAY,GAAS;IACzB;IACA,IAAI,CAAC6D,aAAa,CACd,IAAI,CAAC3E,KAAK,CAACM,UAAU,CAACC,GAAG,CAAC,IAAI,CAACE,KAAK,CAACC,YAAY,CAAC,CAACqE,YAAY,GAC3D,IAAI,CACX;;IAED;IACA,IAAI,CAAC3B,oBAAoB,CACrB,IAAI,CAACpD,KAAK,CAACM,UAAU,CAACC,GAAG,CAAC,IAAI,CAACE,KAAK,CAACC,YAAY,CAAC,EAClD2C,oCAAiB,CAAC2B,UAAU,CAC/B;EACL;;EAEA;AACJ;AACA;AACA;EACY5D,cAAc,GAAa;IAC/B,OAAO6D,uBAAU,CAACC,MAAM,CAAC;MACrB3D,QAAQ,EAAE;QACNE,KAAK,EAAE,MAAM;QACbC,MAAM,EAAE;MACZ,CAAC;MACDE,OAAO,EAAE;QACLH,KAAK,EAAE,MAAM;QACbC,MAAM,EAAE;MACZ;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
1
+ {"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","adadaptedApiRequests","_adadaptedApiTypes","_reactNativeWebview","_util","_ReportAdButton","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","cycleAdTimer","AdZone","props","startingAdIndex","Math","floor","random","adZoneData","ads","length","adIndexShown","setAdIndexShown","useState","touchStartCoords","setTouchStartCoords","x","y","isAdVisible","setIsAdVisibile","isAdZoneVisible","useEffect","DeviceEventEmitter","addListener","event","itemName","acknowledge","offScreenAdZone","sendAdImpression","clearTimeout","removeAllListeners","startAdTimer","generateStyles","StyleSheet","create","mainView","width","height","webView","reportAd","position","top","right","styles","currentAd","undefined","finalMainViewStyle","creative_url","onAdZoneSelected","currentlyDisplayedAd","action_type","AdActionType","EXTERNAL","action_path","Linking","openURL","then","CONTENT","payload","detailed_list_items","safeInvoke","onAddToListTriggered","cycleDisplayedAd","forEach","ad","item","product_title","triggerReportAdEvent","ReportedEventType","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","View","style","WebView","source","uri","androidLayerType","automaticallyAdjustContentInsets","onTouchStart","e","nativeEvent","pageX","pageY","onTouchEnd","touchEndCoords","abs","xyDragDistanceAllowed","ReportAdButton","adId"],"sourceRoot":"../../../src","sources":["components/AdZone.tsx"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,oBAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AAOA,IAAAI,mBAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAN,OAAA;AAAkD,SAAAO,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAT,wBAAAa,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,w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;EAAS,gBACzBrE,KAAA,CAAA8H,aAAA,CAACtH,eAAA,CAAAuI,cAAc;IAACC,IAAI,EAAEtE,SAAS,CAACsC,KAAM;IAACF,IAAI,EAAE7E,KAAK,CAAC6E;EAAK,CAAE,CACxD,CACJ,CAAC;AAEf"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ReportAdButton = ReportAdButton;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ /**
12
+ * Creates the ReportAdButton component.
13
+ * @param props The component's props.
14
+ * @returns a reportSdButton JSX Element.
15
+ */
16
+ function ReportAdButton(props) {
17
+ const reportAdUrlBase = new URL("https://feedback.add-it.io/");
18
+ const styles = _reactNative.StyleSheet.create({
19
+ buttonStyle: {
20
+ width: 14,
21
+ height: 14
22
+ }
23
+ });
24
+ (0, _react.useEffect)(() => {
25
+ reportAdUrlBase.searchParams.append("aid", props.adId);
26
+ reportAdUrlBase.searchParams.append("uid", props.udid);
27
+ // eslint-disable-next-line react-hooks/exhaustive-deps
28
+ }, [props]);
29
+ return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
30
+ style: styles.buttonStyle,
31
+ onPress: () => {
32
+ _reactNative.Linking.openURL(reportAdUrlBase.toString());
33
+ }
34
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
35
+ source: require("../images/ReportIcon.png")
36
+ }));
37
+ }
38
+ //# sourceMappingURL=ReportAdButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ReportAdButton","props","reportAdUrlBase","URL","styles","StyleSheet","create","buttonStyle","width","height","useEffect","searchParams","append","adId","udid","createElement","TouchableOpacity","style","onPress","Linking","openURL","toString","Image","source"],"sourceRoot":"../../../src","sources":["components/ReportAdButton.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAA4E,SAAAE,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,C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