apps-sdk 1.1.14 → 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 +1 -1
- package/src/libraries/MixPanel.js +17 -0
- package/src/libraries/PayWallLogic.js +15 -8
- package/types/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -134,6 +134,23 @@ class MixPanel {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
async resetUserID() {
|
|
138
|
+
if (!this.mixpanel) {
|
|
139
|
+
console.log('Mixpanel is not initialized');
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
if (!this.devMode) {
|
|
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
|
+
}
|
|
137
154
|
|
|
138
155
|
async setUserProperties(properties) {
|
|
139
156
|
if (!this.mixpanel) {
|
|
@@ -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.
|
|
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.
|
|
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,6 +188,7 @@ 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
|
+
resetUserID(): Promise<void>;
|
|
191
192
|
setUserProperties(properties: any): Promise<void>;
|
|
192
193
|
disableTracking(): Promise<void>;
|
|
193
194
|
enableTracking(): Promise<void>;
|