@brizz/sdk 0.1.5 → 0.1.6

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
@@ -117,6 +117,12 @@ declare function emitEvent(name: string, attributes?: Record<string, string | nu
117
117
  declare function getSpanExporter(): SpanExporter;
118
118
  declare function getSpanProcessor(): SpanProcessor;
119
119
 
120
+ declare function callWithProperties<A extends unknown[], F extends (...args: A) => ReturnType<F>>(properties: {
121
+ [name: string]: string;
122
+ }, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
123
+ declare function withProperties<F extends (this: any, ...args: any[]) => any>(properties: {
124
+ [name: string]: string;
125
+ }, fn: F, thisArg?: ThisParameterType<F>): F;
120
126
  declare function withSessionId<F extends (this: any, ...args: any[]) => any>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>): F;
121
127
  declare function callWithSessionId<A extends unknown[], F extends (...args: A) => ReturnType<F>>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
122
128
 
@@ -136,4 +142,4 @@ declare namespace init {
136
142
  export { };
137
143
  }
138
144
 
139
- 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 };
145
+ 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, callWithProperties, callWithSessionId, detectRuntime, emitEvent, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel, withProperties, withSessionId };
package/dist/index.d.ts CHANGED
@@ -117,6 +117,12 @@ declare function emitEvent(name: string, attributes?: Record<string, string | nu
117
117
  declare function getSpanExporter(): SpanExporter;
118
118
  declare function getSpanProcessor(): SpanProcessor;
119
119
 
120
+ declare function callWithProperties<A extends unknown[], F extends (...args: A) => ReturnType<F>>(properties: {
121
+ [name: string]: string;
122
+ }, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
123
+ declare function withProperties<F extends (this: any, ...args: any[]) => any>(properties: {
124
+ [name: string]: string;
125
+ }, fn: F, thisArg?: ThisParameterType<F>): F;
120
126
  declare function withSessionId<F extends (this: any, ...args: any[]) => any>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>): F;
121
127
  declare function callWithSessionId<A extends unknown[], F extends (...args: A) => ReturnType<F>>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
122
128
 
@@ -136,4 +142,4 @@ declare namespace init {
136
142
  export { };
137
143
  }
138
144
 
139
- 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 };
145
+ 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, callWithProperties, callWithSessionId, detectRuntime, emitEvent, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel, withProperties, withSessionId };
package/dist/index.js CHANGED
@@ -1617,26 +1617,28 @@ function getSpanProcessor() {
1617
1617
 
1618
1618
  // src/internal/trace/session.ts
1619
1619
  import { context as context3 } from "@opentelemetry/api";
1620
- function withProperties(properties, fn, thisArg, ...args) {
1621
- if (Object.keys(properties).length === 0) {
1622
- return fn.apply(thisArg, args);
1623
- }
1624
- const newContext = context3.active().setValue(PROPERTIES_CONTEXT_KEY, properties);
1625
- return context3.with(newContext, fn, thisArg, ...args);
1620
+ function callWithProperties(properties, fn, thisArg, ...args) {
1621
+ const base = context3.active();
1622
+ const prev = base.getValue(PROPERTIES_CONTEXT_KEY);
1623
+ const merged = prev ? { ...prev, ...properties } : properties;
1624
+ const next = base.setValue(PROPERTIES_CONTEXT_KEY, merged);
1625
+ return context3.with(next, fn, thisArg, ...args);
1626
1626
  }
1627
- function withSessionId(sessionId, fn, thisArg) {
1627
+ function withProperties(properties, fn, thisArg) {
1628
1628
  return function wrapped(...args) {
1629
- const base = context3.active();
1630
- const prev = base.getValue(PROPERTIES_CONTEXT_KEY);
1631
- const next = base.setValue(
1632
- PROPERTIES_CONTEXT_KEY,
1633
- prev ? { ...prev, [SESSION_ID]: sessionId } : { [SESSION_ID]: sessionId }
1629
+ return callWithProperties(
1630
+ properties,
1631
+ fn,
1632
+ thisArg !== void 0 ? thisArg : this,
1633
+ ...args
1634
1634
  );
1635
- return context3.with(next, fn, thisArg ?? this, ...args);
1636
1635
  };
1637
1636
  }
1637
+ function withSessionId(sessionId, fn, thisArg) {
1638
+ return withProperties({ [SESSION_ID]: sessionId }, fn, thisArg);
1639
+ }
1638
1640
  function callWithSessionId(sessionId, fn, thisArg, ...args) {
1639
- return withProperties({ [SESSION_ID]: sessionId }, fn, thisArg, ...args);
1641
+ return callWithProperties({ [SESSION_ID]: sessionId }, fn, thisArg, ...args);
1640
1642
  }
1641
1643
 
1642
1644
  // src/internal/sdk.ts
@@ -1886,6 +1888,7 @@ export {
1886
1888
  DEFAULT_PII_PATTERNS,
1887
1889
  LogLevel,
1888
1890
  SeverityNumber2 as SeverityNumber,
1891
+ callWithProperties,
1889
1892
  callWithSessionId,
1890
1893
  detectRuntime,
1891
1894
  emitEvent,
@@ -1899,6 +1902,7 @@ export {
1899
1902
  maskAttributes,
1900
1903
  maskValue,
1901
1904
  setLogLevel,
1905
+ withProperties,
1902
1906
  withSessionId
1903
1907
  };
1904
1908
  //# sourceMappingURL=index.js.map