@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
104 lines (103 loc) • 2.57 kB
JavaScript
import es from "./custom-event-data.js";
import ns from "./custom-event-property-data.js";
import ls from "./filter-set.js";
import bi from "./in-app-message-click-data.js";
import os from "./purchase-data.js";
import fs from "./purchase-property-data.js";
import jr from "./push-click-data.js";
import ot from "./trigger-events.js";
import { logger as b } from "../../../shared-lib/index.js";
import { getErrorMessage as hi } from "../../util/error-utils.js";
export default class pi {
constructor(e, t) {
(this.type = e), (this.data = t), (this.type = e), (this.data = t);
}
_c(e, t) {
return pi.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 b.info("Failed to unencode analytics id " + e + ": " + hi(t)), !1;
}
return t === r.split("_")[0];
}
static fromJson(e) {
const t = e.type;
let r = null;
switch (t) {
case pi.la.OPEN:
case pi.la.Os:
break;
case pi.la.qr:
r = os.fromJson(e.data);
break;
case pi.la.Pc:
r = fs.fromJson(e.data);
break;
case pi.la.Sr:
r = jr.fromJson(e.data);
break;
case pi.la.he:
r = es.fromJson(e.data);
break;
case pi.la.Rc:
r = ns.fromJson(e.data);
break;
case pi.la.rm:
r = bi.fromJson(e.data);
}
return new pi(t, r);
}
qt() {
return { t: this.type, d: this.data ? this.data.qt() : null };
}
static _u(e) {
let t,
r = null;
switch (e.t) {
case pi.la.OPEN:
case pi.la.Os:
break;
case pi.la.qr:
r = new os(e.d);
break;
case pi.la.Pc:
(t = e.d || {}), (r = new fs(t.id, ls._u(t.pf || [])));
break;
case pi.la.Sr:
r = new jr(e.d);
break;
case pi.la.he:
r = new es(e.d);
break;
case pi.la.Rc:
(t = e.d || {}), (r = new ns(t.e, ls._u(t.pf || [])));
break;
case pi.la.rm:
r = new bi(e.d);
}
return new pi(e.t, r);
}
}
(pi.la = {
OPEN: "open",
qr: "purchase",
Pc: "purchase_property",
Sr: "push_click",
he: "custom_event",
Rc: "custom_event_property",
rm: "iam_click",
Os: "test",
}),
(pi.Ec = {}),
(pi.Ec[pi.la.OPEN] = ot.OPEN),
(pi.Ec[pi.la.qr] = ot.qr),
(pi.Ec[pi.la.Pc] = ot.qr),
(pi.Ec[pi.la.Sr] = ot.Sr),
(pi.Ec[pi.la.he] = ot.he),
(pi.Ec[pi.la.Rc] = ot.he),
(pi.Ec[pi.la.rm] = ot.rm),
(pi.Ec[pi.la.Os] = ot.Os);