apps-sdk 1.0.56 → 1.0.58

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/config.js CHANGED
@@ -2,7 +2,8 @@ export var ENDPOINTS = {
2
2
  CONTENT: "https://backend.ailandsapp.com/content",
3
3
  PAYMENT_CARD: "https://backend.ailandsapp.com/payment-card",
4
4
  EVENTS_PUSH: "https://backend.ailandsapp.com/event/push",
5
- ATTRIBUTION_SET_ID: "https://backend.ailandsapp.com/user/set-adjust-id",
5
+ ATTRIBUTION_SET_ID: "https://backend.ailandsapp.com/user/set-attribution-data",
6
+ SET_ATTRIBUTION_DATA: "https://backend.ailandsapp.com/user/set-attribution-data",
6
7
  USER_CREATE_ID: "https://backend.ailandsapp.com/user/create-id",
7
8
  NOTIFICATION_SET_TOKEN: "https://backend.ailandsapp.com/user/notification-token",
8
9
  CONFIG: "https://backend.ailandsapp.com/core/config",
@@ -34,9 +35,15 @@ export const EVENT_TYPES = {
34
35
  }
35
36
 
36
37
  export const ADJUST = {
37
- ADJUST_TOKEN : 'y4o1gcezs6ps',
38
- ENVIRONMENT : 'SANDBOX', // or 'PRODUCTION'
39
- LOG_LEVEL : 'VERBOSE'
38
+ ADJUST_TOKEN : 'y4o1gcezs6ps',
39
+ ENVIRONMENT : 'SANDBOX', // or 'PRODUCTION'
40
+ LOG_LEVEL : 'VERBOSE',
41
+ ATTRIBUTION_DATA : {
42
+ ATTRIBUTION: {},
43
+ ADID: '',
44
+ IDFA: '',
45
+ GOOGLE_AID: '',
46
+ },
40
47
  }
41
48
 
42
49
  export var TRACKING_ACTIVE = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.56",
3
+ "version": "1.0.58",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,19 +1,57 @@
1
1
  import { Adjust, AdjustEvent, AdjustConfig, AdjustPlayStoreSubscription, AdjustAppStoreSubscription, AdjustAttribution } from 'react-native-adjust';
2
2
  import * as config from '../../config';
3
3
  import { default as storage } from './Storage';
4
+ import Session from './Session';
4
5
  import {Platform} from "react-native";
6
+ import Networking from './Networking';
5
7
 
6
8
  class AdJust {
9
+ sdkVersion = null;
7
10
  initialize() {
8
11
  const adjustEnvironment = config.ADJUST.ENVIRONMENT === 'SANDBOX' ? AdjustConfig.EnvironmentSandbox : AdjustConfig.EnvironmentProduction;
9
12
  const adjustLogLevel = config.ADJUST.LOG_LEVEL === 'VERBOSE' ? AdjustConfig.LogLevelVerbose : AdjustConfig.LogLevelSuppress;
10
13
  console.log("Initializing AdJust. Environment: " + adjustEnvironment + ", Log level: " + adjustLogLevel);
11
14
  const adjustConfig = new AdjustConfig(config.ADJUST.ADJUST_TOKEN, adjustEnvironment);
12
15
  adjustConfig.setLogLevel(adjustLogLevel);
16
+ const self = this;
13
17
  adjustConfig.setAttributionCallbackListener(function(attribution) {
14
- console.log("AdJust Attribution callback received: ", JSON.stringify(attribution));
18
+ setTimeout(() => {
19
+ self.sendAttributionData(attribution);
20
+ }, 60000);
15
21
  });
16
22
  Adjust.create(adjustConfig);
23
+ this.getAttribution();
24
+ this.getAdid();
25
+ this.getIdfa();
26
+ this.getGoogleAdId();
27
+ this.getSDKVersion();
28
+ }
29
+
30
+ async getAttributionData() {
31
+ return new Promise((resolve, reject) => {
32
+ Adjust.getAttribution(attr => {
33
+ if (attr) {
34
+ resolve(attr);
35
+ } else {
36
+ reject('No attribution data');
37
+ }
38
+ });
39
+ });
40
+ }
41
+
42
+ async sendAttributionData(attribution) {
43
+ const data = {
44
+ user_id: Session.getUserID(),
45
+ adjust: {
46
+ attribution_id: Session.getAdjustAttributionID(),
47
+ googleAdid: Session.getAdjustGoogleAdid(),
48
+ idfa: Session.getAdjustIDFA(),
49
+ sdkVersion: this.sdkVersion,
50
+ attribution: attribution,
51
+ }
52
+ }
53
+ console.log('sendAttributionData', data);
54
+ Networking.request(config.ENDPOINTS.SET_ATTRIBUTION_DATA, data);
17
55
  }
18
56
 
19
57
  trackEventIfExist(eventKeyword, eventValue= 0) {
@@ -63,6 +101,37 @@ class AdJust {
63
101
  isSpecialEvent(eventKeyword) {
64
102
  return config.SPECIAL_EVENTS.includes(eventKeyword);
65
103
  }
104
+
105
+ async getAttribution() {
106
+ Adjust.getAttribution((attribution) => {
107
+ Session.setAdjustAttribution(attribution);
108
+ });
109
+ }
110
+
111
+
112
+ async getAdid() {
113
+ Adjust.getAdid((adid) => {
114
+ Session.setAdjustAttributionID(adid);
115
+ });
116
+ }
117
+
118
+ async getIdfa() {
119
+ await Adjust.getIdfa((idfa) => {
120
+ Session.setAdjustIDFA(idfa);
121
+ });
122
+ }
123
+
124
+ async getGoogleAdId() {
125
+ Adjust.getGoogleAdId((googleAdId) => {
126
+ Session.setAdjustGoogleAdid(googleAdId);
127
+ });
128
+ }
129
+
130
+ getSDKVersion() {
131
+ Adjust.getSdkVersion((sdkVersion) => {
132
+ this.sdkVersion = sdkVersion;
133
+ });
134
+ }
66
135
  }
67
136
 
68
137
  export default new AdJust();
@@ -31,7 +31,7 @@ class Networking {
31
31
  this.setEvents(initData.data.attribution);
32
32
  this.setPayWallData(initData);
33
33
  this.checkSubscription();
34
- this.setForcedUpdate(initData);
34
+ this.setForcedUpdate(initData.data);
35
35
  }
36
36
  } catch (error) {
37
37
  console.error(error);
@@ -155,7 +155,10 @@ class Networking {
155
155
 
156
156
  setForcedUpdate = (data) => {
157
157
  const currentVersion = DeviceInfo.getVersion();
158
- return data.update_state === 'force' && semver.lt(currentVersion, data.release);
158
+ const updateNeeded = (data.update_state === 'force' && semver.lt(currentVersion, data.release));
159
+ console.log('update_state: ' + data.update_state + ', currentVersion: ' + currentVersion + ', initVersion: ' + data.release + ', updateNeeded: ' + updateNeeded);
160
+ config.FORCED_UPDATE = updateNeeded;
161
+ return updateNeeded;
159
162
  }
160
163
 
161
164
  setEvents(events) {
@@ -105,6 +105,7 @@ class PayWallLogic {
105
105
  ...(offerToken && {subscriptionOffers: [{sku, offerToken}]}),
106
106
  });
107
107
  subscribed = true;
108
+ Session.setIsSubscribed(true);
108
109
  if (hidePayWallCallback) {
109
110
  hidePayWallCallback();
110
111
  }
@@ -4,6 +4,7 @@ import { Platform } from 'react-native';
4
4
  import * as Localization from 'expo-localization'
5
5
  import Storage from './Storage';
6
6
  import Networking from './Networking';
7
+ import AdJust from './AdJust';
7
8
  import * as config from "../../config";
8
9
 
9
10
  class Session {
@@ -45,7 +46,9 @@ class Session {
45
46
  "domains": "0"
46
47
  },
47
48
  adjust : {
48
-
49
+ attribution_id: '',
50
+ idfa: AdJust.getIdfa(),
51
+ googleAdid: '',
49
52
  },
50
53
  dev : false,
51
54
  lang : Localization.getLocales()[0].languageCode || 'en',
@@ -140,6 +143,35 @@ class Session {
140
143
  return this.sessionData.user_id;
141
144
  }
142
145
 
146
+ setAdjustIDFA = (idfa) => {
147
+ this.sessionData.adjust.idfa = idfa;
148
+ }
149
+
150
+ getAdjustIDFA = () => {
151
+ return this.sessionData.adjust.idfa;
152
+ }
153
+
154
+ setAdjustGoogleAdid = (googleAdid) => {
155
+ this.sessionData.adjust.googleAdid = googleAdid;
156
+ }
157
+
158
+ getAdjustGoogleAdid = () => {
159
+ return this.sessionData.adjust.googleAdid;
160
+ }
161
+
162
+ setAdjustAttributionID = (attribution_id) => {
163
+ this.sessionData.adjust.attribution_id = attribution_id;
164
+ }
165
+
166
+ getAdjustAttributionID = () => {
167
+ return this.sessionData.adjust.attribution_id;
168
+ }
169
+
170
+ setAdjustAttribution = (attribution) => {
171
+ console.log('setAdjustAttribution', attribution);
172
+ }
173
+
174
+
143
175
  sendFirstOpen = async () => {
144
176
  config.DEBUG_MODE && console.debug("sendFirstOpen");
145
177
  try {
package/types/index.d.ts CHANGED
@@ -26,27 +26,38 @@ declare module 'apps-sdk' {
26
26
  }
27
27
 
28
28
  export class Session {
29
- sessionData: SessionData;
29
+ sessionData: any;
30
30
  sessionID: string | null;
31
31
  isFirstOpen: boolean;
32
32
  isSubscribed: boolean;
33
+ subscriptionData: any;
33
34
  isDevUser: boolean;
35
+ forcedUpdate: boolean;
34
36
  init(): Promise<void>;
35
37
  storeSessionStructure(): Promise<void>;
36
38
  checkFirstOpen(): Promise<void>;
37
- checkUserID(): Promise<void>;
38
- setSubscriptionID(subscriptionID: string): void;
39
39
  generateSessionID(): string;
40
- getSessionData(): SessionData;
40
+ checkUserID(): Promise<string | null>;
41
+ getSessionData(): any;
41
42
  getSessionID(): string | null;
42
43
  getIsFirstOpen(): boolean;
43
44
  getIsSubscribed(): boolean;
44
45
  getIsDevUser(): boolean;
45
46
  setIsSubscribed(isSubscribed: boolean): void;
47
+ setSubscriptionData(subscriptionData: any): void;
48
+ setSubscriptionID(subscriptionID: string): void;
46
49
  setIsDevUser(isDevUser: boolean): void;
47
50
  setUserID(userID: string): void;
48
51
  getUserID(): string | null;
49
- setSubscriptionData(subscriptionData: any): void;
52
+ setAdjustIDFA(idfa: string): void;
53
+ getAdjustIDFA(): string;
54
+ setAdjustGoogleAdid(googleAdid: string): void;
55
+ getAdjustGoogleAdid(): string;
56
+ setAdjustAttributionID(attributionID: string): void;
57
+ getAdjustAttributionID(): string;
58
+ setAdjustAttribution(attribution: any): void;
59
+ sendFirstOpen(): Promise<void>;
60
+ checkSubscription(): Promise<void>;
50
61
  checkSubscription24h(): Promise<void>;
51
62
  isForcedUpdate(): boolean;
52
63
  }
@@ -112,8 +123,18 @@ declare module 'apps-sdk' {
112
123
  }
113
124
 
114
125
  export class AdJust {
126
+ sdkVersion: string | null;
115
127
  initialize(): Promise<void>;
116
- trackEvent(eventKeyword: string, eventValue: number): void;
128
+ getAttributionData(): Promise<any>;
129
+ sendAttributionData(attribution: any): Promise<void>;
130
+ trackEventIfExist(eventKeyword: string, eventValue?: number): void;
131
+ storeSubscription(subscriptionData: any): void;
132
+ isSpecialEvent(eventKeyword: string): boolean;
133
+ getAttribution(): Promise<void>;
134
+ getAdid(): Promise<void>;
135
+ getIdfa(): Promise<void>;
136
+ getGoogleAdId(): Promise<void>;
137
+ getSDKVersion(): void;
117
138
  }
118
139
 
119
140
  export class TrackingTransparency {