@bprotsyk/aso-core 1.2.69 → 1.2.70
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.
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { PlugType } from "index";
|
|
2
1
|
export interface IUpsertFlashAppRequest {
|
|
3
2
|
id: number;
|
|
4
3
|
name: string;
|
|
5
4
|
bundle: string;
|
|
6
|
-
|
|
7
|
-
plugType: PlugType;
|
|
8
|
-
reservePlugUrl?: string;
|
|
9
|
-
reservePlugType?: PlugType;
|
|
5
|
+
plugContent?: string;
|
|
10
6
|
onesignalAppId: string;
|
|
11
7
|
onesignalRestApiKey: string;
|
|
12
8
|
developerName: string;
|
|
@@ -33,6 +33,7 @@ const keitaro_service_1 = require("../network/keitaro/keitaro-service");
|
|
|
33
33
|
const sleep_promise_1 = __importDefault(require("sleep-promise"));
|
|
34
34
|
const fs = require("fs");
|
|
35
35
|
const util = __importStar(require("util"));
|
|
36
|
+
const axios_1 = __importDefault(require("axios"));
|
|
36
37
|
const readFile = util.promisify(fs.readFile);
|
|
37
38
|
const FLASH_REDIRECT_GROUP_ID = 82;
|
|
38
39
|
exports.TRAFFIC_SOURCE_ID_FLASH_AI = 22;
|
|
@@ -379,12 +380,13 @@ let changeSourceForFA = async () => {
|
|
|
379
380
|
}
|
|
380
381
|
};
|
|
381
382
|
let gatherInfoForFlashApps = async () => {
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
const
|
|
383
|
+
console.log(__dirname);
|
|
384
|
+
const pasteMap = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-paste.json', 'utf8'));
|
|
385
|
+
const trackingMap = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-tracking.json', 'utf8'));
|
|
386
|
+
const flashApps = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-apps.json', 'utf8'));
|
|
385
387
|
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(
|
|
387
|
-
let redirectCampaigns = allCampaigns.filter(c => new RegExp(`^F #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(
|
|
388
|
+
let owCampaigns = allCampaigns.filter(c => new RegExp(`^FA #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#(.*) \(/g).exec(obj.name)?.[1] || obj.name]: obj }), {});
|
|
389
|
+
let redirectCampaigns = allCampaigns.filter(c => new RegExp(`^F #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#(.*) \(/g).exec(obj.name)?.[1] || obj.name]: obj }), {});
|
|
388
390
|
let result = [];
|
|
389
391
|
for (let [id, paste] of Object.entries(pasteMap)) {
|
|
390
392
|
console.log(`- #${id}`);
|
|
@@ -392,68 +394,79 @@ let gatherInfoForFlashApps = async () => {
|
|
|
392
394
|
let redirect = redirectCampaigns[id];
|
|
393
395
|
let tracking = trackingMap[id];
|
|
394
396
|
let app = flashApps[id];
|
|
397
|
+
if (!app) {
|
|
398
|
+
console.log(`! No app for ${id}`);
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
395
401
|
if (paste.status == flash_app_1.FlashAppPlugStatus.ENABLED) {
|
|
396
402
|
if (!ow)
|
|
397
403
|
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
404
|
if (!redirect)
|
|
403
405
|
console.log(`No redirect for #${id}`);
|
|
404
406
|
else if (!paste.content.includes(redirect.domain))
|
|
405
407
|
console.log(`#${id}: Redirect domain (${redirect.domain}) differs from paste domain (${paste.content})`);
|
|
406
|
-
else if (!paste.content.includes(redirect.
|
|
407
|
-
console.log(`#${id}: Redirect campaign
|
|
408
|
+
else if (!paste.content.includes(redirect.alias))
|
|
409
|
+
console.log(`#${id}: Redirect campaign alias (${redirect.alias}) differs from paste id (${paste.content})`);
|
|
410
|
+
}
|
|
411
|
+
let appId;
|
|
412
|
+
for (let parameter of Object.values(redirect?.parameters || {})) {
|
|
413
|
+
if (parameter.name == "appId") {
|
|
414
|
+
appId = parameter.placeholder;
|
|
415
|
+
}
|
|
408
416
|
}
|
|
409
|
-
|
|
410
|
-
if (!appId)
|
|
417
|
+
if (!appId && ow)
|
|
411
418
|
console.log(`No app id for #${id}`);
|
|
412
|
-
else if (appId != id)
|
|
419
|
+
else if (appId != id && ow)
|
|
413
420
|
console.log(`Wrong app id (${appId}) for #${id}`);
|
|
414
|
-
let owDomain = ow?.domain;
|
|
421
|
+
let owDomain = ow?.domain?.split("/")[2];
|
|
415
422
|
let owDomainId = ow?.domain_id;
|
|
416
423
|
let owCampaignId = ow?.id;
|
|
417
424
|
let owCampaignName = ow?.name;
|
|
418
|
-
let redirectDomain = redirect?.domain;
|
|
425
|
+
let redirectDomain = redirect?.domain?.split("/")[2];
|
|
419
426
|
let redirectDomainId = redirect?.domain_id;
|
|
420
427
|
let redirectCampaignId = redirect?.id;
|
|
421
428
|
let redirectCampaignName = redirect?.name;
|
|
422
|
-
let clickIdParameterName =
|
|
423
|
-
let offerIdParameterName =
|
|
424
|
-
if (!clickIdParameterName)
|
|
429
|
+
let clickIdParameterName = ow?.parameters?.sub_id_8?.name;
|
|
430
|
+
let offerIdParameterName = ow?.parameters?.sub_id_15?.name;
|
|
431
|
+
if (!clickIdParameterName && app && ow)
|
|
425
432
|
console.log(`No click id parameter for #${id}`);
|
|
426
|
-
if (!offerIdParameterName)
|
|
433
|
+
if (!offerIdParameterName && app && ow)
|
|
427
434
|
console.log(`No offer id parameter for #${id}`);
|
|
428
435
|
let trackingLink = tracking?.trackingUrl;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
436
|
+
app.plugStatus = paste.status;
|
|
437
|
+
app.plugContent = paste.content;
|
|
438
|
+
app.plugType = flash_app_1.PlugType.PASTEBIN;
|
|
439
|
+
app.plugId = paste.paste_id;
|
|
440
|
+
app.plugAccountId = parseInt(paste.accountId);
|
|
441
|
+
app.keitaroData.redirectDomainName = redirectDomain || "none";
|
|
442
|
+
app.keitaroData.redirectDomainId = redirectDomainId || 0;
|
|
443
|
+
app.keitaroData.redirectCampaignId = redirectCampaignId || 0;
|
|
444
|
+
app.keitaroData.redirectCampaignName = redirectCampaignName || "none";
|
|
445
|
+
app.keitaroData.trackingDomainId = owDomainId || 0;
|
|
446
|
+
app.keitaroData.trackingDomainName = owDomain || "none";
|
|
447
|
+
app.keitaroData.trackingCampaignId = owCampaignId || 0;
|
|
448
|
+
app.keitaroData.trackingCampaignName = owCampaignName || "none";
|
|
449
|
+
if (clickIdParameterName)
|
|
450
|
+
app.keitaroData.clickIdParameterName = clickIdParameterName;
|
|
451
|
+
if (offerIdParameterName)
|
|
452
|
+
app.keitaroData.offerIdParameterName = offerIdParameterName;
|
|
453
|
+
if (trackingLink)
|
|
454
|
+
app.trackingUrl = trackingLink;
|
|
455
|
+
if (!owCampaignName?.includes(app.bundle) && ow) {
|
|
456
|
+
console.log(`OW: bundle differs (${app.bundle} in DB and ${owCampaignName})`);
|
|
450
457
|
}
|
|
451
|
-
|
|
452
|
-
console.log(
|
|
458
|
+
if (!redirectCampaignName?.includes(app.bundle) && redirect) {
|
|
459
|
+
console.log(`Redirect: bundle differs (${app.bundle} in DB and ${redirectCampaignName})`);
|
|
453
460
|
}
|
|
461
|
+
result.push(app);
|
|
454
462
|
console.log("--------------------");
|
|
455
463
|
}
|
|
456
|
-
|
|
464
|
+
await axios_1.default.post(`https://aipanel-secondary.com/flash/batch-update`, result, {
|
|
465
|
+
headers: {
|
|
466
|
+
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNjg3Mjc2NjA0LCJleHAiOjE2ODc4ODE0MDR9.XesrnNGmWlK-yBBMs5TeKvTe07A8Sud7B4MyfZAOMag"
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
// console.log(result)
|
|
457
470
|
};
|
|
458
471
|
// removeBrokenDomain()
|
|
459
472
|
// createFlashCampaigns(sampleApp)
|
package/package.json
CHANGED
|
@@ -4,10 +4,7 @@ export interface IUpsertFlashAppRequest {
|
|
|
4
4
|
id: number
|
|
5
5
|
name: string
|
|
6
6
|
bundle: string
|
|
7
|
-
|
|
8
|
-
plugType: PlugType
|
|
9
|
-
reservePlugUrl?: string
|
|
10
|
-
reservePlugType?: PlugType
|
|
7
|
+
plugContent?: string,
|
|
11
8
|
|
|
12
9
|
onesignalAppId: string
|
|
13
10
|
onesignalRestApiKey: string
|
|
@@ -388,13 +388,14 @@ let changeSourceForFA = async () => {
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
let gatherInfoForFlashApps = async () => {
|
|
391
|
-
|
|
392
|
-
const
|
|
393
|
-
const
|
|
391
|
+
console.log(__dirname)
|
|
392
|
+
const pasteMap: PasteMap = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-paste.json', 'utf8'));
|
|
393
|
+
const trackingMap: TrackingMap = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-tracking.json', 'utf8'));
|
|
394
|
+
const flashApps: { [key: string]: IFlashApp | undefined } = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-apps.json', 'utf8'));
|
|
394
395
|
|
|
395
396
|
let allCampaigns = await KeitaroService.getAllCampaigns()
|
|
396
|
-
let owCampaigns = allCampaigns.filter(c => new RegExp(`^FA #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(
|
|
397
|
-
let redirectCampaigns = allCampaigns.filter(c => new RegExp(`^F #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(
|
|
397
|
+
let owCampaigns = allCampaigns.filter(c => new RegExp(`^FA #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#(.*) \(/g).exec(obj.name)?.[1] || obj.name]: obj }), {});
|
|
398
|
+
let redirectCampaigns = allCampaigns.filter(c => new RegExp(`^F #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#(.*) \(/g).exec(obj.name)?.[1] || obj.name]: obj }), {});
|
|
398
399
|
|
|
399
400
|
let result = []
|
|
400
401
|
for (let [id, paste] of Object.entries(pasteMap)) {
|
|
@@ -404,66 +405,84 @@ let gatherInfoForFlashApps = async () => {
|
|
|
404
405
|
let tracking = trackingMap[id as keyof object]
|
|
405
406
|
let app = flashApps[id as keyof object]
|
|
406
407
|
|
|
408
|
+
if (!app) {
|
|
409
|
+
console.log(`! No app for ${id}`)
|
|
410
|
+
continue
|
|
411
|
+
}
|
|
412
|
+
|
|
407
413
|
if (paste.status == FlashAppPlugStatus.ENABLED) {
|
|
408
414
|
if (!ow) console.log(`#${id}: no OW`)
|
|
409
|
-
else if (!paste.content.includes(ow.domain)) console.log(`#${id}: OW domain (${ow.domain}) differs from paste domain (${paste.content})`)
|
|
410
|
-
else if (!paste.content.includes(ow.id.toString())) console.log(`#${id}: OW campaign id (${ow.id}) differs from paste id (${paste.content})`)
|
|
411
415
|
|
|
412
416
|
if (!redirect) console.log(`No redirect for #${id}`)
|
|
413
417
|
else if (!paste.content.includes(redirect.domain)) console.log(`#${id}: Redirect domain (${redirect.domain}) differs from paste domain (${paste.content})`)
|
|
414
|
-
else if (!paste.content.includes(redirect.
|
|
418
|
+
else if (!paste.content.includes(redirect.alias)) console.log(`#${id}: Redirect campaign alias (${redirect.alias}) differs from paste id (${paste.content})`)
|
|
415
419
|
}
|
|
416
420
|
|
|
417
|
-
let appId
|
|
418
|
-
|
|
419
|
-
|
|
421
|
+
let appId
|
|
422
|
+
for (let parameter of Object.values(redirect?.parameters || {})) {
|
|
423
|
+
if (parameter.name == "appId") {
|
|
424
|
+
appId = parameter.placeholder
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (!appId && ow) console.log(`No app id for #${id}`)
|
|
428
|
+
else if (appId != id && ow) console.log(`Wrong app id (${appId}) for #${id}`)
|
|
420
429
|
|
|
421
|
-
let owDomain = ow?.domain
|
|
430
|
+
let owDomain = ow?.domain?.split("/")[2]
|
|
422
431
|
let owDomainId = ow?.domain_id
|
|
423
432
|
let owCampaignId = ow?.id
|
|
424
433
|
let owCampaignName = ow?.name
|
|
425
|
-
let redirectDomain = redirect?.domain
|
|
434
|
+
let redirectDomain = redirect?.domain?.split("/")[2]
|
|
426
435
|
let redirectDomainId = redirect?.domain_id
|
|
427
436
|
let redirectCampaignId = redirect?.id
|
|
428
437
|
let redirectCampaignName = redirect?.name
|
|
429
438
|
|
|
430
|
-
let clickIdParameterName =
|
|
431
|
-
let offerIdParameterName =
|
|
432
|
-
if (!clickIdParameterName) console.log(`No click id parameter for #${id}`)
|
|
433
|
-
if (!offerIdParameterName) console.log(`No offer id parameter for #${id}`)
|
|
439
|
+
let clickIdParameterName = ow?.parameters?.sub_id_8?.name
|
|
440
|
+
let offerIdParameterName = ow?.parameters?.sub_id_15?.name
|
|
441
|
+
if (!clickIdParameterName && app && ow) console.log(`No click id parameter for #${id}`)
|
|
442
|
+
if (!offerIdParameterName && app && ow) console.log(`No offer id parameter for #${id}`)
|
|
434
443
|
|
|
435
444
|
let trackingLink = tracking?.trackingUrl
|
|
436
445
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
|
|
446
|
+
app.plugStatus = paste.status
|
|
447
|
+
app.plugContent = paste.content
|
|
448
|
+
app.plugType = PlugType.PASTEBIN
|
|
449
|
+
app.plugId = paste.paste_id
|
|
450
|
+
app.plugAccountId = parseInt(paste.accountId)
|
|
451
|
+
|
|
452
|
+
app.keitaroData.redirectDomainName = redirectDomain || "none"
|
|
453
|
+
app.keitaroData.redirectDomainId = redirectDomainId || 0
|
|
454
|
+
app.keitaroData.redirectCampaignId = redirectCampaignId || 0
|
|
455
|
+
app.keitaroData.redirectCampaignName = redirectCampaignName || "none"
|
|
456
|
+
app.keitaroData.trackingDomainId = owDomainId || 0
|
|
457
|
+
app.keitaroData.trackingDomainName = owDomain || "none"
|
|
458
|
+
app.keitaroData.trackingCampaignId = owCampaignId || 0
|
|
459
|
+
app.keitaroData.trackingCampaignName = owCampaignName || "none"
|
|
460
|
+
|
|
461
|
+
if (clickIdParameterName) app.keitaroData.clickIdParameterName = clickIdParameterName
|
|
462
|
+
if (offerIdParameterName) app.keitaroData.offerIdParameterName = offerIdParameterName
|
|
463
|
+
|
|
464
|
+
if (trackingLink) app.trackingUrl = trackingLink
|
|
465
|
+
|
|
466
|
+
if (!owCampaignName?.includes(app.bundle) && ow) {
|
|
467
|
+
console.log(`OW: bundle differs (${app.bundle} in DB and ${owCampaignName})`)
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (!redirectCampaignName?.includes(app.bundle) && redirect) {
|
|
471
|
+
console.log(`Redirect: bundle differs (${app.bundle} in DB and ${redirectCampaignName})`)
|
|
461
472
|
}
|
|
462
473
|
|
|
474
|
+
result.push(app)
|
|
475
|
+
|
|
463
476
|
console.log("--------------------")
|
|
464
477
|
}
|
|
465
478
|
|
|
466
|
-
|
|
479
|
+
await axios.post(`https://aipanel-secondary.com/flash/batch-update`, result, {
|
|
480
|
+
headers: {
|
|
481
|
+
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNjg3Mjc2NjA0LCJleHAiOjE2ODc4ODE0MDR9.XesrnNGmWlK-yBBMs5TeKvTe07A8Sud7B4MyfZAOMag"
|
|
482
|
+
}
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
// console.log(result)
|
|
467
486
|
}
|
|
468
487
|
|
|
469
488
|
// removeBrokenDomain()
|