apps-sdk 1.0.102 → 1.0.103

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.102",
3
+ "version": "1.0.103",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -69,27 +69,13 @@ class AdJust {
69
69
  }
70
70
 
71
71
  async trackEventIfExist(eventKeyword, eventValue= 0) {
72
- let finalKeyword = eventKeyword;
73
- if (config.EVENTS[finalKeyword]) {
74
- if (this.isSpecialEvent(eventKeyword)) {
75
- finalKeyword = 'first_' + eventKeyword;
76
- if (config.EVENTS[finalKeyword]) {
77
- const alreadySent = await storage.getData(finalKeyword);
78
- console.log("Already sent: " + finalKeyword + " " + JSON.stringify(alreadySent));
79
- if (!alreadySent) {
80
- console.log("Storing event: " + finalKeyword);
81
- storage.storeData(finalKeyword, true);
82
- } else {
83
- finalKeyword = eventKeyword;
84
- }
85
- }
86
- }
87
- const adjustEvent = new AdjustEvent(config.EVENTS[finalKeyword]);
72
+ if (config.EVENTS[eventKeyword]) {
73
+ const adjustEvent = new AdjustEvent(config.EVENTS[eventKeyword]);
88
74
  if (eventValue > 0) {
89
75
  adjustEvent.setRevenue(eventValue, 'EUR');
90
76
  }
91
77
  Adjust.trackEvent(adjustEvent);
92
- console.log("Event sent to AdJust: " + eventKeyword + " with value: " + eventValue + " and keyword: " + finalKeyword + " and event: " + config.EVENTS[finalKeyword]);
78
+ console.log("Event sent to AdJust: " + eventKeyword + " with value: " + eventValue + " and keyword: " + eventKeyword + " and event: " + config.EVENTS[eventKeyword]);
93
79
  } else {
94
80
  console.log("Event not found in AdJust, not sent: " + eventKeyword);
95
81
  }
@@ -116,10 +102,6 @@ class AdJust {
116
102
  }
117
103
  }
118
104
 
119
- isSpecialEvent(eventKeyword) {
120
- return config.SPECIAL_EVENTS.includes(eventKeyword);
121
- }
122
-
123
105
  async getAttribution() {
124
106
  Adjust.getAttribution((attribution) => {
125
107
  if (attribution) {
@@ -7,6 +7,7 @@ import CryptoES from "crypto-es";
7
7
  import semver from 'semver';
8
8
  import Constants from 'expo-constants';
9
9
  import { Platform } from 'react-native';
10
+ import utils from "./Utils";
10
11
 
11
12
  class Networking {
12
13
  constructor() {
@@ -218,13 +219,31 @@ class Networking {
218
219
  }
219
220
  return;
220
221
  }
221
- config.DEBUG_MODE && console.debug("sendEvent", eventType, eventKeyword, eventData);
222
+
223
+ let finalKeyword = eventKeyword;
224
+ if (config.EVENTS[finalKeyword]) {
225
+ if (utils.isSpecialEvent(finalKeyword)) {
226
+ finalKeyword = 'first_' + eventKeyword;
227
+ if (config.EVENTS[finalKeyword]) {
228
+ const alreadySent = await storage.getData(finalKeyword);
229
+ console.log("Already sent: " + finalKeyword + " " + JSON.stringify(alreadySent));
230
+ if (!alreadySent) {
231
+ console.log("Storing event: " + finalKeyword);
232
+ storage.storeData(finalKeyword, true);
233
+ } else {
234
+ finalKeyword = eventKeyword;
235
+ }
236
+ }
237
+ }
238
+ }
239
+
240
+ config.DEBUG_MODE && console.debug("sendEvent", eventType, finalKeyword, eventData);
222
241
  try {
223
- AdJust.trackEventIfExist(eventKeyword);
242
+ AdJust.trackEventIfExist(finalKeyword);
224
243
  let eventResponse = await this.request(config.ENDPOINTS.EVENTS_PUSH, {
225
- event_name: eventKeyword,
244
+ event_name: finalKeyword,
226
245
  event_type: eventType,
227
- appevent: eventKeyword,
246
+ appevent: finalKeyword,
228
247
  payload: eventData,
229
248
  ...Session.sessionData,
230
249
  });
@@ -1,3 +1,5 @@
1
+ import * as config from "../../config";
2
+
1
3
  class Utils {
2
4
  isBase64(str) {
3
5
  if (str ==='' || str.trim() ===''){ return false; }
@@ -20,6 +22,10 @@ class Utils {
20
22
  }
21
23
  return result;
22
24
  };
25
+
26
+ isSpecialEvent(eventKeyword) {
27
+ return config.SPECIAL_EVENTS.includes(eventKeyword);
28
+ }
23
29
  }
24
30
 
25
31
  export default new Utils();
package/types/index.d.ts CHANGED
@@ -105,6 +105,7 @@ declare module 'apps-sdk' {
105
105
  export class Utils {
106
106
  isBase64(str: string): boolean;
107
107
  isBase64Image(str: string): boolean;
108
+ isSpecialEvent(eventKeyword: string): boolean;
108
109
  }
109
110
 
110
111
  export class Rating {
@@ -141,7 +142,6 @@ declare module 'apps-sdk' {
141
142
  sendAttributionData(attribution: any): Promise<void>;
142
143
  trackEventIfExist(eventKeyword: string, eventValue?: number): void;
143
144
  storeSubscription(subscriptionData: any): void;
144
- isSpecialEvent(eventKeyword: string): boolean;
145
145
  getAttribution(): Promise<void>;
146
146
  getAdid(): Promise<void>;
147
147
  getIdfa(): Promise<void>;