gomarketme-react-native 1.0.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/.editorconfig +15 -0
- package/.gitattributes +3 -0
- package/.github/actions/setup/action.yml +27 -0
- package/.github/workflows/ci.yml +157 -0
- package/.nvmrc +1 -0
- package/.watchmanconfig +1 -0
- package/.yarn/releases/yarn-4.3.1-git.20240705.hash-35167b2.cjs +894 -0
- package/.yarnrc.yml +5 -0
- package/README.md +8 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +460 -0
- package/lefthook.yml +35 -0
- package/package.json +34 -0
- package/src/index.tsx +234 -0
- package/tsconfig.json +19 -0
package/.yarnrc.yml
ADDED
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare class GoMarketMe {
|
|
2
|
+
private static instance;
|
|
3
|
+
private sdkInitializedKey;
|
|
4
|
+
private affiliateCampaignCode;
|
|
5
|
+
private deviceId;
|
|
6
|
+
private sdkInitializationUrl;
|
|
7
|
+
private systemInfoUrl;
|
|
8
|
+
private eventUrl;
|
|
9
|
+
private constructor();
|
|
10
|
+
static getInstance(): GoMarketMe;
|
|
11
|
+
initialize(apiKey: string): Promise<void>;
|
|
12
|
+
private addListener;
|
|
13
|
+
private getSystemInfo;
|
|
14
|
+
private postSDKInitialization;
|
|
15
|
+
private postSystemInfo;
|
|
16
|
+
private readAndroidDeviceInfo;
|
|
17
|
+
private readIosDeviceInfo;
|
|
18
|
+
private fetchPurchases;
|
|
19
|
+
private fetchPurchaseProducts;
|
|
20
|
+
private sendEventToServer;
|
|
21
|
+
private serializePurchaseDetails;
|
|
22
|
+
private serializeProductDetails;
|
|
23
|
+
private markSDKAsInitialized;
|
|
24
|
+
private isSDKInitialized;
|
|
25
|
+
}
|
|
26
|
+
declare const _default: GoMarketMe;
|
|
27
|
+
export default _default;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var react_native_1 = require("react-native");
|
|
43
|
+
var react_native_device_info_1 = __importDefault(require("react-native-device-info"));
|
|
44
|
+
var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
45
|
+
var react_native_iap_1 = __importDefault(require("react-native-iap"));
|
|
46
|
+
var axios_1 = __importDefault(require("axios"));
|
|
47
|
+
var GoMarketMe = /** @class */ (function () {
|
|
48
|
+
function GoMarketMe() {
|
|
49
|
+
this.sdkInitializedKey = 'GOMARKETME_SDK_INITIALIZED';
|
|
50
|
+
this.affiliateCampaignCode = '';
|
|
51
|
+
this.deviceId = '';
|
|
52
|
+
this.sdkInitializationUrl = 'https://api.gomarketme.net/v1/sdk-initialization';
|
|
53
|
+
this.systemInfoUrl = 'https://api.gomarketme.net/v1/mobile/system-info';
|
|
54
|
+
this.eventUrl = 'https://api.gomarketme.net/v1/event';
|
|
55
|
+
}
|
|
56
|
+
GoMarketMe.getInstance = function () {
|
|
57
|
+
if (!GoMarketMe.instance) {
|
|
58
|
+
GoMarketMe.instance = new GoMarketMe();
|
|
59
|
+
}
|
|
60
|
+
return GoMarketMe.instance;
|
|
61
|
+
};
|
|
62
|
+
GoMarketMe.prototype.initialize = function (apiKey) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
var isSDKInitialized, systemInfo, e_1;
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
switch (_a.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
_a.trys.push([0, 7, , 8]);
|
|
69
|
+
return [4 /*yield*/, this.isSDKInitialized()];
|
|
70
|
+
case 1:
|
|
71
|
+
isSDKInitialized = _a.sent();
|
|
72
|
+
if (!!isSDKInitialized) return [3 /*break*/, 3];
|
|
73
|
+
return [4 /*yield*/, this.postSDKInitialization(apiKey)];
|
|
74
|
+
case 2:
|
|
75
|
+
_a.sent();
|
|
76
|
+
_a.label = 3;
|
|
77
|
+
case 3: return [4 /*yield*/, this.getSystemInfo()];
|
|
78
|
+
case 4:
|
|
79
|
+
systemInfo = _a.sent();
|
|
80
|
+
return [4 /*yield*/, this.postSystemInfo(systemInfo, apiKey)];
|
|
81
|
+
case 5:
|
|
82
|
+
_a.sent();
|
|
83
|
+
return [4 /*yield*/, this.addListener(apiKey)];
|
|
84
|
+
case 6:
|
|
85
|
+
_a.sent();
|
|
86
|
+
return [3 /*break*/, 8];
|
|
87
|
+
case 7:
|
|
88
|
+
e_1 = _a.sent();
|
|
89
|
+
console.error('Error initializing GoMarketMe:', e_1);
|
|
90
|
+
return [3 /*break*/, 8];
|
|
91
|
+
case 8: return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
GoMarketMe.prototype.addListener = function (apiKey) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
var _this = this;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
react_native_iap_1.default.purchaseUpdatedListener(function (purchase) { return __awaiter(_this, void 0, void 0, function () {
|
|
101
|
+
var productIds;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
if (!this.affiliateCampaignCode) return [3 /*break*/, 3];
|
|
106
|
+
return [4 /*yield*/, this.fetchPurchases([purchase], apiKey)];
|
|
107
|
+
case 1:
|
|
108
|
+
productIds = _a.sent();
|
|
109
|
+
return [4 /*yield*/, this.fetchPurchaseProducts(productIds, apiKey)];
|
|
110
|
+
case 2:
|
|
111
|
+
_a.sent();
|
|
112
|
+
_a.label = 3;
|
|
113
|
+
case 3: return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}); });
|
|
117
|
+
return [2 /*return*/];
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
GoMarketMe.prototype.getSystemInfo = function () {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
+
var deviceData, _a, _b, windowData;
|
|
124
|
+
var _c;
|
|
125
|
+
return __generator(this, function (_d) {
|
|
126
|
+
switch (_d.label) {
|
|
127
|
+
case 0:
|
|
128
|
+
_b = (_a = react_native_1.Platform).select;
|
|
129
|
+
_c = {};
|
|
130
|
+
return [4 /*yield*/, this.readIosDeviceInfo()];
|
|
131
|
+
case 1:
|
|
132
|
+
_c.ios = _d.sent();
|
|
133
|
+
return [4 /*yield*/, this.readAndroidDeviceInfo()];
|
|
134
|
+
case 2:
|
|
135
|
+
deviceData = _b.apply(_a, [(_c.android = _d.sent(),
|
|
136
|
+
_c)]);
|
|
137
|
+
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,
|
|
141
|
+
};
|
|
142
|
+
return [2 /*return*/, {
|
|
143
|
+
device_info: deviceData,
|
|
144
|
+
window_info: windowData,
|
|
145
|
+
time_zone_code: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
146
|
+
language_code: react_native_device_info_1.default.getDeviceId(),
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
GoMarketMe.prototype.postSDKInitialization = function (apiKey) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
+
var response, e_2;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
_a.trys.push([0, 5, , 6]);
|
|
159
|
+
return [4 /*yield*/, axios_1.default.post(this.sdkInitializationUrl, {}, {
|
|
160
|
+
headers: {
|
|
161
|
+
'Content-Type': 'application/json',
|
|
162
|
+
'x-api-key': apiKey,
|
|
163
|
+
},
|
|
164
|
+
})];
|
|
165
|
+
case 1:
|
|
166
|
+
response = _a.sent();
|
|
167
|
+
if (!(response.status === 200)) return [3 /*break*/, 3];
|
|
168
|
+
return [4 /*yield*/, this.markSDKAsInitialized()];
|
|
169
|
+
case 2:
|
|
170
|
+
_a.sent();
|
|
171
|
+
return [3 /*break*/, 4];
|
|
172
|
+
case 3:
|
|
173
|
+
console.error('Failed to mark SDK as Initialized. Status code:', response.status);
|
|
174
|
+
_a.label = 4;
|
|
175
|
+
case 4: return [3 /*break*/, 6];
|
|
176
|
+
case 5:
|
|
177
|
+
e_2 = _a.sent();
|
|
178
|
+
console.error('Error sending SDK information to server:', e_2);
|
|
179
|
+
return [3 /*break*/, 6];
|
|
180
|
+
case 6: return [2 /*return*/];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
GoMarketMe.prototype.postSystemInfo = function (systemInfo, apiKey) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
+
var response, responseData, e_3;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0:
|
|
191
|
+
_a.trys.push([0, 2, , 3]);
|
|
192
|
+
return [4 /*yield*/, axios_1.default.post(this.systemInfoUrl, systemInfo, {
|
|
193
|
+
headers: {
|
|
194
|
+
'Content-Type': 'application/json',
|
|
195
|
+
'x-api-key': apiKey,
|
|
196
|
+
},
|
|
197
|
+
})];
|
|
198
|
+
case 1:
|
|
199
|
+
response = _a.sent();
|
|
200
|
+
if (response.status === 200) {
|
|
201
|
+
responseData = response.data;
|
|
202
|
+
if (responseData.affiliate_campaign_code) {
|
|
203
|
+
this.affiliateCampaignCode = responseData.affiliate_campaign_code;
|
|
204
|
+
}
|
|
205
|
+
if (responseData.device_id) {
|
|
206
|
+
this.deviceId = responseData.device_id;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
console.error('Failed to send system info. Status code:', response.status);
|
|
211
|
+
}
|
|
212
|
+
return [3 /*break*/, 3];
|
|
213
|
+
case 2:
|
|
214
|
+
e_3 = _a.sent();
|
|
215
|
+
console.error('Error sending system info to server:', e_3);
|
|
216
|
+
return [3 /*break*/, 3];
|
|
217
|
+
case 3: return [2 /*return*/];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
GoMarketMe.prototype.readAndroidDeviceInfo = function () {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
+
var _a;
|
|
225
|
+
return __generator(this, function (_b) {
|
|
226
|
+
switch (_b.label) {
|
|
227
|
+
case 0:
|
|
228
|
+
_a = {};
|
|
229
|
+
return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
|
|
230
|
+
case 1:
|
|
231
|
+
_a.deviceId = _b.sent();
|
|
232
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
|
|
233
|
+
case 2:
|
|
234
|
+
_a.systemName = _b.sent();
|
|
235
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
|
|
236
|
+
case 3:
|
|
237
|
+
_a.systemVersion = _b.sent();
|
|
238
|
+
return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
|
|
239
|
+
case 4:
|
|
240
|
+
_a.brand = _b.sent();
|
|
241
|
+
return [4 /*yield*/, react_native_device_info_1.default.getModel()];
|
|
242
|
+
case 5:
|
|
243
|
+
_a.model = _b.sent();
|
|
244
|
+
return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
|
|
245
|
+
case 6:
|
|
246
|
+
_a.manufacturer = _b.sent();
|
|
247
|
+
return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
|
|
248
|
+
case 7:
|
|
249
|
+
_a.isEmulator = _b.sent();
|
|
250
|
+
return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
|
|
251
|
+
case 8: return [2 /*return*/, (_a.uniqueId = _b.sent(),
|
|
252
|
+
_a)];
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
GoMarketMe.prototype.readIosDeviceInfo = function () {
|
|
258
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
259
|
+
var _a;
|
|
260
|
+
return __generator(this, function (_b) {
|
|
261
|
+
switch (_b.label) {
|
|
262
|
+
case 0:
|
|
263
|
+
_a = {};
|
|
264
|
+
return [4 /*yield*/, react_native_device_info_1.default.getDeviceId()];
|
|
265
|
+
case 1:
|
|
266
|
+
_a.deviceId = _b.sent();
|
|
267
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemName()];
|
|
268
|
+
case 2:
|
|
269
|
+
_a.systemName = _b.sent();
|
|
270
|
+
return [4 /*yield*/, react_native_device_info_1.default.getSystemVersion()];
|
|
271
|
+
case 3:
|
|
272
|
+
_a.systemVersion = _b.sent();
|
|
273
|
+
return [4 /*yield*/, react_native_device_info_1.default.getBrand()];
|
|
274
|
+
case 4:
|
|
275
|
+
_a.brand = _b.sent();
|
|
276
|
+
return [4 /*yield*/, react_native_device_info_1.default.getModel()];
|
|
277
|
+
case 5:
|
|
278
|
+
_a.model = _b.sent();
|
|
279
|
+
return [4 /*yield*/, react_native_device_info_1.default.getManufacturer()];
|
|
280
|
+
case 6:
|
|
281
|
+
_a.manufacturer = _b.sent();
|
|
282
|
+
return [4 /*yield*/, react_native_device_info_1.default.isEmulator()];
|
|
283
|
+
case 7:
|
|
284
|
+
_a.isEmulator = _b.sent();
|
|
285
|
+
return [4 /*yield*/, react_native_device_info_1.default.getUniqueId()];
|
|
286
|
+
case 8: return [2 /*return*/, (_a.uniqueId = _b.sent(),
|
|
287
|
+
_a)];
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
GoMarketMe.prototype.fetchPurchases = function (purchaseDetailsList, apiKey) {
|
|
293
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
+
var productIds, _i, purchaseDetailsList_1, purchase;
|
|
295
|
+
return __generator(this, function (_a) {
|
|
296
|
+
switch (_a.label) {
|
|
297
|
+
case 0:
|
|
298
|
+
productIds = [];
|
|
299
|
+
_i = 0, purchaseDetailsList_1 = purchaseDetailsList;
|
|
300
|
+
_a.label = 1;
|
|
301
|
+
case 1:
|
|
302
|
+
if (!(_i < purchaseDetailsList_1.length)) return [3 /*break*/, 4];
|
|
303
|
+
purchase = purchaseDetailsList_1[_i];
|
|
304
|
+
if (!purchase.transactionReceipt) return [3 /*break*/, 3];
|
|
305
|
+
return [4 /*yield*/, this.sendEventToServer(JSON.stringify(this.serializePurchaseDetails(purchase)), 'purchase', apiKey)];
|
|
306
|
+
case 2:
|
|
307
|
+
_a.sent();
|
|
308
|
+
if (purchase.productId && !productIds.includes(purchase.productId)) {
|
|
309
|
+
productIds.push(purchase.productId);
|
|
310
|
+
}
|
|
311
|
+
_a.label = 3;
|
|
312
|
+
case 3:
|
|
313
|
+
_i++;
|
|
314
|
+
return [3 /*break*/, 1];
|
|
315
|
+
case 4: return [2 /*return*/, productIds];
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
GoMarketMe.prototype.fetchPurchaseProducts = function (productIds, apiKey) {
|
|
321
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
+
var products, _i, products_1, product, e_4;
|
|
323
|
+
return __generator(this, function (_a) {
|
|
324
|
+
switch (_a.label) {
|
|
325
|
+
case 0:
|
|
326
|
+
_a.trys.push([0, 9, , 10]);
|
|
327
|
+
return [4 /*yield*/, react_native_iap_1.default.getProducts(productIds)];
|
|
328
|
+
case 1:
|
|
329
|
+
products = _a.sent();
|
|
330
|
+
if (!(products.length > 0)) return [3 /*break*/, 6];
|
|
331
|
+
_i = 0, products_1 = products;
|
|
332
|
+
_a.label = 2;
|
|
333
|
+
case 2:
|
|
334
|
+
if (!(_i < products_1.length)) return [3 /*break*/, 5];
|
|
335
|
+
product = products_1[_i];
|
|
336
|
+
return [4 /*yield*/, this.sendEventToServer(JSON.stringify(this.serializeProductDetails(product)), 'product', apiKey)];
|
|
337
|
+
case 3:
|
|
338
|
+
_a.sent();
|
|
339
|
+
_a.label = 4;
|
|
340
|
+
case 4:
|
|
341
|
+
_i++;
|
|
342
|
+
return [3 /*break*/, 2];
|
|
343
|
+
case 5: return [3 /*break*/, 8];
|
|
344
|
+
case 6: return [4 /*yield*/, this.sendEventToServer(JSON.stringify({ notFoundIDs: productIds.join(',') }), 'product', apiKey)];
|
|
345
|
+
case 7:
|
|
346
|
+
_a.sent();
|
|
347
|
+
_a.label = 8;
|
|
348
|
+
case 8: return [3 /*break*/, 10];
|
|
349
|
+
case 9:
|
|
350
|
+
e_4 = _a.sent();
|
|
351
|
+
console.error('Error fetching products:', e_4);
|
|
352
|
+
return [3 /*break*/, 10];
|
|
353
|
+
case 10: return [2 /*return*/];
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
GoMarketMe.prototype.sendEventToServer = function (body, eventType, apiKey) {
|
|
359
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
360
|
+
var response, e_5;
|
|
361
|
+
return __generator(this, function (_a) {
|
|
362
|
+
switch (_a.label) {
|
|
363
|
+
case 0:
|
|
364
|
+
_a.trys.push([0, 2, , 3]);
|
|
365
|
+
return [4 /*yield*/, axios_1.default.post(this.eventUrl, body, {
|
|
366
|
+
headers: {
|
|
367
|
+
'Content-Type': 'application/json',
|
|
368
|
+
'x-affiliate-campaign-code': this.affiliateCampaignCode,
|
|
369
|
+
'x-device-id': this.deviceId,
|
|
370
|
+
'x-event-type': eventType,
|
|
371
|
+
'x-product-type': react_native_1.Platform.OS,
|
|
372
|
+
'x-source-name': react_native_1.Platform.OS === 'android' ? 'google_play' : 'app_store',
|
|
373
|
+
'x-api-key': apiKey,
|
|
374
|
+
},
|
|
375
|
+
})];
|
|
376
|
+
case 1:
|
|
377
|
+
response = _a.sent();
|
|
378
|
+
if (response.status === 200) {
|
|
379
|
+
console.log("".concat(eventType, " sent successfully"));
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
console.error("Failed to send ".concat(eventType, ". Status code:"), response.status);
|
|
383
|
+
}
|
|
384
|
+
return [3 /*break*/, 3];
|
|
385
|
+
case 2:
|
|
386
|
+
e_5 = _a.sent();
|
|
387
|
+
console.error("Error sending ".concat(eventType, " to server:"), e_5);
|
|
388
|
+
return [3 /*break*/, 3];
|
|
389
|
+
case 3: return [2 /*return*/];
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
GoMarketMe.prototype.serializePurchaseDetails = function (purchase) {
|
|
395
|
+
return {
|
|
396
|
+
productID: purchase.productId,
|
|
397
|
+
purchaseID: purchase.transactionId || '',
|
|
398
|
+
transactionDate: purchase.transactionDate || '',
|
|
399
|
+
status: react_native_1.Platform.select({
|
|
400
|
+
ios: purchase.transactionStateIOS,
|
|
401
|
+
android: purchase.purchaseStateAndroid,
|
|
402
|
+
}),
|
|
403
|
+
verificationData: {
|
|
404
|
+
localVerificationData: purchase.transactionReceipt,
|
|
405
|
+
},
|
|
406
|
+
};
|
|
407
|
+
};
|
|
408
|
+
GoMarketMe.prototype.serializeProductDetails = function (product) {
|
|
409
|
+
return {
|
|
410
|
+
productID: product.productId,
|
|
411
|
+
productTitle: product.title,
|
|
412
|
+
productDescription: product.description,
|
|
413
|
+
productPrice: product.price,
|
|
414
|
+
productRawPrice: product.price,
|
|
415
|
+
productCurrencyCode: product.currency,
|
|
416
|
+
};
|
|
417
|
+
};
|
|
418
|
+
GoMarketMe.prototype.markSDKAsInitialized = function () {
|
|
419
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
420
|
+
var e_6;
|
|
421
|
+
return __generator(this, function (_a) {
|
|
422
|
+
switch (_a.label) {
|
|
423
|
+
case 0:
|
|
424
|
+
_a.trys.push([0, 2, , 3]);
|
|
425
|
+
return [4 /*yield*/, async_storage_1.default.setItem(this.sdkInitializedKey, 'true')];
|
|
426
|
+
case 1:
|
|
427
|
+
_a.sent();
|
|
428
|
+
return [2 /*return*/, true];
|
|
429
|
+
case 2:
|
|
430
|
+
e_6 = _a.sent();
|
|
431
|
+
console.error('Failed to save SDK initialization:', e_6);
|
|
432
|
+
return [2 /*return*/, false];
|
|
433
|
+
case 3: return [2 /*return*/];
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
GoMarketMe.prototype.isSDKInitialized = function () {
|
|
439
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
440
|
+
var value, e_7;
|
|
441
|
+
return __generator(this, function (_a) {
|
|
442
|
+
switch (_a.label) {
|
|
443
|
+
case 0:
|
|
444
|
+
_a.trys.push([0, 2, , 3]);
|
|
445
|
+
return [4 /*yield*/, async_storage_1.default.getItem(this.sdkInitializedKey)];
|
|
446
|
+
case 1:
|
|
447
|
+
value = _a.sent();
|
|
448
|
+
return [2 /*return*/, value === 'true'];
|
|
449
|
+
case 2:
|
|
450
|
+
e_7 = _a.sent();
|
|
451
|
+
console.error('Failed to load SDK initialization:', e_7);
|
|
452
|
+
return [2 /*return*/, false];
|
|
453
|
+
case 3: return [2 /*return*/];
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
};
|
|
458
|
+
return GoMarketMe;
|
|
459
|
+
}());
|
|
460
|
+
exports.default = GoMarketMe.getInstance();
|
package/lefthook.yml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# EXAMPLE USAGE:
|
|
2
|
+
#
|
|
3
|
+
# Refer for explanation to following link:
|
|
4
|
+
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
|
|
5
|
+
#
|
|
6
|
+
# pre-push:
|
|
7
|
+
# commands:
|
|
8
|
+
# packages-audit:
|
|
9
|
+
# tags: frontend security
|
|
10
|
+
# run: yarn audit
|
|
11
|
+
# gems-audit:
|
|
12
|
+
# tags: backend security
|
|
13
|
+
# run: bundle audit
|
|
14
|
+
#
|
|
15
|
+
# pre-commit:
|
|
16
|
+
# parallel: true
|
|
17
|
+
# commands:
|
|
18
|
+
# eslint:
|
|
19
|
+
# glob: "*.{js,ts,jsx,tsx}"
|
|
20
|
+
# run: yarn eslint {staged_files}
|
|
21
|
+
# rubocop:
|
|
22
|
+
# tags: backend style
|
|
23
|
+
# glob: "*.rb"
|
|
24
|
+
# exclude: '(^|/)(application|routes)\.rb$'
|
|
25
|
+
# run: bundle exec rubocop --force-exclusion {all_files}
|
|
26
|
+
# govet:
|
|
27
|
+
# tags: backend style
|
|
28
|
+
# files: git ls-files -m
|
|
29
|
+
# glob: "*.go"
|
|
30
|
+
# run: go vet {files}
|
|
31
|
+
# scripts:
|
|
32
|
+
# "hello.js":
|
|
33
|
+
# runner: node
|
|
34
|
+
# "any.go":
|
|
35
|
+
# runner: go run
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gomarketme-react-native",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Affiliate Marketing for React Native-Based iOS and Android Apps.",
|
|
5
|
+
"main": "dist/index.js",
|
|
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
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"react-native",
|
|
14
|
+
"gomarketme",
|
|
15
|
+
"sdk"
|
|
16
|
+
],
|
|
17
|
+
"author": "GoMarketMe",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@react-native-async-storage/async-storage": "^1.15.6",
|
|
21
|
+
"axios": "^0.21.1",
|
|
22
|
+
"react-native-device-info": "^8.0.1",
|
|
23
|
+
"react-native-iap": "^7.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^15.12.5",
|
|
27
|
+
"@types/react-native": "^0.64.12",
|
|
28
|
+
"typescript": "^4.3.5"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": "*",
|
|
32
|
+
"react-native": "*"
|
|
33
|
+
}
|
|
34
|
+
}
|