@brizz/sdk 0.1.32 → 0.1.33

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.
@@ -4,7 +4,7 @@
4
4
  var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
5
5
 
6
6
 
7
- var _chunkSCYD7XCIcjs = require('./chunk-SCYD7XCI.cjs');
7
+ var _chunk3ITCDKTJcjs = require('./chunk-3ITCDKTJ.cjs');
8
8
 
9
9
 
10
10
 
@@ -13,7 +13,7 @@ var _chunkSCYD7XCIcjs = require('./chunk-SCYD7XCI.cjs');
13
13
  var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
14
14
 
15
15
 
16
- var _chunkA3OOY5A2cjs = require('./chunk-A3OOY5A2.cjs');
16
+ var _chunkLFLYWZ6Dcjs = require('./chunk-LFLYWZ6D.cjs');
17
17
 
18
18
 
19
19
 
@@ -34,7 +34,24 @@ var _chunkA3OOY5A2cjs = require('./chunk-A3OOY5A2.cjs');
34
34
 
35
35
 
36
36
 
37
- var _chunkOZCOXBB7cjs = require('./chunk-OZCOXBB7.cjs');
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+ var _chunkLIFLVFK6cjs = require('./chunk-LIFLVFK6.cjs');
38
55
 
39
56
 
40
57
  var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
@@ -144,7 +161,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
144
161
  const mcpModules = this.manualModules.mcp;
