apps-sdk 1.1.14 → 1.1.16
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 +2 -0
- package/package.json +1 -1
- package/src/libraries/MixPanel.js +17 -0
- package/src/libraries/Networking.js +10 -1
- package/src/libraries/PayWallLogic.js +15 -8
- package/types/index.d.ts +2 -0
package/config.js
CHANGED
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) {
|
|
@@ -26,9 +26,10 @@ class Networking {
|
|
|
26
26
|
this.setEvents(initData.data.attribution);
|
|
27
27
|
this.setEventsMixPanel(initData.data.tracking);
|
|
28
28
|
this.setPayWallData(initData);
|
|
29
|
-
this.checkSubscription();
|
|
29
|
+
await this.checkSubscription();
|
|
30
30
|
this.setForcedUpdate(initData.data);
|
|
31
31
|
this.setConfigExtra(initData.data.config || {});
|
|
32
|
+
this.setQuickActions(initData.data.quick_actions);
|
|
32
33
|
if (initData.data.image) {
|
|
33
34
|
this.setImageCompression(initData.data.image);
|
|
34
35
|
}
|
|
@@ -184,6 +185,14 @@ class Networking {
|
|
|
184
185
|
return config.CONFIG_EXTRA;
|
|
185
186
|
}
|
|
186
187
|
|
|
188
|
+
setQuickActions = (quickActions) => {
|
|
189
|
+
config.QUICK_ACTIONS = quickActions;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
getQuickActions = () => {
|
|
193
|
+
return config.QUICK_ACTIONS;
|
|
194
|
+
}
|
|
195
|
+
|
|
187
196
|
setEvents(events) {
|
|
188
197
|
events && (config.EVENTS = events);
|
|
189
198
|
}
|
|
@@ -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
|
@@ -84,6 +84,7 @@ declare module 'apps-sdk' {
|
|
|
84
84
|
setPayWallData(payWallData: any): void;
|
|
85
85
|
getPayWallData(): any;
|
|
86
86
|
getConfigExtra(): any;
|
|
87
|
+
getQuickActions(): any;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
export class Storage {
|
|
@@ -188,6 +189,7 @@ declare module 'apps-sdk' {
|
|
|
188
189
|
superProperties(properties: object): Promise<void>;
|
|
189
190
|
superPropertiesAppend(properties: object): Promise<void>;
|
|
190
191
|
identifyUser(userID: string): Promise<void>;
|
|
192
|
+
resetUserID(): Promise<void>;
|
|
191
193
|
setUserProperties(properties: any): Promise<void>;
|
|
192
194
|
disableTracking(): Promise<void>;
|
|
193
195
|
enableTracking(): Promise<void>;
|