UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

29 lines (28 loc) 831 B
import { impressOnBottom as f, impressOnTop as j, detectImpression as $, } from "../../common/detect-impression.js"; import { topIsInView as g, bottomIsInView as x } from "../../util/dom-utils.js"; import { logBannerImpressions as B } from "../log-banner-impressions.js"; import { BANNER_HTML_CLASS as I, BANNER_PLACEMENT_ID as k, CONTROL_BANNER_HTML_CLASS as q, } from "./banner-to-html.js"; export function detectBannerImpressions() { const o = document.querySelectorAll(`.${I}, .${q}`), t = []; for (let n = 0; n < o.length; n++) { const s = o[n], i = s.getAttribute(k); if (!i) continue; const m = $.oo(s), r = $.no(s); if (m && r) continue; const e = g(s), c = x(s); e && !m && j(s), c && !r && f(s), $.oo(s) && $.no(s) && t.push(i); } t.length > 0 && B(t); }