insert-affiliate-react-native-sdk 1.7.0 → 1.8.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.
@@ -44,6 +44,8 @@ const clipboard_1 = __importDefault(require("@react-native-clipboard/clipboard")
44
44
  const netinfo_1 = __importDefault(require("@react-native-community/netinfo"));
45
45
  const react_native_device_info_1 = __importDefault(require("react-native-device-info"));
46
46
  const react_native_play_install_referrer_1 = require("react-native-play-install-referrer");
47
+ // Development environment check for React Native
48
+ const isDevelopmentEnvironment = typeof __DEV__ !== 'undefined' && __DEV__;
47
49
  const ASYNC_KEYS = {
48
50
  REFERRER_LINK: '@app_referrer_link',
49
51
  USER_PURCHASE: '@app_user_purchase',
@@ -1058,6 +1060,15 @@ const DeepLinkIapProvider = ({ children, }) => {
1058
1060
  }
1059
1061
  }
1060
1062
  catch (error) {
1063
+ // Handle E_IAP_NOT_AVAILABLE error gracefully
1064
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'E_IAP_NOT_AVAILABLE' ||
1065
+ (error instanceof Error && error.message.includes('E_IAP_NOT_AVAILABLE'))) {
1066
+ if (isDevelopmentEnvironment) {
1067
+ console.warn('[Insert Affiliate] IAP not available in development environment. Cannot store expected transaction.');
1068
+ verboseLog('E_IAP_NOT_AVAILABLE error in returnUserAccountTokenAndStoreExpectedTransaction - gracefully handling in development');
1069
+ }
1070
+ return null; // Return null but don't crash
1071
+ }
1061
1072
  console.error('[Insert Affiliate] Error in returnUserAccountTokenAndStoreExpectedTransaction:', error);
1062
1073
  return null;
1063
1074
  }
@@ -1258,7 +1269,21 @@ const DeepLinkIapProvider = ({ children, }) => {
1258
1269
  });
1259
1270
  }
