apps-sdk 1.0.148 → 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.148",
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,7 +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
- Networking.sendEvent('other', 'DEBUG_INIT_initData', JSON.stringify(initData));
33
+ this.sendEvent('other', 'DEBUG_INIT_initData', JSON.stringify(initData));
34
34
  config.TRACKING_ANSWERED = await storage.getData('TRACKING_PERMISSION_ANSWERED');
35
35
  this.setEndpoints(initData.data.domains);
36
36
  this.setEvents(initData.data.attribution);
@@ -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;