@pydantic/logfire-browser 0.14.0 → 0.14.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/dist/index.cjs CHANGED
@@ -1 +1 @@
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]})});
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.1",...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.js CHANGED
@@ -155,7 +155,7 @@ function Ae(t) {
155
155
  [M]: "logfire-browser",
156
156
  ...t.environment ? { [$]: t.environment } : {},
157
157
  // eslint-disable-next-line no-undef
158
- [P]: "0.14.0",
158
+ [P]: "0.14.1",
159
159
  ...navigator.userAgentData ? {
160
160
  [U]: navigator.userAgentData.brands.map((g) => `${g.brand} ${g.version}`),
161
161
  [G]: navigator.userAgentData.mobile,
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "stats",
26
26
  "monitoring"
27
27
  ],
28
- "version": "0.14.0",
28
+ "version": "0.14.1",
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.13.0"
53
+ "logfire": "0.13.1"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@opentelemetry/sdk-trace-web": "^2.0.1",