@brizz/sdk 0.1.41 → 0.1.42

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/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7;
2
2
 
3
3
 
4
4
  var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
5
5
 
6
6
 
7
- var _chunk3QYP2SDNcjs = require('./chunk-3QYP2SDN.cjs');
7
+ var _chunkK3NPYISBcjs = require('./chunk-K3NPYISB.cjs');
8
8
 
9
9
 
10
10
 
@@ -15,7 +15,7 @@ var _chunk3QYP2SDNcjs = require('./chunk-3QYP2SDN.cjs');
15
15
  var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
16
16
 
17
17
 
18
- var _chunkEVRCHF74cjs = require('./chunk-EVRCHF74.cjs');
18
+ var _chunkQUV5HYJ2cjs = require('./chunk-QUV5HYJ2.cjs');
19
19
 
20
20
 
21
21
 
@@ -67,7 +67,9 @@ var _chunkEVRCHF74cjs = require('./chunk-EVRCHF74.cjs');
67
67
 
68
68
 
69
69
 
70
- var _chunk77UGZGMPcjs = require('./chunk-77UGZGMP.cjs');
70
+
71
+
72
+ var _chunkFORVS4QWcjs = require('./chunk-FORVS4QW.cjs');
71
73
 
72
74
 
73
75
  var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
