@brizz/sdk 0.1.41 → 0.1.43

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