@pydantic/logfire-browser 0.8.1 → 0.9.1

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 ADDED
@@ -0,0 +1,30 @@
1
+ # Pydantic Logfire — JavaScript SDK
2
+
3
+ From the team behind [Pydantic Validation](https://pydantic.dev/), **Pydantic Logfire** is an observability platform built on the same belief as our open source library — that the most powerful tools can be easy to use.
4
+
5
+ What sets Logfire apart:
6
+
7
+ - **Simple and Powerful:** Logfire's dashboard is simple relative to the power it provides, ensuring your entire engineering team will actually use it.
8
+ - **SQL:** Query your data using standard SQL — all the control and (for many) nothing new to learn. Using SQL also means you can query your data with existing BI tools and database querying libraries.
9
+ - **OpenTelemetry:** Logfire is an opinionated wrapper around OpenTelemetry, allowing you to leverage existing tooling, infrastructure, and instrumentation for many common packages, and enabling support for virtually any language.
10
+
11
+ See the [documentation](https://logfire.pydantic.dev/docs/) for more information.
12
+
13
+ **Feel free to report issues and ask any questions about Logfire in this repository!**
14
+
15
+ This repo contains the JavaScript Browser SDK; the server application for recording and displaying data is closed source.
16
+
17
+ If you need to instrument your Node.js application, see the [`logfire` package](https://www.npmjs.com/package/logfire).
18
+ If you're instrumenting Cloudflare, see the [Logfire CF workers package](https://www.npmjs.com/package/@pydantic/logfire-cf-workers).
19
+
20
+ ## Basic usage
21
+
22
+ See the [Logfire Browser docs for a primer](https://logfire.pydantic.dev/docs/integrations/javascript/browser/). Ready to run examples are available in the repository [in vanilla browser](https://github.com/pydantic/logfire-js/tree/main/examples/browser) and [Next.js variants](https://github.com/pydantic/logfire-js/tree/main/examples/nextjs-client-side-instrumentation).
23
+
24
+ ## Contributing
25
+
26
+ See [CONTRIBUTING.md](https://github.com/pydantic/logfire-js/blob/main/CONTRIBUTING.md) for development instructions.
27
+
28
+ ## License
29
+
30
+ MIT
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var f=(e,r,t)=>r in e?E(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var l=(e,r,t)=>f(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@opentelemetry/api"),d=require("@opentelemetry/instrumentation"),_=require("@opentelemetry/resources"),u=require("@opentelemetry/sdk-trace-web"),o=require("@opentelemetry/semantic-conventions"),a=require("@opentelemetry/semantic-conventions/incubating"),c=require("@pydantic/logfire-api"),g=require("@opentelemetry/otlp-exporter-base"),R=require("@opentelemetry/otlp-exporter-base/browser-http"),A=require("@opentelemetry/otlp-transformer");function p(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const b=p(c);class m extends g.OTLPExporterBase{constructor(r,t){const s={...g.mergeOtlpSharedConfigurationWithDefaults({compression:r.compression,concurrencyLimit:r.concurrencyLimit,timeoutMillis:r.timeoutMillis},{},g.getSharedConfigurationDefaults()),agentOptions:{keepAlive:!0},headers:()=>({"Content-Type":"application/json",...r.headers??{},...t?t():{}}),url:r.url??"http://localhost:4318/v1/traces"};super(R.createOtlpXhrExportDelegate(s,A.JsonTraceSerializer))}}const T="target_xpath",L="event_type";function h(){return{}}function w(e){e.diagLogLevel!==void 0&&i.diag.setLogger(new i.DiagConsoleLogger,e.diagLogLevel),e.scrubbing!==void 0&&b.configureLogfireApi({scrubbing:e.scrubbing});const r=_.resourceFromAttributes({[a.ATTR_BROWSER_LANGUAGE]:navigator.language,[o.ATTR_SERVICE_NAME]:e.serviceName??"logfire-browser",[o.ATTR_SERVICE_VERSION]:e.serviceVersion??"0.0.1",[o.ATTR_TELEMETRY_SDK_LANGUAGE]:o.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,[o.ATTR_TELEMETRY_SDK_NAME]:"logfire-browser",...e.environment?{[a.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]:e.environment}:{},[o.ATTR_TELEMETRY_SDK_VERSION]:"0.8.1",...navigator.userAgentData?{[a.ATTR_BROWSER_BRANDS]:navigator.userAgentData.brands.map(s=>`${s.brand} ${s.version}`),[a.ATTR_BROWSER_MOBILE]:navigator.userAgentData.mobile,[a.ATTR_BROWSER_PLATFORM]:navigator.userAgentData.platform}:{[o.ATTR_USER_AGENT_ORIGINAL]:navigator.userAgent}});i.diag.info("logfire-browser: starting");const t=new u.WebTracerProvider({idGenerator:new c.ULIDGenerator,resource:r,spanProcessors:[new S(new u.BatchSpanProcessor(new m({...e.traceExporterConfig,url:e.traceUrl},e.traceExporterHeaders??h),e.batchSpanProcessorConfig))]});t.register({contextManager:e.contextManager??new u.StackContextManager});const n=d.registerInstrumentations({instrumentations:e.instrumentations??[],tracerProvider:t});return async()=>{i.diag.info("logfire-browser: shutting down"),n(),await t.forceFlush(),await t.shutdown(),i.diag.info("logfire-browser: shut down complete")}}class S{constructor(r){l(this,"wrapped");this.wrapped=r}async forceFlush(){return this.wrapped.forceFlush()}onEnd(r){this.wrapped.onEnd(r)}onStart(r,t){if(a.ATTR_HTTP_URL in r.attributes){const n=new URL(r.attributes[a.ATTR_HTTP_URL]);Reflect.set(r,"name",`${r.name} ${n.pathname}`)}T in r.attributes&&Reflect.set(r,"name",`${r.attributes[L]??"unknown"} ${r.attributes[T]??""}`),this.wrapped.onStart(r,t)}async shutdown(){return this.wrapped.shutdown()}}Object.defineProperty(exports,"DiagLogLevel",{enumerable:!0,get:()=>i.DiagLogLevel});exports.configure=w;Object.keys(c).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>c[e]})});
1
+ "use strict";var m=Object.defineProperty;var p=(r,e,t)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var l=(r,e,t)=>p(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@opentelemetry/api"),A=require("@opentelemetry/instrumentation"),_=require("@opentelemetry/resources"),c=require("@opentelemetry/sdk-trace-web"),a=require("@opentelemetry/semantic-conventions"),i=require("@opentelemetry/semantic-conventions/incubating"),u=require("@pydantic/logfire-api"),g=require("@opentelemetry/core"),E=require("@opentelemetry/otlp-exporter-base"),S=require("@opentelemetry/otlp-exporter-base/browser-http"),R=require("@opentelemetry/otlp-transformer");function w(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const L=w(u),d="target_xpath",v="event_type",O={1:"trace",5:"debug",9:"info",10:"notice",13:"warning",17:"error",21:"fatal"},f={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 o of e){const n=O[o.attributes["logfire.level_num"]]??"info",{attributes:T,name:b,...h}=this.exportInfo(o);console.log(`%cLogfire %c${n}`,"background-color: #E520E9; color: #FFFFFF",`background-color: ${f[`on-${n}`]}; color: ${f[n]}`,b,T,h)}t&&t({code:g.ExportResultCode.SUCCESS})}}class x{constructor(e,t){l(this,"console");l(this,"wrapped");t&&(this.console=new c.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 o;if(i.ATTR_HTTP_URL in e.attributes){const n=new URL(e.attributes[i.ATTR_HTTP_URL]);Reflect.set(e,"name",`${e.name} ${n.pathname}`)}d in e.attributes&&Reflect.set(e,"name",`${e.attributes[v]??"unknown"} ${e.attributes[d]??""}`),(o=this.console)==null||o.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 C extends E.OTLPExporterBase{constructor(e,t){const n={...E.mergeOtlpSharedConfigurationWithDefaults({compression:e.compression,concurrencyLimit:e.concurrencyLimit,timeoutMillis:e.timeoutMillis},{},E.getSharedConfigurationDefaults()),agentOptions:{keepAlive:!0},headers:()=>({"Content-Type":"application/json",...e.headers??{},...t?t():{}}),url:e.url??"http://localhost:4318/v1/traces"};super(S.createOtlpXhrExportDelegate(n,R.JsonTraceSerializer))}}function P(){return{}}function F(r){r.diagLogLevel!==void 0&&s.diag.setLogger(new s.DiagConsoleLogger,r.diagLogLevel),r.scrubbing!==void 0&&L.configureLogfireApi({scrubbing:r.scrubbing});const e=_.resourceFromAttributes({[i.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?{[i.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]:r.environment}:{},[a.ATTR_TELEMETRY_SDK_VERSION]:"0.9.1",...navigator.userAgentData?{[i.ATTR_BROWSER_BRANDS]:navigator.userAgentData.brands.map(n=>`${n.brand} ${n.version}`),[i.ATTR_BROWSER_MOBILE]:navigator.userAgentData.mobile,[i.ATTR_BROWSER_PLATFORM]:navigator.userAgentData.platform}:{[a.ATTR_USER_AGENT_ORIGINAL]:navigator.userAgent}});s.diag.info("logfire-browser: starting");const t=new c.WebTracerProvider({idGenerator:new u.ULIDGenerator,resource:e,spanProcessors:[new x(new c.BatchSpanProcessor(new C({...r.traceExporterConfig,url:r.traceUrl},r.traceExporterHeaders??P),r.batchSpanProcessorConfig),!!r.console)]});t.register({contextManager:r.contextManager??new c.StackContextManager});const o=A.registerInstrumentations({instrumentations:r.instrumentations??[],tracerProvider:t});return async()=>{s.diag.info("logfire-browser: shutting down"),o(),await t.forceFlush(),await t.shutdown(),s.diag.info("logfire-browser: shut down complete")}}Object.defineProperty(exports,"DiagLogLevel",{enumerable:!0,get:()=>s.DiagLogLevel});exports.configure=F;Object.keys(u).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>u[r]})});
package/dist/index.d.cts CHANGED
@@ -14,6 +14,10 @@ export declare interface LogfireConfigOptions {
14
14
  * The configuration of the batch span processor.
15
15
  */
16
16
  batchSpanProcessorConfig?: BufferConfig;
17
+ /**
18
+ * Whether to log the spans to the console in addition to sending them to the Logfire API.
19
+ */
20
+ console?: boolean;
17
21
  /**
18
22
  * Pass a context manager (e.g. ZoneContextManager) to use.
19
23
  */
package/dist/index.d.ts CHANGED
@@ -14,6 +14,10 @@ export declare interface LogfireConfigOptions {
14
14
  * The configuration of the batch span processor.
15
15
  */
16
16
  batchSpanProcessorConfig?: BufferConfig;
17
+ /**
18
+ * Whether to log the spans to the console in addition to sending them to the Logfire API.
19
+ */
20
+ console?: boolean;
17
21
  /**
18
22
  * Pass a context manager (e.g. ZoneContextManager) to use.
19
23
  */
package/dist/index.js CHANGED
@@ -1,115 +1,195 @@
1
- var u = Object.defineProperty;
2
- var T = (e, r, t) => r in e ? u(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var i = (e, r, t) => T(e, typeof r != "symbol" ? r + "" : r, t);
4
- import { diag as a, DiagConsoleLogger as g } from "@opentelemetry/api";
5
- import { DiagLogLevel as rr } from "@opentelemetry/api";
6
- import { registerInstrumentations as E } from "@opentelemetry/instrumentation";
7
- import { resourceFromAttributes as m } from "@opentelemetry/resources";
8
- import { WebTracerProvider as f, BatchSpanProcessor as l, StackContextManager as R } from "@opentelemetry/sdk-trace-web";
9
- import { TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS as A, ATTR_USER_AGENT_ORIGINAL as _, ATTR_TELEMETRY_SDK_VERSION as p, ATTR_TELEMETRY_SDK_NAME as d, ATTR_TELEMETRY_SDK_LANGUAGE as h, ATTR_SERVICE_VERSION as L, ATTR_SERVICE_NAME as w } from "@opentelemetry/semantic-conventions";
10
- import { ATTR_BROWSER_PLATFORM as S, ATTR_BROWSER_MOBILE as b, ATTR_BROWSER_BRANDS as v, ATTR_DEPLOYMENT_ENVIRONMENT_NAME as D, ATTR_BROWSER_LANGUAGE as N, ATTR_HTTP_URL as s } from "@opentelemetry/semantic-conventions/incubating";
11
- import * as x from "@pydantic/logfire-api";
12
- import { ULIDGenerator as M } from "@pydantic/logfire-api";
1
+ var m = Object.defineProperty;
2
+ var T = (t, e, r) => e in t ? m(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var i = (t, e, r) => T(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { diag as a, DiagConsoleLogger as d } from "@opentelemetry/api";
5
+ import { DiagLogLevel as le } from "@opentelemetry/api";
6
+ import { registerInstrumentations as h } from "@opentelemetry/instrumentation";
7
+ import { resourceFromAttributes as A } from "@opentelemetry/resources";
8
+ import { SimpleSpanProcessor as p, WebTracerProvider as R, BatchSpanProcessor as S, StackContextManager as _ } from "@opentelemetry/sdk-trace-web";
9
+ import { TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS as w, ATTR_USER_AGENT_ORIGINAL as b, ATTR_TELEMETRY_SDK_VERSION as L, ATTR_TELEMETRY_SDK_NAME as v, ATTR_TELEMETRY_SDK_LANGUAGE as x, ATTR_SERVICE_VERSION as C, ATTR_SERVICE_NAME as D } from "@opentelemetry/semantic-conventions";
10
+ import { ATTR_HTTP_URL as s, ATTR_BROWSER_PLATFORM as F, ATTR_BROWSER_MOBILE as M, ATTR_BROWSER_BRANDS as N, ATTR_DEPLOYMENT_ENVIRONMENT_NAME as O, ATTR_BROWSER_LANGUAGE as I } from "@opentelemetry/semantic-conventions/incubating";
11
+ import * as P from "@pydantic/logfire-api";
12
+ import { ULIDGenerator as B } from "@pydantic/logfire-api";
13
13
  export * from "@pydantic/logfire-api";
14
- import { OTLPExporterBase as O, mergeOtlpSharedConfigurationWithDefaults as P, getSharedConfigurationDefaults as C } from "@opentelemetry/otlp-exporter-base";
15
- import { createOtlpXhrExportDelegate as G } from "@opentelemetry/otlp-exporter-base/browser-http";
16
- import { JsonTraceSerializer as I } from "@opentelemetry/otlp-transformer";
17
- class B extends O {
18
- constructor(r, t) {
19
- const n = {
20
- ...P(
14
+ import { hrTimeToMicroseconds as c, ExportResultCode as G } from "@opentelemetry/core";
15
+ import { OTLPExporterBase as U, mergeOtlpSharedConfigurationWithDefaults as $, getSharedConfigurationDefaults as k } from "@opentelemetry/otlp-exporter-base";
16
+ import { createOtlpXhrExportDelegate as y } from "@opentelemetry/otlp-exporter-base/browser-http";
17
+ import { JsonTraceSerializer as V } from "@opentelemetry/otlp-transformer";
18
+ const u = "target_xpath", W = "event_type", Y = {
19
+ 1: "trace",
20
+ 5: "debug",
21
+ 9: "info",
22
+ 10: "notice",
23
+ 13: "warning",
24
+ 17: "error",
25
+ 21: "fatal"
26
+ }, l = {
27
+ debug: "#E3E3E3",
28
+ error: "#EA4335",
29
+ fatal: "#EA4335",
30
+ info: "#9EC1FB",
31
+ notice: "#A5D490",
32
+ "on-debug": "#636262",
33
+ "on-error": "#FFEDE9",
34
+ "on-fatal": "#FFEDE9",
35
+ "on-info": "#063175",
36
+ "on-notice": "#222222",
37
+ "on-trace": "#636262",
38
+ "on-warning": "#613A0D",
39
+ trace: "#E3E3E3",
40
+ warning: "#EFB77A"
41
+ };
42
+ class H {
43
+ export(e, r) {
44
+ this.sendSpans(e, r);
45
+ }
46
+ forceFlush() {
47
+ return Promise.resolve();
48
+ }
49
+ shutdown() {
50
+ return this.sendSpans([]), this.forceFlush();
51
+ }
52
+ /**
53
+ * converts span info into more readable format
54
+ * @param span
55
+ */
56
+ exportInfo(e) {
57
+ var r;
58
+ return {
59
+ attributes: e.attributes,
60
+ duration: c(e.duration),
61
+ events: e.events,
62
+ id: e.spanContext().spanId,
63
+ instrumentationScope: e.instrumentationScope,
64
+ kind: e.kind,
65
+ links: e.links,
66
+ name: e.name,
67
+ parentSpanContext: e.parentSpanContext,
68
+ resource: {
69
+ attributes: e.resource.attributes
70
+ },
71
+ status: e.status,
72
+ timestamp: c(e.startTime),
73
+ traceId: e.spanContext().traceId,
74
+ traceState: (r = e.spanContext().traceState) == null ? void 0 : r.serialize()
75
+ };
76
+ }
77
+ sendSpans(e, r) {
78
+ for (const n of e) {
79
+ const o = Y[n.attributes["logfire.level_num"]] ?? "info", { attributes: E, name: g, ...f } = this.exportInfo(n);
80
+ console.log(
81
+ `%cLogfire %c${o}`,
82
+ "background-color: #E520E9; color: #FFFFFF",
83
+ `background-color: ${l[`on-${o}`]}; color: ${l[o]}`,
84
+ g,
85
+ E,
86
+ f
87
+ );
88
+ }
89
+ r && r({ code: G.SUCCESS });
90
+ }
91
+ }
92
+ class K {
93
+ constructor(e, r) {
94
+ i(this, "console");
95
+ i(this, "wrapped");
96
+ r && (this.console = new p(new H())), this.wrapped = e;
97
+ }
98
+ async forceFlush() {
99
+ var e;
100
+ return await ((e = this.console) == null ? void 0 : e.forceFlush()), this.wrapped.forceFlush();
101
+ }
102
+ onEnd(e) {
103
+ var r;
104
+ (r = this.console) == null || r.onEnd(e), this.wrapped.onEnd(e);
105
+ }
106
+ onStart(e, r) {
107
+ var n;
108
+ if (s in e.attributes) {
109
+ const o = new URL(e.attributes[s]);
110
+ Reflect.set(e, "name", `${e.name} ${o.pathname}`);
111
+ }
112
+ u in e.attributes && Reflect.set(e, "name", `${e.attributes[W] ?? "unknown"} ${e.attributes[u] ?? ""}`), (n = this.console) == null || n.onStart(e, r), this.wrapped.onStart(e, r);
113
+ }
114
+ async shutdown() {
115
+ var e;
116
+ return await ((e = this.console) == null ? void 0 : e.shutdown()), this.wrapped.shutdown();
117
+ }
118
+ }
119
+ class z extends U {
120
+ constructor(e, r) {
121
+ const o = {
122
+ ...$(
21
123
  {
22
- compression: r.compression,
23
- concurrencyLimit: r.concurrencyLimit,
24
- timeoutMillis: r.timeoutMillis
124
+ compression: e.compression,
125
+ concurrencyLimit: e.concurrencyLimit,
126
+ timeoutMillis: e.timeoutMillis
25
127
  },
26
128
  {},
27
- C()
129
+ k()
28
130
  ),
29
131
  agentOptions: { keepAlive: !0 },
30
132
  headers: () => ({
31
133
  "Content-Type": "application/json",
32
- ...r.headers ?? {},
33
- ...t ? t() : {}
134
+ ...e.headers ?? {},
135
+ ...r ? r() : {}
34
136
  }),
35
- url: r.url ?? "http://localhost:4318/v1/traces"
137
+ url: e.url ?? "http://localhost:4318/v1/traces"
36
138
  };
37
- super(G(n, I));
139
+ super(y(o, V));
38
140
  }
39
141
  }
40
- const c = "target_xpath", U = "event_type";
41
- function y() {
142
+ function J() {
42
143
  return {};
43
144
  }
44
- function q(e) {
45
- e.diagLogLevel !== void 0 && a.setLogger(new g(), e.diagLogLevel), e.scrubbing !== void 0 && x.configureLogfireApi({ scrubbing: e.scrubbing });
46
- const r = m({
47
- [N]: navigator.language,
48
- [w]: e.serviceName ?? "logfire-browser",
49
- [L]: e.serviceVersion ?? "0.0.1",
50
- [h]: A,
51
- [d]: "logfire-browser",
52
- ...e.environment ? { [D]: e.environment } : {},
145
+ function se(t) {
146
+ t.diagLogLevel !== void 0 && a.setLogger(new d(), t.diagLogLevel), t.scrubbing !== void 0 && P.configureLogfireApi({ scrubbing: t.scrubbing });
147
+ const e = A({
148
+ [I]: navigator.language,
149
+ [D]: t.serviceName ?? "logfire-browser",
150
+ [C]: t.serviceVersion ?? "0.0.1",
151
+ [x]: w,
152
+ [v]: "logfire-browser",
153
+ ...t.environment ? { [O]: t.environment } : {},
53
154
  // eslint-disable-next-line no-undef
54
- [p]: "0.8.1",
155
+ [L]: "0.9.1",
55
156
  ...navigator.userAgentData ? {
56
- [v]: navigator.userAgentData.brands.map((n) => `${n.brand} ${n.version}`),
57
- [b]: navigator.userAgentData.mobile,
58
- [S]: navigator.userAgentData.platform
157
+ [N]: navigator.userAgentData.brands.map((o) => `${o.brand} ${o.version}`),
158
+ [M]: navigator.userAgentData.mobile,
159
+ [F]: navigator.userAgentData.platform
59
160
  } : {
60
- [_]: navigator.userAgent
161
+ [b]: navigator.userAgent
61
162
  }
62
163
  });
63
164
  a.info("logfire-browser: starting");
64
- const t = new f({
65
- idGenerator: new M(),
66
- resource: r,
165
+ const r = new R({
166
+ idGenerator: new B(),
167
+ resource: e,
67
168
  spanProcessors: [
68
- new V(
69
- new l(
70
- new B(
71
- { ...e.traceExporterConfig, url: e.traceUrl },
72
- e.traceExporterHeaders ?? y
169
+ new K(
170
+ new S(
171
+ new z(
172
+ { ...t.traceExporterConfig, url: t.traceUrl },
173
+ t.traceExporterHeaders ?? J
73
174
  ),
74
- e.batchSpanProcessorConfig
75
- )
175
+ t.batchSpanProcessorConfig
176
+ ),
177
+ !!t.console
76
178
  )
77
179
  ]
78
180
  });
79
- t.register({
80
- contextManager: e.contextManager ?? new R()
181
+ r.register({
182
+ contextManager: t.contextManager ?? new _()
81
183
  });
82
- const o = E({
83
- instrumentations: e.instrumentations ?? [],
84
- tracerProvider: t
184
+ const n = h({
185
+ instrumentations: t.instrumentations ?? [],
186
+ tracerProvider: r
85
187
  });
86
188
  return async () => {
87
- a.info("logfire-browser: shutting down"), o(), await t.forceFlush(), await t.shutdown(), a.info("logfire-browser: shut down complete");
189
+ a.info("logfire-browser: shutting down"), n(), await r.forceFlush(), await r.shutdown(), a.info("logfire-browser: shut down complete");
88
190
  };
89
191
  }
90
- class V {
91
- constructor(r) {
92
- i(this, "wrapped");
93
- this.wrapped = r;
94
- }
95
- async forceFlush() {
96
- return this.wrapped.forceFlush();
97
- }
98
- onEnd(r) {
99
- this.wrapped.onEnd(r);
100
- }
101
- onStart(r, t) {
102
- if (s in r.attributes) {
103
- const o = new URL(r.attributes[s]);
104
- Reflect.set(r, "name", `${r.name} ${o.pathname}`);
105
- }
106
- c in r.attributes && Reflect.set(r, "name", `${r.attributes[U] ?? "unknown"} ${r.attributes[c] ?? ""}`), this.wrapped.onStart(r, t);
107
- }
108
- async shutdown() {
109
- return this.wrapped.shutdown();
110
- }
111
- }
112
192
  export {
113
- rr as DiagLogLevel,
114
- q as configure
193
+ le as DiagLogLevel,
194
+ se as configure
115
195
  };
package/package.json CHANGED
@@ -6,6 +6,10 @@
6
6
  "email": "engineering@pydantic.dev",
7
7
  "url": "https://pydantic.dev"
8
8
  },
9
+ "repository": {
10
+ "url": "https://github.com/pydantic/logfire-js",
11
+ "directory": "packages/logfire-browser"
12
+ },
9
13
  "sideEffects": false,
10
14
  "homepage": "https://pydantic.dev/logfire",
11
15
  "license": "MIT",
@@ -21,7 +25,7 @@
21
25
  "stats",
22
26
  "monitoring"
23
27
  ],
24
- "version": "0.8.1",
28
+ "version": "0.9.1",
25
29
  "type": "module",
26
30
  "main": "./dist/index.cjs",
27
31
  "module": "./dist/index.js",