apps-sdk 1.1.13 → 1.1.15

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.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -134,7 +134,7 @@ class MixPanel {
134
134
  }
135
135
  }
136
136
 
137
- async setUserProperty(propertyName, propertyValue) {
137
+ async resetUserID() {
138
138
  if (!this.mixpanel) {
139
139
  console.log('Mixpanel is not initialized');
140
140
  return;
@@ -142,16 +142,31 @@ class MixPanel {
142
142
 
143
143
  try {
144
144
  if (!this.devMode) {
145
- // const distinctId = await this.getDistinctID();
146
- // const userProperties = { [propertyName]: propertyValue, distinct_id: distinctId };
147
- await this.mixpanel.getPeople().set(propertyName, propertyValue);
148
- config.DEBUG_MODE && console.log(`MixPanel User property set: ${propertyName} = ${propertyValue}`);
149
- // config.DEBUG_MODE && console.log(`MixPanel User property set: ${propertyName} = ${propertyValue}, distinct_id = ${distinctId}`);
145
+ await this.mixpanel.reset();
146
+ config.DEBUG_MODE && console.log('MixPanel User ID reset');
147
+ } else {
148
+ config.DEBUG_MODE && console.log('MixPanel User ID reset but not send (DEV_MODE ON)');
149
+ }
150
+ } catch (error) {
151
+ console.error('Error resetting user ID:', error);
152
+ }
153
+ }
154
+
155
+ async setUserProperties(properties) {
156
+ if (!this.mixpanel) {
157
+ console.log('Mixpanel is not initialized');
158
+ return;
159
+ }
160
+
161
+ try {
162
+ if (!this.devMode) {
163
+ await this.mixpanel.getPeople().set(properties);
164
+ config.DEBUG_MODE && console.log('MixPanel User properties set:', properties);
150
165
  } else {
151
- config.DEBUG_MODE && console.log(`MixPanel User property set but not send (DEV_MODE ON): ${propertyName} = ${propertyValue}`);
166
+ config.DEBUG_MODE && console.log('MixPanel User properties set but not send (DEV_MODE ON):', properties);
152
167
  }
153
168
  } catch (error) {
154
- console.error('Error setting user property:', error);
169
+ console.error('Error setting user properties:', error);
155
170
  }
156
171
  }
157
172
 
@@ -47,7 +47,7 @@ class PayWallLogic {
47
47
  let data = await this.purchaseResp(s,purchase.purchaseToken)
48
48
  const purchaseResponse = await Networking.createSubscription(data);
49
49
  if(purchaseResponse.success){
50
- Session.setIsSubscribed(true);
50
+ await Session.setIsSubscribed(true);
51
51
  Session.setSubscriptionID(data.subs_id);
52
52
  Session.setSubscriptionData(purchaseResponse.data);
53
53
  if (data.source) {
@@ -58,10 +58,16 @@ class PayWallLogic {
58
58
  "plan_type": purchase.productId,
59
59
  });
60
60
  if (data.subs_id) {
61
- Mixpanel.identifyUser(data.subs_id);
61
+ await Mixpanel.resetUserID();
62
+ await Mixpanel.identifyUser(data.subs_id);
63
+ console.log('SDK purchaseUpdatedListener Mixpanel identifyUser', data.subs_id);
62
64
  } else {
63
65
  console.log('No subs_id in purchaseResp');
64
66
  }
67
+ await Mixpanel.superProperties({
68
+ "subscription_status": "premium",
69
+ "plan_type": purchase.productId,
70
+ });
65
71
  }
66
72
  }
67
73
  } catch (error) {
@@ -80,22 +86,23 @@ class PayWallLogic {
80
86
  let data = await this.purchaseResp(s,(purchase.originalTransactionIdentifierIOS ? purchase.originalTransactionIdentifierIOS : purchase.transactionId))
81
87
  const purchaseResponse = await Networking.createSubscription(data);
82
88
  if(purchaseResponse.success){
83
- Session.setIsSubscribed(true);
89
+ await Session.setIsSubscribed(true);
84
90
  Session.setSubscriptionID(data.subs_id);
85
91
  Session.setSubscriptionData(purchaseResponse.data);
86
92
  if (data.source) {
87
93
  Networking.sendEvent('action', 'subscription_from_source', {source: data.source});
88
94
  }
89
- Mixpanel.superProperties({
90
- "subscription_status": "premium",
91
- "plan_type": purchase.productId,
92
- });
93
95
  if (data.subs_id) {
94
- Mixpanel.identifyUser(data.subs_id);
96
+ await Mixpanel.resetUserID();
97
+ await Mixpanel.identifyUser(data.subs_id);
95
98
  console.log('SDK purchaseUpdatedListener Mixpanel identifyUser', data.subs_id);
96
99
  } else {
97
100
  console.log('No subs_id in purchaseResp');
98
101
  }
102
+ await Mixpanel.superProperties({
103
+ "subscription_status": "premium",
104
+ "plan_type": purchase.productId,
105
+ });
99
106
  } else {
100
107
  console.log('SDK checkSubscription fail')
101
108
  }
package/types/index.d.ts CHANGED
@@ -188,7 +188,8 @@ declare module 'apps-sdk' {
188
188
  superProperties(properties: object): Promise<void>;
189
189
  superPropertiesAppend(properties: object): Promise<void>;
190
190
  identifyUser(userID: string): Promise<void>;
191
- setUserProperty(property: string, value: any): Promise<void>;
191
+ resetUserID(): Promise<void>;
192
+ setUserProperties(properties: any): Promise<void>;
192
193
  disableTracking(): Promise<void>;
193
194
  enableTracking(): Promise<void>;
194
195
  }