@bprotsyk/aso-core 2.1.122 → 2.1.123
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.
|
@@ -8,6 +8,20 @@ const http_1 = __importDefault(require("./http"));
|
|
|
8
8
|
const app_1 = require("../../../app/app");
|
|
9
9
|
const openai_1 = require("../../../network/openai/openai");
|
|
10
10
|
const words_1 = require("../../../templates/words");
|
|
11
|
+
// Константи для функції updateStreamsForApp
|
|
12
|
+
const STREAM_NAMES = {
|
|
13
|
+
CLO: "CLO"
|
|
14
|
+
};
|
|
15
|
+
const FILTER_NAMES = {
|
|
16
|
+
COUNTRY: "country"
|
|
17
|
+
};
|
|
18
|
+
const FILTER_MODES = {
|
|
19
|
+
ACCEPT: "accept"
|
|
20
|
+
};
|
|
21
|
+
const STREAM_STATES = {
|
|
22
|
+
ACTIVE: "active",
|
|
23
|
+
DISABLED: "disabled"
|
|
24
|
+
};
|
|
11
25
|
async function getAllOffers() {
|
|
12
26
|
const { data: offers } = await http_1.default.get('offers');
|
|
13
27
|
return offers;
|
|
@@ -760,6 +774,12 @@ async function updateStreamsForApp(app, platform) {
|
|
|
760
774
|
console.log(`No platform data for platform ${platform}`);
|
|
761
775
|
return false;
|
|
762
776
|
}
|
|
777
|
+
// Перевіряємо чи є directType і чи він трафлєвський
|
|
778
|
+
const directType = platformData.direct?.directType;
|
|
779
|
+
if (!directType || (directType !== app_1.EDirectType.TRAFFLE_KEITARO_OFFER && directType !== app_1.EDirectType.TRAFFLE_OFFER_DIRECT)) {
|
|
780
|
+
console.log(`Skipping stream update for platform ${platform}: directType is not traffle (${directType})`);
|
|
781
|
+
return false;
|
|
782
|
+
}
|
|
763
783
|
const campaign = await findCampaignForAppPlatform(app, platform);
|
|
764
784
|
if (!campaign) {
|
|
765
785
|
console.log(`No campaign found for app ${app.id} (${app.bundle}) and platform ${platform}`);
|
|
@@ -777,10 +797,10 @@ async function updateStreamsForApp(app, platform) {
|
|
|
777
797
|
});
|
|
778
798
|
if (!platformData.enabled) {
|
|
779
799
|
for (const s of streams) {
|
|
780
|
-
const isClo = s.name ===
|
|
781
|
-
const hasCountryFilter = Array.isArray(s.filters) && s.filters.some((f) => f?.name ===
|
|
782
|
-
if ((isClo || hasCountryFilter) && s.state !==
|
|
783
|
-
await updateStreamState(s.id,
|
|
800
|
+
const isClo = s.name === STREAM_NAMES.CLO;
|
|
801
|
+
const hasCountryFilter = Array.isArray(s.filters) && s.filters.some((f) => f?.name === FILTER_NAMES.COUNTRY);
|
|
802
|
+
if ((isClo || hasCountryFilter) && s.state !== STREAM_STATES.DISABLED) {
|
|
803
|
+
await updateStreamState(s.id, STREAM_STATES.DISABLED);
|
|
784
804
|
changed = true;
|
|
785
805
|
}
|
|
786
806
|
}
|
|
@@ -789,21 +809,21 @@ async function updateStreamsForApp(app, platform) {
|
|
|
789
809
|
// enabled: turn on CLO and geo streams that match platform geo. Leave others as-is.
|
|
790
810
|
const platformGeo = platformData.geo || [];
|
|
791
811
|
for (const s of streams) {
|
|
792
|
-
const isClo = s.name ===
|
|
793
|
-
if (isClo && s.state !==
|
|
794
|
-
await updateStreamState(s.id,
|
|
812
|
+
const isClo = s.name === STREAM_NAMES.CLO;
|
|
813
|
+
if (isClo && s.state !== STREAM_STATES.ACTIVE) {
|
|
814
|
+
await updateStreamState(s.id, STREAM_STATES.ACTIVE);
|
|
795
815
|
changed = true;
|
|
796
816
|
continue;
|
|
797
817
|
}
|
|
798
|
-
const countryFilter = Array.isArray(s.filters) ? s.filters.find((f) => f?.name ===
|
|
818
|
+
const countryFilter = Array.isArray(s.filters) ? s.filters.find((f) => f?.name === FILTER_NAMES.COUNTRY) : null;
|
|
799
819
|
if (!countryFilter)
|
|
800
820
|
continue;
|
|
801
821
|
// Heuristic: enable only geo streams whose payload intersects platform geo when mode is 'accept'.
|
|
802
822
|
const mode = countryFilter?.mode;
|
|
803
823
|
const payload = Array.isArray(countryFilter?.payload) ? countryFilter.payload : [];
|
|
804
|
-
if (mode ===
|
|
805
|
-
if (s.state !==
|
|
806
|
-
await updateStreamState(s.id,
|
|
824
|
+
if (mode === FILTER_MODES.ACCEPT && arraysIntersect(payload, platformGeo)) {
|
|
825
|
+
if (s.state !== STREAM_STATES.ACTIVE) {
|
|
826
|
+
await updateStreamState(s.id, STREAM_STATES.ACTIVE);
|
|
807
827
|
changed = true;
|
|
808
828
|
}
|
|
809
829
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { IOffer } from "../../../offers/offer"
|
|
|
3
3
|
import keitaroApi from "./http"
|
|
4
4
|
import { IKeitaroCampaign } from "../../../keitaro/keitaro-campaign";
|
|
5
5
|
import { IKeitaroDomain } from "../../../keitaro/keitaro-domain";
|
|
6
|
-
import { EPlatform, getPlatformName, IApp } from "../../../app/app";
|
|
6
|
+
import { EPlatform, getPlatformName, IApp, EDirectType } from "../../../app/app";
|
|
7
7
|
import { TRAFFIC_SOURCE_ID_FLASH_AI, prepareOWCampaignParameters } from "../../../utils/keitaro-utils";
|
|
8
8
|
import { convertMillisToDate, getTimestampsForTodayAndYesterday } from "../../../utils/general";
|
|
9
9
|
import { IKeitaroOffer, IKeitaroOffersFilter } from "index";
|
|
@@ -13,6 +13,24 @@ import { off } from "process";
|
|
|
13
13
|
import { IKeitaroCampaignParameters } from "../../../keitaro/keitaro-campaign";
|
|
14
14
|
import { getRandomWord } from "../../../templates/words";
|
|
15
15
|
|
|
16
|
+
// Константи для функції updateStreamsForApp
|
|
17
|
+
const STREAM_NAMES = {
|
|
18
|
+
CLO: "CLO"
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
const FILTER_NAMES = {
|
|
22
|
+
COUNTRY: "country"
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
const FILTER_MODES = {
|
|
26
|
+
ACCEPT: "accept"
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
const STREAM_STATES = {
|
|
30
|
+
ACTIVE: "active",
|
|
31
|
+
DISABLED: "disabled"
|
|
32
|
+
} as const;
|
|
33
|
+
|
|
16
34
|
async function getAllOffers(): Promise<IKeitaroOffer[]> {
|
|
17
35
|
const { data: offers } = await keitaroApi.get<IKeitaroOffer[]>('offers')
|
|
18
36
|
|
|
@@ -909,6 +927,13 @@ export async function updateStreamsForApp(app: IApp, platform: EPlatform): Promi
|
|
|
909
927
|
return false;
|
|
910
928
|
}
|
|
911
929
|
|
|
930
|
+
// Перевіряємо чи є directType і чи він трафлєвський
|
|
931
|
+
const directType = platformData.direct?.directType;
|
|
932
|
+
if (!directType || (directType !== EDirectType.TRAFFLE_KEITARO_OFFER && directType !== EDirectType.TRAFFLE_OFFER_DIRECT)) {
|
|
933
|
+
console.log(`Skipping stream update for platform ${platform}: directType is not traffle (${directType})`);
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
|
|
912
937
|
const campaign = await findCampaignForAppPlatform(app, platform);
|
|
913
938
|
if (!campaign) {
|
|
914
939
|
console.log(`No campaign found for app ${app.id} (${app.bundle}) and platform ${platform}`);
|
|
@@ -930,10 +955,10 @@ export async function updateStreamsForApp(app: IApp, platform: EPlatform): Promi
|
|
|
930
955
|
|
|
931
956
|
if (!platformData.enabled) {
|
|
932
957
|
for (const s of streams) {
|
|
933
|
-
const isClo = s.name ===
|
|
934
|
-
const hasCountryFilter = Array.isArray(s.filters) && s.filters.some((f: any) => f?.name ===
|
|
935
|
-
if ((isClo || hasCountryFilter) && s.state !==
|
|
936
|
-
await updateStreamState((s as any).id,
|
|
958
|
+
const isClo = s.name === STREAM_NAMES.CLO;
|
|
959
|
+
const hasCountryFilter = Array.isArray(s.filters) && s.filters.some((f: any) => f?.name === FILTER_NAMES.COUNTRY);
|
|
960
|
+
if ((isClo || hasCountryFilter) && s.state !== STREAM_STATES.DISABLED) {
|
|
961
|
+
await updateStreamState((s as any).id, STREAM_STATES.DISABLED);
|
|
937
962
|
changed = true;
|
|
938
963
|
}
|
|
939
964
|
}
|
|
@@ -943,22 +968,22 @@ export async function updateStreamsForApp(app: IApp, platform: EPlatform): Promi
|
|
|
943
968
|
// enabled: turn on CLO and geo streams that match platform geo. Leave others as-is.
|
|
944
969
|
const platformGeo = platformData.geo || [];
|
|
945
970
|
for (const s of streams) {
|
|
946
|
-
const isClo = s.name ===
|
|
947
|
-
if (isClo && s.state !==
|
|
948
|
-
await updateStreamState((s as any).id,
|
|
971
|
+
const isClo = s.name === STREAM_NAMES.CLO;
|
|
972
|
+
if (isClo && s.state !== STREAM_STATES.ACTIVE) {
|
|
973
|
+
await updateStreamState((s as any).id, STREAM_STATES.ACTIVE);
|
|
949
974
|
changed = true;
|
|
950
975
|
continue;
|
|
951
976
|
}
|
|
952
977
|
|
|
953
|
-
const countryFilter = Array.isArray(s.filters) ? s.filters.find((f: any) => f?.name ===
|
|
978
|
+
const countryFilter = Array.isArray(s.filters) ? s.filters.find((f: any) => f?.name === FILTER_NAMES.COUNTRY) : null;
|
|
954
979
|
if (!countryFilter) continue;
|
|
955
980
|
|
|
956
981
|
// Heuristic: enable only geo streams whose payload intersects platform geo when mode is 'accept'.
|
|
957
982
|
const mode: string | undefined = countryFilter?.mode;
|
|
958
983
|
const payload: string[] = Array.isArray(countryFilter?.payload) ? countryFilter.payload : [];
|
|
959
|
-
if (mode ===
|
|
960
|
-
if (s.state !==
|
|
961
|
-
await updateStreamState((s as any).id,
|
|
984
|
+
if (mode === FILTER_MODES.ACCEPT && arraysIntersect(payload, platformGeo)) {
|
|
985
|
+
if (s.state !== STREAM_STATES.ACTIVE) {
|
|
986
|
+
await updateStreamState((s as any).id, STREAM_STATES.ACTIVE);
|
|
962
987
|
changed = true;
|
|
963
988
|
}
|
|
964
989
|
}
|