UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

39 lines (38 loc) 1.21 kB
import r from "../managers/braze-instance.js"; import c from "../common/event-logger.js"; import { logger as E, EventTypes as m } from "../../shared-lib/index.js"; import ot from "../triggers/models/trigger-events.js"; import { TriggersProviderFactory as rt } from "../triggers/triggers-provider-factory.js"; import { validateCustomProperties as nt, validateCustomString as mt, } from "../util/validation-utils.js"; import { LOG_CUSTOM_EVENT_STRING as gt } from "../common/constants.js"; export function logCustomEvent(t, e) { if (!r.rr()) return !1; if (null == t || t.length <= 0) return ( E.error( `logCustomEvent requires a non-empty eventName, got "${t}". Ignoring event.`, ), !1 ); if (!mt(t, "log custom event", "the event name")) return !1; const [o, n] = nt( e, gt, "eventProperties", `log custom event "${t}"`, "event", ); if (!o) return !1; const i = r.l(); if (i && i.ge(t)) return E.info(`Custom Event "${t}" is blocklisted, ignoring.`), !1; const s = c.rt(m.CustomEvent, { n: t, p: n }); if (s.W) { E.info(`Logged custom event "${t}".`); for (const o of s.ue) rt.o().ve(ot.pe, [t, e], o); } return s.W; }