145
162
  void (async () => {
146
163
  try {
147
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-GXP22YAQ.cjs")));
164
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-OKSS2R56.cjs")));
148
165
  const instrumentation = new MCPInstrumentation({ exceptionLogger });
149
166
  instrumentation.manuallyInstrument(mcpModules);
150
167
  _chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
@@ -635,10 +652,10 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
635
652
  if (maskingConfig) {
636
653
  maskLog(logRecord, maskingConfig);
637
654
  }
638
- const associationProperties = _api.context.active().getValue(_chunkOZCOXBB7cjs.PROPERTIES_CONTEXT_KEY);
655
+ const associationProperties = _api.context.active().getValue(_chunkLIFLVFK6cjs.PROPERTIES_CONTEXT_KEY);
639
656
  if (associationProperties) {
640
657
  for (const [key, value] of Object.entries(associationProperties)) {
641
- logRecord.setAttribute(`${_chunkOZCOXBB7cjs.BRIZZ}.${key}`, value);
658
+ logRecord.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${key}`, value);
642
659
  }
643
660
  }
644
661
  super.onEmit(logRecord);
@@ -655,10 +672,10 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
655
672
  if (maskingConfig) {
656
673
  maskLog(logRecord, maskingConfig);
657
674
  }
658
- const associationProperties = _api.context.active().getValue(_chunkOZCOXBB7cjs.PROPERTIES_CONTEXT_KEY);
675
+ const associationProperties = _api.context.active().getValue(_chunkLIFLVFK6cjs.PROPERTIES_CONTEXT_KEY);
659
676
  if (associationProperties) {
660
677
  for (const [key, value] of Object.entries(associationProperties)) {
661
- logRecord.setAttribute(`${_chunkOZCOXBB7cjs.BRIZZ}.${key}`, value);
678
+ logRecord.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${key}`, value);
662
679
  }
663
680
  }
664
681
  super.onEmit(logRecord);
@@ -685,7 +702,7 @@ function maskLog(logRecord, config) {
685
702
  newAttributes[key] = value;
686
703
  }
687
704
  for (const [key, value] of Object.entries(logRecord.attributes)) {
688
- if (key.startsWith(_chunkOZCOXBB7cjs.INTERNAL_EVENT_PREFIX)) {
705
+ if (key.startsWith(_chunkLIFLVFK6cjs.INTERNAL_EVENT_PREFIX)) {
689
706
  newAttributes[key] = value;
690
707
  }
691
708
  }
@@ -776,7 +793,7 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
776
793
  const resourceAttributes = {
777
794
  ...config.resourceAttributes,
778
795
  "service.name": config.appName,
779
- [BRIZZ_SDK_VERSION]: _chunkSCYD7XCIcjs.getSDKVersion.call(void 0, ),
796
+ [BRIZZ_SDK_VERSION]: _chunk3ITCDKTJcjs.getSDKVersion.call(void 0, ),
780
797
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
781
798
  };
782
799
  if (config.environment) {
@@ -892,16 +909,16 @@ function setCurrentSpanCustomProperties(properties) {
892
909
  }
893
910
  for (const [key, value] of Object.entries(properties)) {
894
911
  try {
895
- current.setAttribute(`${_chunkOZCOXBB7cjs.BRIZZ}.${key}`, value);
912
+ current.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${key}`, value);
896
913
  } catch (e) {
897
914
  }
898
915
  }
899
916
  }
900
917
  function callWithProperties(properties, fn, thisArg, ...args) {
901
918
  const base = _api.context.active();
902
- const prev = base.getValue(_chunkOZCOXBB7cjs.PROPERTIES_CONTEXT_KEY);
919
+ const prev = base.getValue(_chunkLIFLVFK6cjs.PROPERTIES_CONTEXT_KEY);
903
920
  const merged = prev ? { ...prev, ...properties } : properties;
904
- const next = base.setValue(_chunkOZCOXBB7cjs.PROPERTIES_CONTEXT_KEY, merged);
921
+ const next = base.setValue(_chunkLIFLVFK6cjs.PROPERTIES_CONTEXT_KEY, merged);
905
922
  return _api.context.with(next, fn, thisArg, ...args);
906
923
  }
907
924
  function withProperties(properties, fn, thisArg) {
@@ -914,14 +931,144 @@ function withProperties(properties, fn, thisArg) {
914
931
  );
915
932
  };
916
933
  }
934
+ function propagatePropertiesImperatively(properties) {
935
+ try {
936
+ const manager = _api.context;
937
+ const mgr = _optionalChain([manager, 'access', _35 => _35._getContextManager, 'optionalCall', _36 => _36()]);
938
+ const store = _optionalChain([mgr, 'optionalAccess', _37 => _37._asyncLocalStorage]);
939
+ if (!store || typeof store.enterWith !== "function") {
940
+ return;
941
+ }
942
+ const base = _api.context.active();
943
+ const prev = base.getValue(_chunkLIFLVFK6cjs.PROPERTIES_CONTEXT_KEY);
944
+ const merged = prev ? { ...prev, ...properties } : properties;
945
+ store.enterWith(base.setValue(_chunkLIFLVFK6cjs.PROPERTIES_CONTEXT_KEY, merged));
946
+ } catch (e2) {
947
+ }
948
+ }
949
+ function setUser(user) {
950
+ const properties = { [_chunkLIFLVFK6cjs.USER_ID]: user.id };
951
+ if (user.email !== void 0) {
952
+ properties[_chunkLIFLVFK6cjs.USER_EMAIL] = user.email;
953
+ }
954
+ if (user.name !== void 0) {
955
+ properties[_chunkLIFLVFK6cjs.USER_NAME] = user.name;
956
+ }
957
+ if (user.role !== void 0) {
958
+ properties[_chunkLIFLVFK6cjs.USER_ROLE] = user.role;
959
+ }
960
+ if (user.plan !== void 0) {
961
+ properties[_chunkLIFLVFK6cjs.USER_PLAN] = user.plan;
962
+ }
963
+ if (user.traits) {
964
+ for (const [key, value] of Object.entries(user.traits)) {
965
+ const k = `user.${key}`;
966
+ if (properties[k] === void 0) {
967
+ properties[k] = value;
968
+ }
969
+ }
970
+ }
971
+ setCurrentSpanCustomProperties(properties);
972
+ propagatePropertiesImperatively(properties);
973
+ }
974
+ function setOrganization(org) {
975
+ const properties = { [_chunkLIFLVFK6cjs.ORGANIZATION_ID]: org.id };
976
+ if (org.name !== void 0) {
977
+ properties[_chunkLIFLVFK6cjs.ORGANIZATION_NAME] = org.name;
978
+ }
979
+ if (org.plan !== void 0) {
980
+ properties[_chunkLIFLVFK6cjs.ORGANIZATION_PLAN] = org.plan;
981
+ }
982
+ if (org.domain !== void 0) {
983
+ properties[_chunkLIFLVFK6cjs.ORGANIZATION_DOMAIN] = org.domain;
984
+ }
985
+ if (org.traits) {
986
+ for (const [key, value] of Object.entries(org.traits)) {
987
+ const k = `organization.${key}`;
988
+ if (properties[k] === void 0) {
989
+ properties[k] = value;
990
+ }
991
+ }
992
+ }
993
+ setCurrentSpanCustomProperties(properties);
994
+ propagatePropertiesImperatively(properties);
995
+ }
996
+ function setMessageId(id) {
997
+ const properties = { [_chunkLIFLVFK6cjs.MESSAGE_ID]: id };
998
+ setCurrentSpanCustomProperties(properties);
999
+ propagatePropertiesImperatively(properties);
1000
+ }
1001
+ function userProperties(user) {
1002
+ const properties = { [_chunkLIFLVFK6cjs.USER_ID]: user.id };
1003
+ if (user.email !== void 0) {
1004
+ properties[_chunkLIFLVFK6cjs.USER_EMAIL] = user.email;
1005
+ }
1006
+ if (user.name !== void 0) {
1007
+ properties[_chunkLIFLVFK6cjs.USER_NAME] = user.name;
1008
+ }
1009
+ if (user.role !== void 0) {
1010
+ properties[_chunkLIFLVFK6cjs.USER_ROLE] = user.role;
1011
+ }
1012
+ if (user.plan !== void 0) {
1013
+ properties[_chunkLIFLVFK6cjs.USER_PLAN] = user.plan;
1014
+ }
1015
+ if (user.traits) {
1016
+ for (const [key, value] of Object.entries(user.traits)) {
1017
+ const k = `user.${key}`;
1018
+ if (properties[k] === void 0) {
1019
+ properties[k] = value;
1020
+ }
1021
+ }
1022
+ }
1023
+ return properties;
1024
+ }
1025
+ function organizationProperties(org) {
1026
+ const properties = { [_chunkLIFLVFK6cjs.ORGANIZATION_ID]: org.id };
1027
+ if (org.name !== void 0) {
1028
+ properties[_chunkLIFLVFK6cjs.ORGANIZATION_NAME] = org.name;
1029
+ }
1030
+ if (org.plan !== void 0) {
1031
+ properties[_chunkLIFLVFK6cjs.ORGANIZATION_PLAN] = org.plan;
1032
+ }
1033
+ if (org.domain !== void 0) {
1034
+ properties[_chunkLIFLVFK6cjs.ORGANIZATION_DOMAIN] = org.domain;
1035
+ }
1036
+ if (org.traits) {
1037
+ for (const [key, value] of Object.entries(org.traits)) {
1038
+ const k = `organization.${key}`;
1039
+ if (properties[k] === void 0) {
1040
+ properties[k] = value;
1041
+ }
1042
+ }
1043
+ }
1044
+ return properties;
1045
+ }
1046
+ function callWithUser(user, fn, thisArg, ...args) {
1047
+ return callWithProperties(userProperties(user), fn, thisArg, ...args);
1048
+ }
1049
+ function withUser(user, fn, thisArg) {
1050
+ return withProperties(userProperties(user), fn, thisArg);
1051
+ }
1052
+ function callWithOrganization(org, fn, thisArg, ...args) {
1053
+ return callWithProperties(organizationProperties(org), fn, thisArg, ...args);
1054
+ }
1055
+ function withOrganization(org, fn, thisArg) {
1056
+ return withProperties(organizationProperties(org), fn, thisArg);
1057
+ }
1058
+ function callWithMessageId(id, fn, thisArg, ...args) {
1059
+ return callWithProperties({ [_chunkLIFLVFK6cjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
1060
+ }
1061
+ function withMessageId(id, fn, thisArg) {
1062
+ return withProperties({ [_chunkLIFLVFK6cjs.MESSAGE_ID]: id }, fn, thisArg);
1063
+ }
917
1064
  function muteProperties(options) {
918
1065
  const { input = true, output = true } = options;
919
1066
  const properties = {};
920
1067
  if (input) {
921
- properties[_chunkOZCOXBB7cjs.MUTE_INPUT] = "true";
1068
+ properties[_chunkLIFLVFK6cjs.MUTE_INPUT] = "true";
922
1069
  }
923
1070
  if (output) {
924
- properties[_chunkOZCOXBB7cjs.MUTE_OUTPUT] = "true";
1071
+ properties[_chunkLIFLVFK6cjs.MUTE_OUTPUT] = "true";
925
1072
  }
926
1073
  return properties;
927
1074
  }
@@ -932,11 +1079,11 @@ function withMute(options, fn, thisArg) {
932
1079
  return withProperties(muteProperties(options), fn, thisArg);
933
1080
  }
934
1081
  function withSessionId(sessionId, fn, thisArg, extraProperties) {
935
- const properties = { [_chunkOZCOXBB7cjs.SESSION_ID]: sessionId, ...extraProperties };
1082
+ const properties = { [_chunkLIFLVFK6cjs.SESSION_ID]: sessionId, ...extraProperties };
936
1083
  return withProperties(properties, fn, thisArg);
937
1084
  }
938
1085
  function callWithSessionId(sessionId, fn, thisArg, ...args) {
939
- return callWithProperties({ [_chunkOZCOXBB7cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
1086
+ return callWithProperties({ [_chunkLIFLVFK6cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
940
1087
  }
941
1088
  var Session = (_class3 = class {
942
1089
 
@@ -964,8 +1111,8 @@ var Session = (_class3 = class {
964
1111
  setInput(text, context4) {
965
1112
  this.inputs.push(text);
966
1113
  this.inputContexts.push(_nullishCoalesce(context4, () => ( {})));
967
- this.span.setAttribute(_chunkOZCOXBB7cjs.SESSION_INPUT, JSON.stringify(this.inputs));
968
- this.span.setAttribute(_chunkOZCOXBB7cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
1114
+ this.span.setAttribute(_chunkLIFLVFK6cjs.SESSION_INPUT, JSON.stringify(this.inputs));
1115
+ this.span.setAttribute(_chunkLIFLVFK6cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
969
1116
  }
970
1117
  /**
971
1118
  * Append an assistant turn to session output tracking.
@@ -980,8 +1127,8 @@ var Session = (_class3 = class {
980
1127
  setOutput(text, context4) {
981
1128
  this.outputs.push(text);
982
1129
  this.outputContexts.push(_nullishCoalesce(context4, () => ( {})));
983
- this.span.setAttribute(_chunkOZCOXBB7cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
984
- this.span.setAttribute(_chunkOZCOXBB7cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
1130
+ this.span.setAttribute(_chunkLIFLVFK6cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
1131
+ this.span.setAttribute(_chunkLIFLVFK6cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
985
1132
  }
986
1133
  /**
987
1134
  * Set the session title on the span.
@@ -989,7 +1136,7 @@ var Session = (_class3 = class {
989
1136
  * @param title - The generated title string
990
1137
  */
991
1138
  setTitle(title) {
992
- this.span.setAttribute(_chunkOZCOXBB7cjs.SESSION_TITLE, title);
1139
+ this.span.setAttribute(_chunkLIFLVFK6cjs.SESSION_TITLE, title);
993
1140
  }
994
1141
  /**
995
1142
  * Update custom properties on the session span.
@@ -999,7 +1146,56 @@ var Session = (_class3 = class {
999
1146
  */
1000
1147
  updateProperties(properties) {
1001
1148
  for (const [key, value] of Object.entries(properties)) {
1002
- this.span.setAttribute(`${_chunkOZCOXBB7cjs.BRIZZ}.${key}`, value);
1149
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${key}`, value);
1150
+ }
1151
+ }
1152
+ /**
1153
+ * Set end-user identity on the session span: `brizz.user.id` and, when
1154
+ * provided, `brizz.user.email` / `brizz.user.name`. Undefined fields are omitted.
1155
+ *
1156
+ * @param user - User identity (`id` required; `email` / `name` optional)
1157
+ */
1158
+ setUser(user) {
1159
+ if (user.traits) {
1160
+ for (const [key, value] of Object.entries(user.traits)) {
1161
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.user.${key}`, value);
1162
+ }
1163
+ }
1164
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.USER_ID}`, user.id);
1165
+ if (user.email !== void 0) {
1166
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.USER_EMAIL}`, user.email);
1167
+ }
1168
+ if (user.name !== void 0) {
1169
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.USER_NAME}`, user.name);
1170
+ }
1171
+ if (user.role !== void 0) {
1172
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.USER_ROLE}`, user.role);
1173
+ }
1174
+ if (user.plan !== void 0) {
1175
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.USER_PLAN}`, user.plan);
1176
+ }
1177
+ }
1178
+ /**
1179
+ * Set organization identity on the session span: `brizz.organization.id` and,
1180
+ * when provided, `brizz.organization.name`. Undefined fields are omitted.
1181
+ *
1182
+ * @param org - Organization identity (`id` required; `name` optional)
1183
+ */
1184
+ setOrganization(org) {
1185
+ if (org.traits) {
1186
+ for (const [key, value] of Object.entries(org.traits)) {
1187
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.organization.${key}`, value);
1188
+ }
1189
+ }
1190
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.ORGANIZATION_ID}`, org.id);
1191
+ if (org.name !== void 0) {
1192
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.ORGANIZATION_NAME}`, org.name);
1193
+ }
1194
+ if (org.plan !== void 0) {
1195
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.ORGANIZATION_PLAN}`, org.plan);
1196
+ }
1197
+ if (org.domain !== void 0) {
1198
+ this.span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.ORGANIZATION_DOMAIN}`, org.domain);
1003
1199
  }
1004
1200
  }
1005
1201
  /**
@@ -1015,7 +1211,7 @@ var Session = (_class3 = class {
1015
1211
  * (free-form category, defaults to `'generic'`)
1016
1212
  */
1017
1213
  addExternalLink(url, options) {
1018
- emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _35 => _35.title]), _optionalChain([options, 'optionalAccess', _36 => _36.linkType]));
1214
+ emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _38 => _38.title]), _optionalChain([options, 'optionalAccess', _39 => _39.linkType]));
1019
1215
  }
1020
1216
  }, _class3);
1021
1217
  var SessionTitle = class {
@@ -1029,56 +1225,106 @@ var SessionTitle = class {
1029
1225
  * @param title - The generated title string
1030
1226
  */
1031
1227
  setTitle(title) {
1032
- this.span.setAttribute(_chunkOZCOXBB7cjs.SESSION_TITLE, title);
1228
+ this.span.setAttribute(_chunkLIFLVFK6cjs.SESSION_TITLE, title);
1033
1229
  }
1034
1230
  };
1035
1231
  function getActiveSession() {
1036
- return _api.context.active().getValue(_chunkOZCOXBB7cjs.SESSION_OBJECT_CONTEXT_KEY);
1232
+ return _api.context.active().getValue(_chunkLIFLVFK6cjs.SESSION_OBJECT_CONTEXT_KEY);
1037
1233
  }
1038
1234
  function resolveSessionIdFromContext() {
1039
1235
  const active = getActiveSession();
1040
1236
  if (active) {
1041
1237
  return active.sessionId;
1042
1238
  }
1043
- const props = _api.context.active().getValue(_chunkOZCOXBB7cjs.PROPERTIES_CONTEXT_KEY);
1044
- return _optionalChain([props, 'optionalAccess', _37 => _37[_chunkOZCOXBB7cjs.SESSION_ID]]);
1239
+ const props = _api.context.active().getValue(_chunkLIFLVFK6cjs.PROPERTIES_CONTEXT_KEY);
1240
+ return _optionalChain([props, 'optionalAccess', _40 => _40[_chunkLIFLVFK6cjs.SESSION_ID]]);
1241
+ }
1242
+ function resolveMessageIdFromContext() {
1243
+ const props = _api.context.active().getValue(_chunkLIFLVFK6cjs.PROPERTIES_CONTEXT_KEY);
1244
+ return _optionalChain([props, 'optionalAccess', _41 => _41[_chunkLIFLVFK6cjs.MESSAGE_ID]]);
1045
1245
  }
1046
1246
  function emitExternalLink(sessionId, url, title, linkType) {
1047
1247
  try {
1048
- emitEventWithSessionId(sessionId, _chunkOZCOXBB7cjs.EXTERNAL_LINK_EVENT_NAME, {
1049
- [_chunkOZCOXBB7cjs.EXTERNAL_LINK_URL]: url,
1050
- [_chunkOZCOXBB7cjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
1051
- [_chunkOZCOXBB7cjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
1248
+ emitEventWithSessionId(sessionId, _chunkLIFLVFK6cjs.EXTERNAL_LINK_EVENT_NAME, {
1249
+ [_chunkLIFLVFK6cjs.EXTERNAL_LINK_URL]: url,
1250
+ [_chunkLIFLVFK6cjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
1251
+ [_chunkLIFLVFK6cjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
1052
1252
  });
1053
1253
  } catch (error) {
1054
1254
  _chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
1055
1255
  }
1056
1256
  }
1057
1257
  function addExternalLink(url, options) {
1058
- const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _38 => _38.sessionId]), () => ( resolveSessionIdFromContext()));
1258
+ const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _42 => _42.sessionId]), () => ( resolveSessionIdFromContext()));
1059
1259
  if (!sessionId) {
1060
1260
  _chunkWC573FCIcjs.logger.warn(
1061
1261
  "addExternalLink called without a resolvable session id; link dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope."
1062
1262
  );
1063
1263
  return;
1064
1264
  }
1065
- emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _39 => _39.title]), _optionalChain([options, 'optionalAccess', _40 => _40.linkType]));
1265
+ emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _43 => _43.title]), _optionalChain([options, 'optionalAccess', _44 => _44.linkType]));
1266
+ }
1267
+ function recordFeedback(type, options) {
1268
+ const attributes = { [_chunkLIFLVFK6cjs.FEEDBACK_TYPE]: type };
1269
+ if (_optionalChain([options, 'optionalAccess', _45 => _45.score]) !== void 0) {
1270
+ attributes[_chunkLIFLVFK6cjs.FEEDBACK_SCORE] = options.score;
1271
+ }
1272
+ if (_optionalChain([options, 'optionalAccess', _46 => _46.reason]) !== void 0) {
1273
+ attributes[_chunkLIFLVFK6cjs.FEEDBACK_REASON] = options.reason;
1274
+ }
1275
+ if (_optionalChain([options, 'optionalAccess', _47 => _47.comment]) !== void 0) {
1276
+ attributes[_chunkLIFLVFK6cjs.FEEDBACK_COMMENT] = options.comment;
1277
+ }
1278
+ if (_optionalChain([options, 'optionalAccess', _48 => _48.source]) !== void 0) {
1279
+ attributes[_chunkLIFLVFK6cjs.FEEDBACK_SOURCE] = options.source;
1280
+ }
1281
+ if (_optionalChain([options, 'optionalAccess', _49 => _49.traits])) {
1282
+ for (const [key, value] of Object.entries(options.traits)) {
1283
+ const k = `${_chunkLIFLVFK6cjs.FEEDBACK_ATTR_PREFIX}${key}`;
1284
+ if (attributes[k] === void 0) {
1285
+ attributes[k] = value;
1286
+ }
1287
+ }
1288
+ }
1289
+ const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _50 => _50.messageId]), () => ( resolveMessageIdFromContext()));
1290
+ const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _51 => _51.sessionId]), () => ( resolveSessionIdFromContext()));
1291
+ if (messageId === void 0 && sessionId === void 0) {
1292
+ _chunkWC573FCIcjs.logger.warn(
1293
+ "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."
1294
+ );
1295
+ }
1296
+ const anchor = {};
1297
+ if (messageId !== void 0) {
1298
+ anchor[_chunkLIFLVFK6cjs.MESSAGE_ID] = messageId;
1299
+ }
1300
+ if (sessionId !== void 0) {
1301
+ anchor[_chunkLIFLVFK6cjs.SESSION_ID] = sessionId;
1302
+ }
1303
+ try {
1304
+ if (Object.keys(anchor).length === 0) {
1305
+ emitEvent(_chunkLIFLVFK6cjs.FEEDBACK_EVENT_NAME, attributes);
1306
+ } else {
1307
+ callWithProperties(anchor, () => emitEvent(_chunkLIFLVFK6cjs.FEEDBACK_EVENT_NAME, attributes));
1308
+ }
1309
+ } catch (error) {
1310
+ _chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
1311
+ }
1066
1312
  }
1067
1313
  function startSession(sessionId, callback, extraProperties, options) {
1068
- const isTitle = _optionalChain([options, 'optionalAccess', _41 => _41.mode]) === "title";
1069
- const spanName = isTitle ? _chunkOZCOXBB7cjs.SESSION_TITLE_SPAN_NAME : _chunkOZCOXBB7cjs.SESSION_SPAN_NAME;
1314
+ const isTitle = _optionalChain([options, 'optionalAccess', _52 => _52.mode]) === "title";
1315
+ const spanName = isTitle ? _chunkLIFLVFK6cjs.SESSION_TITLE_SPAN_NAME : _chunkLIFLVFK6cjs.SESSION_SPAN_NAME;
1070
1316
  const tracer = _api.trace.getTracer("@brizz/sdk");
1071
1317
  return tracer.startActiveSpan(spanName, (span) => {
1072
- span.setAttribute(`${_chunkOZCOXBB7cjs.BRIZZ}.${_chunkOZCOXBB7cjs.SESSION_ID}`, sessionId);
1318
+ span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.SESSION_ID}`, sessionId);
1073
1319
  if (extraProperties) {
1074
1320
  for (const [key, value] of Object.entries(extraProperties)) {
1075
- span.setAttribute(`${_chunkOZCOXBB7cjs.BRIZZ}.${key}`, value);
1321
+ span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${key}`, value);
1076
1322
  }
1077
1323
  }
1078
1324
  const session = new Session(sessionId, span);
1079
- const contextProperties = { [_chunkOZCOXBB7cjs.SESSION_ID]: sessionId };
1325
+ const contextProperties = { [_chunkLIFLVFK6cjs.SESSION_ID]: sessionId };
1080
1326
  if (isTitle) {
1081
- contextProperties[_chunkOZCOXBB7cjs.SESSION_TITLE_GENERATION] = "true";
1327
+ contextProperties[_chunkLIFLVFK6cjs.SESSION_TITLE_GENERATION] = "true";
1082
1328
  }
1083
1329
  if (extraProperties) {
1084
1330
  for (const [key, value] of Object.entries(extraProperties)) {
@@ -1086,7 +1332,7 @@ function startSession(sessionId, callback, extraProperties, options) {
1086
1332
  }
1087
1333
  }
1088
1334
  return callWithProperties(contextProperties, () => {
1089
- const sessionCtx = _api.context.active().setValue(_chunkOZCOXBB7cjs.SESSION_OBJECT_CONTEXT_KEY, session);
1335
+ const sessionCtx = _api.context.active().setValue(_chunkLIFLVFK6cjs.SESSION_OBJECT_CONTEXT_KEY, session);
1090
1336
  return _api.context.with(sessionCtx, () => {
1091
1337
  try {
1092
1338
  const result = callback(session);
@@ -1114,16 +1360,16 @@ function startSession(sessionId, callback, extraProperties, options) {
1114
1360
  });
1115
1361
  }
1116
1362
  function startSessionTitle(callback, options) {
1117
- const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _42 => _42.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _43 => _43(), 'optionalAccess', _44 => _44.sessionId])));
1363
+ const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _54 => _54(), 'optionalAccess', _55 => _55.sessionId])));
1118
1364
  const tracer = _api.trace.getTracer("@brizz/sdk");
1119
- return tracer.startActiveSpan(_chunkOZCOXBB7cjs.SESSION_TITLE_SPAN_NAME, (span) => {
1365
+ return tracer.startActiveSpan(_chunkLIFLVFK6cjs.SESSION_TITLE_SPAN_NAME, (span) => {
1120
1366
  if (resolvedSessionId) {
1121
- span.setAttribute(`${_chunkOZCOXBB7cjs.BRIZZ}.${_chunkOZCOXBB7cjs.SESSION_ID}`, resolvedSessionId);
1367
+ span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${_chunkLIFLVFK6cjs.SESSION_ID}`, resolvedSessionId);
1122
1368
  }
