@bprotsyk/aso-core 2.1.131 → 2.1.132
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.
|
@@ -5,6 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.KeitaroCLOGeosService = exports.getAppsNeedingGeoUpdate = exports.getAppGeoSyncDetails = exports.syncKeitaroCLOGeosWithApps = void 0;
|
|
7
7
|
const http_1 = __importDefault(require("../network/keitaro/traffle/http"));
|
|
8
|
+
// Хелпер для нормалізації списку гео
|
|
9
|
+
function normalizeGeos(geos) {
|
|
10
|
+
if (!Array.isArray(geos))
|
|
11
|
+
return [];
|
|
12
|
+
const unique = new Set();
|
|
13
|
+
for (const raw of geos) {
|
|
14
|
+
if (typeof raw !== 'string')
|
|
15
|
+
continue;
|
|
16
|
+
const val = raw.trim().toUpperCase();
|
|
17
|
+
if (!val)
|
|
18
|
+
continue;
|
|
19
|
+
unique.add(val);
|
|
20
|
+
}
|
|
21
|
+
return Array.from(unique).sort();
|
|
22
|
+
}
|
|
8
23
|
/**
|
|
9
24
|
* Отримує всі кампанії з Keitaro
|
|
10
25
|
*/
|
|
@@ -191,16 +206,17 @@ async function syncKeitaroCLOGeosWithApps(apps) {
|
|
|
191
206
|
console.log(` Визначена платформа: ${platform}`);
|
|
192
207
|
// Отримуємо гео з CLO потоку кампанії
|
|
193
208
|
console.log(` Отримуємо гео з CLO потоку...`);
|
|
194
|
-
const
|
|
209
|
+
const keitaroGeosRaw = await getCLOGeosFromCampaign(campaign.id);
|
|
210
|
+
const keitaroGeos = normalizeGeos(keitaroGeosRaw);
|
|
195
211
|
console.log(` Keitaro CLO гео: ${keitaroGeos.join(', ')}`);
|
|
196
212
|
// Отримуємо гео з додатку для конкретної платформи
|
|
197
213
|
const platformData = app.platforms[platform];
|
|
198
|
-
const appGeos = platformData?.geo
|
|
214
|
+
const appGeos = normalizeGeos(platformData?.geo);
|
|
199
215
|
console.log(` App гео для платформи ${platform}: ${appGeos.join(', ')}`);
|
|
200
216
|
// Порівнюємо гео
|
|
201
217
|
const missingGeos = keitaroGeos.filter(geo => !appGeos.includes(geo));
|
|
202
|
-
const
|
|
203
|
-
|
|
218
|
+
const extraGeos = appGeos.filter(geo => !keitaroGeos.includes(geo));
|
|
219
|
+
const needsUpdate = missingGeos.length > 0 || extraGeos.length > 0;
|
|
204
220
|
console.log(` Відсутні гео в app: ${missingGeos.join(', ')}`);
|
|
205
221
|
console.log(` Потребує оновлення: ${needsUpdate}`);
|
|
206
222
|
if (needsUpdate) {
|
|
@@ -217,6 +233,7 @@ async function syncKeitaroCLOGeosWithApps(apps) {
|
|
|
217
233
|
console.log(` Keitaro гео: ${keitaroGeos.join(', ')}`);
|
|
218
234
|
console.log(` App гео: ${appGeos.join(', ')}`);
|
|
219
235
|
console.log(` Відсутні гео в app: ${missingGeos.join(', ')}`);
|
|
236
|
+
console.log(` Зайві гео в app: ${extraGeos.join(', ')}`);
|
|
220
237
|
console.log(` Нові гео (з Keitaro): ${updateData.newGeos.join(', ')}`);
|
|
221
238
|
}
|
|
222
239
|
else {
|
package/package.json
CHANGED
|
@@ -3,6 +3,19 @@ import { IKeitaroCampaign } from "./keitaro-campaign";
|
|
|
3
3
|
import { IKeitaroStream } from "./keitaro-stream";
|
|
4
4
|
import { IApp, IPlatformParams, EPlatform } from "../app/app";
|
|
5
5
|
|
|
6
|
+
// Хелпер для нормалізації списку гео
|
|
7
|
+
function normalizeGeos(geos: string[] | undefined | null): string[] {
|
|
8
|
+
if (!Array.isArray(geos)) return [];
|
|
9
|
+
const unique = new Set<string>();
|
|
10
|
+
for (const raw of geos) {
|
|
11
|
+
if (typeof raw !== 'string') continue;
|
|
12
|
+
const val = raw.trim().toUpperCase();
|
|
13
|
+
if (!val) continue;
|
|
14
|
+
unique.add(val);
|
|
15
|
+
}
|
|
16
|
+
return Array.from(unique).sort();
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
// Інтерфейс для результату синхронізації гео
|
|
7
20
|
export interface IGeoSyncResult {
|
|
8
21
|
appId: number;
|
|
@@ -242,18 +255,19 @@ export async function syncKeitaroCLOGeosWithApps(apps: IApp[]): Promise<IGeoSync
|
|
|
242
255
|
|
|
243
256
|
// Отримуємо гео з CLO потоку кампанії
|
|
244
257
|
console.log(` Отримуємо гео з CLO потоку...`);
|
|
245
|
-
const
|
|
258
|
+
const keitaroGeosRaw = await getCLOGeosFromCampaign(campaign.id);
|
|
259
|
+
const keitaroGeos = normalizeGeos(keitaroGeosRaw);
|
|
246
260
|
console.log(` Keitaro CLO гео: ${keitaroGeos.join(', ')}`);
|
|
247
261
|
|
|
248
262
|
// Отримуємо гео з додатку для конкретної платформи
|
|
249
263
|
const platformData = app.platforms[platform as EPlatform];
|
|
250
|
-
const appGeos = platformData?.geo
|
|
264
|
+
const appGeos = normalizeGeos(platformData?.geo);
|
|
251
265
|
console.log(` App гео для платформи ${platform}: ${appGeos.join(', ')}`);
|
|
252
266
|
|
|
253
267
|
// Порівнюємо гео
|
|
254
268
|
const missingGeos = keitaroGeos.filter(geo => !appGeos.includes(geo));
|
|
255
|
-
const
|
|
256
|
-
|
|
269
|
+
const extraGeos = appGeos.filter(geo => !keitaroGeos.includes(geo));
|
|
270
|
+
const needsUpdate = missingGeos.length > 0 || extraGeos.length > 0;
|
|
257
271
|
|
|
258
272
|
console.log(` Відсутні гео в app: ${missingGeos.join(', ')}`);
|
|
259
273
|
console.log(` Потребує оновлення: ${needsUpdate}`);
|
|
@@ -275,6 +289,7 @@ export async function syncKeitaroCLOGeosWithApps(apps: IApp[]): Promise<IGeoSync
|
|
|
275
289
|
console.log(` Keitaro гео: ${keitaroGeos.join(', ')}`);
|
|
276
290
|
console.log(` App гео: ${appGeos.join(', ')}`);
|
|
277
291
|
console.log(` Відсутні гео в app: ${missingGeos.join(', ')}`);
|
|
292
|
+
console.log(` Зайві гео в app: ${extraGeos.join(', ')}`);
|
|
278
293
|
console.log(` Нові гео (з Keitaro): ${updateData.newGeos.join(', ')}`);
|
|
279
294
|
} else {
|
|
280
295
|
console.log(`✅ Додаток ${group} (${platform}) не потребує оновлення гео - гео ідентичні`);
|