@brizz/sdk 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -116,7 +116,8 @@ declare function emitEvent(name: string, attributes?: Record<string, string | nu
116
116
  declare function getSpanExporter(): SpanExporter;
117
117
  declare function getSpanProcessor(): SpanProcessor;
118
118
 
119
- declare function WithSessionId<A extends unknown[], F extends (...args: A) => ReturnType<F>>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
119
+ declare function withSessionId<F extends (this: any, ...args: any[]) => any>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>): F;
120
+ declare function callWithSessionId<A extends unknown[], F extends (...args: A) => ReturnType<F>>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
120
121
 
121
122
  declare function getMetricsExporter(): OTLPMetricExporter;
122
123
  declare function getMetricsReader(): MetricReader;
@@ -134,4 +135,4 @@ declare namespace init {
134
135
  export { };
135
136
  }
136
137
 
137
- export { Brizz, DEFAULT_PII_PATTERNS, type IAttributesMaskingRule, type IBrizzInitializeOptions, type IEventMaskingConfig, type IEventMaskingRule, type IInstrumentModules, type ILogMaskingConfig, type ILogger, type IMaskingConfig, type ISpanMaskingConfig, LogLevel, type MaskingMode, type RuntimeInfo, WithSessionId, detectRuntime, emitEvent, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel };
138
+ export { Brizz, DEFAULT_PII_PATTERNS, type IAttributesMaskingRule, type IBrizzInitializeOptions, type IEventMaskingConfig, type IEventMaskingRule, type IInstrumentModules, type ILogMaskingConfig, type ILogger, type IMaskingConfig, type ISpanMaskingConfig, LogLevel, type MaskingMode, type RuntimeInfo, callWithSessionId, detectRuntime, emitEvent, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel, withSessionId };
package/dist/index.d.ts CHANGED
@@ -116,7 +116,8 @@ declare function emitEvent(name: string, attributes?: Record<string, string | nu
116
116
  declare function getSpanExporter(): SpanExporter;
117
117
  declare function getSpanProcessor(): SpanProcessor;
118
118
 
119
- declare function WithSessionId<A extends unknown[], F extends (...args: A) => ReturnType<F>>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
119
+ declare function withSessionId<F extends (this: any, ...args: any[]) => any>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>): F;
120
+ declare function callWithSessionId<A extends unknown[], F extends (...args: A) => ReturnType<F>>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
120
121
 
121
122
  declare function getMetricsExporter(): OTLPMetricExporter;
122
123
  declare function getMetricsReader(): MetricReader;
@@ -134,4 +135,4 @@ declare namespace init {
134
135
  export { };
135
136
  }
136
137
 
137
- export { Brizz, DEFAULT_PII_PATTERNS, type IAttributesMaskingRule, type IBrizzInitializeOptions, type IEventMaskingConfig, type IEventMaskingRule, type IInstrumentModules, type ILogMaskingConfig, type ILogger, type IMaskingConfig, type ISpanMaskingConfig, LogLevel, type MaskingMode, type RuntimeInfo, WithSessionId, detectRuntime, emitEvent, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel };
138
+ export { Brizz, DEFAULT_PII_PATTERNS, type IAttributesMaskingRule, type IBrizzInitializeOptions, type IEventMaskingConfig, type IEventMaskingRule, type IInstrumentModules, type ILogMaskingConfig, type ILogger, type IMaskingConfig, type ISpanMaskingConfig, LogLevel, type MaskingMode, type RuntimeInfo, callWithSessionId, detectRuntime, emitEvent, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel, withSessionId };
package/dist/index.js CHANGED
@@ -1751,7 +1751,15 @@ function withProperties(properties, fn, thisArg, ...args) {
1751
1751
  const newContext = context3.active().setValue(PROPERTIES_CONTEXT_KEY, properties);
1752
1752
  return context3.with(newContext, fn, thisArg, ...args);
1753
1753
  }
1754
- function WithSessionId(sessionId, fn, thisArg, ...args) {
1754
+ function withSessionId(sessionId, fn, thisArg) {
1755
+ return function wrapped(...args) {
1756
+ const base = context3.active();
1757
+ const prev = base.getValue(PROPERTIES_CONTEXT_KEY);
1758
+ const next = base.setValue(PROPERTIES_CONTEXT_KEY, prev ? { ...prev, [SESSION_ID]: sessionId } : { [SESSION_ID]: sessionId });
1759
+ return context3.with(next, fn, thisArg ?? this, ...args);
1760
+ };
1761
+ }
1762
+ function callWithSessionId(sessionId, fn, thisArg, ...args) {
1755
1763
  return withProperties({ [SESSION_ID]: sessionId }, fn, thisArg, ...args);
1756
1764
  }
1757
1765
 
@@ -1994,7 +2002,7 @@ export {
1994
2002
  DEFAULT_PII_PATTERNS,
1995
2003
  LogLevel,
1996
2004
  SeverityNumber2 as SeverityNumber,
1997
- WithSessionId,
2005
+ callWithSessionId,
1998
2006
  detectRuntime,
1999
2007
  emitEvent,
2000
2008
  getLogLevel,
@@ -2006,6 +2014,7 @@ export {
2006
2014
  logger,
2007
2015
  maskAttributes,
2008
2016
  maskValue,
2009
- setLogLevel
2017
+ setLogLevel,
2018
+ withSessionId
2010
2019
  };
2011
2020
  //# sourceMappingURL=index.js.map