apps-sdk 1.0.161 → 1.0.162

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.161",
3
+ "version": "1.0.162",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,6 +1,8 @@
1
1
  import { Mixpanel } from "mixpanel-react-native";
2
2
  import * as config from '../../config';
3
3
  import {Session} from "./index";
4
+ import Constants from "expo-constants";
5
+ import * as Localization from "expo-localization";
4
6
 
5
7
  class MixPanel {
6
8
  constructor() {
@@ -33,14 +35,25 @@ class MixPanel {
33
35
  }
34
36
 
35
37
  async trackEvent(eventName, properties = {}) {
38
+ const defaultProperties = {
39
+ user_id: Session.getUserID(),
40
+ distinct_id: Session.getUserID(),
41
+ subscribed_user: Session.getIsSubscribed(),
42
+ campaign_source: Session.sessionData.adjust.attribution.source || '',
43
+ app_version: Constants.expoConfig.version,
44
+ language: Localization.getLocales()[0].languageCode || 'en',
45
+ };
46
+
36
47
  if (!this.mixpanel) {
37
48
  console.error('Mixpanel is not initialized');
38
49
  return;
39
50
  }
40
51
 
52
+ const finalProperties = {...defaultProperties, ...properties};
53
+
41
54
  try {
42
- await this.mixpanel.track(eventName, properties);
43
- console.log(`Event tracked: ${eventName}`);
55
+ await this.mixpanel.track(eventName, finalProperties);
56
+ config.DEBUG_MODE && console.log(`Event tracked: ${eventName}`);
44
57
  } catch (error) {
45
58
  console.error('Error tracking event:', error);
46
59
  }