1123
1369
  const sessionTitle = new SessionTitle(span);
1124
- const properties = { [_chunkOZCOXBB7cjs.SESSION_TITLE_GENERATION]: "true" };
1370
+ const properties = { [_chunkLIFLVFK6cjs.SESSION_TITLE_GENERATION]: "true" };
1125
1371
  if (resolvedSessionId) {
1126
- properties[_chunkOZCOXBB7cjs.SESSION_ID] = resolvedSessionId;
1372
+ properties[_chunkLIFLVFK6cjs.SESSION_ID] = resolvedSessionId;
1127
1373
  }
1128
1374
  return callWithProperties(properties, () => {
1129
1375
  try {
@@ -1268,7 +1514,7 @@ var BrizzSpanExporter = class {
1268
1514
  const resourceAttrs = {
1269
1515
  ...config.resourceAttributes,
1270
1516
  "service.name": config.appName,
1271
- [BRIZZ_SDK_VERSION]: _chunkSCYD7XCIcjs.getSDKVersion.call(void 0, ),
1517
+ [BRIZZ_SDK_VERSION]: _chunk3ITCDKTJcjs.getSDKVersion.call(void 0, ),
1272
1518
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
1273
1519
  };
1274
1520
  if (config.environment) {
@@ -1320,7 +1566,7 @@ var BrizzSpanExporter = class {
1320
1566
  return this._delegate.shutdown();
1321
1567
  }
1322
1568
  async forceFlush() {
1323
- return _optionalChain([this, 'access', _45 => _45._delegate, 'access', _46 => _46.forceFlush, 'optionalCall', _47 => _47()]);
1569
+ return _optionalChain([this, 'access', _56 => _56._delegate, 'access', _57 => _57.forceFlush, 'optionalCall', _58 => _58()]);
1324
1570
  }
1325
1571
  };
1326
1572
 
@@ -1331,10 +1577,10 @@ var BrizzSpanExporter = class {
1331
1577
 
1332
1578
  var _sdktracebase = require('@opentelemetry/sdk-trace-base');
1333
1579
  function applyContextAttributes(span) {
1334
- const sessionProperties = _api.context.active().getValue(_chunkOZCOXBB7cjs.PROPERTIES_CONTEXT_KEY);
1580
+ const sessionProperties = _api.context.active().getValue(_chunkLIFLVFK6cjs.PROPERTIES_CONTEXT_KEY);
1335
1581
  if (sessionProperties) {
1336
1582
  for (const [key, value] of Object.entries(sessionProperties)) {
1337
- span.setAttribute(`${_chunkOZCOXBB7cjs.BRIZZ}.${key}`, value);
1583
+ span.setAttribute(`${_chunkLIFLVFK6cjs.BRIZZ}.${key}`, value);
1338
1584
  }
1339
1585
  }
1340
1586
  }
@@ -1355,7 +1601,7 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
1355
1601
  super.onStart(span, parentContext);
1356
1602
  }
1357
1603
  onEnd(span) {
1358
- const maskingConfig = _optionalChain([this, 'access', _48 => _48.config, 'access', _49 => _49.masking, 'optionalAccess', _50 => _50.spanMasking]);
1604
+ const maskingConfig = _optionalChain([this, 'access', _59 => _59.config, 'access', _60 => _60.masking, 'optionalAccess', _61 => _61.spanMasking]);
1359
1605
  if (maskingConfig) {
1360
1606
  maskReadableSpan(span, maskingConfig);
1361
1607
  }
@@ -1373,7 +1619,7 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
1373
1619
  super.onStart(span, parentContext);
1374
1620
  }
1375
1621
  onEnd(span) {
1376
- const maskingConfig = _optionalChain([this, 'access', _51 => _51.config, 'access', _52 => _52.masking, 'optionalAccess', _53 => _53.spanMasking]);
1622
+ const maskingConfig = _optionalChain([this, 'access', _62 => _62.config, 'access', _63 => _63.masking, 'optionalAccess', _64 => _64.spanMasking]);
1377
1623
  if (maskingConfig) {
1378
1624
  maskReadableSpan(span, maskingConfig);
1379
1625
  }
@@ -1453,7 +1699,7 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
1453
1699
  }
1454
1700
  _chunkWC573FCIcjs.logger.debug("Initializing span processor", {
1455
1701
  disableBatch: config.disableBatch,
1456
- hasMasking: !!_optionalChain([config, 'access', _54 => _54.masking, 'optionalAccess', _55 => _55.spanMasking])
1702
+ hasMasking: !!_optionalChain([config, 'access', _65 => _65.masking, 'optionalAccess', _66 => _66.spanMasking])
1457
1703
  });
1458
1704
  const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
1459
1705
  _chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
@@ -1533,7 +1779,7 @@ var _sdktracenode = require('@opentelemetry/sdk-trace-node');
1533
1779
 
1534
1780
  // src/internal/config.ts
1535
1781
  function resolveConfig(options) {
1536
- const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access', _56 => _56.logLevel, 'optionalAccess', _57 => _57.toString, 'call', _58 => _58()]) || _chunkWC573FCIcjs.DEFAULT_LOG_LEVEL.toString();
1782
+ const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access', _67 => _67.logLevel, 'optionalAccess', _68 => _68.toString, 'call', _69 => _69()]) || _chunkWC573FCIcjs.DEFAULT_LOG_LEVEL.toString();
1537
1783
  let resolvedLogLevel;
1538
1784
  if (envLogLevel) {
1539
1785
  resolvedLogLevel = _chunkWC573FCIcjs.parseLogLevel.call(void 0, envLogLevel);
@@ -1704,7 +1950,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
1704
1950
  const resourceAttributes = {
1705
1951
  ...resolvedConfig.resourceAttributes,
1706
1952
  "service.name": resolvedConfig.appName,
1707
- [BRIZZ_SDK_VERSION]: _chunkSCYD7XCIcjs.getSDKVersion.call(void 0, ),
1953
+ [BRIZZ_SDK_VERSION]: _chunk3ITCDKTJcjs.getSDKVersion.call(void 0, ),
1708
1954
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
1709
1955
  };
1710
1956
  if (resolvedConfig.environment) {
@@ -1716,7 +1962,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
1716
1962
  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));
1717
1963
  this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
1718
1964
  resource,
1719
- spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkA3OOY5A2cjs.InterruptPropagator)(), getSpanProcessor()]
1965
+ spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkLFLYWZ6Dcjs.InterruptPropagator)(), getSpanProcessor()]
1720
1966
  });
