@launchdarkly/observability 0.1.16 → 0.1.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @launchdarkly/observability
2
2
 
3
+ ## 0.1.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 3f513ca: remove verbosity of user instrumentation events by default.
8
+ only reports click, input, and submit window events as spans unless `otel.eventNames` is provided.
9
+ - Updated dependencies [3f513ca]
10
+ - highlight.run@9.18.13
11
+
3
12
  ## 0.1.16
4
13
 
5
14
  ### Patch Changes
@@ -13199,17 +13199,20 @@ class $g extends Dg {
13199
13199
  super.export(e, i);
13200
13200
  }
13201
13201
  }
13202
- const Fg = "OT_ZONE_CONTEXT", Vg = "Navigation:";
13203
- function Gg() {
13202
+ const Fg = "OT_ZONE_CONTEXT", Vg = "Navigation:", Gg = ["click", "input", "submit"];
13203
+ function Hg() {
13204
13204
  return !1;
13205
13205
  }
13206
13206
  const kr = class xe extends Ba {
13207
13207
  constructor(e = {}) {
13208
+ var n;
13208
13209
  super(
13209
13210
  xe.moduleName,
13210
13211
  xe.version,
13211
13212
  e
13212
- ), D(this, "_spansData", /* @__PURE__ */ new WeakMap()), D(this, "_zonePatched"), D(this, "_wrappedListeners", /* @__PURE__ */ new WeakMap()), D(this, "_eventsSpanMap", /* @__PURE__ */ new WeakMap()), D(this, "_shouldPreventSpanCreation"), this._shouldPreventSpanCreation = typeof e?.shouldPreventSpanCreation == "function" ? e.shouldPreventSpanCreation : Gg;
13213
+ ), D(this, "_spansData", /* @__PURE__ */ new WeakMap()), D(this, "_zonePatched"), D(this, "_wrappedListeners", /* @__PURE__ */ new WeakMap()), D(this, "_eventsSpanMap", /* @__PURE__ */ new WeakMap()), D(this, "_eventNames"), D(this, "_shouldPreventSpanCreation"), this._eventNames = new Set(
13214
+ (n = e?.eventNames) != null ? n : Gg
13215
+ ), this._shouldPreventSpanCreation = typeof e?.shouldPreventSpanCreation == "function" ? e.shouldPreventSpanCreation : Hg;
13213
13216
  }
13214
13217
  init() {
13215
13218
  }
@@ -13229,7 +13232,7 @@ const kr = class xe extends Ba {
13229
13232
  * Controls whether or not to create a span, based on the event type.
13230
13233
  */
13231
13234
  _allowEventName(e) {
13232
- return !0;
13235
+ return this._eventNames.has(e);
13233
13236
  }
13234
13237
  /**
13235
13238
  * Creates a new span
@@ -13597,8 +13600,8 @@ const kr = class xe extends Ba {
13597
13600
  }
13598
13601
  };
13599
13602
  D(kr, "version", "0.1.0"), D(kr, "moduleName", "user-interaction");
13600
- let Hg = kr, Ne = {}, Ke;
13601
- const vn = "highlight.record", qg = "highlight.session_id", zg = "launchdarkly.js.log", Xg = (t, e) => {
13603
+ let qg = kr, Ne = {}, Ke;
13604
+ const vn = "highlight.record", zg = "highlight.session_id", Xg = "launchdarkly.js.log", Kg = (t, e) => {
13602
13605
  var n, r, i, o, a, u, c, s, l;
13603
13606
  if (Ne.tracerProvider !== void 0) {
13604
13607
  console.warn("OTEL already initialized. Skipping...");
@@ -13623,7 +13626,7 @@ const vn = "highlight.record", qg = "highlight.session_id", zg = "launchdarkly.j
13623
13626
  }, v = new Bg(
13624
13627
  y,
13625
13628
  e
13626
- ), _ = new Kg(v, {
13629
+ ), _ = new Yg(v, {
13627
13630
  maxExportBatchSize: 100,
13628
13631
  maxQueueSize: 1e3,
13629
13632
  exportTimeoutMillis: y.timeoutMillis,
@@ -13651,10 +13654,14 @@ const vn = "highlight.record", qg = "highlight.session_id", zg = "launchdarkly.j
13651
13654
  applyCustomAttributesOnSpan: {
13652
13655
  documentLoad: So,
13653
13656
  documentFetch: So,
13654
- resourceFetch: Jg
13657
+ resourceFetch: Qg
13655
13658
  }
13656
13659
  })
13657
- ), ((u = t.instrumentations) == null ? void 0 : u["@opentelemetry/instrumentation-user-interaction"]) !== !1 && k.push(new Hg()), (c = t.networkRecordingOptions) != null && c.enabled && (((s = t.instrumentations) == null ? void 0 : s["@opentelemetry/instrumentation-fetch"]) !== !1 && k.push(
13660
+ ), ((u = t.instrumentations) == null ? void 0 : u["@opentelemetry/instrumentation-user-interaction"]) !== !1 && k.push(
13661
+ new qg({
13662
+ eventNames: t.eventNames
13663
+ })
13664
+ ), (c = t.networkRecordingOptions) != null && c.enabled && (((s = t.instrumentations) == null ? void 0 : s["@opentelemetry/instrumentation-fetch"]) !== !1 && k.push(
13658
13665
  new Vd({
13659
13666
  propagateTraceHeaderCorsUrls: wo(
13660
13667
  t.tracingOrigins
@@ -13725,7 +13732,7 @@ const vn = "highlight.record", qg = "highlight.session_id", zg = "launchdarkly.j
13725
13732
  propagator: new Sa({
13726
13733
  propagators: [
13727
13734
  new ma(),
13728
- new Yg({
13735
+ new Wg({
13729
13736
  backendUrl: p,
13730
13737
  otlpEndpoint: t.otlpEndpoint,
13731
13738
  tracingOrigins: t.tracingOrigins,
@@ -13735,15 +13742,15 @@ const vn = "highlight.record", qg = "highlight.session_id", zg = "launchdarkly.j
13735
13742
  })
13736
13743
  });
13737
13744
  };
13738
- class Kg extends Va {
13745
+ class Yg extends Va {
13739
13746
  onStart(e, n) {
13740
- e.setAttribute(qg, Ee()), super.onStart(e, n);
13747
+ e.setAttribute(zg, Ee()), super.onStart(e, n);
13741
13748
  }
13742
13749
  onEnd(e) {
13743
13750
  e.attributes[vn] !== !1 && super.onEnd(e);
13744
13751
  }
13745
13752
  }
13746
- class Yg extends wa {
13753
+ class Wg extends wa {
13747
13754
  constructor(e) {
13748
13755
  super(), D(this, "highlightEndpoints"), D(this, "tracingOrigins"), D(this, "urlBlocklist"), this.highlightEndpoints = [
13749
13756
  e.backendUrl,
@@ -13758,7 +13765,7 @@ class Yg extends wa {
13758
13765
  if (!o || !o.attributes)
13759
13766
  return;
13760
13767
  const a = o.attributes["http.url"];
13761
- typeof a == "string" && (Wg(
13768
+ typeof a == "string" && (Jg(
13762
13769
  a,
13763
13770
  this.highlightEndpoints,
13764
13771
  this.tracingOrigins,
@@ -13818,7 +13825,7 @@ const Cs = "highlight-browser", qt = Cs, bo = () => {
13818
13825
  Object.fromEntries(u.searchParams)
13819
13826
  )
13820
13827
  });
13821
- }, Wg = (t, e, n, r) => r != null && r.some(
13828
+ }, Jg = (t, e, n, r) => r != null && r.some(
13822
13829
  (i) => t.toLowerCase().includes(i)
13823
13830
  ) ? !1 : Py(
13824
13831
  t,
@@ -13876,7 +13883,7 @@ function ee(t, e, n) {
13876
13883
  const o = r.time[0] * 1e9 + r.time[1];
13877
13884
  return i.time[0] * 1e9 + i.time[1] - o;
13878
13885
  }
13879
- const Jg = (t, e) => {
13886
+ const Qg = (t, e) => {
13880
13887
  const n = {
13881
13888
  domain_lookup: (e.domainLookupEnd - e.domainLookupStart) * 1e6,
13882
13889
  connect: (e.connectEnd - e.connectStart) * 1e6,
@@ -13909,18 +13916,18 @@ const Jg = (t, e) => {
13909
13916
  return `${Number(t.toFixed(1))}ns`;
13910
13917
  }, wo = (t) => t === !0 ? [/localhost/, /^\//, new RegExp(window.location.host)] : Array.isArray(t) ? t.map(
13911
13918
  (e) => typeof e == "string" ? new RegExp(e) : e
13912
- ) : /^$/, Qg = 30, Zg = () => new Promise(
13919
+ ) : /^$/, Zg = 30, e_ = () => new Promise(
13913
13920
  (t) => requestAnimationFrame(
13914
13921
  (e) => requestAnimationFrame((n) => t(n - e))
13915
13922
  )
13916
- ), e_ = () => Tn(void 0, null, function* () {
13923
+ ), t_ = () => Tn(void 0, null, function* () {
13917
13924
  const t = [];
13918
- for (let e = 0; e < Qg; e++)
13919
- t.push(yield Zg());
13925
+ for (let e = 0; e < Zg; e++)
13926
+ t.push(yield e_());
13920
13927
  return t.reduce((e, n) => e + n, 0) / t.length;
13921
- }), t_ = (t, e) => {
13928
+ }), n_ = (t, e) => {
13922
13929
  let n = {}, r = 16.666666666666668;
13923
- e_().then((c) => r = c);
13930
+ t_().then((c) => r = c);
13924
13931
  const i = (c) => {
13925
13932
  var s;
13926
13933
  n != null && n.event || (n = {
@@ -13947,7 +13954,7 @@ const Jg = (t, e) => {
13947
13954
  return window.addEventListener("click", i, !0), window.addEventListener("keydown", i, !0), () => {
13948
13955
  window.removeEventListener("keydown", i, !0), window.removeEventListener("click", i, !0);
13949
13956
  };
13950
- }, n_ = typeof window < "u", Oo = n_ && "performance" in window && "memory" in performance ? performance : { memory: {} }, r_ = (t, e) => {
13957
+ }, r_ = typeof window < "u", Oo = r_ && "performance" in window && "memory" in performance ? performance : { memory: {} }, i_ = (t, e) => {
13951
13958
  let n = 0, r = 0;
13952
13959
  const i = () => {
13953
13960
  const s = ((/* @__PURE__ */ new Date()).getTime() - e) / 1e3, l = Oo.memory.jsHeapSizeLimit || 0, p = Oo.memory.usedJSHeapSize || 0;
