@influto/react-native-sdk 1.2.2 → 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 CHANGED
@@ -95,7 +95,7 @@ function App() {
95
95
 
96
96
  // 3. Store in RevenueCat for webhook attribution
97
97
  await Purchases.setAttributes({
98
- 'referral_code': attribution.referralCode
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: { referral_code: referralCode }
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
- 'referral_code': attribution.referralCode
210
+ 'influto_code': attribution.referralCode
211
211
  });
212
212
  }
213
213
  ```
package/lib/InfluTo.d.ts CHANGED
@@ -59,7 +59,7 @@ declare class InfluToSDK {
59
59
  */
60
60
  getActiveCampaigns(): Promise<Campaign[]>;
61
61
  /**
62
- * Get stored referral code (if any)
62
+ * Get stored InfluTo code (if any)
63
63
  */
64
64
  getReferralCode(): Promise<string | null>;
65
65
  /**
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
- REFERRAL_CODE: `${STORAGE_PREFIX}referral_code`,
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.REFERRAL_CODE, response.referral_code);
120
- // 🎯 AUTO-INTEGRATION: Set RevenueCat attribute if available
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
- referral_code: response.referral_code
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] ✅ Referral code set in RevenueCat automatically');
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 referral_code manually');
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 referral code (if any)
233
+ * Get stored InfluTo code (if any)
232
234
  */
233
235
  async getReferralCode() {
234
- return await async_storage_1.default.getItem(STORAGE_KEYS.REFERRAL_CODE);
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.REFERRAL_CODE, normalizedCode);
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
- referral_code: normalizedCode
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] ✅ Referral code set in RevenueCat');
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.REFERRAL_CODE,
427
+ STORAGE_KEYS.INFLUTO_CODE,
424
428
  STORAGE_KEYS.APP_USER_ID
425
429
  ]);
426
430
  }
@@ -126,7 +126,9 @@ const ReferralCodeInput = ({ autoPrefill = true, autoValidate = false, onValidat
126
126
  }
127
127
  };
128
128
  const handleValidate = async (codeToValidate = code) => {
129
- if (!codeToValidate || codeToValidate.length < 4) {
129
+ // Uppercase the code before validation
130
+ const uppercaseCode = codeToValidate.toUpperCase();
131
+ if (!uppercaseCode || uppercaseCode.length < 4) {
130
132
  setState('invalid');
131
133
  setValidationResult({
132
134
  valid: false,
@@ -138,12 +140,12 @@ const ReferralCodeInput = ({ autoPrefill = true, autoValidate = false, onValidat
138
140
  setState('validating');
139
141
  setValidationResult(null);
140
142
  try {
141
- const result = await InfluTo_1.default.validateCode(codeToValidate);
143
+ const result = await InfluTo_1.default.validateCode(uppercaseCode);
142
144
  setValidationResult(result);
143
145
  if (result.valid) {
144
146
  setState('valid');
145
- // Automatically set the code if valid
146
- const setResult = await InfluTo_1.default.setReferralCode(codeToValidate, appUserId);
147
+ // Automatically set the code if valid (use uppercase version)
148
+ const setResult = await InfluTo_1.default.setReferralCode(uppercaseCode, appUserId);
147
149
  if (setResult.success) {
148
150
  onApplied?.(result);
149
151
  }
@@ -225,7 +227,7 @@ const ReferralCodeInput = ({ autoPrefill = true, autoValidate = false, onValidat
225
227
  },
226
228
  style.input
227
229
  ], value: code, onChangeText: (text) => {
228
- setCode(text.toUpperCase());
230
+ setCode(text);
229
231
  if (state !== 'idle' && state !== 'validating') {
230
232
  setState('idle');
231
233
  setValidationResult(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@influto/react-native-sdk",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "InfluTo SDK for React Native - Track influencer referrals and conversions",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
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
- REFERRAL_CODE: `${STORAGE_PREFIX}referral_code`,
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.REFERRAL_CODE, response.referral_code);
135
+ await AsyncStorage.setItem(STORAGE_KEYS.INFLUTO_CODE, response.referral_code);
136
136
 
137
- // 🎯 AUTO-INTEGRATION: Set RevenueCat attribute if available
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
- referral_code: response.referral_code
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] ✅ Referral code set in RevenueCat automatically');
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 referral_code manually');
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 referral code (if any)
257
+ * Get stored InfluTo code (if any)
256
258
  */
257
259
  async getReferralCode(): Promise<string | null> {
258
- return await AsyncStorage.getItem(STORAGE_KEYS.REFERRAL_CODE);
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.REFERRAL_CODE, normalizedCode);
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
- referral_code: normalizedCode
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] ✅ Referral code set in RevenueCat');
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.REFERRAL_CODE,
469
+ STORAGE_KEYS.INFLUTO_CODE,
466
470
  STORAGE_KEYS.APP_USER_ID
467
471
  ]);
468
472
  }
@@ -228,7 +228,10 @@ export const ReferralCodeInput: React.FC<ReferralCodeInputProps> = ({
228
228
  };
229
229
 
230
230
  const handleValidate = async (codeToValidate: string = code) => {
231
- if (!codeToValidate || codeToValidate.length < 4) {
231
+ // Uppercase the code before validation
232
+ const uppercaseCode = codeToValidate.toUpperCase();
233
+
234
+ if (!uppercaseCode || uppercaseCode.length < 4) {
232
235
  setState('invalid');
233
236
  setValidationResult({
234
237
  valid: false,
@@ -242,14 +245,14 @@ export const ReferralCodeInput: React.FC<ReferralCodeInputProps> = ({
242
245
  setValidationResult(null);
243
246
 
244
247
  try {
245
- const result = await InfluTo.validateCode(codeToValidate);
248
+ const result = await InfluTo.validateCode(uppercaseCode);
246
249
  setValidationResult(result);
247
250
 
248
251
  if (result.valid) {
249
252
  setState('valid');
250
253
 
251
- // Automatically set the code if valid
252
- const setResult = await InfluTo.setReferralCode(codeToValidate, appUserId);
254
+ // Automatically set the code if valid (use uppercase version)
255
+ const setResult = await InfluTo.setReferralCode(uppercaseCode, appUserId);
253
256
 
254
257
  if (setResult.success) {
255
258
  onApplied?.(result);
@@ -352,7 +355,7 @@ export const ReferralCodeInput: React.FC<ReferralCodeInputProps> = ({
352
355
  ]}
353
356
  value={code}
354
357
  onChangeText={(text) => {
355
- setCode(text.toUpperCase());
358
+ setCode(text);
356
359
  if (state !== 'idle' && state !== 'validating') {
357
360
  setState('idle');
358
361
  setValidationResult(null);