@pydantic/logfire-browser 0.14.2 → 0.14.3

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 R=Object.defineProperty;var p=(r,e,t)=>e in r?R(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var E=(r,e,t)=>p(r,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("@opentelemetry/api"),_=require("@opentelemetry/exporter-trace-otlp-http"),w=require("@opentelemetry/instrumentation"),m=require("@opentelemetry/resources"),l=require("@opentelemetry/sdk-trace-web"),i=require("@opentelemetry/semantic-conventions"),c=require("@opentelemetry/semantic-conventions/incubating"),o=require("logfire"),T=require("@opentelemetry/core"),A="target_xpath",v="event_type",h={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 C{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:T.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:T.hrTimeToMicroseconds(e.startTime),traceId:e.spanContext().traceId,traceState:(t=e.spanContext().traceState)==null?void 0:t.serialize()}}sendSpans(e,t){for(const a of e){const n=h[a.attributes["logfire.level_num"]]??"info",{attributes:u,name:d,...f}=this.exportInfo(a);console.log(`%cLogfire %c${n}`,"background-color: #E520E9; color: #FFFFFF",`background-color: ${S[`on-${n}`]}; color: ${S[n]}`,d,u,f)}t&&t({code:T.ExportResultCode.SUCCESS})}}class D{constructor(e,t){E(this,"console");E(this,"wrapped");t&&(this.console=new l.SimpleSpanProcessor(new C)),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 a;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}`)}A in e.attributes&&Reflect.set(e,"name",`${e.attributes[v]??"unknown"} ${e.attributes[A]??""}`),(a=this.console)==null||a.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()}}function F(){return{}}async function P(r,e){return{...typeof r=="function"?await r():r??{},...e()}}function L(r){var f,b;r.diagLogLevel!==void 0&&s.diag.setLogger(new s.DiagConsoleLogger,r.diagLogLevel),o.configureLogfireApi({errorFingerprinting:r.errorFingerprinting??!1,scrubbing:r.scrubbing});const e=m.resourceFromAttributes({[c.ATTR_BROWSER_LANGUAGE]:navigator.language,[i.ATTR_SERVICE_NAME]:r.serviceName??"logfire-browser",[i.ATTR_SERVICE_VERSION]:r.serviceVersion??"0.0.1",[i.ATTR_TELEMETRY_SDK_LANGUAGE]:i.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,[i.ATTR_TELEMETRY_SDK_NAME]:"logfire-browser",...r.environment?{[c.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]:r.environment}:{},[i.ATTR_TELEMETRY_SDK_VERSION]:"0.14.2",...navigator.userAgentData?{[c.ATTR_BROWSER_BRANDS]:navigator.userAgentData.brands.map(g=>`${g.brand} ${g.version}`),[c.ATTR_BROWSER_MOBILE]:navigator.userAgentData.mobile,[c.ATTR_BROWSER_PLATFORM]:navigator.userAgentData.platform}:{[i.ATTR_USER_AGENT_ORIGINAL]:navigator.userAgent}});s.diag.info("logfire-browser: starting");const t=(f=r.sampling)==null?void 0:f.head,a=t!==void 0&&t<1?new l.ParentBasedSampler({root:new l.TraceIdRatioBasedSampler(t)}):void 0;let n=new D(new l.BatchSpanProcessor(new _.OTLPTraceExporter({...r.traceExporterConfig,headers:async()=>{var g;return P((g=r.traceExporterConfig)==null?void 0:g.headers,r.traceExporterHeaders??F)},url:r.traceUrl}),r.batchSpanProcessorConfig),!!r.console);(b=r.sampling)!=null&&b.tail&&(n=new o.TailSamplingProcessor(n,r.sampling.tail));const u=new l.WebTracerProvider({idGenerator:new o.ULIDGenerator,resource:e,...a?{sampler:a}:{},spanProcessors:[n]});u.register({contextManager:r.contextManager??new l.StackContextManager});const d=w.registerInstrumentations({instrumentations:r.instrumentations??[],tracerProvider:u});return async()=>{s.diag.info("logfire-browser: shutting down"),d(),await u.forceFlush(),await u.shutdown(),s.diag.info("logfire-browser: shut down complete")}}const x={configure:L,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=L;exports.default=x;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 R=Object.defineProperty;var p=(r,e,t)=>e in r?R(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var E=(r,e,t)=>p(r,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("@opentelemetry/api"),_=require("@opentelemetry/exporter-trace-otlp-http"),w=require("@opentelemetry/instrumentation"),m=require("@opentelemetry/resources"),l=require("@opentelemetry/sdk-trace-web"),i=require("@opentelemetry/semantic-conventions"),c=require("@opentelemetry/semantic-conventions/incubating"),o=require("logfire"),T=require("@opentelemetry/core"),A="target_xpath",v="event_type",h={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 C{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:T.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:T.hrTimeToMicroseconds(e.startTime),traceId:e.spanContext().traceId,traceState:(t=e.spanContext().traceState)==null?void 0:t.serialize()}}sendSpans(e,t){for(const a of e){const n=h[a.attributes["logfire.level_num"]]??"info",{attributes:u,name:d,...f}=this.exportInfo(a);console.log(`%cLogfire %c${n}`,"background-color: #E520E9; color: #FFFFFF",`background-color: ${S[`on-${n}`]}; color: ${S[n]}`,d,u,f)}t&&t({code:T.ExportResultCode.SUCCESS})}}class D{constructor(e,t){E(this,"console");E(this,"wrapped");t&&(this.console=new l.SimpleSpanProcessor(new C)),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 a;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}`)}A in e.attributes&&Reflect.set(e,"name",`${e.attributes[v]??"unknown"} ${e.attributes[A]??""}`),(a=this.console)==null||a.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()}}function F(){return{}}async function P(r,e){return{...typeof r=="function"?await r():r??{},...e()}}function L(r){var f,b;r.diagLogLevel!==void 0&&s.diag.setLogger(new s.DiagConsoleLogger,r.diagLogLevel),o.configureLogfireApi({errorFingerprinting:r.errorFingerprinting??!1,scrubbing:r.scrubbing});const e=m.resourceFromAttributes({[c.ATTR_BROWSER_LANGUAGE]:navigator.language,[i.ATTR_SERVICE_NAME]:r.serviceName??"logfire-browser",[i.ATTR_SERVICE_VERSION]:r.serviceVersion??"0.0.1",[i.ATTR_TELEMETRY_SDK_LANGUAGE]:i.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,[i.ATTR_TELEMETRY_SDK_NAME]:"logfire-browser",...r.environment?{[c.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]:r.environment}:{},[i.ATTR_TELEMETRY_SDK_VERSION]:"0.14.3",...navigator.userAgentData?{[c.ATTR_BROWSER_BRANDS]:navigator.userAgentData.brands.map(g=>`${g.brand} ${g.version}`),[c.ATTR_BROWSER_MOBILE]:navigator.userAgentData.mobile,[c.ATTR_BROWSER_PLATFORM]:navigator.userAgentData.platform}:{[i.ATTR_USER_AGENT_ORIGINAL]:navigator.userAgent}});s.diag.info("logfire-browser: starting");const t=(f=r.sampling)==null?void 0:f.head,a=t!==void 0&&t<1?new l.ParentBasedSampler({root:new l.TraceIdRatioBasedSampler(t)}):void 0;let n=new D(new l.BatchSpanProcessor(new _.OTLPTraceExporter({...r.traceExporterConfig,headers:async()=>{var g;return P((g=r.traceExporterConfig)==null?void 0:g.headers,r.traceExporterHeaders??F)},url:r.traceUrl}),r.batchSpanProcessorConfig),!!r.console);(b=r.sampling)!=null&&b.tail&&(n=new o.TailSamplingProcessor(n,r.sampling.tail));const u=new l.WebTracerProvider({idGenerator:new o.ULIDGenerator,resource:e,...a?{sampler:a}:{},spanProcessors:[n]});u.register({contextManager:r.contextManager??new l.StackContextManager});const d=w.registerInstrumentations({instrumentations:r.instrumentations??[],tracerProvider:u});return async()=>{s.diag.info("logfire-browser: shutting down"),d(),await u.forceFlush(),await u.shutdown(),s.diag.info("logfire-browser: shut down complete")}}const x={configure:L,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=L;exports.default=x;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.js CHANGED
@@ -136,7 +136,7 @@ function Te(r) {
136
136
  [M]: "logfire-browser",
137
137
  ...r.environment ? { [y]: r.environment } : {},
138
138
  // eslint-disable-next-line no-undef
139
- [I]: "0.14.2",
139
+ [I]: "0.14.3",
140
140
  ...navigator.userAgentData ? {
141
141
  [k]: navigator.userAgentData.brands.map((i) => `${i.brand} ${i.version}`),
142
142
  [$]: navigator.userAgentData.mobile,
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "stats",
26
26
  "monitoring"
27
27
  ],
28
- "version": "0.14.2",
28
+ "version": "0.14.3",
29
29
  "type": "module",
30
30
  "main": "./dist/index.cjs",
31
31
  "module": "./dist/index.js",
@@ -48,7 +48,7 @@
48
48
  "@opentelemetry/exporter-trace-otlp-http": "^0.215.0",
49
49
  "@opentelemetry/instrumentation": "^0.215.0",
50
50
  "@opentelemetry/resources": "^2.7.0",
51
- "logfire": "0.13.2"
51
+ "logfire": "0.14.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@opentelemetry/sdk-trace-web": "^2.7.0",