@bprotsyk/aso-core 2.1.113 → 2.1.115
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/network/keitaro/traffle/traffle-keitaro-service.d.ts +95 -0
- package/lib/network/keitaro/traffle/traffle-keitaro-service.js +252 -24
- package/lib/offers/list.d.ts +18 -18
- package/lib/templates/words.txt +212 -0
- package/package.json +3 -2
- package/src/network/keitaro/traffle/traffle-keitaro-service.ts +284 -26
- package/src/templates/words.txt +212 -0
- package/test-keitaro.js +21 -3
|
@@ -37,6 +37,100 @@ declare function getTraffleAffiliateNetworks(): Promise<IAffiliateNetwork[]>;
|
|
|
37
37
|
declare function deleteOfferById(id: number): Promise<any>;
|
|
38
38
|
declare function addOffersToTraffleKeitaro(offers: ITraffleOffer[]): Promise<void>;
|
|
39
39
|
declare function updateOfferLinkById(id: number, action_payload: string | object): Promise<any>;
|
|
40
|
+
declare function TrafleKeitaroParameters(parameters: any): Promise<{
|
|
41
|
+
parameters: {
|
|
42
|
+
keyword: {
|
|
43
|
+
name: string;
|
|
44
|
+
placeholder: string;
|
|
45
|
+
alias: string;
|
|
46
|
+
};
|
|
47
|
+
cost: {
|
|
48
|
+
name: string;
|
|
49
|
+
placeholder: string;
|
|
50
|
+
alias: string;
|
|
51
|
+
};
|
|
52
|
+
currency: {
|
|
53
|
+
name: string;
|
|
54
|
+
placeholder: string;
|
|
55
|
+
alias: string;
|
|
56
|
+
};
|
|
57
|
+
external_id: {
|
|
58
|
+
name: string;
|
|
59
|
+
placeholder: string;
|
|
60
|
+
alias: string;
|
|
61
|
+
};
|
|
62
|
+
creative_id: {
|
|
63
|
+
name: string;
|
|
64
|
+
placeholder: string;
|
|
65
|
+
alias: string;
|
|
66
|
+
};
|
|
67
|
+
ad_campaign_id: {
|
|
68
|
+
name: string;
|
|
69
|
+
placeholder: string;
|
|
70
|
+
alias: string;
|
|
71
|
+
};
|
|
72
|
+
source: {
|
|
73
|
+
name: string;
|
|
74
|
+
placeholder: string;
|
|
75
|
+
alias: string;
|
|
76
|
+
};
|
|
77
|
+
sub_id_1: {
|
|
78
|
+
name: string;
|
|
79
|
+
placeholder: string;
|
|
80
|
+
alias: string;
|
|
81
|
+
};
|
|
82
|
+
sub_id_2: {
|
|
83
|
+
name: string;
|
|
84
|
+
placeholder: string;
|
|
85
|
+
alias: string;
|
|
86
|
+
};
|
|
87
|
+
sub_id_3: {
|
|
88
|
+
name: string;
|
|
89
|
+
placeholder: string;
|
|
90
|
+
alias: string;
|
|
91
|
+
};
|
|
92
|
+
sub_id_4: {
|
|
93
|
+
name: string;
|
|
94
|
+
placeholder: string;
|
|
95
|
+
alias: string;
|
|
96
|
+
};
|
|
97
|
+
sub_id_5: {
|
|
98
|
+
name: string;
|
|
99
|
+
placeholder: string;
|
|
100
|
+
alias: string;
|
|
101
|
+
};
|
|
102
|
+
sub_id_10: {
|
|
103
|
+
name: string;
|
|
104
|
+
placeholder: string;
|
|
105
|
+
alias: string;
|
|
106
|
+
};
|
|
107
|
+
sub_id_15: {
|
|
108
|
+
name: string;
|
|
109
|
+
placeholder: string;
|
|
110
|
+
alias: string;
|
|
111
|
+
};
|
|
112
|
+
sub_id_16: {
|
|
113
|
+
name: string;
|
|
114
|
+
placeholder: any;
|
|
115
|
+
alias: string;
|
|
116
|
+
};
|
|
117
|
+
sub_id_17: {
|
|
118
|
+
name: string;
|
|
119
|
+
placeholder: string;
|
|
120
|
+
alias: string;
|
|
121
|
+
};
|
|
122
|
+
sub_id_18: {
|
|
123
|
+
name: string;
|
|
124
|
+
placeholder: string;
|
|
125
|
+
alias: string;
|
|
126
|
+
};
|
|
127
|
+
sub_id_19: {
|
|
128
|
+
name: string;
|
|
129
|
+
placeholder: any;
|
|
130
|
+
alias: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
} | null>;
|
|
40
134
|
declare function cloneTraffleCampaign(app: IApp, platform: EPlatform, addDefaultStreams?: boolean): Promise<IKeitaroCampaign | any>;
|
|
41
135
|
export declare const TraffleKeitaroService: {
|
|
42
136
|
addOffersToTraffleKeitaro: typeof addOffersToTraffleKeitaro;
|
|
@@ -47,5 +141,6 @@ export declare const TraffleKeitaroService: {
|
|
|
47
141
|
getAllOffers: typeof getAllOffers;
|
|
48
142
|
updateOfferLinkById: typeof updateOfferLinkById;
|
|
49
143
|
cloneTraffleCampaign: typeof cloneTraffleCampaign;
|
|
144
|
+
TrafleKeitaroParameters: typeof TrafleKeitaroParameters;
|
|
50
145
|
};
|
|
51
146
|
export {};
|
|
@@ -7,6 +7,8 @@ exports.TraffleKeitaroService = exports.ITraffleTrafficType = void 0;
|
|
|
7
7
|
const http_1 = __importDefault(require("./http"));
|
|
8
8
|
const app_1 = require("../../../app/app");
|
|
9
9
|
const openai_1 = require("../../../network/openai/openai");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
10
12
|
async function getAllOffers() {
|
|
11
13
|
const { data: offers } = await http_1.default.get('offers');
|
|
12
14
|
return offers;
|
|
@@ -180,24 +182,13 @@ async function createCampaign(campaignData) {
|
|
|
180
182
|
}
|
|
181
183
|
async function TrafleKeitaroParameters(parameters) {
|
|
182
184
|
const { bundle, appsflyerDevKey, name, originalParameters } = parameters;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
]
|
|
188
|
-
});
|
|
189
|
-
if (!openAIResponse) {
|
|
190
|
-
return null;
|
|
191
|
-
}
|
|
192
|
-
let ParamsGenerationsOpenAIResponse = null;
|
|
193
|
-
try {
|
|
194
|
-
ParamsGenerationsOpenAIResponse = JSON.parse(openAIResponse);
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
console.error("Failed to parse OpenAI response:", error);
|
|
185
|
+
// Генеруємо параметри локально замість OpenAI
|
|
186
|
+
const localParameters = await generateLocalParameters();
|
|
187
|
+
if (!localParameters) {
|
|
188
|
+
console.error("Failed to generate local parameters");
|
|
198
189
|
return null;
|
|
199
190
|
}
|
|
200
|
-
console.log(`
|
|
191
|
+
console.log(`Local generated parameters: ${JSON.stringify(localParameters)}`);
|
|
201
192
|
return {
|
|
202
193
|
parameters: {
|
|
203
194
|
keyword: { name: 'keyword', placeholder: '', alias: '' },
|
|
@@ -213,30 +204,265 @@ async function TrafleKeitaroParameters(parameters) {
|
|
|
213
204
|
sub_id_4: { name: 'DEV', placeholder: '', alias: '' },
|
|
214
205
|
sub_id_5: { name: 'LANG', placeholder: '', alias: '' },
|
|
215
206
|
sub_id_10: { name: 'market', placeholder: '', alias: '' },
|
|
216
|
-
sub_id_15: { name:
|
|
207
|
+
sub_id_15: { name: localParameters.naming, placeholder: '{naming}', alias: 'Naming' },
|
|
217
208
|
sub_id_16: {
|
|
218
209
|
name: 'bundle_id',
|
|
219
210
|
placeholder: bundle,
|
|
220
211
|
alias: 'Bundle ID'
|
|
221
212
|
},
|
|
222
213
|
sub_id_17: {
|
|
223
|
-
name:
|
|
214
|
+
name: localParameters.advertisingid,
|
|
224
215
|
placeholder: '{advertising_id}',
|
|
225
216
|
alias: 'Advertising ID'
|
|
226
217
|
},
|
|
227
218
|
sub_id_18: {
|
|
228
|
-
name:
|
|
219
|
+
name: localParameters.appsflyerDeviceID,
|
|
229
220
|
placeholder: '{appsflyer_device_id}',
|
|
230
221
|
alias: 'Appsflyer Device ID'
|
|
231
222
|
},
|
|
232
223
|
sub_id_19: {
|
|
233
|
-
name:
|
|
224
|
+
name: 'appsflyer_dev_key',
|
|
234
225
|
placeholder: appsflyerDevKey,
|
|
235
226
|
alias: 'Appsflyer Dev Key'
|
|
236
227
|
}
|
|
237
228
|
}
|
|
238
229
|
};
|
|
239
230
|
}
|
|
231
|
+
async function generateLocalParameters() {
|
|
232
|
+
try {
|
|
233
|
+
// Читаємо слова з файлу
|
|
234
|
+
const wordsFilePath = path_1.default.join(__dirname, '../../../templates/words.txt');
|
|
235
|
+
const wordsContent = fs_1.default.readFileSync(wordsFilePath, 'utf-8');
|
|
236
|
+
const words = wordsContent.split('\n').filter(word => word.trim().length > 0);
|
|
237
|
+
if (words.length === 0) {
|
|
238
|
+
console.error("No words found in words.txt file");
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
// Генеруємо випадкові індекси
|
|
242
|
+
const namingIndex = Math.floor(Math.random() * words.length);
|
|
243
|
+
const advertisingIdIndex = Math.floor(Math.random() * words.length);
|
|
244
|
+
const appsflyerDeviceIdIndex = Math.floor(Math.random() * words.length);
|
|
245
|
+
// Отримуємо випадкові слова
|
|
246
|
+
const naming = words[namingIndex];
|
|
247
|
+
const advertisingid = words[advertisingIdIndex];
|
|
248
|
+
const appsflyerDeviceID = words[appsflyerDeviceIdIndex];
|
|
249
|
+
return {
|
|
250
|
+
naming,
|
|
251
|
+
advertisingid,
|
|
252
|
+
appsflyerDeviceID
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
console.error("Error reading words file:", error);
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function checkAndUpdateCampaignParameters(existingCampaign, app, platform) {
|
|
261
|
+
// Отримуємо trackingParams з додатку
|
|
262
|
+
const platformData = app.platforms[platform];
|
|
263
|
+
// Перевіряємо наявність параметрів у кампанії
|
|
264
|
+
const campaignParams = existingCampaign.parameters;
|
|
265
|
+
const hasCampaignParams = campaignParams && campaignParams.sub_id_15 && campaignParams.sub_id_17 && campaignParams.sub_id_18;
|
|
266
|
+
// Перевіряємо чи є trackingParams в app
|
|
267
|
+
const hasAppTrackingParams = platformData?.direct?.keitaroData && typeof platformData.direct.keitaroData !== 'boolean' && platformData.direct.keitaroData.trackingParams;
|
|
268
|
+
// Якщо параметрів нема ні в Keitaro ні в app - генеруємо нові
|
|
269
|
+
if (!hasCampaignParams && !hasAppTrackingParams) {
|
|
270
|
+
console.log("No parameters in campaign and no trackingParams in app, generating new ones...");
|
|
271
|
+
return await generateAndUpdateCampaignParameters(existingCampaign, app, platform);
|
|
272
|
+
}
|
|
273
|
+
// Якщо параметрів нема в Keitaro, але є в app - використовуємо app
|
|
274
|
+
if (!hasCampaignParams && hasAppTrackingParams) {
|
|
275
|
+
console.log("Campaign has no parameters, using app trackingParams...");
|
|
276
|
+
return await updateCampaignWithAppParams(existingCampaign, app, platform);
|
|
277
|
+
}
|
|
278
|
+
// Якщо параметри є в Keitaro, але нема в app - оновлюємо app
|
|
279
|
+
if (hasCampaignParams && !hasAppTrackingParams) {
|
|
280
|
+
console.log("Campaign has parameters but no app trackingParams, updating app with campaign parameters...");
|
|
281
|
+
return await updateAppWithCampaignParams(existingCampaign, app, platform);
|
|
282
|
+
}
|
|
283
|
+
// Якщо параметри є і в Keitaro і в app - перевіряємо чи потрібно оновлювати
|
|
284
|
+
if (hasCampaignParams && hasAppTrackingParams && platformData.direct && typeof platformData.direct.keitaroData !== 'boolean') {
|
|
285
|
+
const appTrackingParams = platformData.direct.keitaroData.trackingParams;
|
|
286
|
+
const needsUpdate = await checkParametersMatch(appTrackingParams, campaignParams, app, platform);
|
|
287
|
+
if (needsUpdate) {
|
|
288
|
+
console.log("Parameters need update due to app changes, updating with app trackingParams...");
|
|
289
|
+
return await updateCampaignWithAppParams(existingCampaign, app, platform);
|
|
290
|
+
}
|
|
291
|
+
console.log("Parameters are up to date, no update needed");
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
async function checkParametersMatch(appTrackingParams, campaignParams, app, platform) {
|
|
297
|
+
// Перевіряємо чи параметри відповідають trackingParams з app
|
|
298
|
+
const namingMatch = campaignParams.sub_id_15?.name === appTrackingParams.naming;
|
|
299
|
+
const advertisingIdMatch = campaignParams.sub_id_17?.name === appTrackingParams.advertising_id;
|
|
300
|
+
const appsflyerDeviceIdMatch = campaignParams.sub_id_18?.name === appTrackingParams.appsflyer_device_id;
|
|
301
|
+
// Перевіряємо чи змінилися ключові налаштування додатку
|
|
302
|
+
const bundleChanged = campaignParams.sub_id_16?.placeholder !== app.bundle;
|
|
303
|
+
const appsflyerDevKeyChanged = campaignParams.sub_id_19?.placeholder !== (app.platforms[platform].appsflyerParams?.devKey || 'appsflyer_dev_key');
|
|
304
|
+
// Якщо всі параметри співпадають з app trackingParams і немає змін в додатку
|
|
305
|
+
if (namingMatch && advertisingIdMatch && appsflyerDeviceIdMatch && !bundleChanged && !appsflyerDevKeyChanged) {
|
|
306
|
+
console.log("All parameters match app trackingParams and app settings unchanged, no update needed");
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
// Логуємо причину оновлення
|
|
310
|
+
if (bundleChanged)
|
|
311
|
+
console.log(`Bundle changed: ${campaignParams.sub_id_16?.placeholder} → ${app.bundle}`);
|
|
312
|
+
if (appsflyerDevKeyChanged)
|
|
313
|
+
console.log(`Appsflyer Dev Key changed: ${campaignParams.sub_id_19?.placeholder} → ${app.platforms[platform].appsflyerParams?.devKey || 'appsflyer_dev_key'}`);
|
|
314
|
+
if (!namingMatch)
|
|
315
|
+
console.log(`Naming changed: ${campaignParams.sub_id_15?.name} → ${appTrackingParams.naming}`);
|
|
316
|
+
if (!advertisingIdMatch)
|
|
317
|
+
console.log(`Advertising ID changed: ${campaignParams.sub_id_17?.name} → ${appTrackingParams.advertising_id}`);
|
|
318
|
+
if (!appsflyerDeviceIdMatch)
|
|
319
|
+
console.log(`Appsflyer Device ID changed: ${campaignParams.sub_id_18?.name} → ${appTrackingParams.appsflyer_device_id}`);
|
|
320
|
+
return true; // Потрібно оновлення
|
|
321
|
+
}
|
|
322
|
+
async function generateAndUpdateCampaignParameters(existingCampaign, app, platform) {
|
|
323
|
+
try {
|
|
324
|
+
// Генеруємо нові параметри
|
|
325
|
+
const newParameters = await TrafleKeitaroParameters({
|
|
326
|
+
bundle: app.bundle,
|
|
327
|
+
appsflyerDevKey: app.platforms[platform].appsflyerParams?.devKey,
|
|
328
|
+
name: existingCampaign.name,
|
|
329
|
+
originalParameters: existingCampaign.parameters
|
|
330
|
+
});
|
|
331
|
+
if (!newParameters) {
|
|
332
|
+
console.error("Failed to generate new parameters");
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
// Оновлюємо кампанію з новими параметрами
|
|
336
|
+
const updatePayload = {
|
|
337
|
+
parameters: newParameters.parameters
|
|
338
|
+
};
|
|
339
|
+
await http_1.default.put(`/campaigns/${existingCampaign.id}`, updatePayload);
|
|
340
|
+
console.log("Campaign parameters updated successfully");
|
|
341
|
+
// Оновлюємо локальний об'єкт кампанії
|
|
342
|
+
existingCampaign.parameters = newParameters.parameters;
|
|
343
|
+
console.log("Local campaign parameters updated:", existingCampaign.parameters);
|
|
344
|
+
// Оновлюємо trackingParams в додатку
|
|
345
|
+
await updateAppTrackingParams(app, platform, newParameters.parameters);
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
console.error("Failed to update campaign parameters:", error);
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
async function updateAppTrackingParams(app, platform, newParameters) {
|
|
354
|
+
try {
|
|
355
|
+
// Оновлюємо trackingParams в додатку
|
|
356
|
+
const platformData = app.platforms[platform];
|
|
357
|
+
if (platformData?.direct?.keitaroData && typeof platformData.direct.keitaroData !== 'boolean' && platformData.direct.keitaroData.trackingParams) {
|
|
358
|
+
platformData.direct.keitaroData.trackingParams = {
|
|
359
|
+
naming: newParameters.sub_id_15?.name || "",
|
|
360
|
+
advertising_id: newParameters.sub_id_17?.name || "",
|
|
361
|
+
appsflyer_device_id: newParameters.sub_id_18?.name || "",
|
|
362
|
+
bundle_id: newParameters.sub_id_16?.name || ""
|
|
363
|
+
};
|
|
364
|
+
console.log("App trackingParams updated:", platformData.direct.keitaroData.trackingParams);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
console.error("Failed to update app trackingParams:", error);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
async function updateCampaignWithAppParams(existingCampaign, app, platform) {
|
|
372
|
+
try {
|
|
373
|
+
const platformData = app.platforms[platform];
|
|
374
|
+
if (!platformData?.direct?.keitaroData || typeof platformData.direct.keitaroData === 'boolean' || !platformData.direct.keitaroData.trackingParams) {
|
|
375
|
+
console.error("No trackingParams found in app");
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
378
|
+
const appTrackingParams = platformData.direct.keitaroData.trackingParams;
|
|
379
|
+
// Використовуємо існуючі параметри з app замість генерації нових
|
|
380
|
+
const newParameters = {
|
|
381
|
+
parameters: {
|
|
382
|
+
keyword: { name: 'keyword', placeholder: '', alias: '' },
|
|
383
|
+
cost: { name: 'cost', placeholder: '', alias: '' },
|
|
384
|
+
currency: { name: 'currency', placeholder: '', alias: '' },
|
|
385
|
+
external_id: { name: 'external_id', placeholder: '', alias: '' },
|
|
386
|
+
creative_id: { name: 'creative_id', placeholder: '', alias: '' },
|
|
387
|
+
ad_campaign_id: { name: 'ad_campaign_id', placeholder: '', alias: '' },
|
|
388
|
+
source: { name: 'source', placeholder: '', alias: '' },
|
|
389
|
+
sub_id_1: { name: 'uqID', placeholder: '', alias: '' },
|
|
390
|
+
sub_id_2: { name: 'AD_ID', placeholder: '', alias: '' },
|
|
391
|
+
sub_id_3: { name: 'USB', placeholder: '', alias: '' },
|
|
392
|
+
sub_id_4: { name: 'DEV', placeholder: '', alias: '' },
|
|
393
|
+
sub_id_5: { name: 'LANG', placeholder: '', alias: '' },
|
|
394
|
+
sub_id_10: { name: 'market', placeholder: '', alias: '' },
|
|
395
|
+
sub_id_15: {
|
|
396
|
+
name: appTrackingParams.naming || 'naming',
|
|
397
|
+
placeholder: '{naming}',
|
|
398
|
+
alias: 'Naming'
|
|
399
|
+
},
|
|
400
|
+
sub_id_16: {
|
|
401
|
+
name: 'bundle_id',
|
|
402
|
+
placeholder: app.bundle,
|
|
403
|
+
alias: 'Bundle ID'
|
|
404
|
+
},
|
|
405
|
+
sub_id_17: {
|
|
406
|
+
name: appTrackingParams.advertising_id || 'advertising_id',
|
|
407
|
+
placeholder: '{advertising_id}',
|
|
408
|
+
alias: 'Advertising ID'
|
|
409
|
+
},
|
|
410
|
+
sub_id_18: {
|
|
411
|
+
name: appTrackingParams.appsflyer_device_id || 'appsflyer_device_id',
|
|
412
|
+
placeholder: '{appsflyer_device_id}',
|
|
413
|
+
alias: 'Appsflyer Device ID'
|
|
414
|
+
},
|
|
415
|
+
sub_id_19: {
|
|
416
|
+
name: 'appsflyer_dev_key',
|
|
417
|
+
placeholder: app.platforms[platform].appsflyerParams?.devKey || 'appsflyer_dev_key',
|
|
418
|
+
alias: 'Appsflyer Dev Key'
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
console.log(`Using app trackingParams: naming=${appTrackingParams.naming}, advertising_id=${appTrackingParams.advertising_id}, appsflyer_device_id=${appTrackingParams.appsflyer_device_id}`);
|
|
423
|
+
// Оновлюємо кампанію з параметрами з app
|
|
424
|
+
const updatePayload = {
|
|
425
|
+
parameters: newParameters.parameters
|
|
426
|
+
};
|
|
427
|
+
await http_1.default.put(`/campaigns/${existingCampaign.id}`, updatePayload);
|
|
428
|
+
console.log("Campaign parameters updated with app trackingParams");
|
|
429
|
+
// Оновлюємо локальний об'єкт кампанії
|
|
430
|
+
existingCampaign.parameters = newParameters.parameters;
|
|
431
|
+
console.log("Local campaign parameters updated with app trackingParams:", existingCampaign.parameters);
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
catch (error) {
|
|
435
|
+
console.error("Failed to update campaign with app params:", error);
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
async function updateAppWithCampaignParams(existingCampaign, app, platform) {
|
|
440
|
+
try {
|
|
441
|
+
const platformData = app.platforms[platform];
|
|
442
|
+
if (!platformData?.direct?.keitaroData || typeof platformData.direct.keitaroData === 'boolean') {
|
|
443
|
+
console.error("No keitaroData found in app");
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
const campaignParams = existingCampaign.parameters;
|
|
447
|
+
if (!campaignParams) {
|
|
448
|
+
console.error("No parameters found in campaign");
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
// Оновлюємо app з параметрами з Keitaro
|
|
452
|
+
platformData.direct.keitaroData.trackingParams = {
|
|
453
|
+
naming: campaignParams.sub_id_15?.name || "",
|
|
454
|
+
advertising_id: campaignParams.sub_id_17?.name || "",
|
|
455
|
+
appsflyer_device_id: campaignParams.sub_id_18?.name || "",
|
|
456
|
+
bundle_id: campaignParams.sub_id_16?.placeholder || ""
|
|
457
|
+
};
|
|
458
|
+
console.log(`Updated app with campaign parameters: naming=${platformData.direct.keitaroData.trackingParams.naming}, advertising_id=${platformData.direct.keitaroData.trackingParams.advertising_id}, appsflyer_device_id=${platformData.direct.keitaroData.trackingParams.appsflyer_device_id}`);
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
console.error("Failed to update app with campaign params:", error);
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
240
466
|
async function cloneTraffleCampaign(app, platform, addDefaultStreams) {
|
|
241
467
|
const ORIGINAL_CLONE_CAMPAIGN_ID = 1925;
|
|
242
468
|
const appsflyerAvailability = app.platforms[platform].appsflyerParams?.apiToken ? "[AF]" : "";
|
|
@@ -253,12 +479,12 @@ async function cloneTraffleCampaign(app, platform, addDefaultStreams) {
|
|
|
253
479
|
// Для конкретної платформи
|
|
254
480
|
const platformName = (0, app_1.getPlatformName)(platform);
|
|
255
481
|
matchingCampaign = allCampaigns.filter((c) => {
|
|
256
|
-
const hasBundle = c.name.includes(`[${app.bundle}]`);
|
|
257
482
|
const hasDomain = c.name.includes(app.domainParams.name);
|
|
483
|
+
const hasGroup = c.group == app.id.toString();
|
|
258
484
|
// Перевіряємо наявність платформи в дужках в кінці назви
|
|
259
485
|
const platformPattern = new RegExp(`\\(.*${platformName}.*\\)\\s*$`);
|
|
260
486
|
const hasPlatform = platformPattern.test(c.name);
|
|
261
|
-
return
|
|
487
|
+
return hasGroup && hasDomain && hasPlatform;
|
|
262
488
|
});
|
|
263
489
|
}
|
|
264
490
|
else {
|
|
@@ -272,9 +498,11 @@ async function cloneTraffleCampaign(app, platform, addDefaultStreams) {
|
|
|
272
498
|
return hasBundle && hasDomain && noPlatformAtEnd;
|
|
273
499
|
});
|
|
274
500
|
}
|
|
275
|
-
// Якщо знайдена існуюча кампанія -
|
|
501
|
+
// Якщо знайдена існуюча кампанія - перевіряємо параметри
|
|
276
502
|
if (matchingCampaign.length > 0) {
|
|
277
503
|
const existingCampaign = matchingCampaign[0];
|
|
504
|
+
// Перевіряємо наявність та актуальність параметрів
|
|
505
|
+
const needsParameterUpdate = await checkAndUpdateCampaignParameters(existingCampaign, app, platform);
|
|
278
506
|
// Отримуємо потоки тільки якщо потрібно щось робити з ними
|
|
279
507
|
const originalStreams = await getStreamsByCampaignId(ORIGINAL_CLONE_CAMPAIGN_ID);
|
|
280
508
|
const existingStreams = await getStreamsByCampaignId(existingCampaign.id);
|
|
@@ -493,5 +721,5 @@ async function cloneTraffleCampaign(app, platform, addDefaultStreams) {
|
|
|
493
721
|
return updatedCampaign;
|
|
494
722
|
}
|
|
495
723
|
exports.TraffleKeitaroService = {
|
|
496
|
-
addOffersToTraffleKeitaro, getTraffleOffersGroups, getTraffleAffiliateNetworks, createGroup, deleteOfferById, getAllOffers, updateOfferLinkById, cloneTraffleCampaign
|
|
724
|
+
addOffersToTraffleKeitaro, getTraffleOffersGroups, getTraffleAffiliateNetworks, createGroup, deleteOfferById, getAllOffers, updateOfferLinkById, cloneTraffleCampaign, TrafleKeitaroParameters
|
|
497
725
|
};
|
package/lib/offers/list.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
44
44
|
name: string;
|
|
45
45
|
content: import("mongoose").Types.DocumentArray<{
|
|
46
46
|
prototype?: {
|
|
47
|
+
toString: {} | null;
|
|
48
|
+
valueOf: {} | null;
|
|
47
49
|
constructor: {
|
|
48
50
|
name?: unknown;
|
|
49
51
|
[Symbol.hasInstance]?: {} | null | undefined;
|
|
@@ -56,9 +58,7 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
56
58
|
call?: {} | null | undefined;
|
|
57
59
|
bind?: {} | null | undefined;
|
|
58
60
|
} | null;
|
|
59
|
-
toString: {} | null;
|
|
60
61
|
toLocaleString: {} | null;
|
|
61
|
-
valueOf: {} | null;
|
|
62
62
|
hasOwnProperty: {} | null;
|
|
63
63
|
isPrototypeOf: {} | null;
|
|
64
64
|
propertyIsEnumerable: {} | null;
|
|
@@ -87,6 +87,8 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
87
87
|
hasOwn?: {} | null | undefined;
|
|
88
88
|
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
89
89
|
prototype?: {
|
|
90
|
+
toString: {} | null;
|
|
91
|
+
valueOf: {} | null;
|
|
90
92
|
constructor: {
|
|
91
93
|
name?: unknown;
|
|
92
94
|
[Symbol.hasInstance]?: {} | null | undefined;
|
|
@@ -99,9 +101,7 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
99
101
|
call?: {} | null | undefined;
|
|
100
102
|
bind?: {} | null | undefined;
|
|
101
103
|
} | null;
|
|
102
|
-
toString: {} | null;
|
|
103
104
|
toLocaleString: {} | null;
|
|
104
|
-
valueOf: {} | null;
|
|
105
105
|
hasOwnProperty: {} | null;
|
|
106
106
|
isPrototypeOf: {} | null;
|
|
107
107
|
propertyIsEnumerable: {} | null;
|
|
@@ -130,6 +130,8 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
130
130
|
hasOwn?: {} | null | undefined;
|
|
131
131
|
}> & {
|
|
132
132
|
prototype?: {
|
|
133
|
+
toString: {} | null;
|
|
134
|
+
valueOf: {} | null;
|
|
133
135
|
constructor: {
|
|
134
136
|
name?: unknown;
|
|
135
137
|
[Symbol.hasInstance]?: {} | null | undefined;
|
|
@@ -142,9 +144,7 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
142
144
|
call?: {} | null | undefined;
|
|
143
145
|
bind?: {} | null | undefined;
|
|
144
146
|
} | null;
|
|
145
|
-
toString: {} | null;
|
|
146
147
|
toLocaleString: {} | null;
|
|
147
|
-
valueOf: {} | null;
|
|
148
148
|
hasOwnProperty: {} | null;
|
|
149
149
|
isPrototypeOf: {} | null;
|
|
150
150
|
propertyIsEnumerable: {} | null;
|
|
@@ -177,6 +177,8 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
177
177
|
name: string;
|
|
178
178
|
content: import("mongoose").Types.DocumentArray<{
|
|
179
179
|
prototype?: {
|
|
180
|
+
toString: {} | null;
|
|
181
|
+
valueOf: {} | null;
|
|
180
182
|
constructor: {
|
|
181
183
|
name?: unknown;
|
|
182
184
|
[Symbol.hasInstance]?: {} | null | undefined;
|
|
@@ -189,9 +191,7 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
189
191
|
call?: {} | null | undefined;
|
|
190
192
|
bind?: {} | null | undefined;
|
|
191
193
|
} | null;
|
|
192
|
-
toString: {} | null;
|
|
193
194
|
toLocaleString: {} | null;
|
|
194
|
-
valueOf: {} | null;
|
|
195
195
|
hasOwnProperty: {} | null;
|
|
196
196
|
isPrototypeOf: {} | null;
|
|
197
197
|
propertyIsEnumerable: {} | null;
|
|
@@ -220,6 +220,8 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
220
220
|
hasOwn?: {} | null | undefined;
|
|
221
221
|
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
222
222
|
prototype?: {
|
|
223
|
+
toString: {} | null;
|
|
224
|
+
valueOf: {} | null;
|
|
223
225
|
constructor: {
|
|
224
226
|
name?: unknown;
|
|
225
227
|
[Symbol.hasInstance]?: {} | null | undefined;
|
|
@@ -232,9 +234,7 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
232
234
|
call?: {} | null | undefined;
|
|
233
235
|
bind?: {} | null | undefined;
|
|
234
236
|
} | null;
|
|
235
|
-
toString: {} | null;
|
|
236
237
|
toLocaleString: {} | null;
|
|
237
|
-
valueOf: {} | null;
|
|
238
238
|
hasOwnProperty: {} | null;
|
|
239
239
|
isPrototypeOf: {} | null;
|
|
240
240
|
propertyIsEnumerable: {} | null;
|
|
@@ -263,6 +263,8 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
263
263
|
hasOwn?: {} | null | undefined;
|
|
264
264
|
}> & {
|
|
265
265
|
prototype?: {
|
|
266
|
+
toString: {} | null;
|
|
267
|
+
valueOf: {} | null;
|
|
266
268
|
constructor: {
|
|
267
269
|
name?: unknown;
|
|
268
270
|
[Symbol.hasInstance]?: {} | null | undefined;
|
|
@@ -275,9 +277,7 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
275
277
|
call?: {} | null | undefined;
|
|
276
278
|
bind?: {} | null | undefined;
|
|
277
279
|
} | null;
|
|
278
|
-
toString: {} | null;
|
|
279
280
|
toLocaleString: {} | null;
|
|
280
|
-
valueOf: {} | null;
|
|
281
281
|
hasOwnProperty: {} | null;
|
|
282
282
|
isPrototypeOf: {} | null;
|
|
283
283
|
propertyIsEnumerable: {} | null;
|
|
@@ -310,6 +310,8 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
310
310
|
name: string;
|
|
311
311
|
content: import("mongoose").Types.DocumentArray<{
|
|
312
312
|
prototype?: {
|
|
313
|
+
toString: {} | null;
|
|
314
|
+
valueOf: {} | null;
|
|
313
315
|
constructor: {
|
|
314
316
|
name?: unknown;
|
|
315
317
|
[Symbol.hasInstance]?: {} | null | undefined;
|
|
@@ -322,9 +324,7 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
322
324
|
call?: {} | null | undefined;
|
|
323
325
|
bind?: {} | null | undefined;
|
|
324
326
|
} | null;
|
|
325
|
-
toString: {} | null;
|
|
326
327
|
toLocaleString: {} | null;
|
|
327
|
-
valueOf: {} | null;
|
|
328
328
|
hasOwnProperty: {} | null;
|
|
329
329
|
isPrototypeOf: {} | null;
|
|
330
330
|
propertyIsEnumerable: {} | null;
|
|
@@ -353,6 +353,8 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
353
353
|
hasOwn?: {} | null | undefined;
|
|
354
354
|
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
355
355
|
prototype?: {
|
|
356
|
+
toString: {} | null;
|
|
357
|
+
valueOf: {} | null;
|
|
356
358
|
constructor: {
|
|
357
359
|
name?: unknown;
|
|
358
360
|
[Symbol.hasInstance]?: {} | null | undefined;
|
|
@@ -365,9 +367,7 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
365
367
|
call?: {} | null | undefined;
|
|
366
368
|
bind?: {} | null | undefined;
|
|
367
369
|
} | null;
|
|
368
|
-
toString: {} | null;
|
|
369
370
|
toLocaleString: {} | null;
|
|
370
|
-
valueOf: {} | null;
|
|
371
371
|
hasOwnProperty: {} | null;
|
|
372
372
|
isPrototypeOf: {} | null;
|
|
373
373
|
propertyIsEnumerable: {} | null;
|
|
@@ -396,6 +396,8 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
396
396
|
hasOwn?: {} | null | undefined;
|
|
397
397
|
}> & {
|
|
398
398
|
prototype?: {
|
|
399
|
+
toString: {} | null;
|
|
400
|
+
valueOf: {} | null;
|
|
399
401
|
constructor: {
|
|
400
402
|
name?: unknown;
|
|
401
403
|
[Symbol.hasInstance]?: {} | null | undefined;
|
|
@@ -408,9 +410,7 @@ export declare const SectionsListSchema: Schema<any, import("mongoose").Model<an
|
|
|
408
410
|
call?: {} | null | undefined;
|
|
409
411
|
bind?: {} | null | undefined;
|
|
410
412
|
} | null;
|
|
411
|
-
toString: {} | null;
|
|
412
413
|
toLocaleString: {} | null;
|
|
413
|
-
valueOf: {} | null;
|
|
414
414
|
hasOwnProperty: {} | null;
|
|
415
415
|
isPrototypeOf: {} | null;
|
|
416
416
|
propertyIsEnumerable: {} | null;
|