@@ -13971,23 +13978,23 @@ const Jg = (t, e) => {
13971
13978
  return c(), () => {
13972
13979
  clearInterval(o), cancelAnimationFrame(r);
13973
13980
  };
13974
- }, i_ = "launchdarkly.js.log", o_ = "log.severity", a_ = "log.message", Ao = "launchdarkly.sampling.ratio";
13975
- function s_(t) {
13981
+ }, o_ = "launchdarkly.js.log", a_ = "log.severity", s_ = "log.message", Ao = "launchdarkly.sampling.ratio";
13982
+ function u_(t) {
13976
13983
  return "regexValue" in t;
13977
13984
  }
13978
- function u_(t) {
13985
+ function c_(t) {
13979
13986
  return "matchValue" in t;
13980
13987
  }
13981
- function c_(t) {
13988
+ function l_(t) {
13982
13989
  const e = Math.trunc(t);
13983
13990
  return e === 1 ? !0 : e === 0 ? !1 : Math.floor(Math.random() * e) === 0;
13984
13991
  }
13985
- class l_ {
13992
+ class p_ {
13986
13993
  /**
13987
13994
  * @param config The sampling configuration.
13988
13995
  * @param sampler The sampler to use. This is intended to be used for testing purposes.
13989
13996
  */
13990
- constructor(e = c_) {
13997
+ constructor(e = l_) {
13991
13998
  D(this, "regexCache", /* @__PURE__ */ new Map()), D(this, "config"), this.sampler = e;
13992
13999
  }
13993
14000
  setConfig(e) {
@@ -13999,7 +14006,7 @@ class l_ {
13999
14006
  }
14000
14007
  shouldSample(e) {
14001
14008
  var n, r;
14002
- return e.name === i_ ? this.sampleLog((n = this.config) == null ? void 0 : n.logs, e) : this.sampleSpan((r = this.config) == null ? void 0 : r.spans, e);
14009
+ return e.name === o_ ? this.sampleLog((n = this.config) == null ? void 0 : n.logs, e) : this.sampleSpan((r = this.config) == null ? void 0 : r.spans, e);
14003
14010
  }
14004
14011
  /**
14005
14012
  * Check if a value matches a match config.
@@ -14007,9 +14014,9 @@ class l_ {
14007
14014
  matchesValue(e, n) {
14008
14015
  if (!e)
14009
14016
  return !1;
14010
- if (u_(e))
14017
+ if (c_(e))
14011
14018
  return e.matchValue === n;
14012
- if (s_(e)) {
14019
+ if (u_(e)) {
14013
14020
  const r = e.regexValue;
14014
14021
  if (r === null)
14015
14022
  return !1;
@@ -14076,12 +14083,12 @@ class l_ {
14076
14083
  }
14077
14084
  matchesLogConfig(e, n) {
14078
14085
  if (e.severityText) {
14079
- const r = n[o_];
14086
+ const r = n[a_];
14080
14087
  if (typeof r == "string" && !this.matchesValue(e.severityText, r))
14081
14088
  return !1;
14082
14089
  }
14083
14090
  if (e.message) {
14084
- const r = n[a_];
14091
+ const r = n[s_];
14085
14092
  if (typeof r == "string" && !this.matchesValue(e.message, r))
14086
14093
  return !1;
14087
14094
  }
@@ -14155,9 +14162,9 @@ const xo = () => {
14155
14162
  };
14156
14163
  return t;
14157
14164
  };
14158
- class p_ {
14165
+ class f_ {
14159
14166
  constructor(e) {
14160
- D(this, "organizationID"), D(this, "_integrations", []), D(this, "_gauges", /* @__PURE__ */ new Map()), D(this, "_counters", /* @__PURE__ */ new Map()), D(this, "_histograms", /* @__PURE__ */ new Map()), D(this, "_up_down_counters", /* @__PURE__ */ new Map()), D(this, "sampler", new l_()), D(this, "graphqlSDK"), typeof e.projectId == "string" ? this.organizationID = e.projectId : this.organizationID = e.projectId.toString(), Xg(e, this.sampler);
14167
+ D(this, "organizationID"), D(this, "_integrations", []), D(this, "_gauges", /* @__PURE__ */ new Map()), D(this, "_counters", /* @__PURE__ */ new Map()), D(this, "_histograms", /* @__PURE__ */ new Map()), D(this, "_up_down_counters", /* @__PURE__ */ new Map()), D(this, "sampler", new p_()), D(this, "graphqlSDK"), typeof e.projectId == "string" ? this.organizationID = e.projectId : this.organizationID = e.projectId.toString(), Kg(e, this.sampler);
14161
14168
  const n = new Uu(`${e.backendUrl}`, {
14162
14169
  headers: {}
14163
14170
  });
@@ -14180,7 +14187,7 @@ class p_ {
14180
14187
  });
14181
14188
  }
14182
14189
  recordLog(e, n, r) {
14183
- this.startSpan(zg, (i) => {
14190
+ this.startSpan(Xg, (i) => {
14184
14191
  const o = typeof e == "string" ? e : Le(e);
14185
14192
  i?.addEvent("log", M({
14186
14193
  "log.severity": n,
@@ -14357,7 +14364,7 @@ class p_ {
14357
14364
  stringLengthLimit: 1e3
14358
14365
  }
14359
14366
  }
14360
- ), e.enablePerformanceRecording !== !1 && (r_((r) => {
14367
+ ), e.enablePerformanceRecording !== !1 && (i_((r) => {
14361
14368
  Object.entries(r).filter(([i]) => i !== "relativeTimestamp").forEach(
14362
14369
  ([i, o]) => o && Se.recordGauge({
14363
14370
  name: i,
@@ -14368,7 +14375,7 @@ class p_ {
14368
14375
  }
14369
14376
  })
14370
14377
  );
14371
- }, 0), t_((r) => {
14378
+ }, 0), n_((r) => {
14372
14379
  Se.recordGauge({
14373
14380
  name: "Jank",
14374
14381
  value: r.jankAmount,
@@ -14401,9 +14408,9 @@ class p_ {
14401
14408
  );
14402
14409
  }
14403
14410
  }
14404
- class S_ extends jc {
14411
+ class w_ extends jc {
14405
14412
  constructor(e, n) {
14406
- var r = (...l) => (super(...l), D(this, "observe"), this), i, o, a, u, c, s;
14413
+ var r = (...p) => (super(...p), D(this, "observe"), this), i, o, a, u, c, s, l;
14407
14414
  try {
14408
14415
  if (r(n), typeof window > "u" || typeof document > "u") {
14409
14416
  console.warn(
@@ -14417,7 +14424,7 @@ class S_ extends jc {
14417
14424
  );
14418
14425
  return;
14419
14426
  }
14420
- const l = {
14427
+ const p = {
14421
14428
  backendUrl: (i = n?.backendUrl) != null ? i : "https://pub.observability.app.launchdarkly.com",
14422
14429
  otlpEndpoint: (a = (o = n?.otel) == null ? void 0 : o.otlpEndpoint) != null ? a : "https://otel.observability.app.launchdarkly.com",
14423
14430
  projectId: e,
@@ -14426,14 +14433,15 @@ class S_ extends jc {
14426
14433
  networkRecordingOptions: typeof n?.networkRecording == "object" ? n.networkRecording : void 0,
14427
14434
  tracingOrigins: n?.tracingOrigins,
14428
14435
  serviceName: (c = n?.serviceName) != null ? c : "browser",
14429
- instrumentations: (s = n?.otel) == null ? void 0 : s.instrumentations
14436
+ instrumentations: (s = n?.otel) == null ? void 0 : s.instrumentations,
14437
+ eventNames: (l = n?.otel) == null ? void 0 : l.eventNames
14430
14438
  };
14431
- this.observe = new p_(l), Se.load(this.observe);
14432
- } catch (l) {
14439
+ this.observe = new f_(p), Se.load(this.observe);
14440
+ } catch (p) {
14433
14441
  ve(
14434
14442
  "Error initializing @launchdarkly/observability SDK",
14435
14443
  "error",
14436
- l
14444
+ p
14437
14445
  );
14438
14446
  }
14439
14447
  }
@@ -14510,6 +14518,6 @@ class S_ extends jc {
14510
14518
  }
14511
14519
  export {
14512
14520
  Se as LDObserve,
14513
- S_ as default
14521
+ w_ as default
14514
14522
  };
14515
14523
  //# sourceMappingURL=observability.js.map