@bprotsyk/aso-core 1.2.67 → 1.2.69
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/lib/flash/flash-app.d.ts +35 -14
- package/lib/flash/flash-app.js +54 -16
- package/lib/keitaro/keitaro-campaign.d.ts +6 -1
- package/lib/keitaro/keitaro-stream.d.ts +4 -0
- package/lib/network/keitaro/keitaro-service.d.ts +16 -2
- package/lib/network/keitaro/keitaro-service.js +58 -12
- package/lib/utils/app-gathering-utils.d.ts +17 -0
- package/lib/utils/app-gathering-utils.js +2 -0
- package/lib/utils/keitaro-utils.d.ts +10 -0
- package/lib/utils/keitaro-utils.js +463 -0
- package/package.json +4 -2
- package/src/flash/flash-app.ts +70 -26
- package/src/keitaro/keitaro-campaign.ts +8 -3
- package/src/keitaro/keitaro-stream.ts +4 -0
- package/src/network/keitaro/keitaro-service.ts +75 -19
- package/src/utils/app-gathering-utils.ts +17 -0
- package/src/utils/data.csv +65 -0
- package/src/utils/keitaro-utils.ts +476 -0
- package/src/utils/map-apps.json +4748 -0
- package/src/utils/map-paste.json +1 -0
- package/src/utils/map-tracking.json +1 -0
- package/src/utils/update-postbacks.js +28 -0
|
@@ -0,0 +1,463 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.createFlashCampaigns = exports.createOWStreamPartialPayload = exports.prepareOWCampaignParameters = exports.createOrFindFlashRedirectCampaign = exports.removeGeosFromAllRedirectCampaigns = exports.addGeosToAllRedirectCampaigns = exports.TRAFFIC_SOURCE_ID_FLASH_AI = void 0;
|
|
30
|
+
const flash_app_1 = require("../flash/flash-app");
|
|
31
|
+
const flash_app_type_1 = require("../flash/flash-app-type");
|
|
32
|
+
const keitaro_service_1 = require("../network/keitaro/keitaro-service");
|
|
33
|
+
const sleep_promise_1 = __importDefault(require("sleep-promise"));
|
|
34
|
+
const fs = require("fs");
|
|
35
|
+
const util = __importStar(require("util"));
|
|
36
|
+
const readFile = util.promisify(fs.readFile);
|
|
37
|
+
const FLASH_REDIRECT_GROUP_ID = 82;
|
|
38
|
+
exports.TRAFFIC_SOURCE_ID_FLASH_AI = 22;
|
|
39
|
+
const UNIQUENESS_METHOD = "ip_ua";
|
|
40
|
+
const MAX_COOKIES_TTL = 8760;
|
|
41
|
+
const TYPE_POSITION = "position";
|
|
42
|
+
const STATE_ACTIVE = "active";
|
|
43
|
+
const COST_TYPE_CPC = "CPC";
|
|
44
|
+
const COST_VALUE = 0;
|
|
45
|
+
const COST_CURRENCY_USD = "USD";
|
|
46
|
+
// clear campaigns from unused / wrong streams
|
|
47
|
+
let sampleApp = {
|
|
48
|
+
id: 96,
|
|
49
|
+
bundle: "com.dynastyof.desert",
|
|
50
|
+
name: "Room of Fortuna",
|
|
51
|
+
plugId: "https://pastebin.com/raw/AR2u7dSD",
|
|
52
|
+
plugType: flash_app_1.PlugType.PASTEBIN,
|
|
53
|
+
plugContent: "",
|
|
54
|
+
plugStatus: flash_app_1.FlashAppPlugStatus.DISABLED,
|
|
55
|
+
plugAccountId: 1,
|
|
56
|
+
reservePlugId: "none",
|
|
57
|
+
reservePlugType: flash_app_1.PlugType.OTHER,
|
|
58
|
+
reservePlugContent: "",
|
|
59
|
+
reservePlugStatus: flash_app_1.FlashAppPlugStatus.DISABLED,
|
|
60
|
+
reservePlugAccountId: 1,
|
|
61
|
+
type: flash_app_type_1.FlashAppType.GAMBLING,
|
|
62
|
+
developerEmail: "bolly.dreams@yahoo.com",
|
|
63
|
+
developerName: "Serhii Bolsky",
|
|
64
|
+
developerOrganization: "S.I.B FOP",
|
|
65
|
+
onesignalAppId: "e66658af-91c3-44bc-8123-ec64b1969cbd",
|
|
66
|
+
onesignalRestApiKey: "MDk2NjZlNTMtMzBhYi00MjEzLTg0ZGItOWVmZWZhMTczMzI0",
|
|
67
|
+
generationOptions: {
|
|
68
|
+
splashActivityClassName: "SplashActivity",
|
|
69
|
+
mainActivityClassName: "YourActivity",
|
|
70
|
+
linkName: "likn",
|
|
71
|
+
savedName: "isOk",
|
|
72
|
+
paranoidSeed: 228143750
|
|
73
|
+
},
|
|
74
|
+
geos: "RU,UA,KZ,ES,BR,PT,CL,MX",
|
|
75
|
+
keitaroData: {
|
|
76
|
+
redirectCampaignId: 0,
|
|
77
|
+
redirectCampaignName: "",
|
|
78
|
+
redirectDomainId: 0,
|
|
79
|
+
redirectDomainName: "",
|
|
80
|
+
trackingCampaignId: 0,
|
|
81
|
+
trackingCampaignName: "",
|
|
82
|
+
trackingDomainId: 0,
|
|
83
|
+
trackingDomainName: "",
|
|
84
|
+
clickIdParameterName: "p",
|
|
85
|
+
offerIdParameterName: "i",
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
let addGeosToAllRedirectCampaigns = async (geosToAdd) => {
|
|
89
|
+
let allCampaigns = await keitaro_service_1.KeitaroService.getAllCampaigns();
|
|
90
|
+
let regexp = new RegExp(`^F #`);
|
|
91
|
+
const matchingCampaigns = allCampaigns.filter(campaign => regexp.exec(campaign.name));
|
|
92
|
+
for (let campaign of matchingCampaigns) {
|
|
93
|
+
console.log(campaign.name);
|
|
94
|
+
console.log("––––––––––––––––––––––––");
|
|
95
|
+
let streams = await keitaro_service_1.KeitaroService.getStreamsByCampaignId(campaign.id);
|
|
96
|
+
let botStream = streams[0];
|
|
97
|
+
botStream.name = "Bot Protection";
|
|
98
|
+
let owStream = streams.find(s => s.name == "OW");
|
|
99
|
+
for (let stream of [owStream, botStream]) {
|
|
100
|
+
if (!stream)
|
|
101
|
+
continue;
|
|
102
|
+
console.log({
|
|
103
|
+
name: stream.name,
|
|
104
|
+
});
|
|
105
|
+
let geos = stream?.filters[0]?.payload;
|
|
106
|
+
if (!geos)
|
|
107
|
+
continue;
|
|
108
|
+
geosToAdd.split(" ").forEach((geo) => {
|
|
109
|
+
let streamForGeo = streams.find((s) => s.name == geo);
|
|
110
|
+
if (streamForGeo && stream && stream.type != "forced")
|
|
111
|
+
return;
|
|
112
|
+
if (!geos.includes(geo))
|
|
113
|
+
geos.push(geo);
|
|
114
|
+
});
|
|
115
|
+
stream.filters[0].payload = geos;
|
|
116
|
+
await keitaro_service_1.KeitaroService.upsertStreamToCampaign(campaign, stream);
|
|
117
|
+
await (0, sleep_promise_1.default)(2000);
|
|
118
|
+
}
|
|
119
|
+
console.log("––––––––––––––––––––––––");
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
exports.addGeosToAllRedirectCampaigns = addGeosToAllRedirectCampaigns;
|
|
123
|
+
let removeGeosFromAllRedirectCampaigns = async (geoToRemove) => {
|
|
124
|
+
let allCampaigns = await keitaro_service_1.KeitaroService.getAllCampaigns();
|
|
125
|
+
let regexp = new RegExp(`^F #`);
|
|
126
|
+
const matchingCampaigns = allCampaigns.filter(campaign => regexp.exec(campaign.name));
|
|
127
|
+
for (let campaign of matchingCampaigns) {
|
|
128
|
+
console.log(campaign.name);
|
|
129
|
+
console.log("––––––––––––––––––––––––");
|
|
130
|
+
let streams = await keitaro_service_1.KeitaroService.getStreamsByCampaignId(campaign.id);
|
|
131
|
+
let botStream = streams[0];
|
|
132
|
+
botStream.name = "Bot Protection";
|
|
133
|
+
let owStream = streams.find(s => s.name == "OW");
|
|
134
|
+
for (let stream of [owStream, botStream]) {
|
|
135
|
+
if (!stream)
|
|
136
|
+
continue;
|
|
137
|
+
let geos = stream?.filters[0]?.payload;
|
|
138
|
+
if (!geos)
|
|
139
|
+
continue;
|
|
140
|
+
let index = geos.findIndex(geo => geo == geoToRemove);
|
|
141
|
+
geos.splice(index, 1);
|
|
142
|
+
let newGeos = stream.filters[0].payload = geos;
|
|
143
|
+
console.log({
|
|
144
|
+
name: stream.name,
|
|
145
|
+
geos: geos,
|
|
146
|
+
geosToRemove: geoToRemove,
|
|
147
|
+
newGeos: newGeos
|
|
148
|
+
});
|
|
149
|
+
await keitaro_service_1.KeitaroService.upsertStreamToCampaign(campaign, stream);
|
|
150
|
+
await (0, sleep_promise_1.default)(1200);
|
|
151
|
+
}
|
|
152
|
+
console.log("––––––––––––––––––––––––");
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
exports.removeGeosFromAllRedirectCampaigns = removeGeosFromAllRedirectCampaigns;
|
|
156
|
+
let createOrFindFlashRedirectCampaign = async (app) => {
|
|
157
|
+
if (app.keitaroData.redirectCampaignId != 0) {
|
|
158
|
+
let campaign = await keitaro_service_1.KeitaroService.getCampaignById(app.keitaroData.redirectCampaignId);
|
|
159
|
+
return campaign;
|
|
160
|
+
}
|
|
161
|
+
// Checking for already existing campaign
|
|
162
|
+
let allCampaigns = await keitaro_service_1.KeitaroService.getAllCampaigns();
|
|
163
|
+
let regexp = new RegExp(`^F #${app.id}`);
|
|
164
|
+
const matchingCampaigns = allCampaigns.filter(campaign => regexp.exec(campaign.name));
|
|
165
|
+
if (matchingCampaigns.length != 0) {
|
|
166
|
+
let campaign = matchingCampaigns[0];
|
|
167
|
+
app.keitaroData.redirectCampaignId = campaign.id;
|
|
168
|
+
console.log("Already exists!");
|
|
169
|
+
// await app.save()
|
|
170
|
+
return campaign;
|
|
171
|
+
}
|
|
172
|
+
// Select domain for a campaign
|
|
173
|
+
let allDomains = await keitaro_service_1.KeitaroService.getDomains(true);
|
|
174
|
+
if (!allDomains) {
|
|
175
|
+
throw Error(`Failed to get all domains list`);
|
|
176
|
+
}
|
|
177
|
+
const domain = allDomains[Math.floor(Math.random() * allDomains.length)];
|
|
178
|
+
// Okay, now we have everything, let's create name for our campaign
|
|
179
|
+
const name = `F #${app.id} (${app.bundle})`;
|
|
180
|
+
// And generate alias
|
|
181
|
+
const alias = Array.from({ length: 8 }, () => Math.floor(Math.random() * 36).toString(36)).join('');
|
|
182
|
+
// Here go the parameters for our campaign
|
|
183
|
+
let parameters = prepareRedirectCampaignParameters(app.id);
|
|
184
|
+
// Now let create a campaign object
|
|
185
|
+
let campaignData = prepareCampaignObject(name, alias, domain, parameters);
|
|
186
|
+
// And POST it to Keitaro!
|
|
187
|
+
let createdCampaign = await keitaro_service_1.KeitaroService.createCampaign(campaignData);
|
|
188
|
+
console.log(`Done! Campaign data:`);
|
|
189
|
+
console.log(createdCampaign);
|
|
190
|
+
return createdCampaign;
|
|
191
|
+
};
|
|
192
|
+
exports.createOrFindFlashRedirectCampaign = createOrFindFlashRedirectCampaign;
|
|
193
|
+
let prepareCampaignObject = (name, alias, domain, parameters) => {
|
|
194
|
+
return {
|
|
195
|
+
name: name,
|
|
196
|
+
alias: alias,
|
|
197
|
+
type: TYPE_POSITION,
|
|
198
|
+
uniqueness_method: UNIQUENESS_METHOD,
|
|
199
|
+
cookies_ttl: MAX_COOKIES_TTL,
|
|
200
|
+
state: STATE_ACTIVE,
|
|
201
|
+
cost_type: COST_TYPE_CPC,
|
|
202
|
+
cost_value: COST_VALUE,
|
|
203
|
+
cost_currency: COST_CURRENCY_USD,
|
|
204
|
+
group_id: FLASH_REDIRECT_GROUP_ID,
|
|
205
|
+
traffic_source_id: exports.TRAFFIC_SOURCE_ID_FLASH_AI,
|
|
206
|
+
domain_id: domain.id,
|
|
207
|
+
parameters: parameters,
|
|
208
|
+
uniqueness_use_cookies: true,
|
|
209
|
+
traffic_loss: 0
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
let prepareRedirectCampaignParameters = (appId) => {
|
|
213
|
+
return {
|
|
214
|
+
"keyword": {
|
|
215
|
+
"name": "keyword",
|
|
216
|
+
"placeholder": "",
|
|
217
|
+
"alias": ""
|
|
218
|
+
},
|
|
219
|
+
"cost": {
|
|
220
|
+
"name": "cost",
|
|
221
|
+
"placeholder": "",
|
|
222
|
+
"alias": ""
|
|
223
|
+
},
|
|
224
|
+
"currency": {
|
|
225
|
+
"name": "currency",
|
|
226
|
+
"placeholder": "",
|
|
227
|
+
"alias": ""
|
|
228
|
+
},
|
|
229
|
+
"external_id": {
|
|
230
|
+
"name": "external_id",
|
|
231
|
+
"placeholder": "",
|
|
232
|
+
"alias": ""
|
|
233
|
+
},
|
|
234
|
+
"creative_id": {
|
|
235
|
+
"name": "creative_id",
|
|
236
|
+
"placeholder": "",
|
|
237
|
+
"alias": ""
|
|
238
|
+
},
|
|
239
|
+
"ad_campaign_id": {
|
|
240
|
+
"name": "ad_campaign_id",
|
|
241
|
+
"placeholder": "",
|
|
242
|
+
"alias": ""
|
|
243
|
+
},
|
|
244
|
+
"source": {
|
|
245
|
+
"name": "source",
|
|
246
|
+
"placeholder": "",
|
|
247
|
+
"alias": ""
|
|
248
|
+
},
|
|
249
|
+
sub_id_1: {
|
|
250
|
+
name: "appId",
|
|
251
|
+
placeholder: `${appId}`,
|
|
252
|
+
alias: ""
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
let prepareOWCampaignParameters = (app) => {
|
|
257
|
+
return {
|
|
258
|
+
"keyword": {
|
|
259
|
+
"name": "keyword",
|
|
260
|
+
"placeholder": "",
|
|
261
|
+
"alias": ""
|
|
262
|
+
},
|
|
263
|
+
"cost": {
|
|
264
|
+
"name": "cost",
|
|
265
|
+
"placeholder": "",
|
|
266
|
+
"alias": ""
|
|
267
|
+
},
|
|
268
|
+
"currency": {
|
|
269
|
+
"name": "currency",
|
|
270
|
+
"placeholder": "",
|
|
271
|
+
"alias": ""
|
|
272
|
+
},
|
|
273
|
+
"external_id": {
|
|
274
|
+
"name": "external_id",
|
|
275
|
+
"placeholder": "",
|
|
276
|
+
"alias": ""
|
|
277
|
+
},
|
|
278
|
+
"creative_id": {
|
|
279
|
+
"name": "creative_id",
|
|
280
|
+
"placeholder": "",
|
|
281
|
+
"alias": ""
|
|
282
|
+
},
|
|
283
|
+
"ad_campaign_id": {
|
|
284
|
+
"name": "ad_campaign_id",
|
|
285
|
+
"placeholder": "",
|
|
286
|
+
"alias": ""
|
|
287
|
+
},
|
|
288
|
+
"source": {
|
|
289
|
+
"name": "source",
|
|
290
|
+
"placeholder": "",
|
|
291
|
+
"alias": ""
|
|
292
|
+
},
|
|
293
|
+
sub_id_8: {
|
|
294
|
+
"name": app.keitaroData.clickIdParameterName,
|
|
295
|
+
"placeholder": "{click_id}",
|
|
296
|
+
"alias": "click_id"
|
|
297
|
+
},
|
|
298
|
+
sub_id_15: {
|
|
299
|
+
"name": app.keitaroData.offerIdParameterName,
|
|
300
|
+
"placeholder": "{offer_custom_id}",
|
|
301
|
+
"alias": "offer_custom_id"
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
exports.prepareOWCampaignParameters = prepareOWCampaignParameters;
|
|
306
|
+
function createBPStreamPartialPayload(app) {
|
|
307
|
+
return {
|
|
308
|
+
name: `Bot Protection`,
|
|
309
|
+
type: "forced",
|
|
310
|
+
action_type: "http",
|
|
311
|
+
action_payload: "https://tomain.com",
|
|
312
|
+
schema: "redirect",
|
|
313
|
+
filter_or: true,
|
|
314
|
+
collect_clicks: true,
|
|
315
|
+
weight: 0,
|
|
316
|
+
filters: [{
|
|
317
|
+
name: "country",
|
|
318
|
+
mode: "reject",
|
|
319
|
+
payload: app.geos.split(",")
|
|
320
|
+
}, {
|
|
321
|
+
name: "bot",
|
|
322
|
+
mode: "accept",
|
|
323
|
+
payload: null,
|
|
324
|
+
}],
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function createOWStreamPartialPayload(app) {
|
|
328
|
+
return {
|
|
329
|
+
name: `OW`,
|
|
330
|
+
type: "regular",
|
|
331
|
+
action_type: "http",
|
|
332
|
+
action_payload: "https://bprtsk-controlpanel.com/ow?appId={appId}&clickId={uid}&countryCode={country}",
|
|
333
|
+
schema: "redirect",
|
|
334
|
+
filter_or: false,
|
|
335
|
+
collect_clicks: true,
|
|
336
|
+
weight: 100,
|
|
337
|
+
filters: [{
|
|
338
|
+
name: "country",
|
|
339
|
+
mode: "accept",
|
|
340
|
+
payload: app.geos.split(",")
|
|
341
|
+
}],
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
exports.createOWStreamPartialPayload = createOWStreamPartialPayload;
|
|
345
|
+
async function createFlashCampaigns(app) {
|
|
346
|
+
// Upserting Flash Redirect campaign
|
|
347
|
+
let redirectCampaign = await (0, exports.createOrFindFlashRedirectCampaign)(app);
|
|
348
|
+
console.log(`Redirect campaign name:`);
|
|
349
|
+
console.log(`${redirectCampaign.domain}${redirectCampaign.alias}?uid=`);
|
|
350
|
+
// Upserting necessary streams
|
|
351
|
+
let botProtectionStream = createBPStreamPartialPayload(app);
|
|
352
|
+
let owStream = createOWStreamPartialPayload(app);
|
|
353
|
+
for (let stream of [botProtectionStream, owStream]) {
|
|
354
|
+
await keitaro_service_1.KeitaroService.upsertStreamToCampaign(redirectCampaign, stream);
|
|
355
|
+
}
|
|
356
|
+
// TODO random domain for OW
|
|
357
|
+
// Upserting OW campaign
|
|
358
|
+
let owCampaign = await keitaro_service_1.KeitaroService.cloneOWCampaign(app);
|
|
359
|
+
console.log("Done! OW campaign link:");
|
|
360
|
+
console.log(`${owCampaign.domain}${owCampaign.alias}?${app.keitaroData.clickIdParameterName}={click_id}&${app.keitaroData.offerIdParameterName}={offer_custom_id}`);
|
|
361
|
+
}
|
|
362
|
+
exports.createFlashCampaigns = createFlashCampaigns;
|
|
363
|
+
// TODO separate files for offers, campaigns etc.
|
|
364
|
+
let removeBrokenDomain = async () => {
|
|
365
|
+
let regexp = new RegExp(`^FA #`);
|
|
366
|
+
let campaigns = (await keitaro_service_1.KeitaroService.getAllCampaigns()).filter(campaign => regexp.exec(campaign.name) && campaign.domain == "https://slottibolt.com/");
|
|
367
|
+
for (let campaign of campaigns) {
|
|
368
|
+
console.log(campaign.name);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
let changeSourceForFA = async () => {
|
|
372
|
+
let regexp = new RegExp(`^FA #`);
|
|
373
|
+
let campaigns = (await keitaro_service_1.KeitaroService.getAllCampaigns()).filter(campaign => regexp.exec(campaign.name));
|
|
374
|
+
for (let campaign of campaigns) {
|
|
375
|
+
console.log(campaign.name);
|
|
376
|
+
await keitaro_service_1.KeitaroService.updateCampaign(campaign.id, {
|
|
377
|
+
traffic_source_id: 22
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
let gatherInfoForFlashApps = async () => {
|
|
382
|
+
const pasteMap = JSON.parse(await readFile('./map-paste.json', 'utf8'));
|
|
383
|
+
const trackingMap = JSON.parse(await readFile('./map-tracking.json', 'utf8'));
|
|
384
|
+
const flashApps = JSON.parse(await readFile('./map-apps.json', 'utf8'));
|
|
385
|
+
let allCampaigns = await keitaro_service_1.KeitaroService.getAllCampaigns();
|
|
386
|
+
let owCampaigns = allCampaigns.filter(c => new RegExp(`^FA #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#\((.*)\)/g).exec(obj.name)[1]]: obj }), {});
|
|
387
|
+
let redirectCampaigns = allCampaigns.filter(c => new RegExp(`^F #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#\((.*)\)/g).exec(obj.name)[1]]: obj }), {});
|
|
388
|
+
let result = [];
|
|
389
|
+
for (let [id, paste] of Object.entries(pasteMap)) {
|
|
390
|
+
console.log(`- #${id}`);
|
|
391
|
+
let ow = owCampaigns[id];
|
|
392
|
+
let redirect = redirectCampaigns[id];
|
|
393
|
+
let tracking = trackingMap[id];
|
|
394
|
+
let app = flashApps[id];
|
|
395
|
+
if (paste.status == flash_app_1.FlashAppPlugStatus.ENABLED) {
|
|
396
|
+
if (!ow)
|
|
397
|
+
console.log(`#${id}: no OW`);
|
|
398
|
+
else if (!paste.content.includes(ow.domain))
|
|
399
|
+
console.log(`#${id}: OW domain (${ow.domain}) differs from paste domain (${paste.content})`);
|
|
400
|
+
else if (!paste.content.includes(ow.id.toString()))
|
|
401
|
+
console.log(`#${id}: OW campaign id (${ow.id}) differs from paste id (${paste.content})`);
|
|
402
|
+
if (!redirect)
|
|
403
|
+
console.log(`No redirect for #${id}`);
|
|
404
|
+
else if (!paste.content.includes(redirect.domain))
|
|
405
|
+
console.log(`#${id}: Redirect domain (${redirect.domain}) differs from paste domain (${paste.content})`);
|
|
406
|
+
else if (!paste.content.includes(redirect.id.toString()))
|
|
407
|
+
console.log(`#${id}: Redirect campaign id (${redirect.id}) differs from paste id (${paste.content})`);
|
|
408
|
+
}
|
|
409
|
+
let appId = ow?.parameters.sub_id_1.placeholder;
|
|
410
|
+
if (!appId)
|
|
411
|
+
console.log(`No app id for #${id}`);
|
|
412
|
+
else if (appId != id)
|
|
413
|
+
console.log(`Wrong app id (${appId}) for #${id}`);
|
|
414
|
+
let owDomain = ow?.domain;
|
|
415
|
+
let owDomainId = ow?.domain_id;
|
|
416
|
+
let owCampaignId = ow?.id;
|
|
417
|
+
let owCampaignName = ow?.name;
|
|
418
|
+
let redirectDomain = redirect?.domain;
|
|
419
|
+
let redirectDomainId = redirect?.domain_id;
|
|
420
|
+
let redirectCampaignId = redirect?.id;
|
|
421
|
+
let redirectCampaignName = redirect?.name;
|
|
422
|
+
let clickIdParameterName = redirect?.parameters?.sub_id_8.name;
|
|
423
|
+
let offerIdParameterName = redirect?.parameters?.sub_id_15.name;
|
|
424
|
+
if (!clickIdParameterName)
|
|
425
|
+
console.log(`No click id parameter for #${id}`);
|
|
426
|
+
if (!offerIdParameterName)
|
|
427
|
+
console.log(`No offer id parameter for #${id}`);
|
|
428
|
+
let trackingLink = tracking?.trackingUrl;
|
|
429
|
+
if (app) {
|
|
430
|
+
app.plugStatus = paste.status;
|
|
431
|
+
app.plugContent = paste.content;
|
|
432
|
+
app.plugType = flash_app_1.PlugType.PASTEBIN;
|
|
433
|
+
app.plugId = paste.paste_id;
|
|
434
|
+
app.plugAccountId = parseInt(paste.accountId);
|
|
435
|
+
app.keitaroData.redirectDomainName = redirectDomain || "none";
|
|
436
|
+
app.keitaroData.redirectDomainId = redirectDomainId || 0;
|
|
437
|
+
app.keitaroData.redirectCampaignId = redirectCampaignId || 0;
|
|
438
|
+
app.keitaroData.redirectCampaignName = redirectCampaignName || "none";
|
|
439
|
+
app.keitaroData.trackingDomainId = owDomainId || 0;
|
|
440
|
+
app.keitaroData.trackingDomainName = owDomain || "none";
|
|
441
|
+
app.keitaroData.trackingCampaignId = owCampaignId || 0;
|
|
442
|
+
app.keitaroData.trackingCampaignName = owCampaignName || "none";
|
|
443
|
+
if (clickIdParameterName)
|
|
444
|
+
app.keitaroData.clickIdParameterName = clickIdParameterName;
|
|
445
|
+
if (offerIdParameterName)
|
|
446
|
+
app.keitaroData.offerIdParameterName = offerIdParameterName;
|
|
447
|
+
if (trackingLink)
|
|
448
|
+
app.trackingUrl = trackingLink;
|
|
449
|
+
result.push(app);
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
console.log(`! No app for ${id}`);
|
|
453
|
+
}
|
|
454
|
+
console.log("--------------------");
|
|
455
|
+
}
|
|
456
|
+
console.log(result);
|
|
457
|
+
};
|
|
458
|
+
// removeBrokenDomain()
|
|
459
|
+
// createFlashCampaigns(sampleApp)
|
|
460
|
+
// changeSourceForFA()
|
|
461
|
+
// addGeosToAllRedirectCampaigns("BE")
|
|
462
|
+
// removeGeosFromAllRedirectCampaigns("BE`")
|
|
463
|
+
gatherInfoForFlashApps();
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bprotsyk/aso-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.69",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prod": "tsc; git add .; git commit -m \"Stub\"; git push origin master; npm version patch; npm publish;",
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"test-flash-creation": "tsc; node lib/utils/keitaro-utils.js"
|
|
10
11
|
},
|
|
11
12
|
"author": "bprotsyk",
|
|
12
13
|
"license": "ISC",
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
"module-alias": "^2.2.2",
|
|
29
30
|
"mongoose": "^6.8.3",
|
|
30
31
|
"react": "^18.2.0",
|
|
32
|
+
"sleep-promise": "^9.1.0",
|
|
31
33
|
"styled-components": "^5.3.9"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
package/src/flash/flash-app.ts
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import { FlashAppType } from "./flash-app-type";
|
|
2
|
-
import mongoose, { Model, model, PipelineStage, Schema, UpdateQuery, UpdateWithAggregationPipeline } from "mongoose";
|
|
2
|
+
import mongoose, { Document, Model, model, PipelineStage, Schema, UpdateQuery, UpdateWithAggregationPipeline } from "mongoose";
|
|
3
3
|
const util = require("util")
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export enum FlashAppPlugStatus {
|
|
6
|
+
DISABLED = 0,
|
|
7
|
+
TEST_MODE = 1,
|
|
8
|
+
ENABLED = 2
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface IFlashApp extends Document {
|
|
6
12
|
id: number
|
|
7
13
|
name: string
|
|
8
14
|
trackingUrl?: string
|
|
9
15
|
bundle: string
|
|
10
16
|
|
|
11
17
|
pushesEnabled?: boolean
|
|
12
|
-
|
|
18
|
+
plugId: string
|
|
13
19
|
plugType: PlugType
|
|
14
|
-
|
|
20
|
+
plugContent: string
|
|
21
|
+
plugStatus: FlashAppPlugStatus
|
|
22
|
+
plugAccountId: number
|
|
23
|
+
reservePlugId?: string
|
|
15
24
|
reservePlugType?: PlugType
|
|
25
|
+
reservePlugContent?: string
|
|
26
|
+
reservePlugStatus?: FlashAppPlugStatus
|
|
27
|
+
reservePlugAccountId: number
|
|
16
28
|
policyUrl?: string
|
|
17
29
|
type: FlashAppType,
|
|
18
30
|
geos: string,
|
|
@@ -36,16 +48,17 @@ export interface IAppGenerationOptions {
|
|
|
36
48
|
}
|
|
37
49
|
|
|
38
50
|
export interface IAppKeitaroData {
|
|
39
|
-
redirectCampaignId:
|
|
51
|
+
redirectCampaignId: number
|
|
40
52
|
redirectCampaignName: string
|
|
41
|
-
|
|
53
|
+
redirectDomainId: number
|
|
54
|
+
redirectDomainName: string
|
|
55
|
+
trackingCampaignId: number
|
|
42
56
|
trackingCampaignName: string
|
|
57
|
+
trackingDomainId: number
|
|
58
|
+
trackingDomainName: string
|
|
43
59
|
|
|
44
60
|
clickIdParameterName: string,
|
|
45
61
|
offerIdParameterName: string,
|
|
46
|
-
|
|
47
|
-
domainId: string
|
|
48
|
-
domainName: string
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
export enum PlugType {
|
|
@@ -72,7 +85,7 @@ export const FlashAppSchema = new Schema({
|
|
|
72
85
|
},
|
|
73
86
|
|
|
74
87
|
pushesEnabled: Boolean,
|
|
75
|
-
|
|
88
|
+
plugId: {
|
|
76
89
|
type: String,
|
|
77
90
|
// unique: true,
|
|
78
91
|
required: true
|
|
@@ -83,7 +96,18 @@ export const FlashAppSchema = new Schema({
|
|
|
83
96
|
default: PlugType.PASTEBIN,
|
|
84
97
|
required: true
|
|
85
98
|
},
|
|
86
|
-
|
|
99
|
+
plugContent: {
|
|
100
|
+
type: String,
|
|
101
|
+
required: false
|
|
102
|
+
},
|
|
103
|
+
plugStatus: {
|
|
104
|
+
type: String,
|
|
105
|
+
enum: PlugType,
|
|
106
|
+
default: FlashAppPlugStatus.DISABLED,
|
|
107
|
+
required: false
|
|
108
|
+
},
|
|
109
|
+
plugAccountId: Number,
|
|
110
|
+
reservePlugID: {
|
|
87
111
|
type: String,
|
|
88
112
|
// unique: true,
|
|
89
113
|
required: false
|
|
@@ -94,6 +118,17 @@ export const FlashAppSchema = new Schema({
|
|
|
94
118
|
default: PlugType.GIST,
|
|
95
119
|
required: false
|
|
96
120
|
},
|
|
121
|
+
reservePlugContent: {
|
|
122
|
+
type: String,
|
|
123
|
+
required: false
|
|
124
|
+
},
|
|
125
|
+
reservePlugStatus: {
|
|
126
|
+
type: String,
|
|
127
|
+
enum: PlugType,
|
|
128
|
+
default: FlashAppPlugStatus.DISABLED,
|
|
129
|
+
required: false
|
|
130
|
+
},
|
|
131
|
+
reservePlugAccountId: Number,
|
|
97
132
|
policyUrl: {
|
|
98
133
|
type: String,
|
|
99
134
|
// unique: true,
|
|
@@ -120,17 +155,17 @@ export const FlashAppSchema = new Schema({
|
|
|
120
155
|
|
|
121
156
|
developerName: {
|
|
122
157
|
type: String,
|
|
123
|
-
unique: true,
|
|
158
|
+
// unique: true,
|
|
124
159
|
required: true
|
|
125
160
|
},
|
|
126
161
|
developerEmail: {
|
|
127
162
|
type: String,
|
|
128
|
-
unique: true,
|
|
163
|
+
// unique: true,
|
|
129
164
|
required: true
|
|
130
165
|
},
|
|
131
166
|
developerOrganization: {
|
|
132
167
|
type: String,
|
|
133
|
-
unique: true,
|
|
168
|
+
// unique: true,
|
|
134
169
|
required: true
|
|
135
170
|
},
|
|
136
171
|
|
|
@@ -160,10 +195,10 @@ export const FlashAppSchema = new Schema({
|
|
|
160
195
|
|
|
161
196
|
keitaroData: {
|
|
162
197
|
redirectCampaignId: {
|
|
163
|
-
type:
|
|
198
|
+
type: Number,
|
|
164
199
|
// unique: true,
|
|
165
200
|
required: true,
|
|
166
|
-
default:
|
|
201
|
+
default: 0
|
|
167
202
|
},
|
|
168
203
|
redirectCampaignName: {
|
|
169
204
|
type: String,
|
|
@@ -171,32 +206,41 @@ export const FlashAppSchema = new Schema({
|
|
|
171
206
|
required: true,
|
|
172
207
|
default: "none"
|
|
173
208
|
},
|
|
174
|
-
|
|
209
|
+
redirectDomainId: {
|
|
210
|
+
type: Number,
|
|
211
|
+
required: true,
|
|
212
|
+
default: 0
|
|
213
|
+
},
|
|
214
|
+
redirectDomainName: {
|
|
175
215
|
type: String,
|
|
176
|
-
// unique: true,
|
|
177
216
|
required: true,
|
|
178
217
|
default: "none"
|
|
179
218
|
},
|
|
219
|
+
trackingCampaignId: {
|
|
220
|
+
type: Number,
|
|
221
|
+
// unique: true,
|
|
222
|
+
required: true,
|
|
223
|
+
default: 0
|
|
224
|
+
},
|
|
180
225
|
trackingCampaignName: {
|
|
181
226
|
type: String,
|
|
182
227
|
// unique: true,
|
|
183
228
|
required: true,
|
|
184
229
|
default: "none"
|
|
185
230
|
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
offerIdParameterName: String,
|
|
189
|
-
|
|
190
|
-
domainId: {
|
|
191
|
-
type: String,
|
|
231
|
+
trackingDomainId: {
|
|
232
|
+
type: Number,
|
|
192
233
|
required: true,
|
|
193
|
-
default:
|
|
234
|
+
default: 0
|
|
194
235
|
},
|
|
195
|
-
|
|
236
|
+
trackingDomainName: {
|
|
196
237
|
type: String,
|
|
197
238
|
required: true,
|
|
198
239
|
default: "none"
|
|
199
240
|
},
|
|
241
|
+
|
|
242
|
+
clickIdParameterName: String,
|
|
243
|
+
offerIdParameterName: String,
|
|
200
244
|
}
|
|
201
245
|
})
|
|
202
246
|
// TODO app type (casino / fin)
|