UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

104 lines (103 loc) 2.57 kB
import ts from "./custom-event-data.js"; import rs from "./custom-event-property-data.js"; import is from "./filter-set.js"; import ni from "./in-app-message-click-data.js"; import ns from "./purchase-data.js"; import hs from "./purchase-property-data.js"; import ur from "./push-click-data.js"; import et from "./trigger-events.js"; import { logger as N } from "../../../shared-lib/index.js"; import { getErrorMessage as si } from "../../util/error-utils.js"; export default class ri { constructor(e, t) { (this.type = e), (this.data = t), (this.type = e), (this.data = t); } _c(e, t) { return ri.Ec[this.type] === e && (null == this.data || this.data.zc(t)); } static sf(e, t) { let r = null; try { r = window.atob(e); } catch (t) { return N.info("Failed to unencode analytics id " + e + ": " + si(t)), !1; } return t === r.split("_")[0]; } static fromJson(e) { const t = e.type; let r = null; switch (t) { case ri.Or.OPEN: case ri.Or.As: break; case ri.Or.Rr: r = ns.fromJson(e.data); break; case ri.Or.Cc: r = hs.fromJson(e.data); break; case ri.Or.hr: r = ur.fromJson(e.data); break; case ri.Or.Ee: r = ts.fromJson(e.data); break; case ri.Or.Pc: r = rs.fromJson(e.data); break; case ri.Or.Zr: r = ni.fromJson(e.data); } return new ri(t, r); } bt() { return { t: this.type, d: this.data ? this.data.bt() : null }; } static Rn(e) { let t, r = null; switch (e.t) { case ri.Or.OPEN: case ri.Or.As: break; case ri.Or.Rr: r = new ns(e.d); break; case ri.Or.Cc: (t = e.d || {}), (r = new hs(t.id, is.Rn(t.pf || []))); break; case ri.Or.hr: r = new ur(e.d); break; case ri.Or.Ee: r = new ts(e.d); break; case ri.Or.Pc: (t = e.d || {}), (r = new rs(t.e, is.Rn(t.pf || []))); break; case ri.Or.Zr: r = new ni(e.d); } return new ri(e.t, r); } } (ri.Or = { OPEN: "open", Rr: "purchase", Cc: "purchase_property", hr: "push_click", Ee: "custom_event", Pc: "custom_event_property", Zr: "iam_click", As: "test", }), (ri.Ec = {}), (ri.Ec[ri.Or.OPEN] = et.OPEN), (ri.Ec[ri.Or.Rr] = et.Rr), (ri.Ec[ri.Or.Cc] = et.Rr), (ri.Ec[ri.Or.hr] = et.hr), (ri.Ec[ri.Or.Ee] = et.Ee), (ri.Ec[ri.Or.Pc] = et.Ee), (ri.Ec[ri.Or.Zr] = et.Zr), (ri.Ec[ri.Or.As] = et.As);