UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

56 lines (55 loc) 1.33 kB
import r from "../managers/braze-instance.js"; import { getAlias as ce } from "../managers/utils.js"; import { isObject as It } from "../util/code-utils.js"; import { convertMsToSeconds as X, timestampOrNow as ts, } from "../util/date-utils.js"; export default class ue { constructor(t, s, i, r, e) { (this.userId = t), (this.type = s), (this.time = i), (this.sessionId = r), (this.data = e), (this.userId = t), (this.type = s), (this.time = ts(i)), (this.sessionId = r), (this.data = e); } Ar() { var t; const s = { name: this.type, time: X(this.time), data: this.data || {}, session_id: this.sessionId, }; null != this.userId && (s.user_id = this.userId); const i = (null === (t = r.Sr()) || void 0 === t ? void 0 : t.fh()) || !1; if (!s.user_id && !i) { const t = ce(r.p()); t && (s.alias = t); } return s; } dt() { return { u: this.userId, t: this.type, ts: this.time, s: this.sessionId, d: this.data, }; } static fromJson(t) { return new ue(t.user_id, t.name, t.time, t.session_id, t.data); } static gE(t) { return null != t && It(t) && null != t.t && "" !== t.t; } static qn(t) { return new ue(t.u, t.t, t.ts, t.s, t.d); } }