@launchdarkly/o11y 1.3.1 → 1.4.1

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/dist/observe.d.ts CHANGED
@@ -57,14 +57,29 @@ declare type CommonOptions = {
57
57
  */
58
58
  storageMode?: 'sessionStorage' | 'localStorage';
59
59
  /**
60
- * By default, session data is stored in the `sessionStorage` of the browser.
60
+ * By default, session data is stored in the `localStorage` of the browser.
61
61
  * Set to `true` to store session data in a cookie instead.
62
62
  * This can help with compliance for cookie-consent regulation.
63
63
  */
64
64
  sessionCookie?: boolean;
65
+ /**
66
+ * Set the `Domain` attribute of the session cookie so the same session can
67
+ * be continued on different subdomains (e.g. `app.example.com` and
68
+ * `checkout.example.com` both see a cookie set for `example.com`).
69
+ * Only applies when `sessionCookie` is set to `true`.
70
+ * By default, the cookie is scoped to the exact host that created it.
71
+ */
72
+ sessionCookieDomain?: string;
65
73
  /**
66
74
  * Specifies if Highlight should not automatically initialize when the class is created.
67
75
  * This should be used with `.start()` and `.stop()` if you want to control when Highlight records.
76
+ *
77
+ * While `start()` has not been called, calls that can be deferred (logs,
78
+ * errors, metrics, `track`) are kept in memory and delivered once
79
+ * `start()` runs. `start()` and `stop()` can safely be called before the
80
+ * SDK has initialized: a start made too early resolves once the SDK is
81
+ * attached. Calls that cannot be deferred (synchronous span callbacks) run
82
+ * their callback on a no-op span while the SDK is not started.
68
83
  * @default false
69
84
  */
70
85
  manualStart?: boolean;
@@ -414,10 +429,15 @@ export declare class Observe extends Plugin_2<ObserveOptions> implements LDPlugi
414
429
  declare interface Observe_2 {
415
430
  /**
416
431
  * Start the observability data capture when running in `manualStart` mode.
432
+ * Can safely be called before the SDK has initialized (e.g. before the
433
+ * plugin registers): the call resolves once the SDK is attached and
434
+ * started, without throwing.
417
435
  */
418
436
  start: () => Promise<void>;
419
437
  /**
420
438
  * Stop the observability data capture.
439
+ * Can safely be called before the SDK has initialized; before `start()`
440
+ * it cancels a pending start instead of throwing.
421
441
  */
422
442
  stop: () => Promise<void>;
423
443
  /**
package/dist/observe.js CHANGED
@@ -1,7 +1,7 @@
1
- import "./common-BjaGmQrE.js";
2
- import { O as e } from "./observe-D78YYNE1.js";
3
- import "./LDObserve-DhF3vCDR.js";
4
- import "./buffer-BjzLorpP.js";
1
+ import "./common-D8kkCWo3.js";
2
+ import { O as e } from "./observe-BCebRa17.js";
3
+ import "./LDObserve-BQr7RYVC.js";
4
+ import "./buffer-CwCRPuMA.js";
5
5
  export {
6
6
  e as Observe
7
7
  };
@@ -40,8 +40,8 @@ var fe = (e, t, s) => new Promise((l, c) => {
40
40
  }, b = (m) => m.done ? l(m.value) : Promise.resolve(m.value).then(u, f);
41
41
  b((s = s.apply(e, t)).next());
42
42
  });
43
- import { y as Bn, z as eo, a as ke, S as Ye, d as Be, g as ri, r as _s, G as ni, b as to, c as io, n as so, o as ro, l as $s, e as li, f as rt, F as qs, V as no, P as lo, h as oo, q as ao, H as er, M as co, i as uo, s as ho, L as po, A as mo, B as tr, C as fo, D as bo, p as yo, k as ir, u as Zo, E as go, x as So, I as sr, J as Xo, K as Ro, N as Go, O as Vo, Q as Wo, R as Io, T as wo } from "./common-BjaGmQrE.js";
44
- import { L as Co, s as xo, i as Me, a as Jt } from "./buffer-BjzLorpP.js";
43
+ import { z as Bn, A as eo, a as Le, S as Ye, d as Be, g as ri, r as _s, G as ni, b as to, c as io, o as so, q as ro, m as $s, e as li, f as rt, F as qs, V as no, P as lo, h as oo, t as ao, H as er, M as co, i as uo, s as ho, L as po, B as mo, C as tr, D as fo, E as bo, p as yo, l as ir, v as Zo, I as go, y as So, J as sr, K as Xo, N as Ro, O as Go, Q as Vo, R as Wo, T as Io, U as wo } from "./common-D8kkCWo3.js";
44
+ import { L as Co, s as xo, i as Me, a as Jt } from "./buffer-CwCRPuMA.js";
45
45
  import { LDRecord as vo } from "./LDRecord.js";
46
46
  const Lo = {
47
47
  key: "_sid"
@@ -9739,13 +9739,13 @@ const { addCustomEvent: Nn } = Ne, ru = (e, t, s) => {
9739
9739
  window.removeEventListener("storage", s), XMLHttpRequest.prototype.send = t;
9740
9740
  };
9741
9741
  }, Tn = () => {
9742
- const e = ke(
9742
+ const e = Le(
9743
9743
  "ajs_user_id"
9744
9744
  /* USER_ID */
9745
- ), t = ke(
9745
+ ), t = Le(
9746
9746
  "ajs_user_traits"
9747
9747
  /* USER_TRAITS */
9748
- ), s = ke(
9748
+ ), s = Le(
9749
9749
  "ajs_anonymous_id"
9750
9750
  /* ANONYMOUS_ID */
9751
9751
  );
@@ -9763,7 +9763,7 @@ const { addCustomEvent: Nn } = Ne, ru = (e, t, s) => {
9763
9763
  } catch (c) {
9764
9764
  return !1;
9765
9765
  }
9766
- const s = uu(t), l = ke(
9766
+ const s = uu(t), l = Le(
9767
9767
  Ye.SEGMENT_LAST_SENT_HASH_KEY
9768
9768
  );
9769
9769
  return l === void 0 ? (Be(Ye.SEGMENT_LAST_SENT_HASH_KEY, s), !0) : s !== l ? (Be(Ye.SEGMENT_LAST_SENT_HASH_KEY, s), !0) : !1;
@@ -9938,13 +9938,13 @@ function Zu(e) {
9938
9938
  }
9939
9939
  }
9940
9940
  const Kn = "iframe parent ready", Fn = "iframe ok", ft = "highlightLogs", gu = (e) => {
9941
- let t = ke(ft) || "";
9941
+ let t = Le(ft) || "";
9942
9942
  t = t + "[" + (/* @__PURE__ */ new Date()).getTime() + "] " + e + `
9943
9943
  `, Be(ft, t);
9944
- }, Su = () => ke(ft) || "", Xu = (e) => {
9944
+ }, Su = () => Le(ft) || "", Xu = (e) => {
9945
9945
  if (!e)
9946
9946
  return;
9947
- let t = ke(ft) || "";
9947
+ let t = Le(ft) || "";
9948
9948
  t && (t.startsWith(e) ? (t = t.slice(e.length), Be(ft, t)) : gu(
9949
9949
  "Unable to clear logs " + e.replace(`
9950
9950
  `, " ") + " from " + t.replace(`
@@ -10068,7 +10068,7 @@ var Vu = /* @__PURE__ */ dt(De, 9, 0), Wu = /* @__PURE__ */ dt(Ht, 5, 0), Bl = f
10068
10068
  return (e + 7) / 8 | 0;
10069
10069
  }, Ql = function(e, t, s) {
10070
10070
  return (s == null || s > e.length) && (s = e.length), new We(e.subarray(t, s));
10071
- }, Je = function(e, t, s) {
10071
+ }, ke = function(e, t, s) {
10072
10072
  s <<= t & 7;
10073
10073
  var l = t / 8 | 0;
10074
10074
  e[l] |= s, e[l + 1] |= s >> 8;
@@ -10153,7 +10153,7 @@ var Vu = /* @__PURE__ */ dt(De, 9, 0), Wu = /* @__PURE__ */ dt(Ht, 5, 0), Bl = f
10153
10153
  e[c + u + 4] = s[u];
10154
10154
  return (c + 4 + l) * 8;
10155
10155
  }, On = function(e, t, s, l, c, u, f, b, m, h, d) {
10156
- Je(t, d++, s), ++c[256];
10156
+ ke(t, d++, s), ++c[256];
10157
10157
  for (var r = ms(c, 15), n = r.t, i = r.l, o = ms(u, 15), a = o.t, p = o.l, X = Hn(n), Z = X.c, S = X.n, G = Hn(a), g = G.c, y = G.n, R = new Ve(19), I = 0; I < Z.length; ++I)
10158
10158
  ++R[Z[I] & 31];
10159
10159
  for (var I = 0; I < g.length; ++I)
@@ -10164,17 +10164,17 @@ var Vu = /* @__PURE__ */ dt(De, 9, 0), Wu = /* @__PURE__ */ dt(Ht, 5, 0), Bl = f
10164
10164
  if (m >= 0 && D <= E && D <= w)
10165
10165
  return Dl(t, d, e.subarray(m, m + h));
10166
10166
  var te, Y, F, B;
10167
- if (Je(t, d, 1 + (w < E)), d += 2, w < E) {
10167
+ if (ke(t, d, 1 + (w < E)), d += 2, w < E) {
10168
10168
  te = dt(n, i, 0), Y = n, F = dt(a, p, 0), B = a;
10169
10169
  var M = dt(W, v, 0);
10170
- Je(t, d, S - 257), Je(t, d + 5, y - 1), Je(t, d + 10, x - 4), d += 14;
10170
+ ke(t, d, S - 257), ke(t, d + 5, y - 1), ke(t, d + 10, x - 4), d += 14;
10171
10171
  for (var I = 0; I < x; ++I)
10172
- Je(t, d + 3 * I, W[Mn[I]]);
10172
+ ke(t, d + 3 * I, W[Mn[I]]);
10173
10173
  d += 3 * x;
10174
10174
  for (var j = [Z, g], ne = 0; ne < 2; ++ne)
10175
10175
  for (var C = j[ne], I = 0; I < C.length; ++I) {
10176
10176
  var oe = C[I] & 31;
10177
- Je(t, d, M[oe]), d += W[oe], oe > 15 && (Je(t, d, C[I] >> 5 & 127), d += C[I] >> 12);
10177
+ ke(t, d, M[oe]), d += W[oe], oe > 15 && (ke(t, d, C[I] >> 5 & 127), d += C[I] >> 12);
10178
10178
  }
10179
10179
  } else
10180
10180
  te = Vu, Y = De, F = Wu, B = Ht;
@@ -10182,7 +10182,7 @@ var Vu = /* @__PURE__ */ dt(De, 9, 0), Wu = /* @__PURE__ */ dt(Ht, 5, 0), Bl = f
10182
10182
  var ee = l[I];
10183
10183
  if (ee > 255) {
10184
10184
  var oe = ee >> 18 & 31;
10185
- nt(t, d, te[oe + 257]), d += Y[oe + 257], oe > 7 && (Je(t, d, ee >> 23 & 31), d += Hs[oe]);
10185
+ nt(t, d, te[oe + 257]), d += Y[oe + 257], oe > 7 && (ke(t, d, ee >> 23 & 31), d += Hs[oe]);
10186
10186
  var de = ee & 31;
10187
10187
  nt(t, d, F[de]), d += B[de], de > 3 && (nt(t, d, ee >> 5 & 8191), d += Os[de]);
10188
10188
  } else
@@ -10343,7 +10343,7 @@ function Ku(e) {
10343
10343
  t && (self.URL || self.webkitURL).revokeObjectURL(t);
10344
10344
  }
10345
10345
  }
10346
- var Le = /* @__PURE__ */ ((e) => (e[e.Initialize = 0] = "Initialize", e[e.Reset = 1] = "Reset", e[e.AsyncEvents = 2] = "AsyncEvents", e[e.Identify = 3] = "Identify", e[e.Properties = 4] = "Properties", e[e.Metrics = 5] = "Metrics", e[e.Feedback = 6] = "Feedback", e[e.CustomEvent = 7] = "CustomEvent", e[e.Stop = 8] = "Stop", e[e.GetStatus = 9] = "GetStatus", e))(Le || {});
10346
+ var Je = /* @__PURE__ */ ((e) => (e[e.Initialize = 0] = "Initialize", e[e.Reset = 1] = "Reset", e[e.AsyncEvents = 2] = "AsyncEvents", e[e.Identify = 3] = "Identify", e[e.Properties = 4] = "Properties", e[e.Metrics = 5] = "Metrics", e[e.Feedback = 6] = "Feedback", e[e.CustomEvent = 7] = "CustomEvent", e[e.Stop = 8] = "Stop", e[e.GetStatus = 9] = "GetStatus", e))(Je || {});
10347
10347
  const Fu = ({
10348
10348
  apiKey: e
10349
10349
  }) => {
@@ -10533,13 +10533,13 @@ class Hu {
10533
10533
  var l, c, u, f, b, m;
10534
10534
  this.options = t, typeof ((l = this.options) == null ? void 0 : l.debug) == "boolean" ? this.debugOptions = this.options.debug ? { clientInteractions: !0 } : {} : this.debugOptions = (u = (c = this.options) == null ? void 0 : c.debug) != null ? u : {}, this.logger = new Co(this.debugOptions.clientInteractions), (f = this.options) != null && f.debug && xo(!0), this._worker = new Ku(), this._worker.onmessage = (h) => {
10535
10535
  var d, r, n;
10536
- ((d = h.data.response) == null ? void 0 : d.type) === Le.AsyncEvents ? (this._eventBytesSinceSnapshot += h.data.response.eventsSize, this.logger.log(
10536
+ ((d = h.data.response) == null ? void 0 : d.type) === Je.AsyncEvents ? (this._eventBytesSinceSnapshot += h.data.response.eventsSize, this.logger.log(
10537
10537
  `Web worker sent payloadID ${h.data.response.id} size ${h.data.response.eventsSize} bytes, compression ratio ${h.data.response.eventsSize / h.data.response.compressedSize}.
10538
10538
  Total since snapshot: ${(this._eventBytesSinceSnapshot / 1e6).toFixed(1)}MB`
10539
- )) : ((r = h.data.response) == null ? void 0 : r.type) === Le.CustomEvent ? this.addCustomEvent(
10539
+ )) : ((r = h.data.response) == null ? void 0 : r.type) === Je.CustomEvent ? this.addCustomEvent(
10540
10540
  h.data.response.tag,
10541
10541
  h.data.response.payload
10542
- ) : ((n = h.data.response) == null ? void 0 : n.type) === Le.Stop && (Me(
10542
+ ) : ((n = h.data.response) == null ? void 0 : n.type) === Je.Stop && (Me(
10543
10543
  "worker.onmessage",
10544
10544
  "warn",
10545
10545
  "Stopping recording due to worker failure",
@@ -10578,8 +10578,8 @@ class Hu {
10578
10578
  let c, u;
10579
10579
  if (!t)
10580
10580
  try {
10581
- c = ke(Ye.USER_IDENTIFIER);
10582
- const f = ke(
10581
+ c = Le(Ye.USER_IDENTIFIER);
10582
+ const f = Le(
10583
10583
  Ye.USER_OBJECT
10584
10584
  );
10585
10585
  f && (u = JSON.parse(f));
@@ -10587,7 +10587,7 @@ class Hu {
10587
10587
  }
10588
10588
  for (const f of Object.values(Ye))
10589
10589
  _s(f);
10590
- this.sessionData.sessionSecureID = s ? ni(`${this.organizationID}-${s}`) : ni(), this.sessionData.sessionKey = s, this.sessionData.sessionStartTime = Date.now(), this.options.sessionSecureID = this.sessionData.sessionSecureID, this.stop(), this._worker.postMessage({ message: { type: Le.Reset } }), yield this.start(), c && u && this.identify(c, u);
10590
+ this.sessionData.sessionSecureID = s ? ni(`${this.organizationID}-${s}`) : ni(), this.sessionData.sessionKey = s, this.sessionData.sessionStartTime = Date.now(), this.options.sessionSecureID = this.sessionData.sessionSecureID, this.stop(), this._worker.postMessage({ message: { type: Je.Reset } }), yield this.start(), c && u && this.identify(c, u);
10591
10591
  });
10592
10592
  }
10593
10593
  _initMembers(t) {
@@ -10627,7 +10627,7 @@ class Hu {
10627
10627
  t.toString()
10628
10628
  ), Be(Ye.USER_OBJECT, JSON.stringify(s)), this._worker.postMessage({
10629
10629
  message: {
10630
- type: Le.Identify,
10630
+ type: Je.Identify,
10631
10631
  userIdentifier: t,
10632
10632
  userObject: s,
10633
10633
  source: l
@@ -10647,7 +10647,7 @@ class Hu {
10647
10647
  }
10648
10648
  }), this._worker.postMessage({
10649
10649
  message: {
10650
- type: Le.Properties,
10650
+ type: Je.Properties,
10651
10651
  propertiesObject: l,
10652
10652
  propertyType: s
10653
10653
  }
@@ -10679,7 +10679,7 @@ class Hu {
10679
10679
  this.sessionData,
10680
10680
  this.options
10681
10681
  ), this.sessionData = (c = ri(this.sessionData.sessionSecureID)) != null ? c : this.sessionData, (u = this.sessionData) != null && u.sessionStartTime ? this._recordingStartTime = (f = this.sessionData) == null ? void 0 : f.sessionStartTime : (this._recordingStartTime = (/* @__PURE__ */ new Date()).getTime(), this.sessionData.sessionStartTime = this._recordingStartTime);
10682
- let n = ke($s.CLIENT_ID);
10682
+ let n = Le($s.CLIENT_ID);
10683
10683
  n || (n = ni(), Be($s.CLIENT_ID, n));
10684
10684
  let i;
10685
10685
  this.options.disableSessionRecording || this.options.disableNetworkRecording !== void 0 || typeof this.options.networkRecording == "boolean" ? i = !1 : i = ((b = this.options.networkRecording) == null ? void 0 : b.recordHeadersAndBody) || !1;
@@ -10725,7 +10725,7 @@ Project ID: ${this.sessionData.projectID}
10725
10725
  SessionSecureID: ${this.sessionData.sessionSecureID}`
10726
10726
  ), this.options.sessionSecureID = this.sessionData.sessionSecureID, this._worker.postMessage({
10727
10727
  message: {
10728
- type: Le.Initialize,
10728
+ type: Je.Initialize,
10729
10729
  sessionSecureID: this.sessionData.sessionSecureID,
10730
10730
  backend: this._backendUrl,
10731
10731
  debug: !!this.debugOptions.clientInteractions,
@@ -10978,22 +10978,8 @@ SessionSecureID: ${this.sessionData.sessionSecureID}`
10978
10978
  yield Ne.snapshotCanvas(t);
10979
10979
  });
10980
10980
  }
10981
- addSessionFeedback({
10982
- timestamp: t,
10983
- verbatim: s,
10984
- user_email: l,
10985
- user_name: c
10986
- }) {
10987
- var u;
10988
- this._worker.postMessage({
10989
- message: {
10990
- type: Le.Feedback,
10991
- verbatim: s,
10992
- timestamp: t,
10993
- userName: c || this.sessionData.userIdentifier,
10994
- userEmail: l || ((u = this.sessionData.userObject) == null ? void 0 : u.name)
10995
- }
10996
- });
10981
+ /** @deprecated Session feedback is no longer supported. This is a no-op. */
10982
+ addSessionFeedback(t) {
10997
10983
  }
10998
10984
  // Reset the events array and push to a backend.
10999
10985
  _save() {
@@ -11077,7 +11063,7 @@ SessionSecureID: ${this.sessionData.sessionSecureID}`
11077
11063
  } else
11078
11064
  this._worker.postMessage({
11079
11065
  message: {
11080
- type: Le.AsyncEvents,
11066
+ type: Je.AsyncEvents,
11081
11067
  id: f,
11082
11068
  events: l,
11083
11069
  messages: [],
@@ -11193,7 +11179,12 @@ class Qu extends go {
11193
11179
  sessionSecureID: this.sessionSecureID,
11194
11180
  privacySetting: (c = l == null ? void 0 : l.privacySetting) != null ? c : "strict"
11195
11181
  });
11196
- this.record = new Hu(i), l != null && l.manualStart || this.record.start(), vo.load(this.record), !((f = (u = l == null ? void 0 : l.integrations) == null ? void 0 : u.mixpanel) != null && f.disabled) && ((m = (b = l == null ? void 0 : l.integrations) == null ? void 0 : b.mixpanel) != null && m.projectToken) && Mu(l.integrations.mixpanel), !((d = (h = l == null ? void 0 : l.integrations) == null ? void 0 : h.amplitude) != null && d.disabled) && ((n = (r = l == null ? void 0 : l.integrations) == null ? void 0 : r.amplitude) != null && n.apiKey) && Fu(l.integrations.amplitude);
11182
+ this.record = new Hu(i);
11183
+ const o = l != null && l.manualStart ? void 0 : this.record.start();
11184
+ vo.load(this.record, {
11185
+ ready: !(l != null && l.manualStart),
11186
+ started: o
11187
+ }), !((f = (u = l == null ? void 0 : l.integrations) == null ? void 0 : u.mixpanel) != null && f.disabled) && ((m = (b = l == null ? void 0 : l.integrations) == null ? void 0 : b.mixpanel) != null && m.projectToken) && Mu(l.integrations.mixpanel), !((d = (h = l == null ? void 0 : l.integrations) == null ? void 0 : h.amplitude) != null && d.disabled) && ((n = (r = l == null ? void 0 : l.integrations) == null ? void 0 : r.amplitude) != null && n.apiKey) && Fu(l.integrations.amplitude);
11197
11188
  } catch (i) {
11198
11189
  Me(
11199
11190
  "Error initializing @launchdarkly/session-replay SDK",
@@ -11272,7 +11263,7 @@ export {
11272
11263
  lu as C,
11273
11264
  ou as F,
11274
11265
  Kn as I,
11275
- Le as M,
11266
+ Je as M,
11276
11267
  au as P,
11277
11268
  Qu as R,
11278
11269
  cu as S,
@@ -11290,4 +11281,4 @@ export {
11290
11281
  Ne as r,
11291
11282
  Mu as s
11292
11283
  };
11293
- //# sourceMappingURL=record-BZHDLKsW.js.map
11284
+ //# sourceMappingURL=record-DG2IcHxO.js.map