gomarketme-react-native 2.0.0 → 4.0.1
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 +58 -12
- package/dist/index.d.ts +6 -4
- package/dist/index.js +234 -293
- package/package.json +24 -10
- package/.editorconfig +0 -15
- package/.gitattributes +0 -3
- package/.github/actions/setup/action.yml +0 -27
- package/.github/workflows/ci.yml +0 -157
- package/.nvmrc +0 -1
- package/.watchmanconfig +0 -1
- package/.yarn/releases/yarn-4.3.1-git.20240705.hash-35167b2.cjs +0 -894
- package/.yarnrc.yml +0 -5
- package/lefthook.yml +0 -35
- package/src/index.tsx +0 -443
- package/tsconfig.json +0 -19
package/dist/index.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
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
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -32,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
9
|
});
|
|
33
10
|
};
|
|
34
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
15
|
function step(op) {
|
|
39
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -67,8 +44,8 @@ var react_native_1 = require("react-native");
|
|
|
67
44
|
var react_native_device_info_1 = __importDefault(require("react-native-device-info"));
|
|
68
45
|
var get_user_locale_1 = __importDefault(require("get-user-locale"));
|
|
69
46
|
var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
70
|
-
var RNIap = __importStar(require("react-native-iap"));
|
|
71
47
|
var axios_1 = __importDefault(require("axios"));
|
|
48
|
+
var react_native_iap_1 = require("react-native-iap");
|
|
72
49
|
var GoMarketMeAffiliateMarketingData = /** @class */ (function () {
|
|
73
50
|
function GoMarketMeAffiliateMarketingData(campaign, affiliate, saleDistribution, affiliateCampaignCode, deviceId, offerCode) {
|
|
74
51
|
this.campaign = campaign;
|
|
@@ -79,10 +56,8 @@ var GoMarketMeAffiliateMarketingData = /** @class */ (function () {
|
|
|
79
56
|
this.offerCode = offerCode;
|
|
80
57
|
}
|
|
81
58
|
GoMarketMeAffiliateMarketingData.fromJson = function (json) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return null; // Return null or undefined, depending on your preference
|
|
85
|
-
}
|
|
59
|
+
if (!json || Object.keys(json).length === 0)
|
|
60
|
+
return null;
|
|
86
61
|
return new GoMarketMeAffiliateMarketingData(Campaign.fromJson(json.campaign), Affiliate.fromJson(json.affiliate), SaleDistribution.fromJson(json.sale_distribution), json.affiliate_campaign_code || '', json.device_id || '', json.offer_code);
|
|
87
62
|
};
|
|
88
63
|
return GoMarketMeAffiliateMarketingData;
|
|
@@ -97,7 +72,7 @@ var Campaign = /** @class */ (function () {
|
|
|
97
72
|
this.publicLinkUrl = publicLinkUrl;
|
|
98
73
|
}
|
|
99
74
|
Campaign.fromJson = function (json) {
|
|
100
|
-
return new Campaign(json.id || '', json.name || '', json.status || '', json.type || '', json.public_link_url);
|
|
75
|
+
return new Campaign((json === null || json === void 0 ? void 0 : json.id) || '', (json === null || json === void 0 ? void 0 : json.name) || '', (json === null || json === void 0 ? void 0 : json.status) || '', (json === null || json === void 0 ? void 0 : json.type) || '', json === null || json === void 0 ? void 0 : json.public_link_url);
|
|
101
76
|
};
|
|
102
77
|
return Campaign;
|
|
103
78
|
}());
|
|
@@ -113,7 +88,7 @@ var Affiliate = /** @class */ (function () {
|
|
|
113
88
|
this.xAccount = xAccount;
|
|
114
89
|
}
|
|
115
90
|
Affiliate.fromJson = function (json) {
|
|
116
|
-
return new Affiliate(json.id || '', json.first_name || '', json.last_name || '', json.country_code || '', json.instagram_account || '', json.tiktok_account || '', json.x_account || '');
|
|
91
|
+
return new Affiliate((json === null || json === void 0 ? void 0 : json.id) || '', (json === null || json === void 0 ? void 0 : json.first_name) || '', (json === null || json === void 0 ? void 0 : json.last_name) || '', (json === null || json === void 0 ? void 0 : json.country_code) || '', (json === null || json === void 0 ? void 0 : json.instagram_account) || '', (json === null || json === void 0 ? void 0 : json.tiktok_account) || '', (json === null || json === void 0 ? void 0 : json.x_account) || '');
|
|
117
92
|
};
|
|
118
93
|
return Affiliate;
|
|
119
94
|
}());
|
|
@@ -124,7 +99,7 @@ var SaleDistribution = /** @class */ (function () {
|
|
|
124
99
|
this.affiliatePercentage = affiliatePercentage;
|
|
125
100
|
}
|
|
126
101
|
SaleDistribution.fromJson = function (json) {
|
|
127
|
-
return new SaleDistribution(json.platform_percentage || '', json.affiliate_percentage || '');
|
|
102
|
+
return new SaleDistribution((json === null || json === void 0 ? void 0 : json.platform_percentage) || '', (json === null || json === void 0 ? void 0 : json.affiliate_percentage) || '');
|
|
128
103
|
};
|
|
129
104
|
return SaleDistribution;
|
|
130
105
|
}());
|
|
@@ -132,7 +107,7 @@ exports.SaleDistribution = SaleDistribution;
|
|
|
132
107
|
var GoMarketMe = /** @class */ (function () {
|
|
133
108
|
function GoMarketMe() {
|
|
134
109
|
this.sdkType = 'ReactNative';
|
|
135
|
-
this.sdkVersion = '
|
|
110
|
+
this.sdkVersion = '4.0.1';
|
|
136
111
|
this.sdkInitializedKey = 'GOMARKETME_SDK_INITIALIZED';
|
|
137
112
|
this.sdkInitializationUrl = 'https://4v9008q1a5.execute-api.us-west-2.amazonaws.com/prod/v1/sdk-initialization';
|
|
138
113
|
this.systemInfoUrl = 'https://4v9008q1a5.execute-api.us-west-2.amazonaws.com/prod/v1/mobile/system-info';
|
|
@@ -140,14 +115,10 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
140
115
|
this._affiliateCampaignCode = '';
|
|
141
116
|
this._deviceId = '';
|
|
142
117
|
this._packageName = '';
|
|
143
|
-
this._getTimeZone = function () {
|
|
144
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
145
|
-
};
|
|
146
118
|
}
|
|
147
119
|
GoMarketMe.getInstance = function () {
|
|
148
|
-
if (!GoMarketMe.instance)
|
|
120
|
+
if (!GoMarketMe.instance)
|
|
149
121
|
GoMarketMe.instance = new GoMarketMe();
|
|
150
|
-
}
|
|
151
122
|
return GoMarketMe.instance;
|
|
152
123
|
};
|
|
153
124
|
GoMarketMe.prototype.initialize = function (apiKey) {
|
|
@@ -174,9 +145,12 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
174
145
|
return [4 /*yield*/, this._postSystemInfo(systemInfo, apiKey)];
|
|
175
146
|
case 5:
|
|
176
147
|
_a.affiliateMarketingData = _b.sent();
|
|
177
|
-
return [4 /*yield*/, this.
|
|
148
|
+
return [4 /*yield*/, this._addListeners(apiKey)];
|
|
178
149
|
case 6:
|
|
179
150
|
_b.sent();
|
|
151
|
+
this._fetchExistingPurchases(apiKey).catch(function (e) {
|
|
152
|
+
console.log('Error in background purchase fetch:', e);
|
|
153
|
+
});
|
|
180
154
|
return [3 /*break*/, 8];
|
|
181
155
|
case 7:
|
|
182
156
|
e_1 = _b.sent();
|
|
@@ -187,27 +161,44 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
187
161
|
});
|
|
188
162
|
});
|
|
189
163
|
};
|
|
190
|
-
GoMarketMe.prototype.
|
|
164
|
+
GoMarketMe.prototype.removeListeners = function () {
|
|
165
|
+
var _a, _b, _c, _d;
|
|
166
|
+
try {
|
|
167
|
+
(_b = (_a = this._purchaseUpdateUnsub) === null || _a === void 0 ? void 0 : _a.remove) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
168
|
+
(_d = (_c = this._purchaseErrorUnsub) === null || _c === void 0 ? void 0 : _c.remove) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
169
|
+
}
|
|
170
|
+
catch (e) {
|
|
171
|
+
console.log('Error removing listeners:', e);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
GoMarketMe.prototype._addListeners = function (apiKey) {
|
|
191
175
|
return __awaiter(this, void 0, void 0, function () {
|
|
192
176
|
var _this = this;
|
|
193
177
|
return __generator(this, function (_a) {
|
|
194
|
-
|
|
195
|
-
|
|
178
|
+
if (!this._purchaseUpdateUnsub) {
|
|
179
|
+
this._purchaseUpdateUnsub = (0, react_native_iap_1.purchaseUpdatedListener)(function (purchase) { return __awaiter(_this, void 0, void 0, function () {
|
|
180
|
+
var e_2;
|
|
196
181
|
return __generator(this, function (_a) {
|
|
197
182
|
switch (_a.label) {
|
|
198
|
-
case 0:
|
|
183
|
+
case 0:
|
|
184
|
+
_a.trys.push([0, 2, , 3]);
|
|
185
|
+
return [4 /*yield*/, this._fetchConsolidatedPurchases([purchase], apiKey)];
|
|
199
186
|
case 1:
|
|
200
187
|
_a.sent();
|
|
201
|
-
return [
|
|
188
|
+
return [3 /*break*/, 3];
|
|
189
|
+
case 2:
|
|
190
|
+
e_2 = _a.sent();
|
|
191
|
+
console.log('purchaseUpdated error:', e_2);
|
|
192
|
+
return [3 /*break*/, 3];
|
|
193
|
+
case 3: return [2 /*return*/];
|
|
202
194
|
}
|
|
203
195
|
});
|
|
204
196
|
}); });
|
|
205
|
-
RNIap.purchaseErrorListener(function (error) {
|
|
206
|
-
console.log('Purchase error:', error);
|
|
207
|
-
});
|
|
208
197
|
}
|
|
209
|
-
|
|
210
|
-
|
|
198
|
+
if (!this._purchaseErrorUnsub) {
|
|
199
|
+
this._purchaseErrorUnsub = (0, react_native_iap_1.purchaseErrorListener)(function (error) {
|
|
200
|
+
console.log('purchaseErrorListener:', error);
|
|
201
|
+
});
|
|
211
202
|
}
|
|
212
203
|
return [2 /*return*/];
|
|
213
204
|
});
|
|
@@ -215,242 +206,197 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
215
206
|
};
|
|
216
207
|
GoMarketMe.prototype._getSystemInfo = function () {
|
|
217
208
|
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
-
var deviceData, _a,
|
|
219
|
-
var
|
|
220
|
-
return __generator(this, function (
|
|
221
|
-
switch (
|
|
209
|
+
var deviceData, _a, devicePixelRatio, dimension;
|
|
210
|
+
var _b;
|
|
211
|
+
return __generator(this, function (_c) {
|
|
212
|
+
switch (_c.label) {
|
|
222
213
|
case 0:
|
|
223
|
-
|
|
224
|
-
_c = {};
|
|
214
|
+
if (!(react_native_1.Platform.OS === 'ios')) return [3 /*break*/, 2];
|
|
225
215
|
return [4 /*yield*/, this._readIosDeviceInfo()];
|
|
226
216
|
case 1:
|
|
227
|
-
|
|
228
|
-
return [
|
|
229
|
-
case 2:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
217
|
+
_a = _c.sent();
|
|
218
|
+
return [3 /*break*/, 4];
|
|
219
|
+
case 2: return [4 /*yield*/, this._readAndroidDeviceInfo()];
|
|
220
|
+
case 3:
|
|
221
|
+
_a = _c.sent();
|
|
222
|
+
_c.label = 4;
|
|
223
|
+
case 4:
|
|
224
|
+
deviceData = _a;
|
|
225
|
+
this._deviceId = deviceData['deviceId'] || '';
|
|
233
226
|
devicePixelRatio = react_native_1.PixelRatio.get();
|
|
234
227
|
dimension = react_native_1.Dimensions.get('window');
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
228
|
+
_b = {
|
|
229
|
+
device_info: deviceData,
|
|
230
|
+
window_info: {
|
|
231
|
+
devicePixelRatio: devicePixelRatio,
|
|
232
|
+
width: dimension.width * devicePixelRatio,
|
|
233
|
+
height: dimension.height * devicePixelRatio,
|
|
234
|
+
},
|
|
235
|
+
time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
236
|
+
language_code: (0, get_user_locale_1.default)(),
|
|
237
|
+
sdk_type: this.sdkType,
|
|
238
|
+
sdk_version: this.sdkVersion,
|
|
239
|
+
package_name: this._packageName
|
|
239
240
|
};
|
|
240
|
-
return [
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
time_zone: this._getTimeZone(),
|
|
244
|
-
language_code: this._getLanguageCode(),
|
|
245
|
-
}];
|
|
241
|
+
return [4 /*yield*/, this._isProduction()];
|
|
242
|
+
case 5: return [2 /*return*/, (_b.is_production = _c.sent(),
|
|
243
|
+
_b)];
|
|
246
244
|
}
|
|
247
245
|
});
|
|
248
246
|
});
|
|
249
247
|
};
|
|
250
248
|
GoMarketMe.prototype._postSDKInitialization = function (apiKey) {
|
|
251
249
|
return __awaiter(this, void 0, void 0, function () {
|
|
252
|
-
var
|
|
250
|
+
var res, e_3;
|
|
253
251
|
return __generator(this, function (_a) {
|
|
254
252
|
switch (_a.label) {
|
|
255
253
|
case 0:
|
|
256
|
-
_a.trys.push([0,
|
|
254
|
+
_a.trys.push([0, 4, , 5]);
|
|
257
255
|
return [4 /*yield*/, axios_1.default.post(this.sdkInitializationUrl, {}, {
|
|
258
|
-
headers: {
|
|
259
|
-
'Content-Type': 'application/json',
|
|
260
|
-
'x-api-key': apiKey,
|
|
261
|
-
},
|
|
256
|
+
headers: { 'x-api-key': apiKey },
|
|
262
257
|
})];
|
|
263
258
|
case 1:
|
|
264
|
-
|
|
265
|
-
if (!(
|
|
259
|
+
res = _a.sent();
|
|
260
|
+
if (!(res.status === 200)) return [3 /*break*/, 3];
|
|
266
261
|
return [4 /*yield*/, this._markSDKAsInitialized()];
|
|
267
262
|
case 2:
|
|
268
263
|
_a.sent();
|
|
269
|
-
|
|
270
|
-
case 3:
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
console.log('Error sending SDK information to server:', e_2);
|
|
277
|
-
return [3 /*break*/, 6];
|
|
278
|
-
case 6: return [2 /*return*/];
|
|
264
|
+
_a.label = 3;
|
|
265
|
+
case 3: return [3 /*break*/, 5];
|
|
266
|
+
case 4:
|
|
267
|
+
e_3 = _a.sent();
|
|
268
|
+
console.log('Error posting SDK initialization:', e_3);
|
|
269
|
+
return [3 /*break*/, 5];
|
|
270
|
+
case 5: return [2 /*return*/];
|
|
279
271
|
}
|
|
280
272
|
});
|
|
281
273
|
});
|
|
282
274
|
};
|
|
283
275
|
GoMarketMe.prototype._postSystemInfo = function (data, apiKey) {
|
|
284
276
|
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
-
var
|
|
277
|
+
var res, obj, e_4;
|
|
286
278
|
return __generator(this, function (_a) {
|
|
287
279
|
switch (_a.label) {
|
|
288
280
|
case 0:
|
|
289
|
-
|
|
290
|
-
_a.label = 1;
|
|
291
|
-
case 1:
|
|
292
|
-
_a.trys.push([1, 3, , 4]);
|
|
293
|
-
data['sdk_type'] = this.sdkType;
|
|
294
|
-
data['sdk_version'] = this.sdkVersion;
|
|
295
|
-
data['package_name'] = this._packageName;
|
|
281
|
+
_a.trys.push([0, 2, , 3]);
|
|
296
282
|
return [4 /*yield*/, axios_1.default.post(this.systemInfoUrl, data, {
|
|
297
|
-
headers: {
|
|
298
|
-
'Content-Type': 'application/json',
|
|
299
|
-
'x-api-key': apiKey,
|
|
300
|
-
},
|
|
283
|
+
headers: { 'x-api-key': apiKey },
|
|
301
284
|
})];
|
|
302
|
-
case
|
|
303
|
-
|
|
304
|
-
if (
|
|
305
|
-
|
|
306
|
-
if (
|
|
307
|
-
this._affiliateCampaignCode =
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
console.log('Failed to send system info. Status code:', response.status);
|
|
285
|
+
case 1:
|
|
286
|
+
res = _a.sent();
|
|
287
|
+
if (res.status === 200) {
|
|
288
|
+
obj = GoMarketMeAffiliateMarketingData.fromJson(res.data);
|
|
289
|
+
if (obj)
|
|
290
|
+
this._affiliateCampaignCode = obj.affiliateCampaignCode;
|
|
291
|
+
return [2 /*return*/, obj];
|
|
312
292
|
}
|
|
313
|
-
return [3 /*break*/,
|
|
314
|
-
case
|
|
315
|
-
|
|
316
|
-
console.log('Error
|
|
317
|
-
return [3 /*break*/,
|
|
318
|
-
case
|
|
293
|
+
return [3 /*break*/, 3];
|
|
294
|
+
case 2:
|
|
295
|
+
e_4 = _a.sent();
|
|
296
|
+
console.log('Error posting system info:', e_4);
|
|
297
|
+
return [3 /*break*/, 3];
|
|
298
|
+
case 3: return [2 /*return*/, null];
|
|
319
299
|
}
|
|
320
300
|
});
|
|
321
301
|
});
|
|
322
302
|
};
|
|
323
303
|
GoMarketMe.prototype._readAndroidDeviceInfo = function () {
|
|
324
304
|
return __awaiter(this, void 0, void 0, function () {
|
|
325
|
-
var
|
|
326
|
-
return __generator(this, function (
|
|
327
|
-
switch (
|
|
328
|
-
case 0:
|
|
305
|
+
var _a;
|
|
306
|
+
return __generator(this, function (_b) {
|
|
307
|
+
switch (_b.label) {
|
|
308
|
+
case 0:
|
|
309
|
+
_a = {};
|
|
310
|
+
return [4 /*yield*/, react_native_device_info_1.default.getAndroidId()];
|
|
329
311
|
case 1:
|
|
330
|
-
|
|
331
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
312
|
+
_a.deviceId = _b.sent();
|
|
313
|
+
return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
|
|
332
314
|
case 2:
|
|
333
|
-
|
|
334
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
315
|
+
_a.brand = _b.sent();
|
|
316
|
+
return [4 /*yield*/, react_native_device_info_1.default.getModel()];
|
|
335
317
|
case 3:
|
|
336
|
-
|
|
337
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
318
|
+
_a.model = _b.sent();
|
|
319
|
+
return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
|
|
338
320
|
case 4:
|
|
339
|
-
|
|
340
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
321
|
+
_a.manufacturer = _b.sent();
|
|
322
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
|
|
341
323
|
case 5:
|
|
342
|
-
|
|
343
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
344
|
-
case 6:
|
|
345
|
-
|
|
346
|
-
return [4 /*yield*/, react_native_device_info_1.default.getModel()];
|
|
347
|
-
case 7:
|
|
348
|
-
model = _a.sent();
|
|
349
|
-
return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
|
|
350
|
-
case 8:
|
|
351
|
-
manufacturer = _a.sent();
|
|
352
|
-
return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
|
|
353
|
-
case 9:
|
|
354
|
-
isEmulator = _a.sent();
|
|
355
|
-
return [2 /*return*/, {
|
|
356
|
-
deviceId: androidId,
|
|
357
|
-
_deviceId: deviceId,
|
|
358
|
-
_uniqueId: uniqueId,
|
|
359
|
-
systemName: systemName,
|
|
360
|
-
systemVersion: systemVersion,
|
|
361
|
-
brand: brand,
|
|
362
|
-
model: model,
|
|
363
|
-
manufacturer: manufacturer,
|
|
364
|
-
isEmulator: isEmulator
|
|
365
|
-
}];
|
|
324
|
+
_a.systemName = _b.sent();
|
|
325
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
|
|
326
|
+
case 6: return [2 /*return*/, (_a.systemVersion = _b.sent(),
|
|
327
|
+
_a)];
|
|
366
328
|
}
|
|
367
329
|
});
|
|
368
330
|
});
|
|
369
331
|
};
|
|
370
332
|
GoMarketMe.prototype._readIosDeviceInfo = function () {
|
|
371
333
|
return __awaiter(this, void 0, void 0, function () {
|
|
372
|
-
var
|
|
373
|
-
return __generator(this, function (
|
|
374
|
-
switch (
|
|
375
|
-
case 0:
|
|
334
|
+
var _a;
|
|
335
|
+
return __generator(this, function (_b) {
|
|
336
|
+
switch (_b.label) {
|
|
337
|
+
case 0:
|
|
338
|
+
_a = {};
|
|
339
|
+
return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
|
|
376
340
|
case 1:
|
|
377
|
-
|
|
378
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
341
|
+
_a.deviceId = _b.sent();
|
|
342
|
+
return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
|
|
379
343
|
case 2:
|
|
380
|
-
|
|
381
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
344
|
+
_a.brand = _b.sent();
|
|
345
|
+
return [4 /*yield*/, react_native_device_info_1.default.getModel()];
|
|
382
346
|
case 3:
|
|
383
|
-
|
|
384
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
347
|
+
_a.model = _b.sent();
|
|
348
|
+
return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
|
|
385
349
|
case 4:
|
|
386
|
-
|
|
387
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
350
|
+
_a.manufacturer = _b.sent();
|
|
351
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
|
|
388
352
|
case 5:
|
|
389
|
-
|
|
390
|
-
return [4 /*yield*/, react_native_device_info_1.default.
|
|
391
|
-
case 6:
|
|
392
|
-
|
|
393
|
-
return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
|
|
394
|
-
case 7:
|
|
395
|
-
manufacturer = _a.sent();
|
|
396
|
-
return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
|
|
397
|
-
case 8:
|
|
398
|
-
isEmulator = _a.sent();
|
|
399
|
-
return [2 /*return*/, {
|
|
400
|
-
deviceId: uniqueId,
|
|
401
|
-
_deviceId: deviceId,
|
|
402
|
-
systemName: systemName,
|
|
403
|
-
systemVersion: systemVersion,
|
|
404
|
-
brand: brand,
|
|
405
|
-
model: model,
|
|
406
|
-
manufacturer: manufacturer,
|
|
407
|
-
isEmulator: isEmulator
|
|
408
|
-
}];
|
|
353
|
+
_a.systemName = _b.sent();
|
|
354
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
|
|
355
|
+
case 6: return [2 /*return*/, (_a.systemVersion = _b.sent(),
|
|
356
|
+
_a)];
|
|
409
357
|
}
|
|
410
358
|
});
|
|
411
359
|
});
|
|
412
360
|
};
|
|
413
|
-
GoMarketMe.prototype.
|
|
414
|
-
return (0, get_user_locale_1.default)();
|
|
415
|
-
};
|
|
416
|
-
GoMarketMe.prototype._fetchConsolidatedPurchases = function (purchaseDetailsList, apiKey) {
|
|
361
|
+
GoMarketMe.prototype._fetchConsolidatedPurchases = function (purchases, apiKey) {
|
|
417
362
|
return __awaiter(this, void 0, void 0, function () {
|
|
418
|
-
var _i,
|
|
419
|
-
return __generator(this, function (
|
|
420
|
-
switch (
|
|
363
|
+
var _i, purchases_1, purchase, receipt, data, pid, products, _a, products_1, p, e_5;
|
|
364
|
+
return __generator(this, function (_b) {
|
|
365
|
+
switch (_b.label) {
|
|
421
366
|
case 0:
|
|
422
|
-
_i = 0,
|
|
423
|
-
|
|
367
|
+
_i = 0, purchases_1 = purchases;
|
|
368
|
+
_b.label = 1;
|
|
424
369
|
case 1:
|
|
425
|
-
if (!(_i <
|
|
426
|
-
purchase =
|
|
427
|
-
|
|
370
|
+
if (!(_i < purchases_1.length)) return [3 /*break*/, 8];
|
|
371
|
+
purchase = purchases_1[_i];
|
|
372
|
+
receipt = purchase.purchaseToken;
|
|
373
|
+
if (!receipt)
|
|
374
|
+
return [3 /*break*/, 7];
|
|
428
375
|
data = this._serializePurchaseDetails(purchase);
|
|
429
|
-
data
|
|
430
|
-
|
|
431
|
-
return [
|
|
376
|
+
data.products = [];
|
|
377
|
+
pid = data.productID || '';
|
|
378
|
+
if (!pid) return [3 /*break*/, 5];
|
|
379
|
+
_b.label = 2;
|
|
432
380
|
case 2:
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
381
|
+
_b.trys.push([2, 4, , 5]);
|
|
382
|
+
return [4 /*yield*/, (0, react_native_iap_1.fetchProducts)({ skus: [pid] })];
|
|
383
|
+
case 3:
|
|
384
|
+
products = _b.sent();
|
|
385
|
+
if (products && products.length) {
|
|
386
|
+
for (_a = 0, products_1 = products; _a < products_1.length; _a++) {
|
|
387
|
+
p = products_1[_a];
|
|
388
|
+
data.products.push(this._serializeProductDetails(p));
|
|
389
|
+
}
|
|
438
390
|
}
|
|
439
391
|
return [3 /*break*/, 5];
|
|
440
|
-
case 3: return [4 /*yield*/, RNIap.getSubscriptions({ skus: [data.productID] })];
|
|
441
392
|
case 4:
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
data['products'].push(this._serializeSubscriptionDetails(product0));
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
_c.label = 5;
|
|
450
|
-
case 5: return [4 /*yield*/, this._sendEventToServer(JSON.stringify(data), 'purchase', apiKey)];
|
|
393
|
+
e_5 = _b.sent();
|
|
394
|
+
console.warn('Error fetching products:', e_5);
|
|
395
|
+
return [3 /*break*/, 5];
|
|
396
|
+
case 5: return [4 /*yield*/, this._sendEventToServer(JSON.stringify(data), 'purchase_product', apiKey)];
|
|
451
397
|
case 6:
|
|
452
|
-
|
|
453
|
-
|
|
398
|
+
_b.sent();
|
|
399
|
+
_b.label = 7;
|
|
454
400
|
case 7:
|
|
455
401
|
_i++;
|
|
456
402
|
return [3 /*break*/, 1];
|
|
@@ -461,14 +407,13 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
461
407
|
};
|
|
462
408
|
GoMarketMe.prototype._sendEventToServer = function (body, eventType, apiKey) {
|
|
463
409
|
return __awaiter(this, void 0, void 0, function () {
|
|
464
|
-
var
|
|
410
|
+
var e_6;
|
|
465
411
|
return __generator(this, function (_a) {
|
|
466
412
|
switch (_a.label) {
|
|
467
413
|
case 0:
|
|
468
414
|
_a.trys.push([0, 2, , 3]);
|
|
469
415
|
return [4 /*yield*/, axios_1.default.post(this.eventUrl, body, {
|
|
470
416
|
headers: {
|
|
471
|
-
'Content-Type': 'application/json',
|
|
472
417
|
'x-affiliate-campaign-code': this._affiliateCampaignCode,
|
|
473
418
|
'x-device-id': this._deviceId,
|
|
474
419
|
'x-event-type': eventType,
|
|
@@ -478,17 +423,12 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
478
423
|
},
|
|
479
424
|
})];
|
|
480
425
|
case 1:
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
console.log("".concat(eventType, " sent successfully"));
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
console.log("Failed to send ".concat(eventType, ". Status code:"), response.status);
|
|
487
|
-
}
|
|
426
|
+
_a.sent();
|
|
427
|
+
console.log("".concat(eventType, " sent successfully"));
|
|
488
428
|
return [3 /*break*/, 3];
|
|
489
429
|
case 2:
|
|
490
|
-
|
|
491
|
-
console.log("Error sending ".concat(eventType, "
|
|
430
|
+
e_6 = _a.sent();
|
|
431
|
+
console.log("Error sending ".concat(eventType, ":"), e_6);
|
|
492
432
|
return [3 /*break*/, 3];
|
|
493
433
|
case 3: return [2 /*return*/];
|
|
494
434
|
}
|
|
@@ -499,101 +439,102 @@ var GoMarketMe = /** @class */ (function () {
|
|
|
499
439
|
return {
|
|
500
440
|
packageName: this._packageName,
|
|
501
441
|
productID: purchase.productId,
|
|
502
|
-
purchaseID: purchase.
|
|
503
|
-
transactionDate: purchase.transactionDate
|
|
504
|
-
status: react_native_1.Platform.select({
|
|
505
|
-
ios: purchase.transactionStateIOS,
|
|
506
|
-
android: purchase.purchaseStateAndroid,
|
|
507
|
-
}),
|
|
442
|
+
purchaseID: purchase.id,
|
|
443
|
+
transactionDate: purchase.transactionDate,
|
|
508
444
|
verificationData: {
|
|
509
|
-
localVerificationData: purchase.
|
|
510
|
-
serverVerificationData: purchase.transactionReceipt,
|
|
445
|
+
localVerificationData: purchase.purchaseToken,
|
|
511
446
|
source: react_native_1.Platform.OS === 'android' ? 'google_play' : 'app_store',
|
|
512
447
|
},
|
|
513
|
-
pendingCompletePurchase: '',
|
|
514
|
-
error: {},
|
|
515
|
-
hashCode: '',
|
|
516
|
-
_purchase: purchase
|
|
517
448
|
};
|
|
518
449
|
};
|
|
519
450
|
GoMarketMe.prototype._serializeProductDetails = function (product) {
|
|
520
451
|
return {
|
|
521
452
|
packageName: this._packageName,
|
|
522
|
-
productID: product.
|
|
453
|
+
productID: product.id,
|
|
523
454
|
productTitle: product.title,
|
|
524
455
|
productDescription: product.description,
|
|
525
|
-
productPrice: product.
|
|
526
|
-
productRawPrice: product.price,
|
|
527
|
-
productCurrencySymbol: product.localizedPrice.replace('product.price', ''),
|
|
456
|
+
productPrice: product.displayPrice,
|
|
457
|
+
productRawPrice: product.price || '',
|
|
528
458
|
productCurrencyCode: product.currency,
|
|
529
|
-
hashCode: '',
|
|
530
|
-
_product: product
|
|
531
|
-
};
|
|
532
|
-
};
|
|
533
|
-
GoMarketMe.prototype._serializeSubscriptionDetails = function (subscription) {
|
|
534
|
-
var _a;
|
|
535
|
-
var output = {
|
|
536
|
-
productID: subscription.productId,
|
|
537
|
-
productTitle: subscription.title,
|
|
538
|
-
productDescription: subscription.description,
|
|
539
|
-
hashCode: '',
|
|
540
459
|
};
|
|
541
|
-
if (react_native_1.Platform.OS === 'ios') {
|
|
542
|
-
var subscriptionIOS = subscription;
|
|
543
|
-
output.productPrice = subscriptionIOS.localizedPrice;
|
|
544
|
-
output.productRawPrice = subscriptionIOS.price;
|
|
545
|
-
output.productCurrencyCode = subscriptionIOS.currency;
|
|
546
|
-
output._subscription = subscriptionIOS;
|
|
547
|
-
}
|
|
548
|
-
else if (react_native_1.Platform.OS === 'android') {
|
|
549
|
-
var subscriptionAndroid = subscription;
|
|
550
|
-
if ((_a = subscriptionAndroid.subscriptionOfferDetails) === null || _a === void 0 ? void 0 : _a.length) {
|
|
551
|
-
var offerDetails = subscriptionAndroid.subscriptionOfferDetails[0];
|
|
552
|
-
var priceAmountMicros = parseInt(offerDetails.pricingPhases.pricingPhaseList[0].priceAmountMicros, 10) || 0;
|
|
553
|
-
output.productPrice = offerDetails.pricingPhases.pricingPhaseList[0].formattedPrice;
|
|
554
|
-
output.productRawPrice = String(priceAmountMicros / 1000000);
|
|
555
|
-
output.productCurrencyCode = offerDetails.pricingPhases.pricingPhaseList[0].priceCurrencyCode;
|
|
556
|
-
}
|
|
557
|
-
output._subscription = subscriptionAndroid;
|
|
558
|
-
}
|
|
559
|
-
return output;
|
|
560
460
|
};
|
|
561
461
|
GoMarketMe.prototype._markSDKAsInitialized = function () {
|
|
562
462
|
return __awaiter(this, void 0, void 0, function () {
|
|
563
|
-
var e_5;
|
|
564
463
|
return __generator(this, function (_a) {
|
|
565
464
|
switch (_a.label) {
|
|
566
|
-
case 0:
|
|
567
|
-
_a.trys.push([0, 2, , 3]);
|
|
568
|
-
return [4 /*yield*/, async_storage_1.default.setItem(this.sdkInitializedKey, 'true')];
|
|
465
|
+
case 0: return [4 /*yield*/, async_storage_1.default.setItem(this.sdkInitializedKey, 'true')];
|
|
569
466
|
case 1:
|
|
570
467
|
_a.sent();
|
|
571
|
-
return [2 /*return
|
|
572
|
-
case 2:
|
|
573
|
-
e_5 = _a.sent();
|
|
574
|
-
console.log('Failed to save SDK initialization:', e_5);
|
|
575
|
-
return [2 /*return*/, false];
|
|
576
|
-
case 3: return [2 /*return*/];
|
|
468
|
+
return [2 /*return*/];
|
|
577
469
|
}
|
|
578
470
|
});
|
|
579
471
|
});
|
|
580
472
|
};
|
|
581
473
|
GoMarketMe.prototype._isSDKInitialized = function () {
|
|
582
474
|
return __awaiter(this, void 0, void 0, function () {
|
|
583
|
-
var
|
|
475
|
+
var val;
|
|
476
|
+
return __generator(this, function (_a) {
|
|
477
|
+
switch (_a.label) {
|
|
478
|
+
case 0: return [4 /*yield*/, async_storage_1.default.getItem(this.sdkInitializedKey)];
|
|
479
|
+
case 1:
|
|
480
|
+
val = _a.sent();
|
|
481
|
+
return [2 /*return*/, val === 'true'];
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
};
|
|
486
|
+
GoMarketMe.prototype._isProduction = function () {
|
|
487
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
488
|
+
var installer, error_1;
|
|
584
489
|
return __generator(this, function (_a) {
|
|
585
490
|
switch (_a.label) {
|
|
586
491
|
case 0:
|
|
587
|
-
|
|
588
|
-
|
|
492
|
+
if (__DEV__)
|
|
493
|
+
return [2 /*return*/, false];
|
|
494
|
+
_a.label = 1;
|
|
589
495
|
case 1:
|
|
590
|
-
|
|
591
|
-
return [
|
|
496
|
+
_a.trys.push([1, 3, , 4]);
|
|
497
|
+
return [4 /*yield*/, react_native_device_info_1.default.getInstallerPackageName()];
|
|
592
498
|
case 2:
|
|
593
|
-
|
|
594
|
-
|
|
499
|
+
installer = _a.sent();
|
|
500
|
+
if (installer === 'com.android.vending' ||
|
|
501
|
+
installer === 'com.amazon.venezia') {
|
|
502
|
+
return [2 /*return*/, true];
|
|
503
|
+
}
|
|
504
|
+
if (installer == null && !__DEV__) {
|
|
505
|
+
return [2 /*return*/, true];
|
|
506
|
+
}
|
|
595
507
|
return [2 /*return*/, false];
|
|
596
|
-
case 3:
|
|
508
|
+
case 3:
|
|
509
|
+
error_1 = _a.sent();
|
|
510
|
+
console.warn('Error determining production status:', error_1);
|
|
511
|
+
return [2 /*return*/, false];
|
|
512
|
+
case 4: return [2 /*return*/];
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
GoMarketMe.prototype._fetchExistingPurchases = function (apiKey) {
|
|
518
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
519
|
+
var purchases, e_7;
|
|
520
|
+
return __generator(this, function (_a) {
|
|
521
|
+
switch (_a.label) {
|
|
522
|
+
case 0:
|
|
523
|
+
_a.trys.push([0, 4, , 5]);
|
|
524
|
+
return [4 /*yield*/, (0, react_native_iap_1.getAvailablePurchases)()];
|
|
525
|
+
case 1:
|
|
526
|
+
purchases = _a.sent();
|
|
527
|
+
if (!(purchases && purchases.length > 0)) return [3 /*break*/, 3];
|
|
528
|
+
return [4 /*yield*/, this._fetchConsolidatedPurchases(purchases, apiKey)];
|
|
529
|
+
case 2:
|
|
530
|
+
_a.sent();
|
|
531
|
+
_a.label = 3;
|
|
532
|
+
case 3: return [3 /*break*/, 5];
|
|
533
|
+
case 4:
|
|
534
|
+
e_7 = _a.sent();
|
|
535
|
+
console.log('Error fetching existing purchases on app open:', e_7);
|
|
536
|
+
return [3 /*break*/, 5];
|
|
537
|
+
case 5: return [2 /*return*/];
|
|
597
538
|
}
|
|
598
539
|
});
|
|
599
540
|
});
|