apps-sdk 1.0.147 → 1.0.149

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
@@ -46,6 +46,11 @@ export const ADJUST = {
46
46
  },
47
47
  }
48
48
 
49
+ export const MIXPANEL = {
50
+ TOKEN: '8893d9ebad697ab26bc63214cf6cc262',
51
+ DEBUG: true,
52
+ }
53
+
49
54
  export var IMAGE_COMPRESSION = {
50
55
  COMPRESSION: 0.8,
51
56
  WIDTH: 800,
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import {NotificationsPush, Networking, Storage, Session, Utils, PayWallLogic, Rating, AdJust, TrackingTransparency, Voice} from "./src/libraries";
1
+ import {NotificationsPush, Networking, Storage, Session, Utils, PayWallLogic, Rating, AdJust, TrackingTransparency, Voice, MixPanel} from "./src/libraries";
2
2
  import PayWall from "./src/components/PayWall";
3
3
 
4
4
  class AppsSDK {
@@ -53,6 +53,7 @@ export default {
53
53
  rating: Rating,
54
54
  paywallLogic: PayWallLogic,
55
55
  adjust: AdJust,
56
+ mixpanel: MixPanel,
56
57
  tracking: TrackingTransparency,
57
58
  paywall: PayWall,
58
59
  notifications: NotificationsPush,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.147",
3
+ "version": "1.0.149",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,6 +29,7 @@
29
29
  "expo-speech": "~13.0.1",
30
30
  "expo-store-review": "~8.0.1",
31
31
  "expo-tracking-transparency": "~5.1.1",
32
+ "mixpanel-react-native": "^3.0.8",
32
33
  "react-native": "0.76.6",
33
34
  "react-native-adjust": "^5.0.2",
34
35
  "react-native-btr": "^2.2.1",
@@ -0,0 +1,50 @@
1
+ import { Mixpanel } from "mixpanel-react-native";
2
+ import * as config from '../../config';
3
+ import {Session} from "./index";
4
+
5
+ class MixPanel {
6
+ constructor() {
7
+ this.mixpanel = null;
8
+ }
9
+
10
+ async initialize(token = null, trackAutomaticEvents = false) {
11
+ const finalToken = token || config.MIXPANEL.TOKEN;
12
+ console.log('Initializing MixPanel with token: ' + finalToken);
13
+ this.mixpanel = new Mixpanel(finalToken, trackAutomaticEvents);
14
+ await this.mixpanel.init({
15
+ debug: config.MIXPANEL.DEBUG,
16
+ });
17
+ }
18
+
19
+ async identifyUser(userId) {
20
+ if (!this.mixpanel) {
21
+ console.error('Mixpanel is not initialized');
22
+ return;
23
+ }
24
+
25
+ try {
26
+ await this.mixpanel.identify(userId);
27
+ this.mixpanel.getPeople().set('userId', userId);
28
+ this.mixpanel.getPeople().set('campaignSource', Session.sessionData.adjust.attribution.source || '');
29
+ console.log(`User identified: ${userId}`);
30
+ } catch (error) {
31
+ console.error('Error identifying user:', error);
32
+ }
33
+ }
34
+
35
+ async trackEvent(eventName, properties = {}) {
36
+ if (!this.mixpanel) {
37
+ console.error('Mixpanel is not initialized');
38
+ return;
39
+ }
40
+
41
+ try {
42
+ await this.mixpanel.track(eventName, properties);
43
+ console.log(`Event tracked: ${eventName}`);
44
+ } catch (error) {
45
+ console.error('Error tracking event:', error);
46
+ }
47
+ }
48
+ }
49
+
50
+ export default new MixPanel();
@@ -30,6 +30,7 @@ class Networking {
30
30
  let initData = await this.request(config.ENDPOINTS.CONFIG);
31
31
  if (initData) {
32
32
  config.DEBUG_MODE && console.debug("initData", JSON.stringify(initData));
33
+ this.sendEvent('other', 'DEBUG_INIT_initData', JSON.stringify(initData));
33
34
  config.TRACKING_ANSWERED = await storage.getData('TRACKING_PERMISSION_ANSWERED');
34
35
  this.setEndpoints(initData.data.domains);
35
36
  this.setEvents(initData.data.attribution);
@@ -185,15 +185,18 @@ class PayWallLogic {
185
185
  let subscriptionsData = {};
186
186
  try {
187
187
  const subscriptionTemplates = await getSubscriptions({skus: productIDs});
188
+ Networking.sendEvent('other', 'DEBUG_PAYMENT_subscriptionTemplates', subscriptionTemplates);
188
189
  if (subscriptionTemplates.length > 0) {
189
190
  subscriptionTemplates.forEach(product => {
190
191
  subscriptionsData[product.productId] = product;
191
192
  });
192
193
  config.PAYWALL_DATA.products_metadata = subscriptionsData;
193
194
  config.DEBUG_MODE && console.debug('products_metadata', config.PAYWALL_DATA.products_metadata);
195
+ Networking.sendEvent('other', 'DEBUG_PAYMENT_products_metadata', config.PAYWALL_DATA.products_metadata);
194
196
  }
195
197
  } catch (err) {
196
198
  console.log('err_code', err.code, 'err_message', err.message);
199
+ Networking.sendEvent('other', 'DEBUG_PAYMENT_getSubscriptionInfo_ERROR', {'error': err.message});
197
200
  return {};
198
201
  }
199
202
  config.DEBUG_MODE && console.log('subscription Metadata: ', subscriptionsData);
@@ -342,6 +345,7 @@ class PayWallLogic {
342
345
  config.PAYWALL_DATA.paywall_info = payWallInfo;
343
346
  if (config.DEBUG_MODE) {
344
347
  console.debug('paywall_info', config.PAYWALL_DATA.paywall_info);
348
+ Networking.sendEvent('other', 'DEBUG_PAYMENT_payment_prices_info_prepared', config.PAYWALL_DATA.paywall_info);
345
349
  }
346
350
  }
347
351
  return payWallInfo;
@@ -350,6 +354,7 @@ class PayWallLogic {
350
354
 
351
355
 
352
356
  getProductIDs = () => {
357
+ Networking.sendEvent('other', 'DEBUG_PAYMENT_getProductIDs', config.PAYWALL_DATA.products);
353
358
  return config.PAYWALL_DATA.products;
354
359
  }
355
360
 
@@ -60,6 +60,7 @@ class Session {
60
60
  attribution_id: '',
61
61
  idfa: '',
62
62
  googleAdid: '',
63
+ attribution: {},
63
64
  },
64
65
  dev : false,
65
66
  lang : Localization.getLocales()[0].languageCode || 'en',
@@ -183,6 +184,7 @@ class Session {
183
184
 
184
185
  setAdjustAttribution = (attribution) => {
185
186
  console.log('setAdjustAttribution', attribution);
187
+ this.sessionData.adjust.attribution = attribution;
186
188
  }
187
189
 
188
190
  sendFirstOpen = async () => {
@@ -5,6 +5,7 @@ export { default as Session } from './Session';
5
5
  export { default as Utils } from './Utils';
6
6
  export { default as Rating } from './Rating';
7
7
  export { default as AdJust } from './AdJust';
8
+ export { default as MixPanel } from './MixPanel';
8
9
  export { default as TrackingTransparency } from './TrackingTransparency';
9
10
  export { default as PayWallLogic } from './PayWallLogic';
10
11
  export { default as Voice } from './Voice';
package/types/index.d.ts CHANGED
@@ -180,6 +180,12 @@ declare module 'apps-sdk' {
180
180
  getSDKVersion(): void;
181
181
  }
182
182
 
183
+ export class MixPanel {
184
+ initialize(token?: string, trackAutomaticEvents?: boolean): void;
185
+ identifyUser(userID: string): void;
186
+ trackEvent(event: string, properties?: object): void;
187
+ }
188
+
183
189
  export class TrackingTransparency {
184
190
  requestTrackingTransparencyPermission(): Promise<string>;
185
191
  getAdvertisingIdentifier(): Promise<string>;
@@ -200,6 +206,7 @@ declare module 'apps-sdk' {
200
206
  paywall : PayWall;
201
207
  rating : Rating;
202
208
  adjust : AdJust;
209
+ mixpanel : MixPanel;
203
210
  tracking : TrackingTransparency;
204
211
  paywallLogic : PayWallLogic;
205
212
  notificationsPush : NotificationsPush;