@@ -124,7 +126,7 @@ function loadGenAIInstrumentations() {
124
126
  function loadMCPInstrumentation() {
125
127
  void (async () => {
126
128
  try {
127
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-DU7AUWUH.cjs")));
129
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-GVGTOWHP.cjs")));
128
130
  const mcp = new MCPInstrumentation({ exceptionLogger });
129
131
  _instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
130
132
  _chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
@@ -180,7 +182,7 @@ function loadVercelAITelemetry() {
180
182
  }
181
183
  const isV7 = typeof ai.registerTelemetry === "function";
182
184
  const integrations = [];
183
- const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-DM3AWSBX.cjs")));
185
+ const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-3NXOTY4N.cjs")));
184
186
  integrations.push(createInterruptIntegration());
185
187
  let otelCollectorLoaded = false;
186
188
  try {
@@ -236,7 +238,7 @@ var _api = require('@opentelemetry/api');
236
238
 
237
239
 
238
240
 
239
- var _resources = require('@opentelemetry/resources');
241
+ var _resources2 = require('@opentelemetry/resources');
240
242
  var _sdkmetrics = require('@opentelemetry/sdk-metrics');
241
243
  var _sdktracenode = require('@opentelemetry/sdk-trace-node');
242
244
 
@@ -507,7 +509,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
507
509
  const mcpModules = this.manualModules.mcp;
508
510
  void (async () => {
509
511
  try {
510
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-DU7AUWUH.cjs")));
512
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-GVGTOWHP.cjs")));
511
513
  const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
512
514
  instrumentation.manuallyInstrument(mcpModules);
513
515
  _chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
@@ -547,8 +549,6 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
547
549
  var _apilogs = require('@opentelemetry/api-logs');
548
550
  var _exporterlogsotlphttp = require('@opentelemetry/exporter-logs-otlp-http');
549
551
 
550
-
551
-
552
552
  var _sdklogs = require('@opentelemetry/sdk-logs');
553
553
 
554
554
  // src/internal/trace/session.ts
@@ -560,16 +560,16 @@ function setCurrentSpanCustomProperties(properties) {
560
560
  }
561
561
  for (const [key, value] of Object.entries(properties)) {
562
562
  try {
563
- current.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
563
+ current.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
564
564
  } catch (e2) {
565
565
  }
566
566
  }
567
567
  }
568
568
  function callWithProperties(properties, fn, thisArg, ...args) {
569
569
  const base = _api.context.active();
570
- const prev = base.getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
570
+ const prev = base.getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
571
571
  const merged = prev ? { ...prev, ...properties } : properties;
572
- const next = base.setValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY, merged);
572
+ const next = base.setValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY, merged);
573
573
  return _api.context.with(next, fn, thisArg, ...args);
574
574
  }
575
575
  function withProperties(properties, fn, thisArg) {
@@ -591,25 +591,25 @@ function propagatePropertiesImperatively(properties) {
591
591
  return;
592
592
  }
593
593
  const base = _api.context.active();
594
- const prev = base.getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
594
+ const prev = base.getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
595
595
  const merged = prev ? { ...prev, ...properties } : properties;
596
- store.enterWith(base.setValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY, merged));
596
+ store.enterWith(base.setValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY, merged));
597
597
  } catch (e3) {
598
598
  }
599
599
  }
600
600
  function setUser(user) {
601
- const properties = { [_chunk77UGZGMPcjs.USER_ID]: user.id };
601
+ const properties = { [_chunkFORVS4QWcjs.USER_ID]: user.id };
602
602
  if (user.email !== void 0) {
603
- properties[_chunk77UGZGMPcjs.USER_EMAIL] = user.email;
603
+ properties[_chunkFORVS4QWcjs.USER_EMAIL] = user.email;
604
604
  }
605
605
  if (user.name !== void 0) {
606
- properties[_chunk77UGZGMPcjs.USER_NAME] = user.name;
606
+ properties[_chunkFORVS4QWcjs.USER_NAME] = user.name;
607
607
  }
608
608
  if (user.role !== void 0) {
609
- properties[_chunk77UGZGMPcjs.USER_ROLE] = user.role;
609
+ properties[_chunkFORVS4QWcjs.USER_ROLE] = user.role;
610
610
  }
611
611
  if (user.plan !== void 0) {
612
- properties[_chunk77UGZGMPcjs.USER_PLAN] = user.plan;
612
+ properties[_chunkFORVS4QWcjs.USER_PLAN] = user.plan;
613
613
  }
614
614
  if (user.traits) {
615
615
  for (const [key, value] of Object.entries(user.traits)) {
@@ -623,15 +623,15 @@ function setUser(user) {
623
623
  propagatePropertiesImperatively(properties);
624
624
  }
625
625
  function setOrganization(org) {
626
- const properties = { [_chunk77UGZGMPcjs.ORGANIZATION_ID]: org.id };
626
+ const properties = { [_chunkFORVS4QWcjs.ORGANIZATION_ID]: org.id };
627
627
  if (org.name !== void 0) {
628
- properties[_chunk77UGZGMPcjs.ORGANIZATION_NAME] = org.name;
628
+ properties[_chunkFORVS4QWcjs.ORGANIZATION_NAME] = org.name;
629
629
  }
630
630
  if (org.plan !== void 0) {
631
- properties[_chunk77UGZGMPcjs.ORGANIZATION_PLAN] = org.plan;
631
+ properties[_chunkFORVS4QWcjs.ORGANIZATION_PLAN] = org.plan;
632
632
  }
633
633
  if (org.domain !== void 0) {
634
- properties[_chunk77UGZGMPcjs.ORGANIZATION_DOMAIN] = org.domain;
634
+ properties[_chunkFORVS4QWcjs.ORGANIZATION_DOMAIN] = org.domain;
635
635
  }
636
636
  if (org.traits) {
637
637
  for (const [key, value] of Object.entries(org.traits)) {
@@ -645,28 +645,64 @@ function setOrganization(org) {
645
645
  propagatePropertiesImperatively(properties);
646
646
  }
647
647
  function setMessageId(id) {
648
- const properties = { [_chunk77UGZGMPcjs.MESSAGE_ID]: id };
648
+ const properties = { [_chunkFORVS4QWcjs.MESSAGE_ID]: id };
649
649
  setCurrentSpanCustomProperties(properties);
650
650
  propagatePropertiesImperatively(properties);
651
651
  }
652
652
  function setSessionId(id) {
653
- const properties = { [_chunk77UGZGMPcjs.SESSION_ID]: id };
653
+ const properties = { [_chunkFORVS4QWcjs.SESSION_ID]: id };
654
+ setCurrentSpanCustomProperties(properties);
655
+ propagatePropertiesImperatively(properties);
656
+ }
657
+ var SERVICE_NAME_MAX_BYTES = 256;
658
+ function serviceNameProperties(name) {
659
+ if (typeof name !== "string" || name === "") {
660
+ _chunkWC573FCIcjs.logger.warn("Service name must be a non-empty string; keeping the configured appName.");
661
+ return {};
662
+ }
663
+ if (/[\r\n\0]/.test(name)) {
664
+ _chunkWC573FCIcjs.logger.warn(
665
+ `Service name ${JSON.stringify(name)} contains CR, LF, or NUL; keeping the configured appName.`
666
+ );
667
+ return {};
668
+ }
669
+ const byteLength = new globalThis.TextEncoder().encode(name).length;
670
+ if (byteLength > SERVICE_NAME_MAX_BYTES) {
671
+ _chunkWC573FCIcjs.logger.warn(
672
+ `Service name is ${byteLength} bytes, over the ${SERVICE_NAME_MAX_BYTES}-byte limit; keeping the configured appName.`
673
+ );
674
+ return {};
675
+ }
676
+ return { [_chunkFORVS4QWcjs.SERVICE_NAME]: name };
677
+ }
678
+ function setServiceName(name) {
679
+ const properties = serviceNameProperties(name);
654
680
  setCurrentSpanCustomProperties(properties);
655
681
  propagatePropertiesImperatively(properties);
656
682
  }
683
+ function callWithServiceName(name, fn, thisArg, ...args) {
684
+ return callWithProperties(serviceNameProperties(name), fn, thisArg, ...args);
685
+ }
686
+ function withServiceName(name, fn, thisArg) {
687
+ return withProperties(serviceNameProperties(name), fn, thisArg);
688
+ }
689
+ function resolveServiceNameFromContext() {
690
+ const props = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
691
+ return _optionalChain([props, 'optionalAccess', _35 => _35[_chunkFORVS4QWcjs.SERVICE_NAME]]);
692
+ }
657
693
  function userProperties(user) {
658
- const properties = { [_chunk77UGZGMPcjs.USER_ID]: user.id };
694
+ const properties = { [_chunkFORVS4QWcjs.USER_ID]: user.id };
659
695
  if (user.email !== void 0) {
660
- properties[_chunk77UGZGMPcjs.USER_EMAIL] = user.email;
696
+ properties[_chunkFORVS4QWcjs.USER_EMAIL] = user.email;
661
697
  }
662
698
  if (user.name !== void 0) {
663
- properties[_chunk77UGZGMPcjs.USER_NAME] = user.name;
699
+ properties[_chunkFORVS4QWcjs.USER_NAME] = user.name;
664
700
  }
665
701
  if (user.role !== void 0) {
666
- properties[_chunk77UGZGMPcjs.USER_ROLE] = user.role;
702
+ properties[_chunkFORVS4QWcjs.USER_ROLE] = user.role;
667
703
  }
668
704
  if (user.plan !== void 0) {
669
- properties[_chunk77UGZGMPcjs.USER_PLAN] = user.plan;
705
+ properties[_chunkFORVS4QWcjs.USER_PLAN] = user.plan;
670
706
  }
671
707
  if (user.traits) {
672
708
  for (const [key, value] of Object.entries(user.traits)) {
@@ -679,15 +715,15 @@ function userProperties(user) {
679
715
  return properties;
680
716
  }
681
717
  function organizationProperties(org) {
682
- const properties = { [_chunk77UGZGMPcjs.ORGANIZATION_ID]: org.id };
718
+ const properties = { [_chunkFORVS4QWcjs.ORGANIZATION_ID]: org.id };
683
719
  if (org.name !== void 0) {
684
- properties[_chunk77UGZGMPcjs.ORGANIZATION_NAME] = org.name;
720
+ properties[_chunkFORVS4QWcjs.ORGANIZATION_NAME] = org.name;
685
721
  }
686
722
  if (org.plan !== void 0) {
687
- properties[_chunk77UGZGMPcjs.ORGANIZATION_PLAN] = org.plan;
723
+ properties[_chunkFORVS4QWcjs.ORGANIZATION_PLAN] = org.plan;
688
724
  }
689
725
  if (org.domain !== void 0) {
690
- properties[_chunk77UGZGMPcjs.ORGANIZATION_DOMAIN] = org.domain;
726
+ properties[_chunkFORVS4QWcjs.ORGANIZATION_DOMAIN] = org.domain;
691
727
  }
692
728
  if (org.traits) {
693
729
  for (const [key, value] of Object.entries(org.traits)) {
@@ -712,32 +748,32 @@ function withOrganization(org, fn, thisArg) {
712
748
  return withProperties(organizationProperties(org), fn, thisArg);
713
749
  }
714
750
  function callWithMessageId(id, fn, thisArg, ...args) {
715
- return callWithProperties({ [_chunk77UGZGMPcjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
751
+ return callWithProperties({ [_chunkFORVS4QWcjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
716
752
  }
717
753
  function withMessageId(id, fn, thisArg) {
718
- return withProperties({ [_chunk77UGZGMPcjs.MESSAGE_ID]: id }, fn, thisArg);
754
+ return withProperties({ [_chunkFORVS4QWcjs.MESSAGE_ID]: id }, fn, thisArg);
719
755
  }
720
756
  function inheritedMuteTools() {
721
- const properties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
722
- return _optionalChain([properties, 'optionalAccess', _35 => _35[_chunk77UGZGMPcjs.MUTE_TOOLS]]);
757
+ const properties = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
758
+ return _optionalChain([properties, 'optionalAccess', _36 => _36[_chunkFORVS4QWcjs.MUTE_TOOLS]]);
723
759
  }
724
760
  function muteProperties(options) {
725
761
  const { input = true, output = true, tools = output } = options;
726
762
  const properties = {};
727
763
  if (input) {
728
- properties[_chunk77UGZGMPcjs.MUTE_INPUT] = "true";
764
+ properties[_chunkFORVS4QWcjs.MUTE_INPUT] = "true";
729
765
  }
730
766
  if (output) {
731
- properties[_chunk77UGZGMPcjs.MUTE_OUTPUT] = "true";
767
+ properties[_chunkFORVS4QWcjs.MUTE_OUTPUT] = "true";
732
768
  }
733
769
  if (tools !== output) {
734
- properties[_chunk77UGZGMPcjs.MUTE_TOOLS] = String(tools);
770
+ properties[_chunkFORVS4QWcjs.MUTE_TOOLS] = String(tools);
735
771
  } else {
736
772
  const inherited = inheritedMuteTools();
737
773
  if (tools && inherited === "false") {
738
- properties[_chunk77UGZGMPcjs.MUTE_TOOLS] = "true";
774
+ properties[_chunkFORVS4QWcjs.MUTE_TOOLS] = "true";
739
775
  } else if (options.tools === false && inherited === "true") {
740
- properties[_chunk77UGZGMPcjs.MUTE_TOOLS] = "false";
776
+ properties[_chunkFORVS4QWcjs.MUTE_TOOLS] = "false";
741
777
  }
742
778
  }
743
779
  return properties;
@@ -749,11 +785,11 @@ function withMute(options, fn, thisArg) {
749
785
  return withProperties(muteProperties(options), fn, thisArg);
750
786
  }
751
787
  function withSessionId(sessionId, fn, thisArg, extraProperties) {
752
- const properties = { [_chunk77UGZGMPcjs.SESSION_ID]: sessionId, ...extraProperties };
788
+ const properties = { [_chunkFORVS4QWcjs.SESSION_ID]: sessionId, ...extraProperties };
753
789
  return withProperties(properties, fn, thisArg);
754
790
  }
755
791
  function callWithSessionId(sessionId, fn, thisArg, ...args) {
756
- return callWithProperties({ [_chunk77UGZGMPcjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
792
+ return callWithProperties({ [_chunkFORVS4QWcjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
757
793
  }
758
794
  var Session = (_class2 = class {
759
795
 
@@ -781,8 +817,8 @@ var Session = (_class2 = class {
781
817
  setInput(text, context4) {
782
818
  this.inputs.push(text);
783
819
  this.inputContexts.push(_nullishCoalesce(context4, () => ( {})));
784
- this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_INPUT, JSON.stringify(this.inputs));
785
- this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
820
+ this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_INPUT, JSON.stringify(this.inputs));
821
+ this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
786
822
  }
787
823
  /**
788
824
  * Append an assistant turn to session output tracking.
@@ -797,8 +833,8 @@ var Session = (_class2 = class {
797
833
  setOutput(text, context4) {
798
834
  this.outputs.push(text);
799
835
  this.outputContexts.push(_nullishCoalesce(context4, () => ( {})));
800
- this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
801
- this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
836
+ this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
837
+ this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
802
838
  }
803
839
  /**
804
840
  * Set the session title on the span.
@@ -806,7 +842,7 @@ var Session = (_class2 = class {
806
842
  * @param title - The generated title string
807
843
  */
808
844
  setTitle(title) {
809
- this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_TITLE, title);
845
+ this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_TITLE, title);
810
846
  }
811
847
  /**
812
848
  * Update custom properties on the session span.
@@ -816,7 +852,7 @@ var Session = (_class2 = class {
816
852
  */
817
853
  updateProperties(properties) {
818
854
  for (const [key, value] of Object.entries(properties)) {
819
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
855
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
820
856
  }
821
857
  }
822
858
  /**
@@ -828,21 +864,21 @@ var Session = (_class2 = class {
828
864
  setUser(user) {
829
865
  if (user.traits) {
830
866
  for (const [key, value] of Object.entries(user.traits)) {
831
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.user.${key}`, value);
867
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.user.${key}`, value);
832
868
  }
833
869
  }
834
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_ID}`, user.id);
870
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_ID}`, user.id);
835
871
  if (user.email !== void 0) {
836
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_EMAIL}`, user.email);
872
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_EMAIL}`, user.email);
837
873
  }
838
874
  if (user.name !== void 0) {
839
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_NAME}`, user.name);
875
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_NAME}`, user.name);
840
876
  }
841
877
  if (user.role !== void 0) {
842
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_ROLE}`, user.role);
878
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_ROLE}`, user.role);
843
879
  }
844
880
  if (user.plan !== void 0) {
845
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_PLAN}`, user.plan);
881
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_PLAN}`, user.plan);
846
882
  }
847
883
  }
848
884
  /**
@@ -854,18 +890,18 @@ var Session = (_class2 = class {
854
890
  setOrganization(org) {
855
891
  if (org.traits) {
856
892
  for (const [key, value] of Object.entries(org.traits)) {
857
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.organization.${key}`, value);
893
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.organization.${key}`, value);
858
894
  }
859
895
  }
860
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_ID}`, org.id);
896
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.ORGANIZATION_ID}`, org.id);
861
897
  if (org.name !== void 0) {
862
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_NAME}`, org.name);
898
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.ORGANIZATION_NAME}`, org.name);
863
899
  }
864
900
  if (org.plan !== void 0) {
865
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_PLAN}`, org.plan);
901
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.ORGANIZATION_PLAN}`, org.plan);
866
902
  }
867
903
  if (org.domain !== void 0) {
868
- this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_DOMAIN}`, org.domain);
904
+ this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.ORGANIZATION_DOMAIN}`, org.domain);
869
905
  }
870
906
  }
871
907
  /**
@@ -881,7 +917,7 @@ var Session = (_class2 = class {
881
917
  * (free-form category, defaults to `'generic'`)
882
918
  */
883
919
  addExternalLink(url, options) {
884
- emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _36 => _36.title]), _optionalChain([options, 'optionalAccess', _37 => _37.linkType]));
920
+ emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _37 => _37.title]), _optionalChain([options, 'optionalAccess', _38 => _38.linkType]));
885
921
  }
886
922
  }, _class2);
887
923
  var SessionTitle = class {
@@ -895,69 +931,69 @@ var SessionTitle = class {
895
931
  * @param title - The generated title string
896
932
  */
897
933
  setTitle(title) {
898
- this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_TITLE, title);
934
+ this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_TITLE, title);
899
935
  }
900
936
  };
901
937
  function getActiveSession() {
902
- return _api.context.active().getValue(_chunk77UGZGMPcjs.SESSION_OBJECT_CONTEXT_KEY);
938
+ return _api.context.active().getValue(_chunkFORVS4QWcjs.SESSION_OBJECT_CONTEXT_KEY);
903
939
  }
904
940
  function resolveSessionIdFromContext() {
905
941
  const active = getActiveSession();
906
942
  if (active) {
907
943
  return active.sessionId;
908
944
  }
909
- const props = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
910
- return _optionalChain([props, 'optionalAccess', _38 => _38[_chunk77UGZGMPcjs.SESSION_ID]]);
945
+ const props = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
946
+ return _optionalChain([props, 'optionalAccess', _39 => _39[_chunkFORVS4QWcjs.SESSION_ID]]);
911
947
  }
912
948
  function resolveMessageIdFromContext() {
913
- const props = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
914
- return _optionalChain([props, 'optionalAccess', _39 => _39[_chunk77UGZGMPcjs.MESSAGE_ID]]);
949
+ const props = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
950
+ return _optionalChain([props, 'optionalAccess', _40 => _40[_chunkFORVS4QWcjs.MESSAGE_ID]]);
915
951
  }
916
952
  function emitExternalLink(sessionId, url, title, linkType) {
917
953
  try {
918
- emitEventWithSessionId(sessionId, _chunk77UGZGMPcjs.EXTERNAL_LINK_EVENT_NAME, {
919
- [_chunk77UGZGMPcjs.EXTERNAL_LINK_URL]: url,
920
- [_chunk77UGZGMPcjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
921
- [_chunk77UGZGMPcjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
954
+ emitEventWithSessionId(sessionId, _chunkFORVS4QWcjs.EXTERNAL_LINK_EVENT_NAME, {
955
+ [_chunkFORVS4QWcjs.EXTERNAL_LINK_URL]: url,
956
+ [_chunkFORVS4QWcjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
957
+ [_chunkFORVS4QWcjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
922
958
  });
923
959
  } catch (error) {
924
960
  _chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
925
961
  }
926
962
  }
927
963
  function addExternalLink(url, options) {
928
- const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.sessionId]), () => ( resolveSessionIdFromContext()));
964
+ const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.sessionId]), () => ( resolveSessionIdFromContext()));
929
965
  if (!sessionId) {
930
966
  _chunkWC573FCIcjs.logger.warn(
931
967
  "addExternalLink called without a resolvable session id; link dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope."
932
968
  );
933
969
  return;
934
970
  }
935
- emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _41 => _41.title]), _optionalChain([options, 'optionalAccess', _42 => _42.linkType]));
971
+ emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _42 => _42.title]), _optionalChain([options, 'optionalAccess', _43 => _43.linkType]));
936
972
  }
937
973
  function recordFeedback(type, options) {
938
- const eventAttributes = { [_chunk77UGZGMPcjs.FEEDBACK_TYPE]: type };
939
- if (_optionalChain([options, 'optionalAccess', _43 => _43.score]) !== void 0) {
940
- eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_SCORE] = options.score;
974
+ const eventAttributes = { [_chunkFORVS4QWcjs.FEEDBACK_TYPE]: type };
975
+ if (_optionalChain([options, 'optionalAccess', _44 => _44.score]) !== void 0) {
976
+ eventAttributes[_chunkFORVS4QWcjs.FEEDBACK_SCORE] = options.score;
941
977
  }
942
- if (_optionalChain([options, 'optionalAccess', _44 => _44.reason]) !== void 0) {
943
- eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_REASON] = options.reason;
978
+ if (_optionalChain([options, 'optionalAccess', _45 => _45.reason]) !== void 0) {
979
+ eventAttributes[_chunkFORVS4QWcjs.FEEDBACK_REASON] = options.reason;
944
980
  }
945
- if (_optionalChain([options, 'optionalAccess', _45 => _45.comment]) !== void 0) {
946
- eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_COMMENT] = options.comment;
981
+ if (_optionalChain([options, 'optionalAccess', _46 => _46.comment]) !== void 0) {
982
+ eventAttributes[_chunkFORVS4QWcjs.FEEDBACK_COMMENT] = options.comment;
947
983
  }
948
- if (_optionalChain([options, 'optionalAccess', _46 => _46.source]) !== void 0) {
949
- eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_SOURCE] = options.source;
984
+ if (_optionalChain([options, 'optionalAccess', _47 => _47.source]) !== void 0) {
985
+ eventAttributes[_chunkFORVS4QWcjs.FEEDBACK_SOURCE] = options.source;
950
986
  }
951
- if (_optionalChain([options, 'optionalAccess', _47 => _47.attributes])) {
987
+ if (_optionalChain([options, 'optionalAccess', _48 => _48.attributes])) {
952
988
  for (const [key, value] of Object.entries(options.attributes)) {
953
- const k = `${_chunk77UGZGMPcjs.FEEDBACK_ATTR_PREFIX}${key}`;
989
+ const k = `${_chunkFORVS4QWcjs.FEEDBACK_ATTR_PREFIX}${key}`;
954
990
  if (eventAttributes[k] === void 0) {
955
991
  eventAttributes[k] = value;
956
992
  }
957
993
  }
958
994
  }
959
- const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _48 => _48.messageId]), () => ( resolveMessageIdFromContext()));
960
- const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.sessionId]), () => ( resolveSessionIdFromContext()));
995
+ const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.messageId]), () => ( resolveMessageIdFromContext()));
996
+ const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _50 => _50.sessionId]), () => ( resolveSessionIdFromContext()));
961
997
  if (messageId === void 0 && sessionId === void 0) {
962
998
  _chunkWC573FCIcjs.logger.warn(
963
999
  "recordFeedback called with no resolvable message id or session id; the feedback cannot be attributed to a message or conversation. Pass options.messageId / options.sessionId or call inside a startSession/callWithMessageId scope."
@@ -965,16 +1001,16 @@ function recordFeedback(type, options) {
965
1001
  }
966
1002
  const anchor = {};
967
1003
  if (messageId !== void 0) {
968
- anchor[_chunk77UGZGMPcjs.MESSAGE_ID] = messageId;
1004
+ anchor[_chunkFORVS4QWcjs.MESSAGE_ID] = messageId;
969
1005
  }
970
1006
  if (sessionId !== void 0) {
971
- anchor[_chunk77UGZGMPcjs.SESSION_ID] = sessionId;
1007
+ anchor[_chunkFORVS4QWcjs.SESSION_ID] = sessionId;
972
1008
  }
973
1009
  try {
974
1010
  if (Object.keys(anchor).length === 0) {
975
- emitEvent(_chunk77UGZGMPcjs.FEEDBACK_EVENT_NAME, eventAttributes);
1011
+ emitEvent(_chunkFORVS4QWcjs.FEEDBACK_EVENT_NAME, eventAttributes);
976
1012
  } else {
977
- callWithProperties(anchor, () => emitEvent(_chunk77UGZGMPcjs.FEEDBACK_EVENT_NAME, eventAttributes));
1013
+ callWithProperties(anchor, () => emitEvent(_chunkFORVS4QWcjs.FEEDBACK_EVENT_NAME, eventAttributes));
978
1014
  }
979
1015
  } catch (error) {
980
1016
  _chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
@@ -988,7 +1024,7 @@ function recordMetric(options) {
988
1024
  try {
989
1025
  recordMetricImpl(options);
990
1026
  } catch (error) {
991
- _chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess', _50 => _50.name]))}) failed; metric dropped.`, error);
1027
+ _chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess', _51 => _51.name]))}) failed; metric dropped.`, error);
992
1028
  }
993
1029
  }
994
1030
  function recordMetricImpl(options) {
@@ -999,7 +1035,7 @@ function recordMetricImpl(options) {
999
1035
  );
1000
1036
  return;
1001
1037
  }
1002
- if (_chunk77UGZGMPcjs.RESERVED_METRIC_NAMES.has(name)) {
1038
+ if (_chunkFORVS4QWcjs.RESERVED_METRIC_NAMES.has(name)) {
1003
1039
  _chunkWC573FCIcjs.logger.warn(
1004
1040
  `recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
1005
1041
  );
@@ -1018,17 +1054,17 @@ function recordMetricImpl(options) {
1018
1054
  return;
1019
1055
  }
1020
1056
  const eventAttributes = {
1021
- [_chunk77UGZGMPcjs.METRIC_NAME]: name,
1022
- [_chunk77UGZGMPcjs.METRIC_VALUE]: numericValue
1057
+ [_chunkFORVS4QWcjs.METRIC_NAME]: name,
1058
+ [_chunkFORVS4QWcjs.METRIC_VALUE]: numericValue
1023
1059
  };
1024
1060
  if (options.unit !== void 0) {
1025
- eventAttributes[_chunk77UGZGMPcjs.METRIC_UNIT] = options.unit;
1061
+ eventAttributes[_chunkFORVS4QWcjs.METRIC_UNIT] = options.unit;
1026
1062
  }
1027
1063
  if (options.minValue !== void 0) {
1028
- eventAttributes[_chunk77UGZGMPcjs.METRIC_MIN] = options.minValue;
1064
+ eventAttributes[_chunkFORVS4QWcjs.METRIC_MIN] = options.minValue;
1029
1065
  }
1030
1066
  if (options.maxValue !== void 0) {
1031
- eventAttributes[_chunk77UGZGMPcjs.METRIC_MAX] = options.maxValue;
1067
+ eventAttributes[_chunkFORVS4QWcjs.METRIC_MAX] = options.maxValue;
1032
1068
  }
1033
1069
  if (options.comment !== void 0) {
1034
1070
  let comment = options.comment;
@@ -1038,21 +1074,21 @@ function recordMetricImpl(options) {
1038
1074
  );
1039
1075
  comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
1040
1076
  }
1041
- eventAttributes[_chunk77UGZGMPcjs.METRIC_COMMENT] = comment;
1077
+ eventAttributes[_chunkFORVS4QWcjs.METRIC_COMMENT] = comment;
1042
1078
  }
1043
1079
  if (options.polarity !== void 0) {
1044
1080
  const polarity = options.polarity;
1045
- if (polarity === _chunk77UGZGMPcjs.METRIC_POLARITY_POSITIVE || polarity === _chunk77UGZGMPcjs.METRIC_POLARITY_NEGATIVE) {
1046
- eventAttributes[_chunk77UGZGMPcjs.METRIC_POLARITY] = polarity;
1081
+ if (polarity === _chunkFORVS4QWcjs.METRIC_POLARITY_POSITIVE || polarity === _chunkFORVS4QWcjs.METRIC_POLARITY_NEGATIVE) {
1082
+ eventAttributes[_chunkFORVS4QWcjs.METRIC_POLARITY] = polarity;
1047
1083
  } else {
1048
1084
  _chunkWC573FCIcjs.logger.warn(
1049
- `recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunk77UGZGMPcjs.METRIC_POLARITY_POSITIVE}' or '${_chunk77UGZGMPcjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
1085
+ `recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunkFORVS4QWcjs.METRIC_POLARITY_POSITIVE}' or '${_chunkFORVS4QWcjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
1050
1086
  );
1051
1087
  }
1052
1088
  }
1053
1089
  if (options.timestamp !== void 0) {
1054
1090
  if (Number.isFinite(options.timestamp.getTime())) {
1055
- eventAttributes[_chunk77UGZGMPcjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1091
+ eventAttributes[_chunkFORVS4QWcjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1056
1092
  } else {
1057
1093
  _chunkWC573FCIcjs.logger.warn(
1058
1094
  `recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
@@ -1082,7 +1118,7 @@ function recordMetricImpl(options) {
1082
1118
  );
1083
1119
  text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
1084
1120
  }
1085
- eventAttributes[`${_chunk77UGZGMPcjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1121
+ eventAttributes[`${_chunkFORVS4QWcjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1086
1122
  accepted += 1;
1087
1123
  }
1088
1124
  }
@@ -1095,28 +1131,28 @@ function recordMetricImpl(options) {
1095
1131
  }
1096
1132
  try {
1097
1133
  callWithProperties(
1098
- { [_chunk77UGZGMPcjs.SESSION_ID]: sessionId },
1099
- () => emitEvent(_chunk77UGZGMPcjs.METRIC_EVENT_NAME, eventAttributes)
1134
+ { [_chunkFORVS4QWcjs.SESSION_ID]: sessionId },
1135
+ () => emitEvent(_chunkFORVS4QWcjs.METRIC_EVENT_NAME, eventAttributes)
1100
1136
  );
1101
1137
  } catch (error) {
1102
1138
  _chunkWC573FCIcjs.logger.warn("recordMetric: failed to emit metric event", error);
1103
1139
  }
1104
1140
  }
1105
1141
  function startSession(sessionId, callback, extraProperties, options) {
1106
- const isTitle = _optionalChain([options, 'optionalAccess', _51 => _51.mode]) === "title";
1107
- const spanName = isTitle ? _chunk77UGZGMPcjs.SESSION_TITLE_SPAN_NAME : _chunk77UGZGMPcjs.SESSION_SPAN_NAME;
1142
+ const isTitle = _optionalChain([options, 'optionalAccess', _52 => _52.mode]) === "title";
1143
+ const spanName = isTitle ? _chunkFORVS4QWcjs.SESSION_TITLE_SPAN_NAME : _chunkFORVS4QWcjs.SESSION_SPAN_NAME;
1108
1144
  const tracer = _api.trace.getTracer("@brizz/sdk");
1109
1145
  return tracer.startActiveSpan(spanName, (span) => {
1110
- span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.SESSION_ID}`, sessionId);
1146
+ span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.SESSION_ID}`, sessionId);
1111
1147
  if (extraProperties) {
1112
1148
  for (const [key, value] of Object.entries(extraProperties)) {
1113
- span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
1149
+ span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
1114
1150
  }
1115
1151
  }
1116
1152
  const session = new Session(sessionId, span);
1117
- const contextProperties = { [_chunk77UGZGMPcjs.SESSION_ID]: sessionId };
1153
+ const contextProperties = { [_chunkFORVS4QWcjs.SESSION_ID]: sessionId };
1118
1154
  if (isTitle) {
1119
- contextProperties[_chunk77UGZGMPcjs.SESSION_TITLE_GENERATION] = "true";
1155
+ contextProperties[_chunkFORVS4QWcjs.SESSION_TITLE_GENERATION] = "true";
1120
1156
  }
1121
1157
  if (extraProperties) {
1122
1158
  for (const [key, value] of Object.entries(extraProperties)) {
@@ -1124,7 +1160,7 @@ function startSession(sessionId, callback, extraProperties, options) {
1124
1160
  }
1125
1161
  }
1126
1162
  return callWithProperties(contextProperties, () => {
1127
- const sessionCtx = _api.context.active().setValue(_chunk77UGZGMPcjs.SESSION_OBJECT_CONTEXT_KEY, session);
1163
+ const sessionCtx = _api.context.active().setValue(_chunkFORVS4QWcjs.SESSION_OBJECT_CONTEXT_KEY, session);
1128
1164
  return _api.context.with(sessionCtx, () => {
1129
1165
  try {
1130
1166
  const result = callback(session);
@@ -1152,16 +1188,16 @@ function startSession(sessionId, callback, extraProperties, options) {
1152
1188
  });
1153
1189
  }
1154
1190
  function startSessionTitle(callback, options) {
1155
- const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _52 => _52.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _53 => _53(), 'optionalAccess', _54 => _54.sessionId])));
1191
+ const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _54 => _54(), 'optionalAccess', _55 => _55.sessionId])));
1156
1192
  const tracer = _api.trace.getTracer("@brizz/sdk");
1157
- return tracer.startActiveSpan(_chunk77UGZGMPcjs.SESSION_TITLE_SPAN_NAME, (span) => {
1193
+ return tracer.startActiveSpan(_chunkFORVS4QWcjs.SESSION_TITLE_SPAN_NAME, (span) => {
1158
1194
  if (resolvedSessionId) {
1159
- span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.SESSION_ID}`, resolvedSessionId);
1195
+ span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.SESSION_ID}`, resolvedSessionId);
1160
1196
  }
1161
1197
  const sessionTitle = new SessionTitle(span);
1162
- const properties = { [_chunk77UGZGMPcjs.SESSION_TITLE_GENERATION]: "true" };
1198
+ const properties = { [_chunkFORVS4QWcjs.SESSION_TITLE_GENERATION]: "true" };
1163
1199
  if (resolvedSessionId) {
1164
- properties[_chunk77UGZGMPcjs.SESSION_ID] = resolvedSessionId;
1200
+ properties[_chunkFORVS4QWcjs.SESSION_ID] = resolvedSessionId;
1165
1201
  }
1166
1202
  return callWithProperties(properties, () => {
1167
1203
  try {
@@ -1624,14 +1660,14 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
1624
1660
  this.config = config;
1625
1661
  }
1626
1662
  onEmit(logRecord) {
1627
- const maskingConfig = _optionalChain([this, 'access', _55 => _55.config, 'access', _56 => _56.masking, 'optionalAccess', _57 => _57.eventMasking]);
1663
+ const maskingConfig = _optionalChain([this, 'access', _56 => _56.config, 'access', _57 => _57.masking, 'optionalAccess', _58 => _58.eventMasking]);
1628
1664
  if (maskingConfig) {
1629
1665
  maskLog(logRecord, maskingConfig);
1630
1666
  }
1631
- const associationProperties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
1667
+ const associationProperties = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
1632
1668
  if (associationProperties) {
1633
1669
  for (const [key, value] of Object.entries(associationProperties)) {
1634
- logRecord.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
1670
+ logRecord.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
1635
1671
  }
1636
1672
  }
1637
1673
  super.onEmit(logRecord);
@@ -1644,14 +1680,14 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
1644
1680
  this.config = config;
1645
1681
  }
1646
1682
  onEmit(logRecord) {
1647
- const maskingConfig = _optionalChain([this, 'access', _58 => _58.config, 'access', _59 => _59.masking, 'optionalAccess', _60 => _60.eventMasking]);
1683
+ const maskingConfig = _optionalChain([this, 'access', _59 => _59.config, 'access', _60 => _60.masking, 'optionalAccess', _61 => _61.eventMasking]);
1648
1684
  if (maskingConfig) {
1649
1685
  maskLog(logRecord, maskingConfig);
1650
1686
  }
1651
- const associationProperties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
1687
+ const associationProperties = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
1652
1688
  if (associationProperties) {
1653
1689
  for (const [key, value] of Object.entries(associationProperties)) {
1654
- logRecord.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
1690
+ logRecord.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
1655
1691
  }
1656
1692
  }
1657
1693
  super.onEmit(logRecord);
@@ -1678,7 +1714,7 @@ function maskLog(logRecord, config) {
1678
1714
  newAttributes[key] = value;
1679
1715
  }
1680
1716
  for (const [key, value] of Object.entries(logRecord.attributes)) {
1681
- if (key.startsWith(_chunk77UGZGMPcjs.INTERNAL_EVENT_PREFIX)) {
1717
+ if (key.startsWith(_chunkFORVS4QWcjs.INTERNAL_EVENT_PREFIX)) {
1682
1718
  newAttributes[key] = value;
1683
1719
  }
1684
1720
  }
@@ -1708,68 +1744,42 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
1708
1744
  }
1709
1745
  return this.instance;
1710
1746
  }
1711
- __init6() {this.logExporter = null}
1712
- __init7() {this.logProcessor = null}
1713
- __init8() {this.loggerProvider = null}
1747
+ __init6() {this.config = null}
1748
+ __init7() {this.loggerProvider = null}
1749
+ /** Providers for scoped service names, keyed by service name. */
1750
+ __init8() {this.scopedProviders = /* @__PURE__ */ new Map()}
1714
1751
  /**
1715
- * Initialize the log exporter
1752
+ * Build the log exporter for a service. The service header is fixed per
1753
+ * exporter and the gateway rewrites service.name from it, so each service
1754
+ * needs its own. A custom exporter is used as-is — the resource still
1755
+ * carries the right service.name.
1716
1756
  */
1717
- initLogExporter(config) {
1718
- if (this.logExporter) {
1719
- _chunkWC573FCIcjs.logger.debug("Log exporter already initialized, skipping re-initialization");
1720
- return;
1721
- }
1757
+ createLogExporter(config, serviceName) {
1722
1758
  if (config.customLogExporter) {
1723
1759
  _chunkWC573FCIcjs.logger.debug("Using custom log exporter");
1724
- this.logExporter = config.customLogExporter;
1725
- _chunkWC573FCIcjs.logger.debug("Custom log exporter initialized successfully");
1726
- return;
1760
+ return config.customLogExporter;
1727
1761
  }
1728
1762
  const logsUrl = config.baseUrl.replace(/\/$/, "") + "/v1/logs";
1729
- _chunkWC573FCIcjs.logger.debug("Initializing default OTLP log exporter", { url: logsUrl });
1730
- const headers = { ...config.headers };
1731
- this.logExporter = new (0, _exporterlogsotlphttp.OTLPLogExporter)({
1732
- url: logsUrl,
1733
- headers
1734
- });
1735
- _chunkWC573FCIcjs.logger.debug("OTLP log exporter initialized successfully");
1763
+ _chunkWC573FCIcjs.logger.debug("Initializing default OTLP log exporter", { url: logsUrl, serviceName });
1764
+ const headers = serviceName === config.appName ? { ...config.headers } : { ...config.headers, [_chunkUNLNNKZ7cjs.SERVICE_NAME_HEADER]: serviceName };
1765
+ return new (0, _exporterlogsotlphttp.OTLPLogExporter)({ url: logsUrl, headers });
1736
1766
  }
1737
1767
  /**
1738
- * Initialize the log processor with masking support
1768
+ * Build a logger provider reporting under `serviceName`, with its own
1769
+ * exporter and masking-aware processor.
1739
1770
  */
1740
- initLogProcessor(config) {
1741
- if (this.logProcessor) {
1742
- _chunkWC573FCIcjs.logger.debug("Log processor already initialized, skipping re-initialization");
1743
- return;
1744
- }
1745
- if (!this.logExporter) {
1746
- throw new Error("Log exporter must be initialized before processor");
1747
- }
1748
- _chunkWC573FCIcjs.logger.debug("Initializing log processor", {
1771
+ createLoggerProvider(config, serviceName) {
1772
+ _chunkWC573FCIcjs.logger.debug("Creating logger provider", {
1773
+ serviceName,
1749
1774
  disableBatch: config.disableBatch,
1750
- hasMasking: !!_optionalChain([config, 'access', _61 => _61.masking, 'optionalAccess', _62 => _62.eventMasking])
1751
- });
1752
- this.logProcessor = config.disableBatch ? new BrizzSimpleLogRecordProcessor(this.logExporter, config) : new BrizzBatchLogRecordProcessor(this.logExporter, config);
1753
- _chunkWC573FCIcjs.logger.debug("Log processor initialized successfully");
1754
- }
1755
- /**
1756
- * Initialize the logger provider
1757
- */
1758
- initLoggerProvider(config) {
1759
- if (this.loggerProvider) {
1760
- _chunkWC573FCIcjs.logger.debug("Logger provider already initialized, skipping re-initialization");
1761
- return;
1762
- }
1763
- if (!this.logProcessor) {
1764
- throw new Error("Log processor must be initialized before logger provider");
1765
- }
1766
- _chunkWC573FCIcjs.logger.debug("Creating resource with service name", {
1767
- serviceName: config.appName
1775
+ hasMasking: !!_optionalChain([config, 'access', _62 => _62.masking, 'optionalAccess', _63 => _63.eventMasking])
1768
1776
  });
1777
+ const exporter = this.createLogExporter(config, serviceName);
1778
+ const processor = config.disableBatch ? new BrizzSimpleLogRecordProcessor(exporter, config) : new BrizzBatchLogRecordProcessor(exporter, config);
1769
1779
  const resourceAttributes = {
1770
1780
  ...config.resourceAttributes,
1771
- "service.name": config.appName,
1772
- [BRIZZ_SDK_VERSION]: _chunk3QYP2SDNcjs.getSDKVersion.call(void 0, ),
1781
+ "service.name": serviceName,
1782
+ [BRIZZ_SDK_VERSION]: _chunkK3NPYISBcjs.getSDKVersion.call(void 0, ),
1773
1783
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
1774
1784
  };
1775
1785
  if (config.environment) {
@@ -1778,22 +1788,38 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
1778
1788
  if (config.appVersion) {
1779
1789
  resourceAttributes["service.version"] = config.appVersion;
1780
1790
  }
1781
- const resource = _resources.resourceFromAttributes.call(void 0, resourceAttributes);
1782
- _chunkWC573FCIcjs.logger.debug("Creating logger provider with resource");
1783
- this.loggerProvider = new (0, _sdklogs.LoggerProvider)({
1784
- resource,
1785
- processors: [this.logProcessor]
1791
+ return new (0, _sdklogs.LoggerProvider)({
1792
+ resource: _resources2.resourceFromAttributes.call(void 0, resourceAttributes),
1793
+ processors: [processor]
1786
1794
  });
1787
- _chunkWC573FCIcjs.logger.debug("Logger provider initialization completed");
1795
+ }
1796
+ /**
1797
+ * The provider events emit through: the scoped service name from
1798
+ * `callWithServiceName`, else the configured appName.
1799
+ */
1800
+ activeLoggerProvider() {
1801
+ const serviceName = resolveServiceNameFromContext();
1802
+ if (!serviceName || !this.config || serviceName === this.config.appName) {
1803
+ return this.loggerProvider;
1804
+ }
1805
+ let provider = this.scopedProviders.get(serviceName);
1806
+ if (!provider) {
1807
+ provider = this.createLoggerProvider(this.config, serviceName);
1808
+ this.scopedProviders.set(serviceName, provider);
1809
+ }
1810
+ return provider;
1788
1811
  }
1789
1812
  /**
1790
1813
  * Initialize the logging module with the provided configuration
1791
1814
  */
1792
1815
  setup(config) {
1793
1816
  _chunkWC573FCIcjs.logger.info("Setting up logging module");
1794
- this.initLogExporter(config);
1795
- this.initLogProcessor(config);
1796
- this.initLoggerProvider(config);
1817
+ this.config = config;
1818
+ if (this.loggerProvider) {
1819
+ _chunkWC573FCIcjs.logger.debug("Logger provider already initialized, skipping re-initialization");
1820
+ } else {
1821
+ this.loggerProvider = this.createLoggerProvider(config, config.appName);
1822
+ }
1797
1823
  _LoggingModule.instance = this;
1798
1824
  _chunkWC573FCIcjs.logger.info("Logging module setup completed");
1799
1825
  }
@@ -1808,7 +1834,8 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
1808
1834
  hasBody: !!body,
1809
1835
  severityNumber
1810
1836
  });
1811
- if (!this.loggerProvider) {
1837
+ const provider = this.activeLoggerProvider();
1838
+ if (!provider) {
1812
1839
  _chunkWC573FCIcjs.logger.error("Cannot emit event: Logger provider not initialized");
1813
1840
  throw new Error("Logging module not initialized");
1814
1841
  }
@@ -1818,7 +1845,7 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
1818
1845
  _chunkWC573FCIcjs.logger.debug("Combined log attributes", { attributes: Object.keys(logAttributes) });
1819
1846
  }
1820
1847
  _chunkWC573FCIcjs.logger.debug("Getting logger instance for brizz_events");
1821
- const eventLogger = this.loggerProvider.getLogger("brizz.events");
1848
+ const eventLogger = provider.getLogger("brizz.events");
1822
1849
  _chunkWC573FCIcjs.logger.debug("Emitting log record with eventName", { eventName: name });
1823
1850
  try {
1824
1851
  eventLogger.emit({
@@ -1860,8 +1887,9 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
1860
1887
  await this.loggerProvider.shutdown();
1861
1888
  this.loggerProvider = null;
1862
1889
  }
1863
- this.logProcessor = null;
1864
- this.logExporter = null;
1890
+ await Promise.all([...this.scopedProviders.values()].map(async (p) => p.shutdown()));
1891
+ this.scopedProviders.clear();
1892
+ this.config = null;
1865
1893
  if (_LoggingModule.instance === this) {
1866
1894
  _LoggingModule.instance = null;
1867
1895
  }
@@ -1985,16 +2013,22 @@ var _exportertraceotlpproto = require('@opentelemetry/exporter-trace-otlp-proto'
1985
2013
  // src/internal/trace/exporters/span-exporter.ts
1986
2014
  var _core = require('@opentelemetry/core');
1987
2015
 
1988
- var BrizzSpanExporter = class {
2016
+ var BrizzSpanExporter = (_class5 = class {
2017
+
1989
2018
 
1990
2019
 
1991
2020
 
1992
- constructor(delegate, config) {
2021
+ __init11() {this._resources = /* @__PURE__ */ new Map()}
2022
+ __init12() {this._delegates = /* @__PURE__ */ new Map()}
2023
+
2024
+ constructor(delegate, config, factory) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);
1993
2025
  this._delegate = delegate;
2026
+ this._delegateFactory = factory;
2027
+ this._defaultServiceName = config.appName;
1994
2028
  const resourceAttrs = {
1995
2029
  ...config.resourceAttributes,
1996
2030
  "service.name": config.appName,
1997
- [BRIZZ_SDK_VERSION]: _chunk3QYP2SDNcjs.getSDKVersion.call(void 0, ),
2031
+ [BRIZZ_SDK_VERSION]: _chunkK3NPYISBcjs.getSDKVersion.call(void 0, ),
1998
2032
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
1999
2033
  };
2000
2034
  if (config.environment) {
@@ -2003,24 +2037,63 @@ var BrizzSpanExporter = class {
2003
2037
  if (config.appVersion) {
2004
2038
  resourceAttrs["service.version"] = config.appVersion;
2005
2039
  }
2006
- this._brizzResource = _resources.resourceFromAttributes.call(void 0, resourceAttrs);
2040
+ this._resourceAttrs = resourceAttrs;
2007
2041
  this._beforeSendSpan = config.beforeSendSpan;
2008
2042
  }
2043
+ /** The service a span reports under: its scoped override, else the configured appName. */
2044
+ _serviceNameOf(span) {
2045
+ const value = span.attributes[_chunkFORVS4QWcjs.SERVICE_NAME_ATTRIBUTE];
2046
+ return typeof value === "string" && value !== "" ? value : this._defaultServiceName;
2047
+ }
2048
+ _resourceFor(serviceName) {
2049
+ let resource = this._resources.get(serviceName);
2050
+ if (!resource) {
2051
+ resource = _resources2.resourceFromAttributes.call(void 0, { ...this._resourceAttrs, "service.name": serviceName });
2052
+ this._resources.set(serviceName, resource);
2053
+ }
2054
+ return resource;
2055
+ }
2056
+ /**
2057
+ * Without a factory (a custom exporter, e.g. in tests) every service shares the
2058
+ * one delegate — the patched Resource still carries the right service.name.
2059
+ */
2060
+ _delegateFor(serviceName) {
2061
+ if (serviceName === this._defaultServiceName || !this._delegateFactory) {
2062
+ return this._delegate;
2063
+ }
2064
+ let delegate = this._delegates.get(serviceName);
2065
+ if (!delegate) {
2066
+ delegate = this._delegateFactory(serviceName);
2067
+ this._delegates.set(serviceName, delegate);
2068
+ }
2069
+ return delegate;
2070
+ }
2009
2071
  export(spans, resultCallback) {
2010
2072
  if (spans.length === 0) {
2011
2073
  resultCallback({ code: _core.ExportResultCode.SUCCESS });
2012
2074
  return;
2013
2075
  }
2014
- const patchedSpans = spans.map((span) => ({
2015
- ...span,
2016
- resource: span.resource.merge(this._brizzResource),
2017
- spanContext: span.spanContext.bind(span)
2018
- }));
2076
+ const groups = /* @__PURE__ */ new Map();
2077
+ for (const span of spans) {
2078
+ const serviceName = this._serviceNameOf(span);
2079
+ const patched = {
2080
+ ...span,
2081
+ resource: span.resource.merge(this._resourceFor(serviceName)),
2082
+ spanContext: span.spanContext.bind(span)
2083
+ };
2084
+ const group = groups.get(serviceName);
2085
+ if (group) {
2086
+ group.push(patched);
2087
+ } else {
2088
+ groups.set(serviceName, [patched]);
2089
+ }
2090
+ }
2019
2091
  const filter = this._beforeSendSpan;
2020
2092
  if (!filter) {
2021
- this._delegate.export(patchedSpans, resultCallback);
2093
+ this._exportGroups(groups, resultCallback);
2022
2094
  return;
2023
2095
  }
2096
+ const patchedSpans = [...groups.values()].flat();
2024
2097
  const verdicts = patchedSpans.map((span) => {
2025
2098
  try {
2026
2099
  return Promise.resolve(filter(span));
@@ -2030,25 +2103,63 @@ var BrizzSpanExporter = class {
2030
2103
  }
2031
2104
  });
2032
2105
  Promise.all(verdicts).then((keep) => {
2033
- const filtered = patchedSpans.filter((_, i) => keep[i] !== false);
2034
- if (filtered.length === 0) {
2106
+ const kept = new Set(patchedSpans.filter((_, i) => keep[i] !== false));
2107
+ const filtered = /* @__PURE__ */ new Map();
2108
+ for (const [serviceName, group] of groups) {
2109
+ const remaining = group.filter((span) => kept.has(span));
2110
+ if (remaining.length > 0) {
2111
+ filtered.set(serviceName, remaining);
2112
+ }
2113
+ }
2114
+ if (filtered.size === 0) {
2035
2115
  resultCallback({ code: _core.ExportResultCode.SUCCESS });
2036
2116
  return;
2037
2117
  }
2038
- this._delegate.export(filtered, resultCallback);
2118
+ this._exportGroups(filtered, resultCallback);
2039
2119
  return;
2040
2120
  }).catch((error) => {
2041
2121
  _chunkWC573FCIcjs.logger.warn("beforeSendSpan rejected; all spans will be kept", { error });
2042
- this._delegate.export(patchedSpans, resultCallback);
2122
+ this._exportGroups(groups, resultCallback);
2043
2123
  });
2044
2124
  }
2125
+ /**
2126
+ * Dispatch each service's spans to its own exporter, reporting the first
2127
+ * failure once every group has answered.
2128
+ */
2129
+ _exportGroups(groups, resultCallback) {
2130
+ const entries = [...groups.entries()];
2131
+ const only = entries[0];
2132
+ if (entries.length === 1 && only) {
2133
+ this._delegateFor(only[0]).export(only[1], resultCallback);
2134
+ return;
2135
+ }
2136
+ let pending = entries.length;
2137
+ let failure;
2138
+ for (const [serviceName, group] of entries) {
2139
+ this._delegateFor(serviceName).export(group, (result) => {
2140
+ if (result.code !== _core.ExportResultCode.SUCCESS && !failure) {
2141
+ failure = result;
2142
+ }
2143
+ pending -= 1;
2144
+ if (pending === 0) {
2145
+ resultCallback(_nullishCoalesce(failure, () => ( { code: _core.ExportResultCode.SUCCESS })));
2146
+ }
2147
+ });
2148
+ }
2149
+ }
2045
2150
  async shutdown() {
2046
- return this._delegate.shutdown();
2151
+ await Promise.all([
2152
+ this._delegate.shutdown(),
2153
+ ...[...this._delegates.values()].map(async (delegate) => delegate.shutdown())
2154
+ ]);
2047
2155
  }
2048
2156
  async forceFlush() {
2049
- return _optionalChain([this, 'access', _63 => _63._delegate, 'access', _64 => _64.forceFlush, 'optionalCall', _65 => _65()]);
2157
+ await Promise.all([
2158
+ _optionalChain([this, 'access', _64 => _64._delegate, 'access', _65 => _65.forceFlush, 'optionalCall', _66 => _66()]),
2159
+ ...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access', _67 => _67.forceFlush, 'optionalCall', _68 => _68()]))
2160
+ ]);
2050
2161
  }
2051
- };
2162
+ }, _class5);
2052
2163
 
2053
2164
  // src/internal/trace/processors/span-processor.ts
2054
2165
 
@@ -2057,10 +2168,10 @@ var BrizzSpanExporter = class {
2057
2168
 
2058
2169
  var _sdktracebase = require('@opentelemetry/sdk-trace-base');
2059
2170
  function applyContextAttributes(span) {
2060
- const sessionProperties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
2171
+ const sessionProperties = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
2061
2172
  if (sessionProperties) {
2062
2173
  for (const [key, value] of Object.entries(sessionProperties)) {
2063
- span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
2174
+ span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
2064
2175
  }
2065
2176
  }
2066
2177
  }
@@ -2081,7 +2192,7 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
2081
2192
  super.onStart(span, parentContext);
2082
2193
  }
2083
2194
  onEnd(span) {
2084
- const maskingConfig = _optionalChain([this, 'access', _66 => _66.config, 'access', _67 => _67.masking, 'optionalAccess', _68 => _68.spanMasking]);
2195
+ const maskingConfig = _optionalChain([this, 'access', _69 => _69.config, 'access', _70 => _70.masking, 'optionalAccess', _71 => _71.spanMasking]);
2085
2196
  if (maskingConfig) {
2086
2197
  maskReadableSpan(span, maskingConfig);
2087
2198
  }
@@ -2099,7 +2210,7 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
2099
2210
  super.onStart(span, parentContext);
2100
2211
  }
2101
2212
  onEnd(span) {
2102
- const maskingConfig = _optionalChain([this, 'access', _69 => _69.config, 'access', _70 => _70.masking, 'optionalAccess', _71 => _71.spanMasking]);
2213
+ const maskingConfig = _optionalChain([this, 'access', _72 => _72.config, 'access', _73 => _73.masking, 'optionalAccess', _74 => _74.spanMasking]);
2103
2214
  if (maskingConfig) {
2104
2215
  maskReadableSpan(span, maskingConfig);
2105
2216
  }
@@ -2133,7 +2244,7 @@ function maskReadableSpan(span, config) {
2133
2244
  }
2134
2245
 
2135
2246
  // src/internal/trace/tracing.ts
2136
- var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this); }
2247
+ var TracingModule = (_class6 = class _TracingModule {constructor() { _class6.prototype.__init13.call(this);_class6.prototype.__init14.call(this); }
2137
2248
  static __initStatic3() {this.instance = null}
2138
2249
  static getInstance() {
2139
2250
  if (!this.instance) {
@@ -2141,8 +2252,8 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
2141
2252
  }
2142
2253
  return this.instance;
2143
2254
  }
2144
- __init11() {this.spanExporter = null}
2145
- __init12() {this.spanProcessor = null}
2255
+ __init13() {this.spanExporter = null}
2256
+ __init14() {this.spanProcessor = null}
2146
2257
  /**
2147
2258
  * Initialize the span exporter
2148
2259
  */
@@ -2163,7 +2274,14 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
2163
2274
  url: tracesUrl,
2164
2275
  headers: config.headers
2165
2276
  });
2166
- this.spanExporter = new BrizzSpanExporter(otlpExporter, config);
2277
+ this.spanExporter = new BrizzSpanExporter(
2278
+ otlpExporter,
2279
+ config,
2280
+ (serviceName) => new (0, _exportertraceotlpproto.OTLPTraceExporter)({
2281
+ url: tracesUrl,
2282
+ headers: { ...config.headers, [_chunkUNLNNKZ7cjs.SERVICE_NAME_HEADER]: serviceName }
2283
+ })
2284
+ );
2167
2285
  _chunkWC573FCIcjs.logger.debug("OTLP span exporter initialized successfully");
2168
2286
  }
2169
2287
  /**
@@ -2179,7 +2297,7 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
2179
2297
  }
2180
2298
  _chunkWC573FCIcjs.logger.debug("Initializing span processor", {
2181
2299
  disableBatch: config.disableBatch,
2182
- hasMasking: !!_optionalChain([config, 'access', _72 => _72.masking, 'optionalAccess', _73 => _73.spanMasking])
2300
+ hasMasking: !!_optionalChain([config, 'access', _75 => _75.masking, 'optionalAccess', _76 => _76.spanMasking])
2183
2301
  });
2184
2302
  const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
2185
2303
  _chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
@@ -2235,7 +2353,7 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
2235
2353
  _TracingModule.instance = null;
2236
2354
  _chunkWC573FCIcjs.logger.debug("Tracing module shutdown completed");
2237
2355
  }
2238
- }, _class5.__initStatic3(), _class5);
2356
+ }, _class6.__initStatic3(), _class6);
2239
2357
  function getSpanExporter() {
2240
2358
  return TracingModule.getInstance().getSpanExporter();
2241
2359
  }
@@ -2244,7 +2362,7 @@ function getSpanProcessor() {
2244
2362
  }
2245
2363
 
2246
2364
  // src/internal/sdk.ts
2247
- var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init13.call(this);_class6.prototype.__init14.call(this);_class6.prototype.__init15.call(this); }
2365
+ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init15.call(this);_class7.prototype.__init16.call(this);_class7.prototype.__init17.call(this); }
2248
2366
  static __initStatic4() {this.instance = null}
2249
2367
  static getInstance() {
2250
2368
  if (!this.instance) {
@@ -2253,11 +2371,11 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
2253
2371
  return this.instance;
2254
2372
  }
2255
2373
  /** Flag indicating if SDK initialization has completed successfully */
2256
- __init13() {this._initialized = false}
2374
+ __init15() {this._initialized = false}
2257
2375
  /** OpenTelemetry tracer provider */
2258
- __init14() {this._tracerProvider = null}
2376
+ __init16() {this._tracerProvider = null}
2259
2377
  /** OpenTelemetry meter provider */
2260
- __init15() {this._meterProvider = null}
2378
+ __init17() {this._meterProvider = null}
2261
2379
  /**
2262
2380
  * Set up instrumentation registry and configure manual modules.
2263
2381
  * @private
@@ -2286,7 +2404,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
2286
2404
  const resourceAttributes = {
2287
2405
  ...resolvedConfig.resourceAttributes,
2288
2406
  "service.name": resolvedConfig.appName,
2289
- [BRIZZ_SDK_VERSION]: _chunk3QYP2SDNcjs.getSDKVersion.call(void 0, ),
2407
+ [BRIZZ_SDK_VERSION]: _chunkK3NPYISBcjs.getSDKVersion.call(void 0, ),
2290
2408
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2291
2409
  };
2292
2410
  if (resolvedConfig.environment) {
@@ -2295,10 +2413,10 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
2295
2413
  if (resolvedConfig.appVersion) {
2296
2414
  resourceAttributes["service.version"] = resolvedConfig.appVersion;
2297
2415
  }
2298
- const resource = _resources.defaultResource.call(void 0, ).merge(_resources.detectResources.call(void 0, { detectors: [_resources.envDetector, _resources.hostDetector, _resources.processDetector] })).merge(_resources.resourceFromAttributes.call(void 0, resourceAttributes));
2416
+ const resource = _resources2.defaultResource.call(void 0, ).merge(_resources2.detectResources.call(void 0, { detectors: [_resources2.envDetector, _resources2.hostDetector, _resources2.processDetector] })).merge(_resources2.resourceFromAttributes.call(void 0, resourceAttributes));
2299
2417
  this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
2300
2418
  resource,
2301
- spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkEVRCHF74cjs.InterruptPropagator)(), getSpanProcessor()]
2419
+ spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkQUV5HYJ2cjs.InterruptPropagator)(), getSpanProcessor()]
2302
2420
  });
2303
2421
  this._tracerProvider.register();
2304
2422
  this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
@@ -2434,10 +2552,10 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
2434
2552
  }
2435
2553
  try {
2436
2554
  await this.shutdownModules();
2437
- await _optionalChain([this, 'access', _74 => _74._tracerProvider, 'optionalAccess', _75 => _75.forceFlush, 'call', _76 => _76()]);
2438
- await _optionalChain([this, 'access', _77 => _77._tracerProvider, 'optionalAccess', _78 => _78.shutdown, 'call', _79 => _79()]);
2439
- await _optionalChain([this, 'access', _80 => _80._meterProvider, 'optionalAccess', _81 => _81.forceFlush, 'call', _82 => _82()]);
2440
- await _optionalChain([this, 'access', _83 => _83._meterProvider, 'optionalAccess', _84 => _84.shutdown, 'call', _85 => _85()]);
2555
+ await _optionalChain([this, 'access', _77 => _77._tracerProvider, 'optionalAccess', _78 => _78.forceFlush, 'call', _79 => _79()]);
2556
+ await _optionalChain([this, 'access', _80 => _80._tracerProvider, 'optionalAccess', _81 => _81.shutdown, 'call', _82 => _82()]);
2557
+ await _optionalChain([this, 'access', _83 => _83._meterProvider, 'optionalAccess', _84 => _84.forceFlush, 'call', _85 => _85()]);
2558
+ await _optionalChain([this, 'access', _86 => _86._meterProvider, 'optionalAccess', _87 => _87.shutdown, 'call', _88 => _88()]);
2441
2559
  this._initialized = false;
2442
2560
  this._tracerProvider = null;
2443
2561
  this._meterProvider = null;
@@ -2452,7 +2570,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
2452
2570
  }
2453
2571
  }
2454
2572
  }
2455
- }, _class6.__initStatic4(), _class6);
2573
+ }, _class7.__initStatic4(), _class7);
2456
2574
  var Brizz = new _Brizz();
2457
2575
 
2458
2576
  // src/index.ts
@@ -2498,4 +2616,7 @@ var Brizz = new _Brizz();
2498
2616
 
2499
2617
 
2500
2618
 
2501
- exports.Brizz = Brizz; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.LogLevel = _chunkWC573FCIcjs.LogLevel; exports.Session = Session; exports.SessionTitle = SessionTitle; exports.SeverityNumber = _apilogs.SeverityNumber; exports.addExternalLink = addExternalLink; exports.callWithMessageId = callWithMessageId; exports.callWithMute = callWithMute; exports.callWithOrganization = callWithOrganization; exports.callWithProperties = callWithProperties; exports.callWithSessionId = callWithSessionId; exports.callWithUser = callWithUser; exports.emitEvent = emitEvent; exports.emitEventWithSessionId = emitEventWithSessionId; exports.getActiveSession = getActiveSession; exports.getLogLevel = _chunkWC573FCIcjs.getLogLevel; exports.getMetricsExporter = getMetricsExporter; exports.getMetricsReader = getMetricsReader; exports.getSpanExporter = getSpanExporter; exports.getSpanProcessor = getSpanProcessor; exports.logger = _chunkWC573FCIcjs.logger; exports.maskAttributes = maskAttributes; exports.maskValue = maskValue; exports.recordFeedback = recordFeedback; exports.recordMetric = recordMetric; exports.setCurrentSpanCustomProperties = setCurrentSpanCustomProperties; exports.setLogLevel = _chunkWC573FCIcjs.setLogLevel; exports.setMessageId = setMessageId; exports.setOrganization = setOrganization; exports.setSessionId = setSessionId; exports.setUser = setUser; exports.startSession = startSession; exports.startSessionTitle = startSessionTitle; exports.withMessageId = withMessageId; exports.withMute = withMute; exports.withOrganization = withOrganization; exports.withProperties = withProperties; exports.withSessionId = withSessionId; exports.withUser = withUser;
2619
+
2620
+
2621
+
2622
+ exports.Brizz = Brizz; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.LogLevel = _chunkWC573FCIcjs.LogLevel; exports.Session = Session; exports.SessionTitle = SessionTitle; exports.SeverityNumber = _apilogs.SeverityNumber; exports.addExternalLink = addExternalLink; exports.callWithMessageId = callWithMessageId; exports.callWithMute = callWithMute; exports.callWithOrganization = callWithOrganization; exports.callWithProperties = callWithProperties; exports.callWithServiceName = callWithServiceName; exports.callWithSessionId = callWithSessionId; exports.callWithUser = callWithUser; exports.emitEvent = emitEvent; exports.emitEventWithSessionId = emitEventWithSessionId; exports.getActiveSession = getActiveSession; exports.getLogLevel = _chunkWC573FCIcjs.getLogLevel; exports.getMetricsExporter = getMetricsExporter; exports.getMetricsReader = getMetricsReader; exports.getSpanExporter = getSpanExporter; exports.getSpanProcessor = getSpanProcessor; exports.logger = _chunkWC573FCIcjs.logger; exports.maskAttributes = maskAttributes; exports.maskValue = maskValue; exports.recordFeedback = recordFeedback; exports.recordMetric = recordMetric; exports.setCurrentSpanCustomProperties = setCurrentSpanCustomProperties; exports.setLogLevel = _chunkWC573FCIcjs.setLogLevel; exports.setMessageId = setMessageId; exports.setOrganization = setOrganization; exports.setServiceName = setServiceName; exports.setSessionId = setSessionId; exports.setUser = setUser; exports.startSession = startSession; exports.startSessionTitle = startSessionTitle; exports.withMessageId = withMessageId; exports.withMute = withMute; exports.withOrganization = withOrganization; exports.withProperties = withProperties; exports.withServiceName = withServiceName; exports.withSessionId = withSessionId; exports.withUser = withUser;