gomarketme-react-native 1.0.1 → 1.0.2

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.d.ts CHANGED
@@ -15,6 +15,8 @@ declare class GoMarketMe {
15
15
  private postSystemInfo;
16
16
  private readAndroidDeviceInfo;
17
17
  private readIosDeviceInfo;
18
+ private getTimeZoneCode;
19
+ private getLanguageCode;
18
20
  private fetchPurchases;
19
21
  private fetchPurchaseProducts;
20
22
  private sendEventToServer;
package/dist/index.js CHANGED
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -41,6 +64,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
41
64
  Object.defineProperty(exports, "__esModule", { value: true });
42
65
  var react_native_1 = require("react-native");
43
66
  var react_native_device_info_1 = __importDefault(require("react-native-device-info"));
67
+ var RNLocalize = __importStar(require("react-native-localize"));
44
68
  var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
45
69
  var react_native_iap_1 = __importDefault(require("react-native-iap"));
46
70
  var axios_1 = __importDefault(require("axios"));
@@ -102,7 +126,7 @@ var GoMarketMe = /** @class */ (function () {
102
126
  return __generator(this, function (_a) {
103
127
  switch (_a.label) {
104
128
  case 0:
105
- if (!this.affiliateCampaignCode) return [3 /*break*/, 3];
129
+ if (!(this.affiliateCampaignCode != '')) return [3 /*break*/, 3];
106
130
  return [4 /*yield*/, this.fetchPurchases([purchase], apiKey)];
107
131
  case 1:
108
132
  productIds = _a.sent();
@@ -120,7 +144,7 @@ var GoMarketMe = /** @class */ (function () {
120
144
  };
121
145
  GoMarketMe.prototype.getSystemInfo = function () {
122
146
  return __awaiter(this, void 0, void 0, function () {
123
- var deviceData, _a, _b, windowData;
147
+ var deviceData, _a, _b, devicePixelRatio, windowData;
124
148
  var _c;
125
149
  return __generator(this, function (_d) {
126
150
  switch (_d.label) {
@@ -134,16 +158,17 @@ var GoMarketMe = /** @class */ (function () {
134
158
  case 2:
135
159
  deviceData = _b.apply(_a, [(_c.android = _d.sent(),
136
160
  _c)]);
161
+ devicePixelRatio = react_native_1.PixelRatio.get();
137
162
  windowData = {
138
- devicePixelRatio: react_native_1.PixelRatio.get(),
139
- width: react_native_1.Dimensions.get('window').width,
140
- height: react_native_1.Dimensions.get('window').height,
163
+ devicePixelRatio: devicePixelRatio,
164
+ width: react_native_1.Dimensions.get('window').width * devicePixelRatio,
165
+ height: react_native_1.Dimensions.get('window').height * devicePixelRatio,
141
166
  };
142
167
  return [2 /*return*/, {
143
168
  device_info: deviceData,
144
169
  window_info: windowData,
145
- time_zone_code: Intl.DateTimeFormat().resolvedOptions().timeZone,
146
- language_code: react_native_device_info_1.default.getDeviceId(),
170
+ time_zone_code: this.getTimeZoneCode(),
171
+ language_code: this.getLanguageCode(),
147
172
  }];
148
173
  }
149
174
  });
@@ -226,29 +251,32 @@ var GoMarketMe = /** @class */ (function () {
226
251
  switch (_b.label) {
227
252
  case 0:
228
253
  _a = {};
229
- return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
254
+ return [4 /*yield*/, react_native_device_info_1.default.getAndroidId()];
230
255
  case 1:
231
256
  _a.deviceId = _b.sent();
232
- return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
257
+ return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
233
258
  case 2:
259
+ _a._deviceId = _b.sent();
260
+ return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
261
+ case 3:
234
262
  _a.systemName = _b.sent();
235
263
  return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
236
- case 3:
264
+ case 4:
237
265
  _a.systemVersion = _b.sent();
238
266
  return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
239
- case 4:
267
+ case 5:
240
268
  _a.brand = _b.sent();
241
269
  return [4 /*yield*/, react_native_device_info_1.default.getModel()];
242
- case 5:
270
+ case 6:
243
271
  _a.model = _b.sent();
244
272
  return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
245
- case 6:
273
+ case 7:
246
274
  _a.manufacturer = _b.sent();
247
275
  return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
248
- case 7:
276
+ case 8:
249
277
  _a.isEmulator = _b.sent();
250
278
  return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
251
- case 8: return [2 /*return*/, (_a.uniqueId = _b.sent(),
279
+ case 9: return [2 /*return*/, (_a.uniqueId = _b.sent(),
252
280
  _a)];
253
281
  }
254
282
  });
@@ -256,39 +284,61 @@ var GoMarketMe = /** @class */ (function () {
256
284
  };
257
285
  GoMarketMe.prototype.readIosDeviceInfo = function () {
258
286
  return __awaiter(this, void 0, void 0, function () {
287
+ var info;
259
288
  var _a;
260
289
  return __generator(this, function (_b) {
261
290
  switch (_b.label) {
262
291
  case 0:
263
292
  _a = {};
264
- return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
293
+ return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
265
294
  case 1:
266
295
  _a.deviceId = _b.sent();
267
- return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
296
+ return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
268
297
  case 2:
298
+ _a._deviceId = _b.sent();
299
+ return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
300
+ case 3:
269
301
  _a.systemName = _b.sent();
270
302
  return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
271
- case 3:
303
+ case 4:
272
304
  _a.systemVersion = _b.sent();
273
305
  return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
274
- case 4:
306
+ case 5:
275
307
  _a.brand = _b.sent();
276
308
  return [4 /*yield*/, react_native_device_info_1.default.getModel()];
277
- case 5:
309
+ case 6:
278
310
  _a.model = _b.sent();
279
311
  return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
280
- case 6:
312
+ case 7:
281
313
  _a.manufacturer = _b.sent();
282
314
  return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
283
- case 7:
315
+ case 8:
284
316
  _a.isEmulator = _b.sent();
285
317
  return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
286
- case 8: return [2 /*return*/, (_a.uniqueId = _b.sent(),
287
- _a)];
318
+ case 9:
319
+ info = (_a.uniqueId = _b.sent(),
320
+ _a);
321
+ return [2 /*return*/];
288
322
  }
289
323
  });
290
324
  });
291
325
  };
326
+ GoMarketMe.prototype.getTimeZoneCode = function () {
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
331
+ var absOffset = Math.abs(timezoneOffset);
332
+ var hours = Math.floor(absOffset / 60);
333
+ var minutes = absOffset % 60;
334
+ var sign = timezoneOffset > 0 ? '-' : '+';
335
+ return "GMT".concat(sign).concat(String(hours).padStart(2, '0'), ":").concat(String(minutes).padStart(2, '0')); // Return GMT format
336
+ };
337
+ GoMarketMe.prototype.getLanguageCode = function () {
338
+ var locales = RNLocalize.getLocales();
339
+ // Check if there are any locales available and return the first one or default to 'en-US'
340
+ return locales.length > 0 ? locales[0].languageTag : 'en-US';
341
+ };
292
342
  GoMarketMe.prototype.fetchPurchases = function (purchaseDetailsList, apiKey) {
293
343
  return __awaiter(this, void 0, void 0, function () {
294
344
  var productIds, _i, purchaseDetailsList_1, purchase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gomarketme-react-native",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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",
@@ -20,8 +20,9 @@
20
20
  "dependencies": {
21
21
  "@react-native-async-storage/async-storage": "^1.15.6",
22
22
  "axios": "^0.21.1",
23
- "react-native-device-info": "^8.0.1",
24
- "react-native-iap": "^7.0.0"
23
+ "react-native-device-info": "^14.0.0",
24
+ "react-native-iap": "^7.0.0",
25
+ "react-native-localize": "^3.2.1"
25
26
  },
26
27
  "devDependencies": {
27
28
  "@types/node": "^15.12.5",
package/src/index.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Platform, Dimensions, PixelRatio } from 'react-native';
2
2
  import DeviceInfo from 'react-native-device-info';
3
+ import * as RNLocalize from 'react-native-localize';
3
4
  import AsyncStorage from '@react-native-async-storage/async-storage';
4
5
  import InAppPurchase, { Purchase, Product, ProductPurchase } from 'react-native-iap';
5
6
  import axios from 'axios';
@@ -38,7 +39,7 @@ class GoMarketMe {
38
39
 
39
40
  private async addListener(apiKey: string): Promise<void> {
40
41
  InAppPurchase.purchaseUpdatedListener(async (purchase: Purchase) => {
41
- if (this.affiliateCampaignCode) {
42
+ if (this.affiliateCampaignCode != '') {
42
43
  const productIds = await this.fetchPurchases([purchase], apiKey);
43
44
  await this.fetchPurchaseProducts(productIds, apiKey);
44
45
  }
@@ -51,17 +52,19 @@ class GoMarketMe {
51
52
  android: await this.readAndroidDeviceInfo(),
52
53
  });
53
54
 
55
+ const devicePixelRatio = PixelRatio.get();
56
+
54
57
  const windowData = {
55
- devicePixelRatio: PixelRatio.get(),
56
- width: Dimensions.get('window').width,
57
- height: Dimensions.get('window').height,
58
+ devicePixelRatio: devicePixelRatio,
59
+ width: Dimensions.get('window').width * devicePixelRatio,
60
+ height: Dimensions.get('window').height * devicePixelRatio,
58
61
  };
59
62
 
60
63
  return {
61
64
  device_info: deviceData,
62
65
  window_info: windowData,
63
- time_zone_code: Intl.DateTimeFormat().resolvedOptions().timeZone,
64
- language_code: DeviceInfo.getDeviceId(),
66
+ time_zone_code: this.getTimeZoneCode(),
67
+ language_code: this.getLanguageCode(),
65
68
  };
66
69
  }
67
70
 
@@ -109,7 +112,8 @@ class GoMarketMe {
109
112
 
110
113
  private async readAndroidDeviceInfo(): Promise<any> {
111
114
  return {
112
- deviceId: await DeviceInfo.getDeviceId(),
115
+ deviceId: await DeviceInfo.getAndroidId(),
116
+ _deviceId: await DeviceInfo.getDeviceId(),
113
117
  systemName: await DeviceInfo.getSystemName(),
114
118
  systemVersion: await DeviceInfo.getSystemVersion(),
115
119
  brand: await DeviceInfo.getBrand(),
@@ -121,8 +125,9 @@ class GoMarketMe {
121
125
  }
122
126
 
123
127
  private async readIosDeviceInfo(): Promise<any> {
124
- return {
125
- deviceId: await DeviceInfo.getDeviceId(),
128
+ var info = {
129
+ deviceId: await DeviceInfo.getUniqueId(),
130
+ _deviceId: await DeviceInfo.getDeviceId(),
126
131
  systemName: await DeviceInfo.getSystemName(),
127
132
  systemVersion: await DeviceInfo.getSystemVersion(),
128
133
  brand: await DeviceInfo.getBrand(),
@@ -133,6 +138,24 @@ class GoMarketMe {
133
138
  };
134
139
  }
135
140
 
141
+ private getTimeZoneCode(): string {
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
146
+ const absOffset = Math.abs(timezoneOffset);
147
+ const hours = Math.floor(absOffset / 60);
148
+ const minutes = absOffset % 60;
149
+ const sign = timezoneOffset > 0 ? '-' : '+';
150
+ return `GMT${sign}${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`; // Return GMT format
151
+ }
152
+
153
+ private getLanguageCode(): string {
154
+ const locales = RNLocalize.getLocales();
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';
157
+ }
158
+
136
159
  private async fetchPurchases(purchaseDetailsList: Purchase[], apiKey: string): Promise<string[]> {
137
160
  const productIds: string[] = [];
138
161
  for (const purchase of purchaseDetailsList) {