@bprotsyk/aso-core 2.1.122 → 2.1.124
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,17 @@ async function updateStreamsForApp(app, platform) {
|
|
|
760
774
|
console.log(`No platform data for platform ${platform}`);
|
|
761
775
|
return false;
|
|
762
776
|
}
|
|
777
|
+
// Перевіряємо чи це не тестова платформа
|
|
778
|
+
if (platform === app_1.EPlatform.TEST) {
|
|
779
|
+
console.log(`Skipping stream update for platform ${platform}: test platform is ignored`);
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
// Перевіряємо чи є directType і чи він трафлєвський
|
|
783
|
+
const directType = platformData.direct?.directType;
|
|
784
|
+
if (!directType || (directType !== app_1.EDirectType.TRAFFLE_KEITARO_OFFER && directType !== app_1.EDirectType.TRAFFLE_OFFER_DIRECT)) {
|
|
785
|
+
console.log(`Skipping stream update for platform ${platform}: directType is not traffle (${directType})`);
|
|
786
|
+
return false;
|
|
787
|
+
}
|
|
763
788
|
const campaign = await findCampaignForAppPlatform(app, platform);
|
|
764
789
|
if (!campaign) {
|
|
765
790
|
console.log(`No campaign found for app ${app.id} (${app.bundle}) and platform ${platform}`);
|
|
@@ -777,10 +802,10 @@ async function updateStreamsForApp(app, platform) {
|
|
|
777
802
|
});
|
|
778
803
|
if (!platformData.enabled) {
|
|
779
804
|
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,
|
|
805
|
+
const isClo = s.name === STREAM_NAMES.CLO;
|
|
806
|
+
const hasCountryFilter = Array.isArray(s.filters) && s.filters.some((f) => f?.name === FILTER_NAMES.COUNTRY);
|
|
807
|
+
if ((isClo || hasCountryFilter) && s.state !== STREAM_STATES.DISABLED) {
|
|
808
|
+
await updateStreamState(s.id, STREAM_STATES.DISABLED);
|
|
784
809
|
changed = true;
|
|
785
810
|
}
|
|
786
811
|
}
|
|
@@ -789,21 +814,21 @@ async function updateStreamsForApp(app, platform) {
|
|
|
789
814
|
// enabled: turn on CLO and geo streams that match platform geo. Leave others as-is.
|
|
790
815
|
const platformGeo = platformData.geo || [];
|
|
791
816
|
for (const s of streams) {
|
|
792
|
-
const isClo = s.name ===
|
|
793
|
-
if (isClo && s.state !==
|
|
794
|
-
await updateStreamState(s.id,
|
|
817
|
+
const isClo = s.name === STREAM_NAMES.CLO;
|
|
818
|
+
if (isClo && s.state !== STREAM_STATES.ACTIVE) {
|
|
819
|
+
await updateStreamState(s.id, STREAM_STATES.ACTIVE);
|
|
795
820
|
changed = true;
|
|
796
821
|
continue;
|
|
797
822
|
}
|
|
798
|
-
const countryFilter = Array.isArray(s.filters) ? s.filters.find((f) => f?.name ===
|
|
823
|
+
const countryFilter = Array.isArray(s.filters) ? s.filters.find((f) => f?.name === FILTER_NAMES.COUNTRY) : null;
|
|
799
824
|
if (!countryFilter)
|
|
800
825
|
continue;
|
|
801
826
|
// Heuristic: enable only geo streams whose payload intersects platform geo when mode is 'accept'.
|
|
802
827
|
const mode = countryFilter?.mode;
|
|
803
828
|
const payload = Array.isArray(countryFilter?.payload) ? countryFilter.payload : [];
|
|
804
|
-
if (mode ===
|
|
805
|
-
if (s.state !==
|
|
806
|
-
await updateStreamState(s.id,
|
|
829
|
+
if (mode === FILTER_MODES.ACCEPT && arraysIntersect(payload, platformGeo)) {
|
|
830
|
+
if (s.state !== STREAM_STATES.ACTIVE) {
|
|
831
|
+
await updateStreamState(s.id, STREAM_STATES.ACTIVE);
|
|
807
832
|
changed = true;
|
|
808
833
|
}
|
|
809
834
|
}
|
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,19 @@ export async function updateStreamsForApp(app: IApp, platform: EPlatform): Promi
|
|
|
909
927
|
return false;
|
|
910
928
|
}
|
|
911
929
|
|
|
930
|
+
// Перевіряємо чи це не тестова платформа
|
|
931
|
+
if (platform === EPlatform.TEST) {
|
|
932
|
+
console.log(`Skipping stream update for platform ${platform}: test platform is ignored`);
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// Перевіряємо чи є directType і чи він трафлєвський
|
|
937
|
+
const directType = platformData.direct?.directType;
|
|
938
|
+
if (!directType || (directType !== EDirectType.TRAFFLE_KEITARO_OFFER && directType !== EDirectType.TRAFFLE_OFFER_DIRECT)) {
|
|
939
|
+
console.log(`Skipping stream update for platform ${platform}: directType is not traffle (${directType})`);
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
|
|
912
943
|
const campaign = await findCampaignForAppPlatform(app, platform);
|
|
913
944
|
if (!campaign) {
|
|
914
945
|
console.log(`No campaign found for app ${app.id} (${app.bundle}) and platform ${platform}`);
|
|
@@ -930,10 +961,10 @@ export async function updateStreamsForApp(app: IApp, platform: EPlatform): Promi
|
|
|
930
961
|
|
|
931
962
|
if (!platformData.enabled) {
|
|
932
963
|
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,
|
|
964
|
+
const isClo = s.name === STREAM_NAMES.CLO;
|
|
965
|
+
const hasCountryFilter = Array.isArray(s.filters) && s.filters.some((f: any) => f?.name === FILTER_NAMES.COUNTRY);
|
|
966
|
+
if ((isClo || hasCountryFilter) && s.state !== STREAM_STATES.DISABLED) {
|
|
967
|
+
await updateStreamState((s as any).id, STREAM_STATES.DISABLED);
|
|
937
968
|
changed = true;
|
|
938
969
|
}
|
|
939
970
|
}
|
|
@@ -943,22 +974,22 @@ export async function updateStreamsForApp(app: IApp, platform: EPlatform): Promi
|
|
|
943
974
|
// enabled: turn on CLO and geo streams that match platform geo. Leave others as-is.
|
|
944
975
|
const platformGeo = platformData.geo || [];
|
|
945
976
|
for (const s of streams) {
|
|
946
|
-
const isClo = s.name ===
|
|
947
|
-
if (isClo && s.state !==
|
|
948
|
-
await updateStreamState((s as any).id,
|
|
977
|
+
const isClo = s.name === STREAM_NAMES.CLO;
|
|
978
|
+
if (isClo && s.state !== STREAM_STATES.ACTIVE) {
|
|
979
|
+
await updateStreamState((s as any).id, STREAM_STATES.ACTIVE);
|
|
949
980
|
changed = true;
|
|
950
981
|
continue;
|
|
951
982
|
}
|
|
952
983
|
|
|
953
|
-
const countryFilter = Array.isArray(s.filters) ? s.filters.find((f: any) => f?.name ===
|
|
984
|
+
const countryFilter = Array.isArray(s.filters) ? s.filters.find((f: any) => f?.name === FILTER_NAMES.COUNTRY) : null;
|
|
954
985
|
if (!countryFilter) continue;
|
|
955
986
|
|
|
956
987
|
// Heuristic: enable only geo streams whose payload intersects platform geo when mode is 'accept'.
|
|
957
988
|
const mode: string | undefined = countryFilter?.mode;
|
|
958
989
|
const payload: string[] = Array.isArray(countryFilter?.payload) ? countryFilter.payload : [];
|
|
959
|
-
if (mode ===
|
|
960
|
-
if (s.state !==
|
|
961
|
-
await updateStreamState((s as any).id,
|
|
990
|
+
if (mode === FILTER_MODES.ACCEPT && arraysIntersect(payload, platformGeo)) {
|
|
991
|
+
if (s.state !== STREAM_STATES.ACTIVE) {
|
|
992
|
+
await updateStreamState((s as any).id, STREAM_STATES.ACTIVE);
|
|
962
993
|
changed = true;
|
|
963
994
|
}
|
|
964
995
|
}
|