1721
1967
  this._tracerProvider.register();
1722
1968
  this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
@@ -1774,19 +2020,19 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
1774
2020
  try {
1775
2021
  const tracingModule = TracingModule.getInstance();
1776
2022
  await tracingModule.shutdown();
1777
- } catch (e2) {
2023
+ } catch (e3) {
1778
2024
  _chunkWC573FCIcjs.logger.debug("Tracing module already shut down or not initialized");
1779
2025
  }
1780
2026
  try {
1781
2027
  const metricsModule = MetricsModule.getInstance();
1782
2028
  metricsModule.shutdown();
1783
- } catch (e3) {
2029
+ } catch (e4) {
1784
2030
  _chunkWC573FCIcjs.logger.debug("Metrics module already shut down or not initialized");
1785
2031
  }
1786
2032
  try {
1787
2033
  const loggingModule = LoggingModule.getInstance();
1788
2034
  await loggingModule.shutdown();
1789
- } catch (e4) {
2035
+ } catch (e5) {
1790
2036
  _chunkWC573FCIcjs.logger.debug("Logging module already shut down or not initialized");
1791
2037
  }
1792
2038
  _chunkWC573FCIcjs.logger.info("All telemetry modules shut down successfully");
@@ -1852,10 +2098,10 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
1852
2098
  }
