@brizz/sdk 0.1.34 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -1
- package/dist/{chunk-64STNQKL.js → chunk-6OGRVH77.js} +1 -1
- package/dist/{chunk-NEF2O7HF.cjs → chunk-77UGZGMP.cjs} +3 -1
- package/dist/{chunk-3LR22M4E.cjs → chunk-CQDWK43A.cjs} +166 -136
- package/dist/{chunk-24CEDVD2.js → chunk-EC3MYSRM.js} +1 -1
- package/dist/{chunk-M3UGFLH7.cjs → chunk-EVRCHF74.cjs} +4 -4
- package/dist/chunk-KFETJN5M.cjs +63 -0
- package/dist/{chunk-VU5YDLUD.cjs → chunk-PXIW2K27.cjs} +1 -1
- package/dist/chunk-TEY6FAVZ.js +63 -0
- package/dist/{chunk-QY4VADPP.js → chunk-WII4R5RE.js} +2 -0
- package/dist/{chunk-F3O3MTQ4.js → chunk-YNCBWOHM.js} +35 -5
- package/dist/google-genai-LMEZ62FB.cjs +10 -0
- package/dist/google-genai-T7I4FFIP.js +10 -0
- package/dist/google-genai.cjs +8 -0
- package/dist/google-genai.d.cts +7 -0
- package/dist/google-genai.d.ts +7 -0
- package/dist/google-genai.js +8 -0
- package/dist/index.cjs +22 -7
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +21 -6
- package/dist/interrupt-DM3AWSBX.cjs +12 -0
- package/dist/{interrupt-KADNA6WK.js → interrupt-YJVZK4VC.js} +2 -2
- package/dist/{mcp-WCMY6ED6.cjs → mcp-HAUJ3G4Q.cjs} +7 -7
- package/dist/{mcp-ZP6AY3FE.js → mcp-ZCRMQV5L.js} +2 -2
- package/dist/preload.cjs +7 -7
- package/dist/preload.js +4 -4
- package/package.json +25 -9
- package/dist/interrupt-7MWQCOY3.cjs +0 -12
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkPXIW2K27cjs = require('./chunk-PXIW2K27.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ var _chunkVU5YDLUDcjs = require('./chunk-VU5YDLUD.cjs');
|
|
|
13
13
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkEVRCHF74cjs = require('./chunk-EVRCHF74.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -64,7 +64,8 @@ var _chunkM3UGFLH7cjs = require('./chunk-M3UGFLH7.cjs');
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
var _chunk77UGZGMPcjs = require('./chunk-77UGZGMP.cjs');
|
|
68
69
|
|
|
69
70
|
|
|
70
71
|
var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
|
|
@@ -170,11 +171,26 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
170
171
|
}
|
|
171
172
|
})();
|
|
172
173
|
}
|
|
173
|
-
if (_optionalChain([this, 'access', _25 => _25.manualModules, 'optionalAccess', _26 => _26.
|
|
174
|
+
if (_optionalChain([this, 'access', _25 => _25.manualModules, 'optionalAccess', _26 => _26.google_genai])) {
|
|
175
|
+
const genaiModule = this.manualModules.google_genai;
|
|
176
|
+
void (async () => {
|
|
177
|
+
try {
|
|
178
|
+
const { GoogleGenAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./google-genai-LMEZ62FB.cjs")));
|
|
179
|
+
const genaiInst = new GoogleGenAIInstrumentation({ exceptionLogger });
|
|
180
|
+
genaiInst.manuallyInstrument(genaiModule);
|
|
181
|
+
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for Google GenAI");
|
|
182
|
+
} catch (error) {
|
|
183
|
+
_chunkWC573FCIcjs.logger.error(
|
|
184
|
+
`Failed to apply Google GenAI instrumentation. Ensure @traceloop/instrumentation-google-generativeai is installed; on a read-only ESM module namespace use instrumentGoogleGenAI from @brizz/sdk/google-genai instead: ${String(error)}`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
})();
|
|
188
|
+
}
|
|
189
|
+
if (_optionalChain([this, 'access', _27 => _27.manualModules, 'optionalAccess', _28 => _28.mcp])) {
|
|
174
190
|
const mcpModules = this.manualModules.mcp;
|
|
175
191
|
void (async () => {
|
|
176
192
|
try {
|
|
177
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
193
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-HAUJ3G4Q.cjs")));
|
|
178
194
|
const instrumentation = new MCPInstrumentation({ exceptionLogger });
|
|
179
195
|
instrumentation.manuallyInstrument(mcpModules);
|
|
180
196
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -661,14 +677,14 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
|
|
|
661
677
|
this.config = config;
|
|
662
678
|
}
|
|
663
679
|
onEmit(logRecord) {
|
|
664
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
680
|
+
const maskingConfig = _optionalChain([this, 'access', _29 => _29.config, 'access', _30 => _30.masking, 'optionalAccess', _31 => _31.eventMasking]);
|
|
665
681
|
if (maskingConfig) {
|
|
666
682
|
maskLog(logRecord, maskingConfig);
|
|
667
683
|
}
|
|
668
|
-
const associationProperties = _api.context.active().getValue(
|
|
684
|
+
const associationProperties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
669
685
|
if (associationProperties) {
|
|
670
686
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
671
|
-
logRecord.setAttribute(`${
|
|
687
|
+
logRecord.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
672
688
|
}
|
|
673
689
|
}
|
|
674
690
|
super.onEmit(logRecord);
|
|
@@ -681,14 +697,14 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
|
|
|
681
697
|
this.config = config;
|
|
682
698
|
}
|
|
683
699
|
onEmit(logRecord) {
|
|
684
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
700
|
+
const maskingConfig = _optionalChain([this, 'access', _32 => _32.config, 'access', _33 => _33.masking, 'optionalAccess', _34 => _34.eventMasking]);
|
|
685
701
|
if (maskingConfig) {
|
|
686
702
|
maskLog(logRecord, maskingConfig);
|
|
687
703
|
}
|
|
688
|
-
const associationProperties = _api.context.active().getValue(
|
|
704
|
+
const associationProperties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
689
705
|
if (associationProperties) {
|
|
690
706
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
691
|
-
logRecord.setAttribute(`${
|
|
707
|
+
logRecord.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
692
708
|
}
|
|
693
709
|
}
|
|
694
710
|
super.onEmit(logRecord);
|
|
@@ -715,7 +731,7 @@ function maskLog(logRecord, config) {
|
|
|
715
731
|
newAttributes[key] = value;
|
|
716
732
|
}
|
|
717
733
|
for (const [key, value] of Object.entries(logRecord.attributes)) {
|
|
718
|
-
if (key.startsWith(
|
|
734
|
+
if (key.startsWith(_chunk77UGZGMPcjs.INTERNAL_EVENT_PREFIX)) {
|
|
719
735
|
newAttributes[key] = value;
|
|
720
736
|
}
|
|
721
737
|
}
|
|
@@ -784,7 +800,7 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
784
800
|
}
|
|
785
801
|
_chunkWC573FCIcjs.logger.debug("Initializing log processor", {
|
|
786
802
|
disableBatch: config.disableBatch,
|
|
787
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
803
|
+
hasMasking: !!_optionalChain([config, 'access', _35 => _35.masking, 'optionalAccess', _36 => _36.eventMasking])
|
|
788
804
|
});
|
|
789
805
|
this.logProcessor = config.disableBatch ? new BrizzSimpleLogRecordProcessor(this.logExporter, config) : new BrizzBatchLogRecordProcessor(this.logExporter, config);
|
|
790
806
|
_chunkWC573FCIcjs.logger.debug("Log processor initialized successfully");
|
|
@@ -806,7 +822,7 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
806
822
|
const resourceAttributes = {
|
|
807
823
|
...config.resourceAttributes,
|
|
808
824
|
"service.name": config.appName,
|
|
809
|
-
[BRIZZ_SDK_VERSION]:
|
|
825
|
+
[BRIZZ_SDK_VERSION]: _chunkPXIW2K27cjs.getSDKVersion.call(void 0, ),
|
|
810
826
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
811
827
|
};
|
|
812
828
|
if (config.environment) {
|
|
@@ -922,16 +938,16 @@ function setCurrentSpanCustomProperties(properties) {
|
|
|
922
938
|
}
|
|
923
939
|
for (const [key, value] of Object.entries(properties)) {
|
|
924
940
|
try {
|
|
925
|
-
current.setAttribute(`${
|
|
941
|
+
current.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
926
942
|
} catch (e) {
|
|
927
943
|
}
|
|
928
944
|
}
|
|
929
945
|
}
|
|
930
946
|
function callWithProperties(properties, fn, thisArg, ...args) {
|
|
931
947
|
const base = _api.context.active();
|
|
932
|
-
const prev = base.getValue(
|
|
948
|
+
const prev = base.getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
933
949
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
934
|
-
const next = base.setValue(
|
|
950
|
+
const next = base.setValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY, merged);
|
|
935
951
|
return _api.context.with(next, fn, thisArg, ...args);
|
|
936
952
|
}
|
|
937
953
|
function withProperties(properties, fn, thisArg) {
|
|
@@ -947,31 +963,31 @@ function withProperties(properties, fn, thisArg) {
|
|
|
947
963
|
function propagatePropertiesImperatively(properties) {
|
|
948
964
|
try {
|
|
949
965
|
const manager = _api.context;
|
|
950
|
-
const mgr = _optionalChain([manager, 'access',
|
|
951
|
-
const store = _optionalChain([mgr, 'optionalAccess',
|
|
966
|
+
const mgr = _optionalChain([manager, 'access', _37 => _37._getContextManager, 'optionalCall', _38 => _38()]);
|
|
967
|
+
const store = _optionalChain([mgr, 'optionalAccess', _39 => _39._asyncLocalStorage]);
|
|
952
968
|
if (!store || typeof store.enterWith !== "function") {
|
|
953
969
|
return;
|
|
954
970
|
}
|
|
955
971
|
const base = _api.context.active();
|
|
956
|
-
const prev = base.getValue(
|
|
972
|
+
const prev = base.getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
957
973
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
958
|
-
store.enterWith(base.setValue(
|
|
974
|
+
store.enterWith(base.setValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY, merged));
|
|
959
975
|
} catch (e2) {
|
|
960
976
|
}
|
|
961
977
|
}
|
|
962
978
|
function setUser(user) {
|
|
963
|
-
const properties = { [
|
|
979
|
+
const properties = { [_chunk77UGZGMPcjs.USER_ID]: user.id };
|
|
964
980
|
if (user.email !== void 0) {
|
|
965
|
-
properties[
|
|
981
|
+
properties[_chunk77UGZGMPcjs.USER_EMAIL] = user.email;
|
|
966
982
|
}
|
|
967
983
|
if (user.name !== void 0) {
|
|
968
|
-
properties[
|
|
984
|
+
properties[_chunk77UGZGMPcjs.USER_NAME] = user.name;
|
|
969
985
|
}
|
|
970
986
|
if (user.role !== void 0) {
|
|
971
|
-
properties[
|
|
987
|
+
properties[_chunk77UGZGMPcjs.USER_ROLE] = user.role;
|
|
972
988
|
}
|
|
973
989
|
if (user.plan !== void 0) {
|
|
974
|
-
properties[
|
|
990
|
+
properties[_chunk77UGZGMPcjs.USER_PLAN] = user.plan;
|
|
975
991
|
}
|
|
976
992
|
if (user.traits) {
|
|
977
993
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
@@ -985,15 +1001,15 @@ function setUser(user) {
|
|
|
985
1001
|
propagatePropertiesImperatively(properties);
|
|
986
1002
|
}
|
|
987
1003
|
function setOrganization(org) {
|
|
988
|
-
const properties = { [
|
|
1004
|
+
const properties = { [_chunk77UGZGMPcjs.ORGANIZATION_ID]: org.id };
|
|
989
1005
|
if (org.name !== void 0) {
|
|
990
|
-
properties[
|
|
1006
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_NAME] = org.name;
|
|
991
1007
|
}
|
|
992
1008
|
if (org.plan !== void 0) {
|
|
993
|
-
properties[
|
|
1009
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_PLAN] = org.plan;
|
|
994
1010
|
}
|
|
995
1011
|
if (org.domain !== void 0) {
|
|
996
|
-
properties[
|
|
1012
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_DOMAIN] = org.domain;
|
|
997
1013
|
}
|
|
998
1014
|
if (org.traits) {
|
|
999
1015
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
@@ -1007,23 +1023,23 @@ function setOrganization(org) {
|
|
|
1007
1023
|
propagatePropertiesImperatively(properties);
|
|
1008
1024
|
}
|
|
1009
1025
|
function setMessageId(id) {
|
|
1010
|
-
const properties = { [
|
|
1026
|
+
const properties = { [_chunk77UGZGMPcjs.MESSAGE_ID]: id };
|
|
1011
1027
|
setCurrentSpanCustomProperties(properties);
|
|
1012
1028
|
propagatePropertiesImperatively(properties);
|
|
1013
1029
|
}
|
|
1014
1030
|
function userProperties(user) {
|
|
1015
|
-
const properties = { [
|
|
1031
|
+
const properties = { [_chunk77UGZGMPcjs.USER_ID]: user.id };
|
|
1016
1032
|
if (user.email !== void 0) {
|
|
1017
|
-
properties[
|
|
1033
|
+
properties[_chunk77UGZGMPcjs.USER_EMAIL] = user.email;
|
|
1018
1034
|
}
|
|
1019
1035
|
if (user.name !== void 0) {
|
|
1020
|
-
properties[
|
|
1036
|
+
properties[_chunk77UGZGMPcjs.USER_NAME] = user.name;
|
|
1021
1037
|
}
|
|
1022
1038
|
if (user.role !== void 0) {
|
|
1023
|
-
properties[
|
|
1039
|
+
properties[_chunk77UGZGMPcjs.USER_ROLE] = user.role;
|
|
1024
1040
|
}
|
|
1025
1041
|
if (user.plan !== void 0) {
|
|
1026
|
-
properties[
|
|
1042
|
+
properties[_chunk77UGZGMPcjs.USER_PLAN] = user.plan;
|
|
1027
1043
|
}
|
|
1028
1044
|
if (user.traits) {
|
|
1029
1045
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
@@ -1036,15 +1052,15 @@ function userProperties(user) {
|
|
|
1036
1052
|
return properties;
|
|
1037
1053
|
}
|
|
1038
1054
|
function organizationProperties(org) {
|
|
1039
|
-
const properties = { [
|
|
1055
|
+
const properties = { [_chunk77UGZGMPcjs.ORGANIZATION_ID]: org.id };
|
|
1040
1056
|
if (org.name !== void 0) {
|
|
1041
|
-
properties[
|
|
1057
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_NAME] = org.name;
|
|
1042
1058
|
}
|
|
1043
1059
|
if (org.plan !== void 0) {
|
|
1044
|
-
properties[
|
|
1060
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_PLAN] = org.plan;
|
|
1045
1061
|
}
|
|
1046
1062
|
if (org.domain !== void 0) {
|
|
1047
|
-
properties[
|
|
1063
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_DOMAIN] = org.domain;
|
|
1048
1064
|
}
|
|
1049
1065
|
if (org.traits) {
|
|
1050
1066
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
@@ -1069,19 +1085,33 @@ function withOrganization(org, fn, thisArg) {
|
|
|
1069
1085
|
return withProperties(organizationProperties(org), fn, thisArg);
|
|
1070
1086
|
}
|
|
1071
1087
|
function callWithMessageId(id, fn, thisArg, ...args) {
|
|
1072
|
-
return callWithProperties({ [
|
|
1088
|
+
return callWithProperties({ [_chunk77UGZGMPcjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
|
|
1073
1089
|
}
|
|
1074
1090
|
function withMessageId(id, fn, thisArg) {
|
|
1075
|
-
return withProperties({ [
|
|
1091
|
+
return withProperties({ [_chunk77UGZGMPcjs.MESSAGE_ID]: id }, fn, thisArg);
|
|
1092
|
+
}
|
|
1093
|
+
function inheritedMuteTools() {
|
|
1094
|
+
const properties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
1095
|
+
return _optionalChain([properties, 'optionalAccess', _40 => _40[_chunk77UGZGMPcjs.MUTE_TOOLS]]);
|
|
1076
1096
|
}
|
|
1077
1097
|
function muteProperties(options) {
|
|
1078
|
-
const { input = true, output = true } = options;
|
|
1098
|
+
const { input = true, output = true, tools = output } = options;
|
|
1079
1099
|
const properties = {};
|
|
1080
1100
|
if (input) {
|
|
1081
|
-
properties[
|
|
1101
|
+
properties[_chunk77UGZGMPcjs.MUTE_INPUT] = "true";
|
|
1082
1102
|
}
|
|
1083
1103
|
if (output) {
|
|
1084
|
-
properties[
|
|
1104
|
+
properties[_chunk77UGZGMPcjs.MUTE_OUTPUT] = "true";
|
|
1105
|
+
}
|
|
1106
|
+
if (tools !== output) {
|
|
1107
|
+
properties[_chunk77UGZGMPcjs.MUTE_TOOLS] = String(tools);
|
|
1108
|
+
} else {
|
|
1109
|
+
const inherited = inheritedMuteTools();
|
|
1110
|
+
if (tools && inherited === "false") {
|
|
1111
|
+
properties[_chunk77UGZGMPcjs.MUTE_TOOLS] = "true";
|
|
1112
|
+
} else if (options.tools === false && inherited === "true") {
|
|
1113
|
+
properties[_chunk77UGZGMPcjs.MUTE_TOOLS] = "false";
|
|
1114
|
+
}
|
|
1085
1115
|
}
|
|
1086
1116
|
return properties;
|
|
1087
1117
|
}
|
|
@@ -1092,11 +1122,11 @@ function withMute(options, fn, thisArg) {
|
|
|
1092
1122
|
return withProperties(muteProperties(options), fn, thisArg);
|
|
1093
1123
|
}
|
|
1094
1124
|
function withSessionId(sessionId, fn, thisArg, extraProperties) {
|
|
1095
|
-
const properties = { [
|
|
1125
|
+
const properties = { [_chunk77UGZGMPcjs.SESSION_ID]: sessionId, ...extraProperties };
|
|
1096
1126
|
return withProperties(properties, fn, thisArg);
|
|
1097
1127
|
}
|
|
1098
1128
|
function callWithSessionId(sessionId, fn, thisArg, ...args) {
|
|
1099
|
-
return callWithProperties({ [
|
|
1129
|
+
return callWithProperties({ [_chunk77UGZGMPcjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
|
|
1100
1130
|
}
|
|
1101
1131
|
var Session = (_class3 = class {
|
|
1102
1132
|
|
|
@@ -1124,8 +1154,8 @@ var Session = (_class3 = class {
|
|
|
1124
1154
|
setInput(text, context4) {
|
|
1125
1155
|
this.inputs.push(text);
|
|
1126
1156
|
this.inputContexts.push(_nullishCoalesce(context4, () => ( {})));
|
|
1127
|
-
this.span.setAttribute(
|
|
1128
|
-
this.span.setAttribute(
|
|
1157
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_INPUT, JSON.stringify(this.inputs));
|
|
1158
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
|
|
1129
1159
|
}
|
|
1130
1160
|
/**
|
|
1131
1161
|
* Append an assistant turn to session output tracking.
|
|
@@ -1140,8 +1170,8 @@ var Session = (_class3 = class {
|
|
|
1140
1170
|
setOutput(text, context4) {
|
|
1141
1171
|
this.outputs.push(text);
|
|
1142
1172
|
this.outputContexts.push(_nullishCoalesce(context4, () => ( {})));
|
|
1143
|
-
this.span.setAttribute(
|
|
1144
|
-
this.span.setAttribute(
|
|
1173
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
|
|
1174
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
|
|
1145
1175
|
}
|
|
1146
1176
|
/**
|
|
1147
1177
|
* Set the session title on the span.
|
|
@@ -1149,7 +1179,7 @@ var Session = (_class3 = class {
|
|
|
1149
1179
|
* @param title - The generated title string
|
|
1150
1180
|
*/
|
|
1151
1181
|
setTitle(title) {
|
|
1152
|
-
this.span.setAttribute(
|
|
1182
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_TITLE, title);
|
|
1153
1183
|
}
|
|
1154
1184
|
/**
|
|
1155
1185
|
* Update custom properties on the session span.
|
|
@@ -1159,7 +1189,7 @@ var Session = (_class3 = class {
|
|
|
1159
1189
|
*/
|
|
1160
1190
|
updateProperties(properties) {
|
|
1161
1191
|
for (const [key, value] of Object.entries(properties)) {
|
|
1162
|
-
this.span.setAttribute(`${
|
|
1192
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
1163
1193
|
}
|
|
1164
1194
|
}
|
|
1165
1195
|
/**
|
|
@@ -1171,21 +1201,21 @@ var Session = (_class3 = class {
|
|
|
1171
1201
|
setUser(user) {
|
|
1172
1202
|
if (user.traits) {
|
|
1173
1203
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
1174
|
-
this.span.setAttribute(`${
|
|
1204
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.user.${key}`, value);
|
|
1175
1205
|
}
|
|
1176
1206
|
}
|
|
1177
|
-
this.span.setAttribute(`${
|
|
1207
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_ID}`, user.id);
|
|
1178
1208
|
if (user.email !== void 0) {
|
|
1179
|
-
this.span.setAttribute(`${
|
|
1209
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_EMAIL}`, user.email);
|
|
1180
1210
|
}
|
|
1181
1211
|
if (user.name !== void 0) {
|
|
1182
|
-
this.span.setAttribute(`${
|
|
1212
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_NAME}`, user.name);
|
|
1183
1213
|
}
|
|
1184
1214
|
if (user.role !== void 0) {
|
|
1185
|
-
this.span.setAttribute(`${
|
|
1215
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_ROLE}`, user.role);
|
|
1186
1216
|
}
|
|
1187
1217
|
if (user.plan !== void 0) {
|
|
1188
|
-
this.span.setAttribute(`${
|
|
1218
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_PLAN}`, user.plan);
|
|
1189
1219
|
}
|
|
1190
1220
|
}
|
|
1191
1221
|
/**
|
|
@@ -1197,18 +1227,18 @@ var Session = (_class3 = class {
|
|
|
1197
1227
|
setOrganization(org) {
|
|
1198
1228
|
if (org.traits) {
|
|
1199
1229
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
1200
|
-
this.span.setAttribute(`${
|
|
1230
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.organization.${key}`, value);
|
|
1201
1231
|
}
|
|
1202
1232
|
}
|
|
1203
|
-
this.span.setAttribute(`${
|
|
1233
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_ID}`, org.id);
|
|
1204
1234
|
if (org.name !== void 0) {
|
|
1205
|
-
this.span.setAttribute(`${
|
|
1235
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_NAME}`, org.name);
|
|
1206
1236
|
}
|
|
1207
1237
|
if (org.plan !== void 0) {
|
|
1208
|
-
this.span.setAttribute(`${
|
|
1238
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_PLAN}`, org.plan);
|
|
1209
1239
|
}
|
|
1210
1240
|
if (org.domain !== void 0) {
|
|
1211
|
-
this.span.setAttribute(`${
|
|
1241
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_DOMAIN}`, org.domain);
|
|
1212
1242
|
}
|
|
1213
1243
|
}
|
|
1214
1244
|
/**
|
|
@@ -1224,7 +1254,7 @@ var Session = (_class3 = class {
|
|
|
1224
1254
|
* (free-form category, defaults to `'generic'`)
|
|
1225
1255
|
*/
|
|
1226
1256
|
addExternalLink(url, options) {
|
|
1227
|
-
emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess',
|
|
1257
|
+
emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _41 => _41.title]), _optionalChain([options, 'optionalAccess', _42 => _42.linkType]));
|
|
1228
1258
|
}
|
|
1229
1259
|
}, _class3);
|
|
1230
1260
|
var SessionTitle = class {
|
|
@@ -1238,69 +1268,69 @@ var SessionTitle = class {
|
|
|
1238
1268
|
* @param title - The generated title string
|
|
1239
1269
|
*/
|
|
1240
1270
|
setTitle(title) {
|
|
1241
|
-
this.span.setAttribute(
|
|
1271
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_TITLE, title);
|
|
1242
1272
|
}
|
|
1243
1273
|
};
|
|
1244
1274
|
function getActiveSession() {
|
|
1245
|
-
return _api.context.active().getValue(
|
|
1275
|
+
return _api.context.active().getValue(_chunk77UGZGMPcjs.SESSION_OBJECT_CONTEXT_KEY);
|
|
1246
1276
|
}
|
|
1247
1277
|
function resolveSessionIdFromContext() {
|
|
1248
1278
|
const active = getActiveSession();
|
|
1249
1279
|
if (active) {
|
|
1250
1280
|
return active.sessionId;
|
|
1251
1281
|
}
|
|
1252
|
-
const props = _api.context.active().getValue(
|
|
1253
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1282
|
+
const props = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
1283
|
+
return _optionalChain([props, 'optionalAccess', _43 => _43[_chunk77UGZGMPcjs.SESSION_ID]]);
|
|
1254
1284
|
}
|
|
1255
1285
|
function resolveMessageIdFromContext() {
|
|
1256
|
-
const props = _api.context.active().getValue(
|
|
1257
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1286
|
+
const props = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
1287
|
+
return _optionalChain([props, 'optionalAccess', _44 => _44[_chunk77UGZGMPcjs.MESSAGE_ID]]);
|
|
1258
1288
|
}
|
|
1259
1289
|
function emitExternalLink(sessionId, url, title, linkType) {
|
|
1260
1290
|
try {
|
|
1261
|
-
emitEventWithSessionId(sessionId,
|
|
1262
|
-
[
|
|
1263
|
-
[
|
|
1264
|
-
[
|
|
1291
|
+
emitEventWithSessionId(sessionId, _chunk77UGZGMPcjs.EXTERNAL_LINK_EVENT_NAME, {
|
|
1292
|
+
[_chunk77UGZGMPcjs.EXTERNAL_LINK_URL]: url,
|
|
1293
|
+
[_chunk77UGZGMPcjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
|
|
1294
|
+
[_chunk77UGZGMPcjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
|
|
1265
1295
|
});
|
|
1266
1296
|
} catch (error) {
|
|
1267
1297
|
_chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
|
|
1268
1298
|
}
|
|
1269
1299
|
}
|
|
1270
1300
|
function addExternalLink(url, options) {
|
|
1271
|
-
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1301
|
+
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.sessionId]), () => ( resolveSessionIdFromContext()));
|
|
1272
1302
|
if (!sessionId) {
|
|
1273
1303
|
_chunkWC573FCIcjs.logger.warn(
|
|
1274
1304
|
"addExternalLink called without a resolvable session id; link dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope."
|
|
1275
1305
|
);
|
|
1276
1306
|
return;
|
|
1277
1307
|
}
|
|
1278
|
-
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess',
|
|
1308
|
+
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _46 => _46.title]), _optionalChain([options, 'optionalAccess', _47 => _47.linkType]));
|
|
1279
1309
|
}
|
|
1280
1310
|
function recordFeedback(type, options) {
|
|
1281
|
-
const eventAttributes = { [
|
|
1282
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1283
|
-
eventAttributes[
|
|
1311
|
+
const eventAttributes = { [_chunk77UGZGMPcjs.FEEDBACK_TYPE]: type };
|
|
1312
|
+
if (_optionalChain([options, 'optionalAccess', _48 => _48.score]) !== void 0) {
|
|
1313
|
+
eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_SCORE] = options.score;
|
|
1284
1314
|
}
|
|
1285
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1286
|
-
eventAttributes[
|
|
1315
|
+
if (_optionalChain([options, 'optionalAccess', _49 => _49.reason]) !== void 0) {
|
|
1316
|
+
eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_REASON] = options.reason;
|
|
1287
1317
|
}
|
|
1288
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1289
|
-
eventAttributes[
|
|
1318
|
+
if (_optionalChain([options, 'optionalAccess', _50 => _50.comment]) !== void 0) {
|
|
1319
|
+
eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_COMMENT] = options.comment;
|
|
1290
1320
|
}
|
|
1291
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1292
|
-
eventAttributes[
|
|
1321
|
+
if (_optionalChain([options, 'optionalAccess', _51 => _51.source]) !== void 0) {
|
|
1322
|
+
eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_SOURCE] = options.source;
|
|
1293
1323
|
}
|
|
1294
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1324
|
+
if (_optionalChain([options, 'optionalAccess', _52 => _52.attributes])) {
|
|
1295
1325
|
for (const [key, value] of Object.entries(options.attributes)) {
|
|
1296
|
-
const k = `${
|
|
1326
|
+
const k = `${_chunk77UGZGMPcjs.FEEDBACK_ATTR_PREFIX}${key}`;
|
|
1297
1327
|
if (eventAttributes[k] === void 0) {
|
|
1298
1328
|
eventAttributes[k] = value;
|
|
1299
1329
|
}
|
|
1300
1330
|
}
|
|
1301
1331
|
}
|
|
1302
|
-
const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1303
|
-
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1332
|
+
const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.messageId]), () => ( resolveMessageIdFromContext()));
|
|
1333
|
+
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _54 => _54.sessionId]), () => ( resolveSessionIdFromContext()));
|
|
1304
1334
|
if (messageId === void 0 && sessionId === void 0) {
|
|
1305
1335
|
_chunkWC573FCIcjs.logger.warn(
|
|
1306
1336
|
"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."
|
|
@@ -1308,16 +1338,16 @@ function recordFeedback(type, options) {
|
|
|
1308
1338
|
}
|
|
1309
1339
|
const anchor = {};
|
|
1310
1340
|
if (messageId !== void 0) {
|
|
1311
|
-
anchor[
|
|
1341
|
+
anchor[_chunk77UGZGMPcjs.MESSAGE_ID] = messageId;
|
|
1312
1342
|
}
|
|
1313
1343
|
if (sessionId !== void 0) {
|
|
1314
|
-
anchor[
|
|
1344
|
+
anchor[_chunk77UGZGMPcjs.SESSION_ID] = sessionId;
|
|
1315
1345
|
}
|
|
1316
1346
|
try {
|
|
1317
1347
|
if (Object.keys(anchor).length === 0) {
|
|
1318
|
-
emitEvent(
|
|
1348
|
+
emitEvent(_chunk77UGZGMPcjs.FEEDBACK_EVENT_NAME, eventAttributes);
|
|
1319
1349
|
} else {
|
|
1320
|
-
callWithProperties(anchor, () => emitEvent(
|
|
1350
|
+
callWithProperties(anchor, () => emitEvent(_chunk77UGZGMPcjs.FEEDBACK_EVENT_NAME, eventAttributes));
|
|
1321
1351
|
}
|
|
1322
1352
|
} catch (error) {
|
|
1323
1353
|
_chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
|
|
@@ -1331,7 +1361,7 @@ function recordMetric(options) {
|
|
|
1331
1361
|
try {
|
|
1332
1362
|
recordMetricImpl(options);
|
|
1333
1363
|
} catch (error) {
|
|
1334
|
-
_chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess',
|
|
1364
|
+
_chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess', _55 => _55.name]))}) failed; metric dropped.`, error);
|
|
1335
1365
|
}
|
|
1336
1366
|
}
|
|
1337
1367
|
function recordMetricImpl(options) {
|
|
@@ -1342,7 +1372,7 @@ function recordMetricImpl(options) {
|
|
|
1342
1372
|
);
|
|
1343
1373
|
return;
|
|
1344
1374
|
}
|
|
1345
|
-
if (
|
|
1375
|
+
if (_chunk77UGZGMPcjs.RESERVED_METRIC_NAMES.has(name)) {
|
|
1346
1376
|
_chunkWC573FCIcjs.logger.warn(
|
|
1347
1377
|
`recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
|
|
1348
1378
|
);
|
|
@@ -1361,17 +1391,17 @@ function recordMetricImpl(options) {
|
|
|
1361
1391
|
return;
|
|
1362
1392
|
}
|
|
1363
1393
|
const eventAttributes = {
|
|
1364
|
-
[
|
|
1365
|
-
[
|
|
1394
|
+
[_chunk77UGZGMPcjs.METRIC_NAME]: name,
|
|
1395
|
+
[_chunk77UGZGMPcjs.METRIC_VALUE]: numericValue
|
|
1366
1396
|
};
|
|
1367
1397
|
if (options.unit !== void 0) {
|
|
1368
|
-
eventAttributes[
|
|
1398
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_UNIT] = options.unit;
|
|
1369
1399
|
}
|
|
1370
1400
|
if (options.minValue !== void 0) {
|
|
1371
|
-
eventAttributes[
|
|
1401
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_MIN] = options.minValue;
|
|
1372
1402
|
}
|
|
1373
1403
|
if (options.maxValue !== void 0) {
|
|
1374
|
-
eventAttributes[
|
|
1404
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_MAX] = options.maxValue;
|
|
1375
1405
|
}
|
|
1376
1406
|
if (options.comment !== void 0) {
|
|
1377
1407
|
let comment = options.comment;
|
|
@@ -1381,21 +1411,21 @@ function recordMetricImpl(options) {
|
|
|
1381
1411
|
);
|
|
1382
1412
|
comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
|
|
1383
1413
|
}
|
|
1384
|
-
eventAttributes[
|
|
1414
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_COMMENT] = comment;
|
|
1385
1415
|
}
|
|
1386
1416
|
if (options.polarity !== void 0) {
|
|
1387
1417
|
const polarity = options.polarity;
|
|
1388
|
-
if (polarity ===
|
|
1389
|
-
eventAttributes[
|
|
1418
|
+
if (polarity === _chunk77UGZGMPcjs.METRIC_POLARITY_POSITIVE || polarity === _chunk77UGZGMPcjs.METRIC_POLARITY_NEGATIVE) {
|
|
1419
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_POLARITY] = polarity;
|
|
1390
1420
|
} else {
|
|
1391
1421
|
_chunkWC573FCIcjs.logger.warn(
|
|
1392
|
-
`recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${
|
|
1422
|
+
`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.`
|
|
1393
1423
|
);
|
|
1394
1424
|
}
|
|
1395
1425
|
}
|
|
1396
1426
|
if (options.timestamp !== void 0) {
|
|
1397
1427
|
if (Number.isFinite(options.timestamp.getTime())) {
|
|
1398
|
-
eventAttributes[
|
|
1428
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
|
|
1399
1429
|
} else {
|
|
1400
1430
|
_chunkWC573FCIcjs.logger.warn(
|
|
1401
1431
|
`recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
|
|
@@ -1425,7 +1455,7 @@ function recordMetricImpl(options) {
|
|
|
1425
1455
|
);
|
|
1426
1456
|
text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
|
|
1427
1457
|
}
|
|
1428
|
-
eventAttributes[`${
|
|
1458
|
+
eventAttributes[`${_chunk77UGZGMPcjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
|
|
1429
1459
|
accepted += 1;
|
|
1430
1460
|
}
|
|
1431
1461
|
}
|
|
@@ -1438,28 +1468,28 @@ function recordMetricImpl(options) {
|
|
|
1438
1468
|
}
|
|
1439
1469
|
try {
|
|
1440
1470
|
callWithProperties(
|
|
1441
|
-
{ [
|
|
1442
|
-
() => emitEvent(
|
|
1471
|
+
{ [_chunk77UGZGMPcjs.SESSION_ID]: sessionId },
|
|
1472
|
+
() => emitEvent(_chunk77UGZGMPcjs.METRIC_EVENT_NAME, eventAttributes)
|
|
1443
1473
|
);
|
|
1444
1474
|
} catch (error) {
|
|
1445
1475
|
_chunkWC573FCIcjs.logger.warn("recordMetric: failed to emit metric event", error);
|
|
1446
1476
|
}
|
|
1447
1477
|
}
|
|
1448
1478
|
function startSession(sessionId, callback, extraProperties, options) {
|
|
1449
|
-
const isTitle = _optionalChain([options, 'optionalAccess',
|
|
1450
|
-
const spanName = isTitle ?
|
|
1479
|
+
const isTitle = _optionalChain([options, 'optionalAccess', _56 => _56.mode]) === "title";
|
|
1480
|
+
const spanName = isTitle ? _chunk77UGZGMPcjs.SESSION_TITLE_SPAN_NAME : _chunk77UGZGMPcjs.SESSION_SPAN_NAME;
|
|
1451
1481
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1452
1482
|
return tracer.startActiveSpan(spanName, (span) => {
|
|
1453
|
-
span.setAttribute(`${
|
|
1483
|
+
span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.SESSION_ID}`, sessionId);
|
|
1454
1484
|
if (extraProperties) {
|
|
1455
1485
|
for (const [key, value] of Object.entries(extraProperties)) {
|
|
1456
|
-
span.setAttribute(`${
|
|
1486
|
+
span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
1457
1487
|
}
|
|
1458
1488
|
}
|
|
1459
1489
|
const session = new Session(sessionId, span);
|
|
1460
|
-
const contextProperties = { [
|
|
1490
|
+
const contextProperties = { [_chunk77UGZGMPcjs.SESSION_ID]: sessionId };
|
|
1461
1491
|
if (isTitle) {
|
|
1462
|
-
contextProperties[
|
|
1492
|
+
contextProperties[_chunk77UGZGMPcjs.SESSION_TITLE_GENERATION] = "true";
|
|
1463
1493
|
}
|
|
1464
1494
|
if (extraProperties) {
|
|
1465
1495
|
for (const [key, value] of Object.entries(extraProperties)) {
|
|
@@ -1467,7 +1497,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1467
1497
|
}
|
|
1468
1498
|
}
|
|
1469
1499
|
return callWithProperties(contextProperties, () => {
|
|
1470
|
-
const sessionCtx = _api.context.active().setValue(
|
|
1500
|
+
const sessionCtx = _api.context.active().setValue(_chunk77UGZGMPcjs.SESSION_OBJECT_CONTEXT_KEY, session);
|
|
1471
1501
|
return _api.context.with(sessionCtx, () => {
|
|
1472
1502
|
try {
|
|
1473
1503
|
const result = callback(session);
|
|
@@ -1495,16 +1525,16 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1495
1525
|
});
|
|
1496
1526
|
}
|
|
1497
1527
|
function startSessionTitle(callback, options) {
|
|
1498
|
-
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1528
|
+
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _57 => _57.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _58 => _58(), 'optionalAccess', _59 => _59.sessionId])));
|
|
1499
1529
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1500
|
-
return tracer.startActiveSpan(
|
|
1530
|
+
return tracer.startActiveSpan(_chunk77UGZGMPcjs.SESSION_TITLE_SPAN_NAME, (span) => {
|
|
1501
1531
|
if (resolvedSessionId) {
|
|
1502
|
-
span.setAttribute(`${
|
|
1532
|
+
span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.SESSION_ID}`, resolvedSessionId);
|
|
1503
1533
|
}
|
|
1504
1534
|
const sessionTitle = new SessionTitle(span);
|
|
1505
|
-
const properties = { [
|
|
1535
|
+
const properties = { [_chunk77UGZGMPcjs.SESSION_TITLE_GENERATION]: "true" };
|
|
1506
1536
|
if (resolvedSessionId) {
|
|
1507
|
-
properties[
|
|
1537
|
+
properties[_chunk77UGZGMPcjs.SESSION_ID] = resolvedSessionId;
|
|
1508
1538
|
}
|
|
1509
1539
|
return callWithProperties(properties, () => {
|
|
1510
1540
|
try {
|
|
@@ -1649,7 +1679,7 @@ var BrizzSpanExporter = class {
|
|
|
1649
1679
|
const resourceAttrs = {
|
|
1650
1680
|
...config.resourceAttributes,
|
|
1651
1681
|
"service.name": config.appName,
|
|
1652
|
-
[BRIZZ_SDK_VERSION]:
|
|
1682
|
+
[BRIZZ_SDK_VERSION]: _chunkPXIW2K27cjs.getSDKVersion.call(void 0, ),
|
|
1653
1683
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
1654
1684
|
};
|
|
1655
1685
|
if (config.environment) {
|
|
@@ -1701,7 +1731,7 @@ var BrizzSpanExporter = class {
|
|
|
1701
1731
|
return this._delegate.shutdown();
|
|
1702
1732
|
}
|
|
1703
1733
|
async forceFlush() {
|
|
1704
|
-
return _optionalChain([this, 'access',
|
|
1734
|
+
return _optionalChain([this, 'access', _60 => _60._delegate, 'access', _61 => _61.forceFlush, 'optionalCall', _62 => _62()]);
|
|
1705
1735
|
}
|
|
1706
1736
|
};
|
|
1707
1737
|
|
|
@@ -1712,10 +1742,10 @@ var BrizzSpanExporter = class {
|
|
|
1712
1742
|
|
|
1713
1743
|
var _sdktracebase = require('@opentelemetry/sdk-trace-base');
|
|
1714
1744
|
function applyContextAttributes(span) {
|
|
1715
|
-
const sessionProperties = _api.context.active().getValue(
|
|
1745
|
+
const sessionProperties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
1716
1746
|
if (sessionProperties) {
|
|
1717
1747
|
for (const [key, value] of Object.entries(sessionProperties)) {
|
|
1718
|
-
span.setAttribute(`${
|
|
1748
|
+
span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
1719
1749
|
}
|
|
1720
1750
|
}
|
|
1721
1751
|
}
|
|
@@ -1736,7 +1766,7 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
|
|
|
1736
1766
|
super.onStart(span, parentContext);
|
|
1737
1767
|
}
|
|
1738
1768
|
onEnd(span) {
|
|
1739
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
1769
|
+
const maskingConfig = _optionalChain([this, 'access', _63 => _63.config, 'access', _64 => _64.masking, 'optionalAccess', _65 => _65.spanMasking]);
|
|
1740
1770
|
if (maskingConfig) {
|
|
1741
1771
|
maskReadableSpan(span, maskingConfig);
|
|
1742
1772
|
}
|
|
@@ -1754,7 +1784,7 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
|
|
|
1754
1784
|
super.onStart(span, parentContext);
|
|
1755
1785
|
}
|
|
1756
1786
|
onEnd(span) {
|
|
1757
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
1787
|
+
const maskingConfig = _optionalChain([this, 'access', _66 => _66.config, 'access', _67 => _67.masking, 'optionalAccess', _68 => _68.spanMasking]);
|
|
1758
1788
|
if (maskingConfig) {
|
|
1759
1789
|
maskReadableSpan(span, maskingConfig);
|
|
1760
1790
|
}
|
|
@@ -1834,7 +1864,7 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
|
|
|
1834
1864
|
}
|
|
1835
1865
|
_chunkWC573FCIcjs.logger.debug("Initializing span processor", {
|
|
1836
1866
|
disableBatch: config.disableBatch,
|
|
1837
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
1867
|
+
hasMasking: !!_optionalChain([config, 'access', _69 => _69.masking, 'optionalAccess', _70 => _70.spanMasking])
|
|
1838
1868
|
});
|
|
1839
1869
|
const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
|
|
1840
1870
|
_chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
|
|
@@ -1914,7 +1944,7 @@ var _sdktracenode = require('@opentelemetry/sdk-trace-node');
|
|
|
1914
1944
|
|
|
1915
1945
|
// src/internal/config.ts
|
|
1916
1946
|
function resolveConfig(options) {
|
|
1917
|
-
const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access',
|
|
1947
|
+
const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access', _71 => _71.logLevel, 'optionalAccess', _72 => _72.toString, 'call', _73 => _73()]) || _chunkWC573FCIcjs.DEFAULT_LOG_LEVEL.toString();
|
|
1918
1948
|
let resolvedLogLevel;
|
|
1919
1949
|
if (envLogLevel) {
|
|
1920
1950
|
resolvedLogLevel = _chunkWC573FCIcjs.parseLogLevel.call(void 0, envLogLevel);
|
|
@@ -2085,7 +2115,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2085
2115
|
const resourceAttributes = {
|
|
2086
2116
|
...resolvedConfig.resourceAttributes,
|
|
2087
2117
|
"service.name": resolvedConfig.appName,
|
|
2088
|
-
[BRIZZ_SDK_VERSION]:
|
|
2118
|
+
[BRIZZ_SDK_VERSION]: _chunkPXIW2K27cjs.getSDKVersion.call(void 0, ),
|
|
2089
2119
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2090
2120
|
};
|
|
2091
2121
|
if (resolvedConfig.environment) {
|
|
@@ -2097,7 +2127,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2097
2127
|
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));
|
|
2098
2128
|
this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
|
|
2099
2129
|
resource,
|
|
2100
|
-
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0,
|
|
2130
|
+
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkEVRCHF74cjs.InterruptPropagator)(), getSpanProcessor()]
|
|
2101
2131
|
});
|
|
2102
2132
|
this._tracerProvider.register();
|
|
2103
2133
|
this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
|
|
@@ -2233,10 +2263,10 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2233
2263
|
}
|
|
2234
2264
|
try {
|
|
2235
2265
|
await this.shutdownModules();
|
|
2236
|
-
await _optionalChain([this, 'access',
|
|
2237
|
-
await _optionalChain([this, 'access',
|
|
2238
|
-
await _optionalChain([this, 'access',
|
|
2239
|
-
await _optionalChain([this, 'access',
|
|
2266
|
+
await _optionalChain([this, 'access', _74 => _74._tracerProvider, 'optionalAccess', _75 => _75.forceFlush, 'call', _76 => _76()]);
|
|
2267
|
+
await _optionalChain([this, 'access', _77 => _77._tracerProvider, 'optionalAccess', _78 => _78.shutdown, 'call', _79 => _79()]);
|
|
2268
|
+
await _optionalChain([this, 'access', _80 => _80._meterProvider, 'optionalAccess', _81 => _81.forceFlush, 'call', _82 => _82()]);
|
|
2269
|
+
await _optionalChain([this, 'access', _83 => _83._meterProvider, 'optionalAccess', _84 => _84.shutdown, 'call', _85 => _85()]);
|
|
2240
2270
|
this._initialized = false;
|
|
2241
2271
|
this._tracerProvider = null;
|
|
2242
2272
|
this._meterProvider = null;
|
|
@@ -2265,7 +2295,7 @@ function detectRuntime() {
|
|
|
2265
2295
|
const supportsLoaderAPI = (_nullishCoalesce(major, () => ( 0))) >= 21 || (_nullishCoalesce(major, () => ( 0))) === 20 && (_nullishCoalesce(minor, () => ( 0))) >= 6 || (_nullishCoalesce(major, () => ( 0))) === 18 && (_nullishCoalesce(minor, () => ( 0))) >= 19;
|
|
2266
2296
|
const supportsRegister = (
|
|
2267
2297
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2268
|
-
!!_optionalChain([process, 'access',
|
|
2298
|
+
!!_optionalChain([process, 'access', _86 => _86.features, 'optionalAccess', _87 => _87.typescript]) || !!_optionalChain([globalThis, 'access', _88 => _88.module, 'optionalAccess', _89 => _89.register])
|
|
2269
2299
|
);
|
|
2270
2300
|
_chunkWC573FCIcjs.logger.debug("Runtime detection results:", {
|
|
2271
2301
|
nodeVersion: `${_nullishCoalesce(major, () => ( 0))}.${_nullishCoalesce(minor, () => ( 0))}`,
|