1260
1271
  const validatePurchaseWithIapticAPI = (jsonIapPurchase, iapticAppId, iapticAppName, iapticPublicKey) => __awaiter(void 0, void 0, void 0, function* () {
1272
+ var _a;
1261
1273
  try {
1274
+ // Check for E_IAP_NOT_AVAILABLE error in development environment
1275
+ if (((_a = jsonIapPurchase === null || jsonIapPurchase === void 0 ? void 0 : jsonIapPurchase.error) === null || _a === void 0 ? void 0 : _a.code) === 'E_IAP_NOT_AVAILABLE' ||
1276
+ (jsonIapPurchase === null || jsonIapPurchase === void 0 ? void 0 : jsonIapPurchase.code) === 'E_IAP_NOT_AVAILABLE' ||
1277
+ (typeof jsonIapPurchase === 'string' && jsonIapPurchase.includes('E_IAP_NOT_AVAILABLE'))) {
1278
+ if (isDevelopmentEnvironment) {
1279
+ console.warn('[Insert Affiliate] IAP not available in development environment. This is expected behavior.');
1280
+ verboseLog('E_IAP_NOT_AVAILABLE error detected in development - gracefully handling');
1281
+ }
1282
+ else {
1283
+ console.error('[Insert Affiliate] IAP not available in production environment. Please check your IAP configuration.');
1284
+ }
1285
+ return false; // Return false but don't crash
1286
+ }
1262
1287
  const baseRequestBody = {
1263
1288
  id: iapticAppId,
1264
1289
  type: 'application',
@@ -1308,6 +1333,18 @@ const DeepLinkIapProvider = ({ children, }) => {
1308
1333
  }
1309
1334
  }
1310
1335
  catch (error) {
1336
+ // Handle E_IAP_NOT_AVAILABLE error gracefully
1337
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'E_IAP_NOT_AVAILABLE' ||
1338
+ (error instanceof Error && error.message.includes('E_IAP_NOT_AVAILABLE'))) {
1339
+ if (isDevelopmentEnvironment) {
1340
+ console.warn('[Insert Affiliate] IAP not available in development environment. SDK will continue without purchase validation.');
1341
+ verboseLog('E_IAP_NOT_AVAILABLE error caught in validatePurchaseWithIapticAPI - gracefully handling in development');
1342
+ }
1343
+ else {
1344
+ console.error('[Insert Affiliate] IAP not available in production environment. Please check your IAP configuration.');
1345
+ }
1346
+ return false; // Return false but don't crash
1347
+ }
1311
1348
  if (error instanceof Error) {
1312
1349
  console.error(`validatePurchaseWithIapticAPI Error: ${error.message}`);
1313
1350
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "insert-affiliate-react-native-sdk",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "A package for connecting with the Insert Affiliate Platform to add app based affiliate marketing.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -7,6 +7,9 @@ import NetInfo from '@react-native-community/netinfo';
7
7
  import DeviceInfo from 'react-native-device-info';
8
8
  import { PlayInstallReferrer, PlayInstallReferrerInfo } from 'react-native-play-install-referrer';
9
9
 
10
+ // Development environment check for React Native
11
+ const isDevelopmentEnvironment = typeof __DEV__ !== 'undefined' && __DEV__;
12
+
10
13
  // TYPES USED IN THIS PROVIDER
11
14
  type T_DEEPLINK_IAP_PROVIDER = {
12
15
  children: React.ReactNode;
@@ -1213,6 +1216,17 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
1213
1216
  return userAccountToken;
1214
1217
  }
1215
1218
  } catch (error) {
1219
+ // Handle E_IAP_NOT_AVAILABLE error gracefully
1220
+ if ((error as any)?.code === 'E_IAP_NOT_AVAILABLE' ||
1221
+ (error instanceof Error && error.message.includes('E_IAP_NOT_AVAILABLE'))) {
1222
+
1223
+ if (isDevelopmentEnvironment) {
1224
+ console.warn('[Insert Affiliate] IAP not available in development environment. Cannot store expected transaction.');
1225
+ verboseLog('E_IAP_NOT_AVAILABLE error in returnUserAccountTokenAndStoreExpectedTransaction - gracefully handling in development');
1226
+ }
1227
+ return null; // Return null but don't crash
1228
+ }
1229
+
1216
1230
  console.error('[Insert Affiliate] Error in returnUserAccountTokenAndStoreExpectedTransaction:', error);
1217
1231
  return null;
1218
1232
  };
@@ -1455,6 +1469,20 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
1455
1469
  iapticPublicKey: string
1456
1470
  ): Promise<boolean> => {
1457
1471
  try {
1472
+ // Check for E_IAP_NOT_AVAILABLE error in development environment
1473
+ if ((jsonIapPurchase as any)?.error?.code === 'E_IAP_NOT_AVAILABLE' ||
1474
+ (jsonIapPurchase as any)?.code === 'E_IAP_NOT_AVAILABLE' ||
1475
+ (typeof jsonIapPurchase === 'string' && (jsonIapPurchase as string).includes('E_IAP_NOT_AVAILABLE'))) {
1476
+
1477
+ if (isDevelopmentEnvironment) {
1478
+ console.warn('[Insert Affiliate] IAP not available in development environment. This is expected behavior.');
1479
+ verboseLog('E_IAP_NOT_AVAILABLE error detected in development - gracefully handling');
1480
+ } else {
1481
+ console.error('[Insert Affiliate] IAP not available in production environment. Please check your IAP configuration.');
1482
+ }
1483
+ return false; // Return false but don't crash
1484
+ }
1485
+
1458
1486
  const baseRequestBody: RequestBody = {
1459
1487
  id: iapticAppId,
1460
1488
  type: 'application',
@@ -1513,6 +1541,19 @@ const DeepLinkIapProvider: React.FC<T_DEEPLINK_IAP_PROVIDER> = ({
1513
1541
  return false;
1514
1542
  }
1515
1543
  } catch (error) {
1544
+ // Handle E_IAP_NOT_AVAILABLE error gracefully
1545
+ if ((error as any)?.code === 'E_IAP_NOT_AVAILABLE' ||
1546
+ (error instanceof Error && error.message.includes('E_IAP_NOT_AVAILABLE'))) {
1547
+
1548
+ if (isDevelopmentEnvironment) {
1549
+ console.warn('[Insert Affiliate] IAP not available in development environment. SDK will continue without purchase validation.');
1550
+ verboseLog('E_IAP_NOT_AVAILABLE error caught in validatePurchaseWithIapticAPI - gracefully handling in development');
1551
+ } else {
1552
+ console.error('[Insert Affiliate] IAP not available in production environment. Please check your IAP configuration.');
1553
+ }
1554
+ return false; // Return false but don't crash
1555
+ }
1556
+
1516
1557
  if (error instanceof Error) {
1517
1558
  console.error(`validatePurchaseWithIapticAPI Error: ${error.message}`);
1518
1559
  } else {