1853
2099
  try {
1854
2100
  await this.shutdownModules();
1855
- await _optionalChain([this, 'access', _59 => _59._tracerProvider, 'optionalAccess', _60 => _60.forceFlush, 'call', _61 => _61()]);
1856
- await _optionalChain([this, 'access', _62 => _62._tracerProvider, 'optionalAccess', _63 => _63.shutdown, 'call', _64 => _64()]);
1857
- await _optionalChain([this, 'access', _65 => _65._meterProvider, 'optionalAccess', _66 => _66.forceFlush, 'call', _67 => _67()]);
1858
- await _optionalChain([this, 'access', _68 => _68._meterProvider, 'optionalAccess', _69 => _69.shutdown, 'call', _70 => _70()]);
2101
+ await _optionalChain([this, 'access', _70 => _70._tracerProvider, 'optionalAccess', _71 => _71.forceFlush, 'call', _72 => _72()]);
2102
+ await _optionalChain([this, 'access', _73 => _73._tracerProvider, 'optionalAccess', _74 => _74.shutdown, 'call', _75 => _75()]);
2103
+ await _optionalChain([this, 'access', _76 => _76._meterProvider, 'optionalAccess', _77 => _77.forceFlush, 'call', _78 => _78()]);
2104
+ await _optionalChain([this, 'access', _79 => _79._meterProvider, 'optionalAccess', _80 => _80.shutdown, 'call', _81 => _81()]);
1859
2105
  this._initialized = false;
1860
2106
  this._tracerProvider = null;
1861
2107
  this._meterProvider = null;
@@ -1884,7 +2130,7 @@ function detectRuntime() {
1884
2130
  const supportsLoaderAPI = (_nullishCoalesce(major, () => ( 0))) >= 21 || (_nullishCoalesce(major, () => ( 0))) === 20 && (_nullishCoalesce(minor, () => ( 0))) >= 6 || (_nullishCoalesce(major, () => ( 0))) === 18 && (_nullishCoalesce(minor, () => ( 0))) >= 19;
1885
2131
  const supportsRegister = (
1886
2132
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1887
- !!_optionalChain([process, 'access', _71 => _71.features, 'optionalAccess', _72 => _72.typescript]) || !!_optionalChain([globalThis, 'access', _73 => _73.module, 'optionalAccess', _74 => _74.register])
2133
+ !!_optionalChain([process, 'access', _82 => _82.features, 'optionalAccess', _83 => _83.typescript]) || !!_optionalChain([globalThis, 'access', _84 => _84.module, 'optionalAccess', _85 => _85.register])
1888
2134
  );
1889
2135
  _chunkWC573FCIcjs.logger.debug("Runtime detection results:", {
1890
2136
  nodeVersion: `${_nullishCoalesce(major, () => ( 0))}.${_nullishCoalesce(minor, () => ( 0))}`,
@@ -1943,4 +2189,14 @@ function detectRuntime() {
1943
2189
 
1944
2190
 
1945
2191
 
1946
- exports.setCurrentSpanCustomProperties = setCurrentSpanCustomProperties; exports.callWithProperties = callWithProperties; exports.withProperties = withProperties; exports.callWithMute = callWithMute; exports.withMute = withMute; exports.withSessionId = withSessionId; exports.callWithSessionId = callWithSessionId; exports.Session = Session; exports.SessionTitle = SessionTitle; exports.getActiveSession = getActiveSession; exports.addExternalLink = addExternalLink; exports.startSession = startSession; exports.startSessionTitle = startSessionTitle; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.maskValue = maskValue; exports.maskAttributes = maskAttributes; exports.emitEvent = emitEvent; exports.emitEventWithSessionId = emitEventWithSessionId; exports.getMetricsExporter = getMetricsExporter; exports.getMetricsReader = getMetricsReader; exports.getSpanExporter = getSpanExporter; exports.getSpanProcessor = getSpanProcessor; exports.Brizz = Brizz; exports.detectRuntime = detectRuntime;
2192
+
2193
+
2194
+
2195
+
2196
+
2197
+
2198
+
2199
+
2200
+
2201
+
2202
+ exports.setCurrentSpanCustomProperties = setCurrentSpanCustomProperties; exports.callWithProperties = callWithProperties; exports.withProperties = withProperties; exports.setUser = setUser; exports.setOrganization = setOrganization; exports.setMessageId = setMessageId; exports.callWithUser = callWithUser; exports.withUser = withUser; exports.callWithOrganization = callWithOrganization; exports.withOrganization = withOrganization; exports.callWithMessageId = callWithMessageId; exports.withMessageId = withMessageId; exports.callWithMute = callWithMute; exports.withMute = withMute; exports.withSessionId = withSessionId; exports.callWithSessionId = callWithSessionId; exports.Session = Session; exports.SessionTitle = SessionTitle; exports.getActiveSession = getActiveSession; exports.addExternalLink = addExternalLink; exports.recordFeedback = recordFeedback; exports.startSession = startSession; exports.startSessionTitle = startSessionTitle; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.maskValue = maskValue; exports.maskAttributes = maskAttributes; exports.emitEvent = emitEvent; exports.emitEventWithSessionId = emitEventWithSessionId; exports.getMetricsExporter = getMetricsExporter; exports.getMetricsReader = getMetricsReader; exports.getSpanExporter = getSpanExporter; exports.getSpanProcessor = getSpanProcessor; exports.Brizz = Brizz; exports.detectRuntime = detectRuntime;