@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
37 lines (36 loc) • 1.32 kB
JavaScript
import { logger as E } from "../../shared-lib/index.js";
import { CoreStrings as R } from "../common/constants.js";
import { BannerStrings as j } from "./constants.js";
import r from "../managers/braze-instance.js";
import { isArray as g } from "../util/code-utils.js";
import { isValidBannerPlacementId as J } from "../util/validation-utils.js";
import i from "./banner-provider-factory.js";
export function requestBannersRefresh(e, t, o) {
if (!r.rr()) return void E.warn(R.ee);
const n = r.l();
if (!n) return;
if (!g(e) || 0 === e.length)
return void E.warn("placementIds should be a non-empty array.");
const s = i.o();
if ((!1 === n.Jt() && E.error(j.aa), !s.P()))
return void n.V(() => {
requestBannersRefresh(e, t, o);
});
const a = n.re();
e.length > a &&
(E.warn(
`Number of placement IDs requested exceeds the max allowed. Trimming placementIds array from length ${e.length} to ${a} (max allowed).`,
),
(e = e.slice(0, a))),
0 !==
(e = e.filter(
(e) =>
!!J(e) ||
(E.warn(
`Placement ID should be a valid utf8 string with no whitespaces, filtering out: ${e}`,
),
!1),
)).length &&
(E.info(`Requesting banners for placement IDs: ${JSON.stringify(e)}`),
s.O(e, t, o));
}