@influto/react-native-sdk 1.2.3 → 1.3.0
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/README.md +3 -3
- package/lib/InfluTo.d.ts +1 -1
- package/lib/InfluTo.js +16 -12
- package/package.json +1 -1
- package/src/InfluTo.ts +16 -12
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ function App() {
|
|
|
95
95
|
|
|
96
96
|
// 3. Store in RevenueCat for webhook attribution
|
|
97
97
|
await Purchases.setAttributes({
|
|
98
|
-
'
|
|
98
|
+
'influto_code': attribution.referralCode
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -120,7 +120,7 @@ function App() {
|
|
|
120
120
|
await InfluTo.trackEvent({
|
|
121
121
|
eventType: 'trial_paywall_shown',
|
|
122
122
|
appUserId: customerInfo.originalAppUserId,
|
|
123
|
-
properties: {
|
|
123
|
+
properties: { influto_code: referralCode }
|
|
124
124
|
});
|
|
125
125
|
} else {
|
|
126
126
|
// Show regular offering
|
|
@@ -207,7 +207,7 @@ InfluTo works seamlessly with RevenueCat:
|
|
|
207
207
|
const attribution = await InfluTo.checkAttribution();
|
|
208
208
|
if (attribution.attributed) {
|
|
209
209
|
await Purchases.setAttributes({
|
|
210
|
-
'
|
|
210
|
+
'influto_code': attribution.referralCode
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
```
|
package/lib/InfluTo.d.ts
CHANGED
package/lib/InfluTo.js
CHANGED
|
@@ -31,7 +31,7 @@ const STORAGE_PREFIX = '@influto/';
|
|
|
31
31
|
const STORAGE_KEYS = {
|
|
32
32
|
ATTRIBUTION: `${STORAGE_PREFIX}attribution`,
|
|
33
33
|
APP_USER_ID: `${STORAGE_PREFIX}app_user_id`,
|
|
34
|
-
|
|
34
|
+
INFLUTO_CODE: `${STORAGE_PREFIX}influto_code`,
|
|
35
35
|
SDK_INITIALIZED: `${STORAGE_PREFIX}initialized`,
|
|
36
36
|
};
|
|
37
37
|
class InfluToSDK {
|
|
@@ -116,24 +116,26 @@ class InfluToSDK {
|
|
|
116
116
|
};
|
|
117
117
|
// Store for future use
|
|
118
118
|
await async_storage_1.default.setItem(STORAGE_KEYS.ATTRIBUTION, JSON.stringify(attribution));
|
|
119
|
-
await async_storage_1.default.setItem(STORAGE_KEYS.
|
|
120
|
-
// 🎯 AUTO-INTEGRATION: Set RevenueCat
|
|
119
|
+
await async_storage_1.default.setItem(STORAGE_KEYS.INFLUTO_CODE, response.referral_code);
|
|
120
|
+
// 🎯 AUTO-INTEGRATION: Set RevenueCat attributes if available
|
|
121
|
+
// Sets both influto_code and influto_referral flag for RevenueCat Targeting
|
|
121
122
|
try {
|
|
122
123
|
// @ts-ignore - RevenueCat might not be installed
|
|
123
124
|
const Purchases = require('react-native-purchases').default;
|
|
124
125
|
if (Purchases && Purchases.setAttributes) {
|
|
125
126
|
await Purchases.setAttributes({
|
|
126
|
-
|
|
127
|
+
influto_code: response.referral_code,
|
|
128
|
+
influto_referral: 'true' // Flag for RevenueCat Targeting rules
|
|
127
129
|
});
|
|
128
130
|
if (this.config?.debug) {
|
|
129
|
-
console.log('[InfluTo] ✅
|
|
131
|
+
console.log('[InfluTo] ✅ RevenueCat attributes set: influto_code + influto_referral=true');
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
135
|
catch (e) {
|
|
134
136
|
// RevenueCat not installed - that's okay, developer can set manually
|
|
135
137
|
if (this.config?.debug) {
|
|
136
|
-
console.log('[InfluTo] RevenueCat not found - set
|
|
138
|
+
console.log('[InfluTo] RevenueCat not found - set influto_code manually');
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
if (this.config?.debug) {
|
|
@@ -228,10 +230,10 @@ class InfluToSDK {
|
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
232
|
/**
|
|
231
|
-
* Get stored
|
|
233
|
+
* Get stored InfluTo code (if any)
|
|
232
234
|
*/
|
|
233
235
|
async getReferralCode() {
|
|
234
|
-
return await async_storage_1.default.getItem(STORAGE_KEYS.
|
|
236
|
+
return await async_storage_1.default.getItem(STORAGE_KEYS.INFLUTO_CODE);
|
|
235
237
|
}
|
|
236
238
|
/**
|
|
237
239
|
* Get prefilled referral code (if user came via attribution link)
|
|
@@ -330,7 +332,7 @@ class InfluToSDK {
|
|
|
330
332
|
const normalizedCode = code.trim().toUpperCase();
|
|
331
333
|
try {
|
|
332
334
|
// Store locally
|
|
333
|
-
await async_storage_1.default.setItem(STORAGE_KEYS.
|
|
335
|
+
await async_storage_1.default.setItem(STORAGE_KEYS.INFLUTO_CODE, normalizedCode);
|
|
334
336
|
// Store attribution record
|
|
335
337
|
const attribution = {
|
|
336
338
|
attributed: true,
|
|
@@ -341,14 +343,16 @@ class InfluToSDK {
|
|
|
341
343
|
};
|
|
342
344
|
await async_storage_1.default.setItem(STORAGE_KEYS.ATTRIBUTION, JSON.stringify(attribution));
|
|
343
345
|
// Set in RevenueCat automatically
|
|
346
|
+
// Sets both influto_code and influto_referral flag for RevenueCat Targeting
|
|
344
347
|
try {
|
|
345
348
|
const Purchases = require('react-native-purchases').default;
|
|
346
349
|
if (Purchases && Purchases.setAttributes) {
|
|
347
350
|
await Purchases.setAttributes({
|
|
348
|
-
|
|
351
|
+
influto_code: normalizedCode,
|
|
352
|
+
influto_referral: 'true' // Flag for RevenueCat Targeting rules
|
|
349
353
|
});
|
|
350
354
|
if (this.config?.debug) {
|
|
351
|
-
console.log('[InfluTo] ✅
|
|
355
|
+
console.log('[InfluTo] ✅ RevenueCat attributes set: influto_code + influto_referral=true');
|
|
352
356
|
}
|
|
353
357
|
}
|
|
354
358
|
}
|
|
@@ -420,7 +424,7 @@ class InfluToSDK {
|
|
|
420
424
|
async clearAttribution() {
|
|
421
425
|
await async_storage_1.default.multiRemove([
|
|
422
426
|
STORAGE_KEYS.ATTRIBUTION,
|
|
423
|
-
STORAGE_KEYS.
|
|
427
|
+
STORAGE_KEYS.INFLUTO_CODE,
|
|
424
428
|
STORAGE_KEYS.APP_USER_ID
|
|
425
429
|
]);
|
|
426
430
|
}
|
package/package.json
CHANGED
package/src/InfluTo.ts
CHANGED
|
@@ -37,7 +37,7 @@ const STORAGE_PREFIX = '@influto/';
|
|
|
37
37
|
const STORAGE_KEYS = {
|
|
38
38
|
ATTRIBUTION: `${STORAGE_PREFIX}attribution`,
|
|
39
39
|
APP_USER_ID: `${STORAGE_PREFIX}app_user_id`,
|
|
40
|
-
|
|
40
|
+
INFLUTO_CODE: `${STORAGE_PREFIX}influto_code`,
|
|
41
41
|
SDK_INITIALIZED: `${STORAGE_PREFIX}initialized`,
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -132,24 +132,26 @@ class InfluToSDK {
|
|
|
132
132
|
|
|
133
133
|
// Store for future use
|
|
134
134
|
await AsyncStorage.setItem(STORAGE_KEYS.ATTRIBUTION, JSON.stringify(attribution));
|
|
135
|
-
await AsyncStorage.setItem(STORAGE_KEYS.
|
|
135
|
+
await AsyncStorage.setItem(STORAGE_KEYS.INFLUTO_CODE, response.referral_code);
|
|
136
136
|
|
|
137
|
-
// 🎯 AUTO-INTEGRATION: Set RevenueCat
|
|
137
|
+
// 🎯 AUTO-INTEGRATION: Set RevenueCat attributes if available
|
|
138
|
+
// Sets both influto_code and influto_referral flag for RevenueCat Targeting
|
|
138
139
|
try {
|
|
139
140
|
// @ts-ignore - RevenueCat might not be installed
|
|
140
141
|
const Purchases = require('react-native-purchases').default;
|
|
141
142
|
if (Purchases && Purchases.setAttributes) {
|
|
142
143
|
await Purchases.setAttributes({
|
|
143
|
-
|
|
144
|
+
influto_code: response.referral_code,
|
|
145
|
+
influto_referral: 'true' // Flag for RevenueCat Targeting rules
|
|
144
146
|
});
|
|
145
147
|
if (this.config?.debug) {
|
|
146
|
-
console.log('[InfluTo] ✅
|
|
148
|
+
console.log('[InfluTo] ✅ RevenueCat attributes set: influto_code + influto_referral=true');
|
|
147
149
|
}
|
|
148
150
|
}
|
|
149
151
|
} catch (e) {
|
|
150
152
|
// RevenueCat not installed - that's okay, developer can set manually
|
|
151
153
|
if (this.config?.debug) {
|
|
152
|
-
console.log('[InfluTo] RevenueCat not found - set
|
|
154
|
+
console.log('[InfluTo] RevenueCat not found - set influto_code manually');
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
|
|
@@ -252,10 +254,10 @@ class InfluToSDK {
|
|
|
252
254
|
}
|
|
253
255
|
|
|
254
256
|
/**
|
|
255
|
-
* Get stored
|
|
257
|
+
* Get stored InfluTo code (if any)
|
|
256
258
|
*/
|
|
257
259
|
async getReferralCode(): Promise<string | null> {
|
|
258
|
-
return await AsyncStorage.getItem(STORAGE_KEYS.
|
|
260
|
+
return await AsyncStorage.getItem(STORAGE_KEYS.INFLUTO_CODE);
|
|
259
261
|
}
|
|
260
262
|
|
|
261
263
|
/**
|
|
@@ -363,7 +365,7 @@ class InfluToSDK {
|
|
|
363
365
|
|
|
364
366
|
try {
|
|
365
367
|
// Store locally
|
|
366
|
-
await AsyncStorage.setItem(STORAGE_KEYS.
|
|
368
|
+
await AsyncStorage.setItem(STORAGE_KEYS.INFLUTO_CODE, normalizedCode);
|
|
367
369
|
|
|
368
370
|
// Store attribution record
|
|
369
371
|
const attribution: AttributionResult = {
|
|
@@ -376,15 +378,17 @@ class InfluToSDK {
|
|
|
376
378
|
await AsyncStorage.setItem(STORAGE_KEYS.ATTRIBUTION, JSON.stringify(attribution));
|
|
377
379
|
|
|
378
380
|
// Set in RevenueCat automatically
|
|
381
|
+
// Sets both influto_code and influto_referral flag for RevenueCat Targeting
|
|
379
382
|
try {
|
|
380
383
|
const Purchases = require('react-native-purchases').default;
|
|
381
384
|
if (Purchases && Purchases.setAttributes) {
|
|
382
385
|
await Purchases.setAttributes({
|
|
383
|
-
|
|
386
|
+
influto_code: normalizedCode,
|
|
387
|
+
influto_referral: 'true' // Flag for RevenueCat Targeting rules
|
|
384
388
|
});
|
|
385
389
|
|
|
386
390
|
if (this.config?.debug) {
|
|
387
|
-
console.log('[InfluTo] ✅
|
|
391
|
+
console.log('[InfluTo] ✅ RevenueCat attributes set: influto_code + influto_referral=true');
|
|
388
392
|
}
|
|
389
393
|
}
|
|
390
394
|
} catch (e) {
|
|
@@ -462,7 +466,7 @@ class InfluToSDK {
|
|
|
462
466
|
async clearAttribution(): Promise<void> {
|
|
463
467
|
await AsyncStorage.multiRemove([
|
|
464
468
|
STORAGE_KEYS.ATTRIBUTION,
|
|
465
|
-
STORAGE_KEYS.
|
|
469
|
+
STORAGE_KEYS.INFLUTO_CODE,
|
|
466
470
|
STORAGE_KEYS.APP_USER_ID
|
|
467
471
|
]);
|
|
468
472
|
}
|