@alxxsck/ai-assistant 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,6 +41,15 @@ const widget = new ChatWidgetInstance({
41
41
  interactionSessionId: session.interactionSessionId,
42
42
  expiresAt: session.expiresAt,
43
43
  },
44
+ onRenewSession: async () => {
45
+ const nextSession = await productApi.createLolaInteractionSession();
46
+ widget.setCustomerInteractionSession(nextSession);
47
+ },
48
+ });
49
+
50
+ await widget.track({
51
+ event: "Deposit Form Opened",
52
+ params: { currency: "EUR" },
44
53
  });
45
54
  ```
46
55
 
@@ -69,6 +78,7 @@ The supported instance methods are:
69
78
  ```ts
70
79
  widget.setOpen(true);
71
80
  widget.setCustomerInteractionSession(nextSession);
81
+ await widget.track({ event: "Game Opened", params: { gameId: "42" } });
72
82
  widget.destroy();
73
83
  ```
74
84
 
@@ -77,16 +87,29 @@ latest requested state is applied when the UI is ready. Session replacement upda
77
87
  authenticated HTTP, realtime, message, voice, and command dependencies without
78
88
  recreating the public widget instance.
79
89
 
80
- The widget emits `renew_session` before expiry and after supported authentication
81
- failures. Refresh through the product backend and replace the session:
90
+ The widget calls `onRenewSession` before expiry and after supported authentication
91
+ failures. Refresh through the product backend and replace the session in the
92
+ callback:
82
93
 
83
94
  ```ts
84
- widget.addEventListener("renew_session", async () => {
85
- const nextSession = await productApi.createLolaInteractionSession();
86
- widget.setCustomerInteractionSession(nextSession);
95
+ const widget = new ChatWidgetInstance({
96
+ customerInteractionSession: session,
97
+ onRenewSession: async () => {
98
+ const nextSession = await productApi.createLolaInteractionSession();
99
+ widget.setCustomerInteractionSession(nextSession);
100
+ },
87
101
  });
88
102
  ```
89
103
 
104
+ No event subscription or listener cleanup is required. Parallel renewal signals
105
+ are debounced, and replacing the session cancels a pending duplicate callback.
106
+
107
+ `track` sends product events directly to Lola Backend using the active interaction
108
+ session. The library owns the Lola URL, bearer authentication, event timestamp,
109
+ route context, and idempotency key. Tracking failures are reported through the
110
+ standard widget logger and do not reject into the product flow. A session replaced
111
+ with `setCustomerInteractionSession` is used by all later tracking calls.
112
+
90
113
  The constructor and replacement method reject empty tokens, empty interaction
91
114
  session identifiers, and invalid expiry timestamps.
92
115
 
@@ -1,4 +1,4 @@
1
- import { B as $s } from "./index-lsZ3qmkK.js";
1
+ import { G as $s } from "./index-DBlYyJlj.js";
2
2
  var Fr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3
3
  const Ul = "182", Hf = 0, bc = 1, Wf = 2, js = 1, Ku = 2, Gr = 3, di = 0, jt = 1, Zn = 2, $n = 0, ur = 1, Ac = 2, Ec = 3, wc = 4, Xf = 5, Ci = 100, qf = 101, Yf = 102, Kf = 103, Zf = 104, $f = 200, jf = 201, Jf = 202, Qf = 203, wo = 204, Ro = 205, ed = 206, td = 207, nd = 208, id = 209, rd = 210, sd = 211, ad = 212, od = 213, ld = 214, Co = 0, Po = 1, Io = 2, dr = 3, Do = 4, Lo = 5, Fo = 6, Uo = 7, xa = 0, cd = 1, ud = 2, Un = 0, Zu = 1, $u = 2, ju = 3, Ju = 4, Qu = 5, eh = 6, th = 7, Rc = "attached", hd = "detached", nh = 300, Oi = 301, pr = 302, aa = 303, No = 304, ya = 306, wt = 1e3, En = 1001, Oo = 1002, Lt = 1003, fd = 1004, Ss = 1005, kt = 1006, La = 1007, Ii = 1008, sn = 1009, ih = 1010, rh = 1011, ts = 1012, Nl = 1013, Bn = 1014, wn = 1015, Jn = 1016, Ol = 1017, Bl = 1018, ns = 1020, sh = 35902, ah = 35899, oh = 1021, lh = 1022, mn = 1023, Qn = 1026, Di = 1027, ch = 1028, kl = 1029, mr = 1030, Vl = 1031, zl = 1033, Js = 33776, Qs = 33777, ea = 33778, ta = 33779, Bo = 35840, ko = 35841, Vo = 35842, zo = 35843, Go = 36196, Ho = 37492, Wo = 37496, Xo = 37488, qo = 37489, Yo = 37490, Ko = 37491, Zo = 37808, $o = 37809, jo = 37810, Jo = 37811, Qo = 37812, el = 37813, tl = 37814, nl = 37815, il = 37816, rl = 37817, sl = 37818, al = 37819, ol = 37820, ll = 37821, cl = 36492, ul = 36494, hl = 36495, fl = 36283, dl = 36284, pl = 36285, ml = 36286, uh = 2200, dd = 2201, pd = 2202, oa = 2300, _l = 2301, Fa = 2302, sr = 2400, ar = 2401, la = 2402, Gl = 2500, md = 2501, _d = 3200, Sa = 0, gd = 1, ci = "", Ue = "srgb", _r = "srgb-linear", ca = "linear", nt = "srgb", Gi = 7680, Cc = 519, vd = 512, xd = 513, yd = 514, Hl = 515, Sd = 516, Md = 517, Wl = 518, Td = 519, Pc = 35044, Ic = "300 es", Fn = 2e3, ua = 2001;
4
4
  function hh(s) {