@pydantic/logfire-browser 0.13.0 → 0.14.0

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.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var S=(r,e,t)=>e in r?L(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var l=(r,e,t)=>S(r,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("@opentelemetry/api"),h=require("@opentelemetry/instrumentation"),_=require("@opentelemetry/resources"),u=require("@opentelemetry/sdk-trace-web"),a=require("@opentelemetry/semantic-conventions"),c=require("@opentelemetry/semantic-conventions/incubating"),o=require("logfire"),g=require("@opentelemetry/core"),f=require("@opentelemetry/otlp-exporter-base"),R=require("@opentelemetry/otlp-exporter-base/browser-http"),m=require("@opentelemetry/otlp-transformer"),d="target_xpath",w="event_type",v={1:"trace",5:"debug",9:"info",10:"notice",13:"warning",17:"error",21:"fatal"},T={debug:"#E3E3E3",error:"#EA4335",fatal:"#EA4335",info:"#9EC1FB",notice:"#A5D490","on-debug":"#636262","on-error":"#FFEDE9","on-fatal":"#FFEDE9","on-info":"#063175","on-notice":"#222222","on-trace":"#636262","on-warning":"#613A0D",trace:"#E3E3E3",warning:"#EFB77A"};class D{export(e,t){this.sendSpans(e,t)}forceFlush(){return Promise.resolve()}shutdown(){return this.sendSpans([]),this.forceFlush()}exportInfo(e){var t;return{attributes:e.attributes,duration:g.hrTimeToMicroseconds(e.duration),events:e.events,id:e.spanContext().spanId,instrumentationScope:e.instrumentationScope,kind:e.kind,links:e.links,name:e.name,parentSpanContext:e.parentSpanContext,resource:{attributes:e.resource.attributes},status:e.status,timestamp:g.hrTimeToMicroseconds(e.startTime),traceId:e.spanContext().traceId,traceState:(t=e.spanContext().traceState)==null?void 0:t.serialize()}}sendSpans(e,t){for(const i of e){const n=v[i.attributes["logfire.level_num"]]??"info",{attributes:E,name:A,...p}=this.exportInfo(i);console.log(`%cLogfire %c${n}`,"background-color: #E520E9; color: #FFFFFF",`background-color: ${T[`on-${n}`]}; color: ${T[n]}`,A,E,p)}t&&t({code:g.ExportResultCode.SUCCESS})}}class C{constructor(e,t){l(this,"console");l(this,"wrapped");t&&(this.console=new u.SimpleSpanProcessor(new D)),this.wrapped=e}async forceFlush(){var e;return await((e=this.console)==null?void 0:e.forceFlush()),this.wrapped.forceFlush()}onEnd(e){var t;(t=this.console)==null||t.onEnd(e),this.wrapped.onEnd(e)}onStart(e,t){var i;if(c.ATTR_HTTP_URL in e.attributes){const n=new URL(e.attributes[c.ATTR_HTTP_URL]);Reflect.set(e,"name",`${e.name} ${n.pathname}`)}d in e.attributes&&Reflect.set(e,"name",`${e.attributes[w]??"unknown"} ${e.attributes[d]??""}`),(i=this.console)==null||i.onStart(e,t),this.wrapped.onStart(e,t)}async shutdown(){var e;return await((e=this.console)==null?void 0:e.shutdown()),this.wrapped.shutdown()}}class x extends f.OTLPExporterBase{constructor(e,t){const n={...f.mergeOtlpSharedConfigurationWithDefaults({compression:e.compression,concurrencyLimit:e.concurrencyLimit,timeoutMillis:e.timeoutMillis},{},f.getSharedConfigurationDefaults()),agentOptions:{keepAlive:!0},headers:async()=>({"Content-Type":"application/json",...typeof e.headers=="function"?await e.headers():e.headers??{},...(t==null?void 0:t())??{}}),url:e.url??"http://localhost:4318/v1/traces"};super(R.createOtlpXhrExportDelegate(n,m.JsonTraceSerializer))}}function F(){return{}}function b(r){r.diagLogLevel!==void 0&&s.diag.setLogger(new s.DiagConsoleLogger,r.diagLogLevel),o.configureLogfireApi({errorFingerprinting:r.errorFingerprinting??!1,scrubbing:r.scrubbing});const e=_.resourceFromAttributes({[c.ATTR_BROWSER_LANGUAGE]:navigator.language,[a.ATTR_SERVICE_NAME]:r.serviceName??"logfire-browser",[a.ATTR_SERVICE_VERSION]:r.serviceVersion??"0.0.1",[a.ATTR_TELEMETRY_SDK_LANGUAGE]:a.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,[a.ATTR_TELEMETRY_SDK_NAME]:"logfire-browser",...r.environment?{[c.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]:r.environment}:{},[a.ATTR_TELEMETRY_SDK_VERSION]:"0.13.0",...navigator.userAgentData?{[c.ATTR_BROWSER_BRANDS]:navigator.userAgentData.brands.map(n=>`${n.brand} ${n.version}`),[c.ATTR_BROWSER_MOBILE]:navigator.userAgentData.mobile,[c.ATTR_BROWSER_PLATFORM]:navigator.userAgentData.platform}:{[a.ATTR_USER_AGENT_ORIGINAL]:navigator.userAgent}});s.diag.info("logfire-browser: starting");const t=new u.WebTracerProvider({idGenerator:new o.ULIDGenerator,resource:e,spanProcessors:[new C(new u.BatchSpanProcessor(new x({...r.traceExporterConfig,url:r.traceUrl},r.traceExporterHeaders??F),r.batchSpanProcessorConfig),!!r.console)]});t.register({contextManager:r.contextManager??new u.StackContextManager});const i=h.registerInstrumentations({instrumentations:r.instrumentations??[],tracerProvider:t});return async()=>{s.diag.info("logfire-browser: shutting down"),i(),await t.forceFlush(),await t.shutdown(),s.diag.info("logfire-browser: shut down complete")}}const O={configure:b,configureLogfireApi:o.configureLogfireApi,debug:o.debug,DiagLogLevel:s.DiagLogLevel,error:o.error,fatal:o.fatal,info:o.info,Level:o.Level,log:o.log,logfireApiConfig:o.logfireApiConfig,LogfireAttributeScrubber:o.LogfireAttributeScrubber,NoopAttributeScrubber:o.NoopAttributeScrubber,notice:o.notice,reportError:o.reportError,resolveBaseUrl:o.resolveBaseUrl,resolveSendToLogfire:o.resolveSendToLogfire,serializeAttributes:o.serializeAttributes,span:o.span,startSpan:o.startSpan,trace:o.trace,ULIDGenerator:o.ULIDGenerator,warning:o.warning};Object.defineProperty(exports,"DiagLogLevel",{enumerable:!0,get:()=>s.DiagLogLevel});exports.configure=b;exports.default=O;Object.keys(o).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>o[r]})});
1
+ "use strict";var L=Object.defineProperty;var m=(r,e,t)=>e in r?L(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e,t)=>m(r,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@opentelemetry/api"),R=require("@opentelemetry/instrumentation"),w=require("@opentelemetry/resources"),l=require("@opentelemetry/sdk-trace-web"),s=require("@opentelemetry/semantic-conventions"),u=require("@opentelemetry/semantic-conventions/incubating"),o=require("logfire"),E=require("@opentelemetry/core"),T=require("@opentelemetry/otlp-exporter-base"),_=require("@opentelemetry/otlp-exporter-base/browser-http"),v=require("@opentelemetry/otlp-transformer"),A="target_xpath",D="event_type",C={1:"trace",5:"debug",9:"info",10:"notice",13:"warning",17:"error",21:"fatal"},S={debug:"#E3E3E3",error:"#EA4335",fatal:"#EA4335",info:"#9EC1FB",notice:"#A5D490","on-debug":"#636262","on-error":"#FFEDE9","on-fatal":"#FFEDE9","on-info":"#063175","on-notice":"#222222","on-trace":"#636262","on-warning":"#613A0D",trace:"#E3E3E3",warning:"#EFB77A"};class x{export(e,t){this.sendSpans(e,t)}forceFlush(){return Promise.resolve()}shutdown(){return this.sendSpans([]),this.forceFlush()}exportInfo(e){var t;return{attributes:e.attributes,duration:E.hrTimeToMicroseconds(e.duration),events:e.events,id:e.spanContext().spanId,instrumentationScope:e.instrumentationScope,kind:e.kind,links:e.links,name:e.name,parentSpanContext:e.parentSpanContext,resource:{attributes:e.resource.attributes},status:e.status,timestamp:E.hrTimeToMicroseconds(e.startTime),traceId:e.spanContext().traceId,traceState:(t=e.spanContext().traceState)==null?void 0:t.serialize()}}sendSpans(e,t){for(const i of e){const n=C[i.attributes["logfire.level_num"]]??"info",{attributes:a,name:f,...g}=this.exportInfo(i);console.log(`%cLogfire %c${n}`,"background-color: #E520E9; color: #FFFFFF",`background-color: ${S[`on-${n}`]}; color: ${S[n]}`,f,a,g)}t&&t({code:E.ExportResultCode.SUCCESS})}}class P{constructor(e,t){d(this,"console");d(this,"wrapped");t&&(this.console=new l.SimpleSpanProcessor(new x)),this.wrapped=e}async forceFlush(){var e;return await((e=this.console)==null?void 0:e.forceFlush()),this.wrapped.forceFlush()}onEnd(e){var t;(t=this.console)==null||t.onEnd(e),this.wrapped.onEnd(e)}onStart(e,t){var i;if(u.ATTR_HTTP_URL in e.attributes){const n=new URL(e.attributes[u.ATTR_HTTP_URL]);Reflect.set(e,"name",`${e.name} ${n.pathname}`)}A in e.attributes&&Reflect.set(e,"name",`${e.attributes[D]??"unknown"} ${e.attributes[A]??""}`),(i=this.console)==null||i.onStart(e,t),this.wrapped.onStart(e,t)}async shutdown(){var e;return await((e=this.console)==null?void 0:e.shutdown()),this.wrapped.shutdown()}}class F extends T.OTLPExporterBase{constructor(e,t){const n={...T.mergeOtlpSharedConfigurationWithDefaults({compression:e.compression,concurrencyLimit:e.concurrencyLimit,timeoutMillis:e.timeoutMillis},{},T.getSharedConfigurationDefaults()),agentOptions:{keepAlive:!0},headers:async()=>({"Content-Type":"application/json",...typeof e.headers=="function"?await e.headers():e.headers??{},...(t==null?void 0:t())??{}}),url:e.url??"http://localhost:4318/v1/traces"};super(_.createOtlpXhrExportDelegate(n,v.JsonTraceSerializer))}}function O(){return{}}function h(r){var g,b;r.diagLogLevel!==void 0&&c.diag.setLogger(new c.DiagConsoleLogger,r.diagLogLevel),o.configureLogfireApi({errorFingerprinting:r.errorFingerprinting??!1,scrubbing:r.scrubbing});const e=w.resourceFromAttributes({[u.ATTR_BROWSER_LANGUAGE]:navigator.language,[s.ATTR_SERVICE_NAME]:r.serviceName??"logfire-browser",[s.ATTR_SERVICE_VERSION]:r.serviceVersion??"0.0.1",[s.ATTR_TELEMETRY_SDK_LANGUAGE]:s.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,[s.ATTR_TELEMETRY_SDK_NAME]:"logfire-browser",...r.environment?{[u.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]:r.environment}:{},[s.ATTR_TELEMETRY_SDK_VERSION]:"0.14.0",...navigator.userAgentData?{[u.ATTR_BROWSER_BRANDS]:navigator.userAgentData.brands.map(p=>`${p.brand} ${p.version}`),[u.ATTR_BROWSER_MOBILE]:navigator.userAgentData.mobile,[u.ATTR_BROWSER_PLATFORM]:navigator.userAgentData.platform}:{[s.ATTR_USER_AGENT_ORIGINAL]:navigator.userAgent}});c.diag.info("logfire-browser: starting");const t=(g=r.sampling)==null?void 0:g.head,i=t!==void 0&&t<1?new l.ParentBasedSampler({root:new l.TraceIdRatioBasedSampler(t)}):void 0;let n=new P(new l.BatchSpanProcessor(new F({...r.traceExporterConfig,url:r.traceUrl},r.traceExporterHeaders??O),r.batchSpanProcessorConfig),!!r.console);(b=r.sampling)!=null&&b.tail&&(n=new o.TailSamplingProcessor(n,r.sampling.tail));const a=new l.WebTracerProvider({idGenerator:new o.ULIDGenerator,resource:e,...i?{sampler:i}:{},spanProcessors:[n]});a.register({contextManager:r.contextManager??new l.StackContextManager});const f=R.registerInstrumentations({instrumentations:r.instrumentations??[],tracerProvider:a});return async()=>{c.diag.info("logfire-browser: shutting down"),f(),await a.forceFlush(),await a.shutdown(),c.diag.info("logfire-browser: shut down complete")}}const M={configure:h,configureLogfireApi:o.configureLogfireApi,debug:o.debug,DiagLogLevel:c.DiagLogLevel,error:o.error,fatal:o.fatal,info:o.info,Level:o.Level,log:o.log,logfireApiConfig:o.logfireApiConfig,LogfireAttributeScrubber:o.LogfireAttributeScrubber,NoopAttributeScrubber:o.NoopAttributeScrubber,notice:o.notice,reportError:o.reportError,resolveBaseUrl:o.resolveBaseUrl,resolveSendToLogfire:o.resolveSendToLogfire,serializeAttributes:o.serializeAttributes,span:o.span,startSpan:o.startSpan,trace:o.trace,ULIDGenerator:o.ULIDGenerator,warning:o.warning};Object.defineProperty(exports,"DiagLogLevel",{enumerable:!0,get:()=>c.DiagLogLevel});exports.configure=h;exports.default=M;Object.keys(o).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>o[r]})});
package/dist/index.d.cts CHANGED
@@ -16,6 +16,7 @@ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
16
16
  import { reportError as reportError_2 } from 'logfire';
17
17
  import { resolveBaseUrl } from 'logfire';
18
18
  import { resolveSendToLogfire } from 'logfire';
19
+ import { SamplingOptions } from 'logfire';
19
20
  import { ScrubbingOptions } from 'logfire';
20
21
  import { serializeAttributes } from 'logfire';
21
22
  import { span } from 'logfire';
@@ -93,6 +94,17 @@ export declare interface LogfireConfigOptions {
93
94
  * The instrumentations to register - a common one [is the fetch instrumentation](https://www.npmjs.com/package/@opentelemetry/instrumentation-fetch).
94
95
  */
95
96
  instrumentations?: (Instrumentation | Instrumentation[])[];
97
+ /**
98
+ * Sampling options for controlling which traces are exported.
99
+ * `head` sets a probabilistic sample rate (0.0-1.0) at trace creation time.
100
+ * `tail` provides a callback evaluated on every span to decide whether to keep the trace.
101
+ *
102
+ * Note: Tail sampling buffers all spans in a trace in memory until either a span meets the
103
+ * sampling criteria or the root span ends. In long-lived browser sessions, this can lead to
104
+ * significant memory usage. Consider using head sampling alone for long-running traces, or
105
+ * ensure tail callbacks accept traces quickly (e.g., on the first error-level span).
106
+ */
107
+ sampling?: SamplingOptions;
96
108
  /**
97
109
  * Options for scrubbing sensitive data. Set to False to disable.
98
110
  */
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
16
16
  import { reportError as reportError_2 } from 'logfire';
17
17
  import { resolveBaseUrl } from 'logfire';
18
18
  import { resolveSendToLogfire } from 'logfire';
19
+ import { SamplingOptions } from 'logfire';
19
20
  import { ScrubbingOptions } from 'logfire';
20
21
  import { serializeAttributes } from 'logfire';
21
22
  import { span } from 'logfire';
@@ -93,6 +94,17 @@ export declare interface LogfireConfigOptions {
93
94
  * The instrumentations to register - a common one [is the fetch instrumentation](https://www.npmjs.com/package/@opentelemetry/instrumentation-fetch).
94
95
  */
95
96
  instrumentations?: (Instrumentation | Instrumentation[])[];
97
+ /**
98
+ * Sampling options for controlling which traces are exported.
99
+ * `head` sets a probabilistic sample rate (0.0-1.0) at trace creation time.
100
+ * `tail` provides a callback evaluated on every span to decide whether to keep the trace.
101
+ *
102
+ * Note: Tail sampling buffers all spans in a trace in memory until either a span meets the
103
+ * sampling criteria or the root span ends. In long-lived browser sessions, this can lead to
104
+ * significant memory usage. Consider using head sampling alone for long-running traces, or
105
+ * ensure tail callbacks accept traces quickly (e.g., on the first error-level span).
106
+ */
107
+ sampling?: SamplingOptions;
96
108
  /**
97
109
  * Options for scrubbing sensitive data. Set to False to disable.
98
110
  */
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
- var d = Object.defineProperty;
2
- var p = (t, e, r) => e in t ? d(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var a = (t, e, r) => p(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { DiagLogLevel as A, diag as i, DiagConsoleLogger as h } from "@opentelemetry/api";
5
- import { DiagLogLevel as Fe } from "@opentelemetry/api";
6
- import { registerInstrumentations as S } from "@opentelemetry/instrumentation";
7
- import { resourceFromAttributes as R } from "@opentelemetry/resources";
8
- import { SimpleSpanProcessor as _, WebTracerProvider as b, BatchSpanProcessor as w, StackContextManager as L } from "@opentelemetry/sdk-trace-web";
9
- import { TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS as v, ATTR_USER_AGENT_ORIGINAL as x, ATTR_TELEMETRY_SDK_VERSION as C, ATTR_TELEMETRY_SDK_NAME as D, ATTR_TELEMETRY_SDK_LANGUAGE as F, ATTR_SERVICE_VERSION as N, ATTR_SERVICE_NAME as M } from "@opentelemetry/semantic-conventions";
10
- import { ATTR_HTTP_URL as c, ATTR_BROWSER_PLATFORM as O, ATTR_BROWSER_MOBILE as I, ATTR_BROWSER_BRANDS as P, ATTR_DEPLOYMENT_ENVIRONMENT_NAME as B, ATTR_BROWSER_LANGUAGE as y } from "@opentelemetry/semantic-conventions/incubating";
11
- import { warning as G, ULIDGenerator as f, trace as U, startSpan as $, span as k, serializeAttributes as V, resolveSendToLogfire as W, resolveBaseUrl as Y, reportError as K, notice as z, NoopAttributeScrubber as H, LogfireAttributeScrubber as J, logfireApiConfig as X, log as j, Level as q, info as Q, fatal as Z, error as ee, debug as re, configureLogfireApi as E } from "logfire";
1
+ var h = Object.defineProperty;
2
+ var A = (t, e, r) => e in t ? h(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var l = (t, e, r) => A(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { DiagLogLevel as S, diag as s, DiagConsoleLogger as R } from "@opentelemetry/api";
5
+ import { DiagLogLevel as Oe } from "@opentelemetry/api";
6
+ import { registerInstrumentations as w } from "@opentelemetry/instrumentation";
7
+ import { resourceFromAttributes as _ } from "@opentelemetry/resources";
8
+ import { SimpleSpanProcessor as b, ParentBasedSampler as L, TraceIdRatioBasedSampler as v, BatchSpanProcessor as x, WebTracerProvider as C, StackContextManager as D } from "@opentelemetry/sdk-trace-web";
9
+ import { TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS as F, ATTR_USER_AGENT_ORIGINAL as N, ATTR_TELEMETRY_SDK_VERSION as P, ATTR_TELEMETRY_SDK_NAME as M, ATTR_TELEMETRY_SDK_LANGUAGE as I, ATTR_SERVICE_VERSION as O, ATTR_SERVICE_NAME as B } from "@opentelemetry/semantic-conventions";
10
+ import { ATTR_HTTP_URL as f, ATTR_BROWSER_PLATFORM as y, ATTR_BROWSER_MOBILE as G, ATTR_BROWSER_BRANDS as U, ATTR_DEPLOYMENT_ENVIRONMENT_NAME as $, ATTR_BROWSER_LANGUAGE as k } from "@opentelemetry/semantic-conventions/incubating";
11
+ import { warning as V, ULIDGenerator as T, trace as W, startSpan as Y, span as K, serializeAttributes as z, resolveSendToLogfire as H, resolveBaseUrl as J, reportError as X, notice as j, NoopAttributeScrubber as q, LogfireAttributeScrubber as Q, logfireApiConfig as Z, log as ee, Level as re, info as te, fatal as oe, error as ne, debug as ae, configureLogfireApi as p, TailSamplingProcessor as ie } from "logfire";
12
12
  export * from "logfire";
13
- import { hrTimeToMicroseconds as u, ExportResultCode as te } from "@opentelemetry/core";
14
- import { OTLPExporterBase as oe, mergeOtlpSharedConfigurationWithDefaults as ne, getSharedConfigurationDefaults as ie } from "@opentelemetry/otlp-exporter-base";
15
- import { createOtlpXhrExportDelegate as ae } from "@opentelemetry/otlp-exporter-base/browser-http";
16
- import { JsonTraceSerializer as se } from "@opentelemetry/otlp-transformer";
17
- const l = "target_xpath", ce = "event_type", ue = {
13
+ import { hrTimeToMicroseconds as E, ExportResultCode as se } from "@opentelemetry/core";
14
+ import { OTLPExporterBase as ce, mergeOtlpSharedConfigurationWithDefaults as le, getSharedConfigurationDefaults as ue } from "@opentelemetry/otlp-exporter-base";
15
+ import { createOtlpXhrExportDelegate as ge } from "@opentelemetry/otlp-exporter-base/browser-http";
16
+ import { JsonTraceSerializer as fe } from "@opentelemetry/otlp-transformer";
17
+ const m = "target_xpath", Ee = "event_type", me = {
18
18
  1: "trace",
19
19
  5: "debug",
20
20
  9: "info",
@@ -22,7 +22,7 @@ const l = "target_xpath", ce = "event_type", ue = {
22
22
  13: "warning",
23
23
  17: "error",
24
24
  21: "fatal"
25
- }, g = {
25
+ }, d = {
26
26
  debug: "#E3E3E3",
27
27
  error: "#EA4335",
28
28
  fatal: "#EA4335",
@@ -38,7 +38,7 @@ const l = "target_xpath", ce = "event_type", ue = {
38
38
  trace: "#E3E3E3",
39
39
  warning: "#EFB77A"
40
40
  };
41
- class le {
41
+ class de {
42
42
  export(e, r) {
43
43
  this.sendSpans(e, r);
44
44
  }
@@ -56,7 +56,7 @@ class le {
56
56
  var r;
57
57
  return {
58
58
  attributes: e.attributes,
59
- duration: u(e.duration),
59
+ duration: E(e.duration),
60
60
  events: e.events,
61
61
  id: e.spanContext().spanId,
62
62
  instrumentationScope: e.instrumentationScope,
@@ -68,31 +68,31 @@ class le {
68
68
  attributes: e.resource.attributes
69
69
  },
70
70
  status: e.status,
71
- timestamp: u(e.startTime),
71
+ timestamp: E(e.startTime),
72
72
  traceId: e.spanContext().traceId,
73
73
  traceState: (r = e.spanContext().traceState) == null ? void 0 : r.serialize()
74
74
  };
75
75
  }
76
76
  sendSpans(e, r) {
77
77
  for (const n of e) {
78
- const o = ue[n.attributes["logfire.level_num"]] ?? "info", { attributes: s, name: m, ...T } = this.exportInfo(n);
78
+ const o = me[n.attributes["logfire.level_num"]] ?? "info", { attributes: a, name: c, ...i } = this.exportInfo(n);
79
79
  console.log(
80
80
  `%cLogfire %c${o}`,
81
81
  "background-color: #E520E9; color: #FFFFFF",
82
- `background-color: ${g[`on-${o}`]}; color: ${g[o]}`,
83
- m,
84
- s,
85
- T
82
+ `background-color: ${d[`on-${o}`]}; color: ${d[o]}`,
83
+ c,
84
+ a,
85
+ i
86
86
  );
87
87
  }
88
- r && r({ code: te.SUCCESS });
88
+ r && r({ code: se.SUCCESS });
89
89
  }
90
90
  }
91
- class ge {
91
+ class Te {
92
92
  constructor(e, r) {
93
- a(this, "console");
94
- a(this, "wrapped");
95
- r && (this.console = new _(new le())), this.wrapped = e;
93
+ l(this, "console");
94
+ l(this, "wrapped");
95
+ r && (this.console = new b(new de())), this.wrapped = e;
96
96
  }
97
97
  async forceFlush() {
98
98
  var e;
@@ -104,28 +104,28 @@ class ge {
104
104
  }
105
105
  onStart(e, r) {
106
106
  var n;
107
- if (c in e.attributes) {
108
- const o = new URL(e.attributes[c]);
107
+ if (f in e.attributes) {
108
+ const o = new URL(e.attributes[f]);
109
109
  Reflect.set(e, "name", `${e.name} ${o.pathname}`);
110
110
  }
111
- l in e.attributes && Reflect.set(e, "name", `${e.attributes[ce] ?? "unknown"} ${e.attributes[l] ?? ""}`), (n = this.console) == null || n.onStart(e, r), this.wrapped.onStart(e, r);
111
+ m in e.attributes && Reflect.set(e, "name", `${e.attributes[Ee] ?? "unknown"} ${e.attributes[m] ?? ""}`), (n = this.console) == null || n.onStart(e, r), this.wrapped.onStart(e, r);
112
112
  }
113
113
  async shutdown() {
114
114
  var e;
115
115
  return await ((e = this.console) == null ? void 0 : e.shutdown()), this.wrapped.shutdown();
116
116
  }
117
117
  }
118
- class fe extends oe {
118
+ class pe extends ce {
119
119
  constructor(e, r) {
120
120
  const o = {
121
- ...ne(
121
+ ...le(
122
122
  {
123
123
  compression: e.compression,
124
124
  concurrencyLimit: e.concurrencyLimit,
125
125
  timeoutMillis: e.timeoutMillis
126
126
  },
127
127
  {},
128
- ie()
128
+ ue()
129
129
  ),
130
130
  agentOptions: { keepAlive: !0 },
131
131
  headers: async () => ({
@@ -135,89 +135,95 @@ class fe extends oe {
135
135
  }),
136
136
  url: e.url ?? "http://localhost:4318/v1/traces"
137
137
  };
138
- super(ae(o, se));
138
+ super(ge(o, fe));
139
139
  }
140
140
  }
141
- function Ee() {
141
+ function he() {
142
142
  return {};
143
143
  }
144
- function me(t) {
145
- t.diagLogLevel !== void 0 && i.setLogger(new h(), t.diagLogLevel), E({
144
+ function Ae(t) {
145
+ var i, u;
146
+ t.diagLogLevel !== void 0 && s.setLogger(new R(), t.diagLogLevel), p({
146
147
  errorFingerprinting: t.errorFingerprinting ?? !1,
147
148
  scrubbing: t.scrubbing
148
149
  });
149
- const e = R({
150
- [y]: navigator.language,
151
- [M]: t.serviceName ?? "logfire-browser",
152
- [N]: t.serviceVersion ?? "0.0.1",
153
- [F]: v,
154
- [D]: "logfire-browser",
155
- ...t.environment ? { [B]: t.environment } : {},
150
+ const e = _({
151
+ [k]: navigator.language,
152
+ [B]: t.serviceName ?? "logfire-browser",
153
+ [O]: t.serviceVersion ?? "0.0.1",
154
+ [I]: F,
155
+ [M]: "logfire-browser",
156
+ ...t.environment ? { [$]: t.environment } : {},
156
157
  // eslint-disable-next-line no-undef
157
- [C]: "0.13.0",
158
+ [P]: "0.14.0",
158
159
  ...navigator.userAgentData ? {
159
- [P]: navigator.userAgentData.brands.map((o) => `${o.brand} ${o.version}`),
160
- [I]: navigator.userAgentData.mobile,
161
- [O]: navigator.userAgentData.platform
160
+ [U]: navigator.userAgentData.brands.map((g) => `${g.brand} ${g.version}`),
161
+ [G]: navigator.userAgentData.mobile,
162
+ [y]: navigator.userAgentData.platform
162
163
  } : {
163
- [x]: navigator.userAgent
164
+ [N]: navigator.userAgent
164
165
  }
165
166
  });
166
- i.info("logfire-browser: starting");
167
- const r = new b({
168
- idGenerator: new f(),
167
+ s.info("logfire-browser: starting");
168
+ const r = (i = t.sampling) == null ? void 0 : i.head, n = r !== void 0 && r < 1 ? new L({ root: new v(r) }) : void 0;
169
+ let o = new Te(
170
+ new x(
171
+ new pe(
172
+ { ...t.traceExporterConfig, url: t.traceUrl },
173
+ t.traceExporterHeaders ?? he
174
+ ),
175
+ t.batchSpanProcessorConfig
176
+ ),
177
+ !!t.console
178
+ );
179
+ (u = t.sampling) != null && u.tail && (o = new ie(
180
+ o,
181
+ t.sampling.tail
182
+ ));
183
+ const a = new C({
184
+ idGenerator: new T(),
169
185
  resource: e,
170
- spanProcessors: [
171
- new ge(
172
- new w(
173
- new fe(
174
- { ...t.traceExporterConfig, url: t.traceUrl },
175
- t.traceExporterHeaders ?? Ee
176
- ),
177
- t.batchSpanProcessorConfig
178
- ),
179
- !!t.console
180
- )
181
- ]
186
+ ...n ? { sampler: n } : {},
187
+ spanProcessors: [o]
182
188
  });
183
- r.register({
184
- contextManager: t.contextManager ?? new L()
189
+ a.register({
190
+ contextManager: t.contextManager ?? new D()
185
191
  });
186
- const n = S({
192
+ const c = w({
187
193
  instrumentations: t.instrumentations ?? [],
188
- tracerProvider: r
194
+ tracerProvider: a
189
195
  });
190
196
  return async () => {
191
- i.info("logfire-browser: shutting down"), n(), await r.forceFlush(), await r.shutdown(), i.info("logfire-browser: shut down complete");
197
+ s.info("logfire-browser: shutting down"), c(), await a.forceFlush(), await a.shutdown(), s.info("logfire-browser: shut down complete");
192
198
  };
193
199
  }
194
- const xe = {
195
- configure: me,
196
- configureLogfireApi: E,
197
- debug: re,
198
- DiagLogLevel: A,
199
- error: ee,
200
- fatal: Z,
201
- info: Q,
200
+ const Pe = {
201
+ configure: Ae,
202
+ configureLogfireApi: p,
203
+ debug: ae,
204
+ DiagLogLevel: S,
205
+ error: ne,
206
+ fatal: oe,
207
+ info: te,
202
208
  // Re-export all from logfire
203
- Level: q,
204
- log: j,
205
- logfireApiConfig: X,
206
- LogfireAttributeScrubber: J,
207
- NoopAttributeScrubber: H,
208
- notice: z,
209
- reportError: K,
210
- resolveBaseUrl: Y,
211
- resolveSendToLogfire: W,
212
- serializeAttributes: V,
213
- span: k,
214
- startSpan: $,
215
- trace: U,
216
- ULIDGenerator: f,
217
- warning: G
209
+ Level: re,
210
+ log: ee,
211
+ logfireApiConfig: Z,
212
+ LogfireAttributeScrubber: Q,
213
+ NoopAttributeScrubber: q,
214
+ notice: j,
215
+ reportError: X,
216
+ resolveBaseUrl: J,
217
+ resolveSendToLogfire: H,
218
+ serializeAttributes: z,
219
+ span: K,
220
+ startSpan: Y,
221
+ trace: W,
222
+ ULIDGenerator: T,
223
+ warning: V
218
224
  };
219
225
  export {
220
- Fe as DiagLogLevel,
221
- me as configure,
222
- xe as default
226
+ Oe as DiagLogLevel,
227
+ Ae as configure,
228
+ Pe as default
223
229
  };
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "stats",
26
26
  "monitoring"
27
27
  ],
28
- "version": "0.13.0",
28
+ "version": "0.14.0",
29
29
  "type": "module",
30
30
  "main": "./dist/index.cjs",
31
31
  "module": "./dist/index.js",
@@ -50,7 +50,7 @@
50
50
  "@opentelemetry/otlp-exporter-base": "^0.209.0",
51
51
  "@opentelemetry/otlp-transformer": "^0.209.0",
52
52
  "@opentelemetry/resources": "^2.0.1",
53
- "logfire": "0.12.0"
53
+ "logfire": "0.13.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@opentelemetry/sdk-trace-web": "^2.0.1",