gomarketme-react-native 1.0.11 → 1.0.13

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/dist/index.js CHANGED
@@ -126,7 +126,7 @@ var GoMarketMe = /** @class */ (function () {
126
126
  return __generator(this, function (_a) {
127
127
  switch (_a.label) {
128
128
  case 0:
129
- if (!this.affiliateCampaignCode) return [3 /*break*/, 3];
129
+ if (!(this.affiliateCampaignCode != '')) return [3 /*break*/, 3];
130
130
  return [4 /*yield*/, this.fetchPurchases([purchase], apiKey)];
131
131
  case 1:
132
132
  productIds = _a.sent();
@@ -224,8 +224,12 @@ var GoMarketMe = /** @class */ (function () {
224
224
  response = _a.sent();
225
225
  if (response.status === 200) {
226
226
  responseData = response.data;
227
- this.affiliateCampaignCode = responseData.affiliate_campaign_code || this.affiliateCampaignCode;
228
- this.deviceId = responseData.device_id || this.deviceId;
227
+ if (responseData.affiliate_campaign_code) {
228
+ this.affiliateCampaignCode = responseData.affiliate_campaign_code;
229
+ }
230
+ if (responseData.device_id) {
231
+ this.deviceId = responseData.device_id;
232
+ }
229
233
  }
230
234
  else {
231
235
  console.error('Failed to send system info. Status code:', response.status);
@@ -250,26 +254,29 @@ var GoMarketMe = /** @class */ (function () {
250
254
  return [4 /*yield*/, react_native_device_info_1.default.getAndroidId()];
251
255
  case 1:
252
256
  _a.deviceId = _b.sent();
253
- return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
257
+ return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
254
258
  case 2:
259
+ _a._deviceId = _b.sent();
260
+ return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
261
+ case 3:
255
262
  _a.systemName = _b.sent();
256
263
  return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
257
- case 3:
264
+ case 4:
258
265
  _a.systemVersion = _b.sent();
259
266
  return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
260
- case 4:
267
+ case 5:
261
268
  _a.brand = _b.sent();
262
269
  return [4 /*yield*/, react_native_device_info_1.default.getModel()];
263
- case 5:
270
+ case 6:
264
271
  _a.model = _b.sent();
265
272
  return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
266
- case 6:
273
+ case 7:
267
274
  _a.manufacturer = _b.sent();
268
275
  return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
269
- case 7:
276
+ case 8:
270
277
  _a.isEmulator = _b.sent();
271
278
  return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
272
- case 8: return [2 /*return*/, (_a.uniqueId = _b.sent(),
279
+ case 9: return [2 /*return*/, (_a.uniqueId = _b.sent(),
273
280
  _a)];
274
281
  }
275
282
  });
@@ -277,6 +284,7 @@ var GoMarketMe = /** @class */ (function () {
277
284
  };
278
285
  GoMarketMe.prototype.readIosDeviceInfo = function () {
279
286
  return __awaiter(this, void 0, void 0, function () {
287
+ var info;
280
288
  var _a;
281
289
  return __generator(this, function (_b) {
282
290
  switch (_b.label) {
@@ -285,41 +293,50 @@ var GoMarketMe = /** @class */ (function () {
285
293
  return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
286
294
  case 1:
287
295
  _a.deviceId = _b.sent();
288
- return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
296
+ return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
289
297
  case 2:
298
+ _a._deviceId = _b.sent();
299
+ return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
300
+ case 3:
290
301
  _a.systemName = _b.sent();
291
302
  return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
292
- case 3:
303
+ case 4:
293
304
  _a.systemVersion = _b.sent();
294
305
  return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
295
- case 4:
306
+ case 5:
296
307
  _a.brand = _b.sent();
297
308
  return [4 /*yield*/, react_native_device_info_1.default.getModel()];
298
- case 5:
309
+ case 6:
299
310
  _a.model = _b.sent();
300
311
  return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
301
- case 6:
312
+ case 7:
302
313
  _a.manufacturer = _b.sent();
303
314
  return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
304
- case 7:
315
+ case 8:
305
316
  _a.isEmulator = _b.sent();
306
317
  return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
307
- case 8: return [2 /*return*/, (_a.uniqueId = _b.sent(),
308
- _a)];
318
+ case 9:
319
+ info = (_a.uniqueId = _b.sent(),
320
+ _a);
321
+ return [2 /*return*/];
309
322
  }
310
323
  });
311
324
  });
312
325
  };
313
326
  GoMarketMe.prototype.getTimeZoneCode = function () {
314
- var timezoneOffset = new Date().getTimezoneOffset();
327
+ // Convert the time zone to GMT format (e.g., "GMT+2")
328
+ var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
329
+ var date = new Date();
330
+ var timezoneOffset = date.getTimezoneOffset(); // in minutes
315
331
  var absOffset = Math.abs(timezoneOffset);
316
332
  var hours = Math.floor(absOffset / 60);
317
333
  var minutes = absOffset % 60;
318
334
  var sign = timezoneOffset > 0 ? '-' : '+';
319
- return "GMT".concat(sign).concat(String(hours).padStart(2, '0'), ":").concat(String(minutes).padStart(2, '0'));
335
+ return "GMT".concat(sign).concat(String(hours).padStart(2, '0'), ":").concat(String(minutes).padStart(2, '0')); // Return GMT format
320
336
  };
321
337
  GoMarketMe.prototype.getLanguageCode = function () {
322
338
  var locales = RNLocalize.getLocales();
339
+ // Check if there are any locales available and return the first one or default to 'en-US'
323
340
  return locales.length > 0 ? locales[0].languageTag : 'en-US';
324
341
  };
325
342
  GoMarketMe.prototype.fetchPurchases = function (purchaseDetailsList, apiKey) {
@@ -357,7 +374,7 @@ var GoMarketMe = /** @class */ (function () {
357
374
  switch (_a.label) {
358
375
  case 0:
359
376
  _a.trys.push([0, 9, , 10]);
360
- return [4 /*yield*/, react_native_iap_1.default.getProducts({ skus: productIds })];
377
+ return [4 /*yield*/, react_native_iap_1.default.getProducts(productIds)];
361
378
  case 1:
362
379
  products = _a.sent();
363
380
  if (!(products.length > 0)) return [3 /*break*/, 6];
@@ -442,30 +459,48 @@ var GoMarketMe = /** @class */ (function () {
442
459
  return {
443
460
  productID: product.productId,
444
461
  productTitle: product.title,
462
+ productDescription: product.description,
445
463
  productPrice: product.price,
464
+ productRawPrice: product.price,
465
+ productCurrencyCode: product.currency,
446
466
  };
447
467
  };
448
- GoMarketMe.prototype.isSDKInitialized = function () {
468
+ GoMarketMe.prototype.markSDKAsInitialized = function () {
449
469
  return __awaiter(this, void 0, void 0, function () {
450
- var value;
470
+ var e_6;
451
471
  return __generator(this, function (_a) {
452
472
  switch (_a.label) {
453
- case 0: return [4 /*yield*/, async_storage_1.default.getItem(this.sdkInitializedKey)];
473
+ case 0:
474
+ _a.trys.push([0, 2, , 3]);
475
+ return [4 /*yield*/, async_storage_1.default.setItem(this.sdkInitializedKey, 'true')];
454
476
  case 1:
455
- value = _a.sent();
456
- return [2 /*return*/, value === 'true'];
477
+ _a.sent();
478
+ return [2 /*return*/, true];
479
+ case 2:
480
+ e_6 = _a.sent();
481
+ console.error('Failed to save SDK initialization:', e_6);
482
+ return [2 /*return*/, false];
483
+ case 3: return [2 /*return*/];
457
484
  }
458
485
  });
459
486
  });
460
487
  };
461
- GoMarketMe.prototype.markSDKAsInitialized = function () {
488
+ GoMarketMe.prototype.isSDKInitialized = function () {
462
489
  return __awaiter(this, void 0, void 0, function () {
490
+ var value, e_7;
463
491
  return __generator(this, function (_a) {
464
492
  switch (_a.label) {
465
- case 0: return [4 /*yield*/, async_storage_1.default.setItem(this.sdkInitializedKey, 'true')];
493
+ case 0:
494
+ _a.trys.push([0, 2, , 3]);
495
+ return [4 /*yield*/, async_storage_1.default.getItem(this.sdkInitializedKey)];
466
496
  case 1:
467
- _a.sent();
468
- return [2 /*return*/];
497
+ value = _a.sent();
498
+ return [2 /*return*/, value === 'true'];
499
+ case 2:
500
+ e_7 = _a.sent();
501
+ console.error('Failed to load SDK initialization:', e_7);
502
+ return [2 /*return*/, false];
503
+ case 3: return [2 /*return*/];
469
504
  }
470
505
  });
471
506
  });
package/package.json CHANGED
@@ -1,35 +1,36 @@
1
1
  {
2
2
  "name": "gomarketme-react-native",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Affiliate Marketing for React Native-Based iOS and Android Apps.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "prepublishOnly": "yarn build",
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
7
12
  "homepage": "https://gomarketme.co",
8
13
  "keywords": [
9
14
  "react-native",
10
15
  "gomarketme",
11
16
  "sdk"
12
17
  ],
13
- "repository": {
14
- "type": "git",
15
- "url": "https://github.com/GoMarketMe/gomarketme-react-native.git"
16
- },
17
18
  "author": "GoMarketMe",
18
19
  "license": "MIT",
19
20
  "dependencies": {
20
- "@react-native-async-storage/async-storage": "^2.0.0",
21
+ "@react-native-async-storage/async-storage": "^1.15.6",
21
22
  "axios": "^1.7.7",
22
- "react-native": "^0.76.1",
23
23
  "react-native-device-info": "^14.0.0",
24
- "react-native-iap": "^12.15.6",
24
+ "react-native-iap": "^7.0.0",
25
25
  "react-native-localize": "^3.2.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^15.12.5",
29
29
  "@types/react-native": "^0.64.12",
30
- "typescript": "^4.9.5"
30
+ "typescript": "^4.3.5"
31
31
  },
32
32
  "peerDependencies": {
33
- "react": "*"
33
+ "react": "*",
34
+ "react-native": "*"
34
35
  }
35
36
  }
package/src/index.tsx CHANGED
@@ -2,7 +2,7 @@ import { Platform, Dimensions, PixelRatio } from 'react-native';
2
2
  import DeviceInfo from 'react-native-device-info';
3
3
  import * as RNLocalize from 'react-native-localize';
4
4
  import AsyncStorage from '@react-native-async-storage/async-storage';
5
- import InAppPurchase, { Purchase, Product } from 'react-native-iap';
5
+ import InAppPurchase, { Purchase, Product, ProductPurchase } from 'react-native-iap';
6
6
  import axios from 'axios';
7
7
 
8
8
  class GoMarketMe {
@@ -39,7 +39,7 @@ class GoMarketMe {
39
39
 
40
40
  private async addListener(apiKey: string): Promise<void> {
41
41
  InAppPurchase.purchaseUpdatedListener(async (purchase: Purchase) => {
42
- if (this.affiliateCampaignCode) {
42
+ if (this.affiliateCampaignCode != '') {
43
43
  const productIds = await this.fetchPurchases([purchase], apiKey);
44
44
  await this.fetchPurchaseProducts(productIds, apiKey);
45
45
  }
@@ -55,7 +55,7 @@ class GoMarketMe {
55
55
  const devicePixelRatio = PixelRatio.get();
56
56
 
57
57
  const windowData = {
58
- devicePixelRatio,
58
+ devicePixelRatio: devicePixelRatio,
59
59
  width: Dimensions.get('window').width * devicePixelRatio,
60
60
  height: Dimensions.get('window').height * devicePixelRatio,
61
61
  };
@@ -96,8 +96,12 @@ class GoMarketMe {
96
96
  });
97
97
  if (response.status === 200) {
98
98
  const responseData = response.data;
99
- this.affiliateCampaignCode = responseData.affiliate_campaign_code || this.affiliateCampaignCode;
100
- this.deviceId = responseData.device_id || this.deviceId;
99
+ if (responseData.affiliate_campaign_code) {
100
+ this.affiliateCampaignCode = responseData.affiliate_campaign_code;
101
+ }
102
+ if (responseData.device_id) {
103
+ this.deviceId = responseData.device_id;
104
+ }
101
105
  } else {
102
106
  console.error('Failed to send system info. Status code:', response.status);
103
107
  }
@@ -109,6 +113,7 @@ class GoMarketMe {
109
113
  private async readAndroidDeviceInfo(): Promise<any> {
110
114
  return {
111
115
  deviceId: await DeviceInfo.getAndroidId(),
116
+ _deviceId: await DeviceInfo.getDeviceId(),
112
117
  systemName: await DeviceInfo.getSystemName(),
113
118
  systemVersion: await DeviceInfo.getSystemVersion(),
114
119
  brand: await DeviceInfo.getBrand(),
@@ -120,8 +125,9 @@ class GoMarketMe {
120
125
  }
121
126
 
122
127
  private async readIosDeviceInfo(): Promise<any> {
123
- return {
128
+ var info = {
124
129
  deviceId: await DeviceInfo.getUniqueId(),
130
+ _deviceId: await DeviceInfo.getDeviceId(),
125
131
  systemName: await DeviceInfo.getSystemName(),
126
132
  systemVersion: await DeviceInfo.getSystemVersion(),
127
133
  brand: await DeviceInfo.getBrand(),
@@ -133,17 +139,21 @@ class GoMarketMe {
133
139
  }
134
140
 
135
141
  private getTimeZoneCode(): string {
136
- const timezoneOffset = new Date().getTimezoneOffset();
142
+ // Convert the time zone to GMT format (e.g., "GMT+2")
143
+ const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
144
+ const date = new Date();
145
+ const timezoneOffset = date.getTimezoneOffset(); // in minutes
137
146
  const absOffset = Math.abs(timezoneOffset);
138
147
  const hours = Math.floor(absOffset / 60);
139
148
  const minutes = absOffset % 60;
140
149
  const sign = timezoneOffset > 0 ? '-' : '+';
141
- return `GMT${sign}${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
150
+ return `GMT${sign}${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // Return GMT format
142
151
  }
143
152
 
144
153
  private getLanguageCode(): string {
145
154
  const locales = RNLocalize.getLocales();
146
- return locales.length > 0 ? locales[0].languageTag : 'en-US';
155
+ // Check if there are any locales available and return the first one or default to 'en-US'
156
+ return locales.length > 0 ? locales[0].languageTag : 'en-US';
147
157
  }
148
158
 
149
159
  private async fetchPurchases(purchaseDetailsList: Purchase[], apiKey: string): Promise<string[]> {
@@ -161,7 +171,7 @@ class GoMarketMe {
161
171
 
162
172
  private async fetchPurchaseProducts(productIds: string[], apiKey: string): Promise<void> {
163
173
  try {
164
- const products = await InAppPurchase.getProducts({skus: productIds});
174
+ const products = await InAppPurchase.getProducts(productIds);
165
175
  if (products.length > 0) {
166
176
  for (const product of products) {
167
177
  await this.sendEventToServer(JSON.stringify(this.serializeProductDetails(product)), 'product', apiKey);
@@ -203,7 +213,7 @@ class GoMarketMe {
203
213
  purchaseID: purchase.transactionId || '',
204
214
  transactionDate: purchase.transactionDate || '',
205
215
  status: Platform.select({
206
- ios: (purchase as any).transactionStateIOS,
216
+ ios: (purchase as any).transactionStateIOS, // Removed non-existent properties
207
217
  android: (purchase as any).purchaseStateAndroid,
208
218
  }),
209
219
  verificationData: {
@@ -216,17 +226,31 @@ class GoMarketMe {
216
226
  return {
217
227
  productID: product.productId,
218
228
  productTitle: product.title,
229
+ productDescription: product.description,
219
230
  productPrice: product.price,
231
+ productRawPrice: product.price,
232
+ productCurrencyCode: product.currency,
220
233
  };
221
234
  }
222
235
 
223
- private async isSDKInitialized(): Promise<boolean> {
224
- const value = await AsyncStorage.getItem(this.sdkInitializedKey);
225
- return value === 'true';
236
+ private async markSDKAsInitialized(): Promise<boolean> {
237
+ try {
238
+ await AsyncStorage.setItem(this.sdkInitializedKey, 'true');
239
+ return true;
240
+ } catch (e) {
241
+ console.error('Failed to save SDK initialization:', e);
242
+ return false;
243
+ }
226
244
  }
227
245
 
228
- private async markSDKAsInitialized(): Promise<void> {
229
- await AsyncStorage.setItem(this.sdkInitializedKey, 'true');
246
+ private async isSDKInitialized(): Promise<boolean> {
247
+ try {
248
+ const value = await AsyncStorage.getItem(this.sdkInitializedKey);
249
+ return value === 'true';
250
+ } catch (e) {
251
+ console.error('Failed to load SDK initialization:', e);
252
+ return false;
253
+ }
230
254
  }
231
255
  }
232
256
 
package/tsconfig.json CHANGED
@@ -16,4 +16,4 @@
16
16
  },
17
17
  "include": ["src/**/*.ts", "src/**/*.tsx"],
18
18
  "exclude": ["node_modules", "dist", "**/__tests__/*"]
19
- }
19
+ }