UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

37 lines (36 loc) 1.32 kB
import { logger as b } from "../../shared-lib/index.js"; import { CoreStrings as R } from "../common/constants.js"; import { BannerStrings as x } 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 b.warn(R.ee); const n = r.l(); if (!n) return; if (!g(e) || 0 === e.length) return void b.warn("placementIds should be a non-empty array."); const s = i.o(); if ((!1 === n.Ot() && b.error(x.aa), !s.P())) return void n.V(() => { requestBannersRefresh(e, t, o); }); const a = n.re(); e.length > a && (b.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) || (b.warn( `Placement ID should be a valid utf8 string with no whitespaces, filtering out: ${e}`, ), !1), )).length && (b.info(`Requesting banners for placement IDs: ${JSON.stringify(e)}`), s.O(e, t, o)); }