@pydantic/logfire-browser 0.5.0 → 0.6.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 +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +68 -40
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";var l=Object.defineProperty;var f=(e,r,t)=>r in e?l(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var g=(e,r,t)=>f(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@opentelemetry/api"),E=require("@opentelemetry/context-zone"),_=require("@opentelemetry/exporter-trace-otlp-http"),R=require("@opentelemetry/instrumentation"),b=require("@opentelemetry/resources"),u=require("@opentelemetry/sdk-trace-web"),n=require("@opentelemetry/semantic-conventions"),a=require("@opentelemetry/semantic-conventions/incubating"),s=require("@pydantic/logfire-api");function A(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const d=A(s),T="target_xpath",w="event_type";function L(e){e.diagLogLevel!==void 0&&o.diag.setLogger(new o.DiagConsoleLogger,e.diagLogLevel),e.scrubbing!==void 0&&d.configureLogfireApi({scrubbing:e.scrubbing});const r=b.resourceFromAttributes({[a.ATTR_BROWSER_LANGUAGE]:navigator.language,[n.ATTR_SERVICE_NAME]:e.serviceName??"logfire-browser",[n.ATTR_SERVICE_VERSION]:e.serviceVersion??"0.0.1",[n.ATTR_TELEMETRY_SDK_LANGUAGE]:n.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,[n.ATTR_TELEMETRY_SDK_NAME]:"logfire-browser",...e.environment?{[a.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]:e.environment}:{},[n.ATTR_TELEMETRY_SDK_VERSION]:"0.6.0",...navigator.userAgentData?{[a.ATTR_BROWSER_BRANDS]:navigator.userAgentData.brands.map(c=>`${c.brand} ${c.version}`),[a.ATTR_BROWSER_MOBILE]:navigator.userAgentData.mobile,[a.ATTR_BROWSER_PLATFORM]:navigator.userAgentData.platform}:{[n.ATTR_USER_AGENT_ORIGINAL]:navigator.userAgent}});o.diag.info("logfire-browser: starting");const t=new u.WebTracerProvider({idGenerator:new s.ULIDGenerator,resource:r,spanProcessors:[new m(new u.BatchSpanProcessor(new _.OTLPTraceExporter({...e.traceExporterConfig,url:e.traceUrl}),e.batchSpanProcessorConfig))]});e.enableZoneContextManager!==!1&&(o.diag.info("logfire-browser: enable zone context manager"),t.register({contextManager:new E.ZoneContextManager}));const i=R.registerInstrumentations({instrumentations:e.instrumentations??[],tracerProvider:t});return async()=>{o.diag.info("logfire-browser: shutting down"),i(),await t.forceFlush(),await t.shutdown(),o.diag.info("logfire-browser: shut down complete")}}class m{constructor(r){g(this,"wrapped");this.wrapped=r}async forceFlush(){return this.wrapped.forceFlush()}onEnd(r){console.log("on end",r),this.wrapped.onEnd(r)}onStart(r,t){if(a.ATTR_HTTP_URL in r.attributes){const i=new URL(r.attributes[a.ATTR_HTTP_URL]);Reflect.set(r,"name",`${r.name} ${i.pathname}`)}T in r.attributes&&Reflect.set(r,"name",`${r.attributes[w]??"unknown"} ${r.attributes[T]??""}`),this.wrapped.onStart(r,t)}async shutdown(){return this.wrapped.shutdown()}}Object.defineProperty(exports,"DiagLogLevel",{enumerable:!0,get:()=>o.DiagLogLevel});exports.configure=L;Object.keys(s).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>s[e]})});
|
package/dist/index.d.cts
CHANGED
|
@@ -33,7 +33,7 @@ export declare interface LogfireConfigOptions {
|
|
|
33
33
|
/**
|
|
34
34
|
* Options for scrubbing sensitive data. Set to False to disable.
|
|
35
35
|
*/
|
|
36
|
-
scrubbing?: false | logfireApi.
|
|
36
|
+
scrubbing?: false | logfireApi.ScrubbingOptions;
|
|
37
37
|
/**
|
|
38
38
|
* Name of this service.
|
|
39
39
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare interface LogfireConfigOptions {
|
|
|
33
33
|
/**
|
|
34
34
|
* Options for scrubbing sensitive data. Set to False to disable.
|
|
35
35
|
*/
|
|
36
|
-
scrubbing?: false | logfireApi.
|
|
36
|
+
scrubbing?: false | logfireApi.ScrubbingOptions;
|
|
37
37
|
/**
|
|
38
38
|
* Name of this service.
|
|
39
39
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,57 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
1
|
+
var T = Object.defineProperty;
|
|
2
|
+
var E = (e, r, t) => r in e ? T(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var i = (e, r, t) => E(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { diag as o, DiagConsoleLogger as c } from "@opentelemetry/api";
|
|
5
|
+
import { DiagLogLevel as k } from "@opentelemetry/api";
|
|
6
|
+
import { ZoneContextManager as f } from "@opentelemetry/context-zone";
|
|
7
|
+
import { OTLPTraceExporter as R } from "@opentelemetry/exporter-trace-otlp-http";
|
|
8
|
+
import { registerInstrumentations as u } from "@opentelemetry/instrumentation";
|
|
9
|
+
import { resourceFromAttributes as _ } from "@opentelemetry/resources";
|
|
10
|
+
import { WebTracerProvider as m, BatchSpanProcessor as A } from "@opentelemetry/sdk-trace-web";
|
|
11
|
+
import { TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS as l, ATTR_USER_AGENT_ORIGINAL as w, ATTR_TELEMETRY_SDK_VERSION as L, ATTR_TELEMETRY_SDK_NAME as b, ATTR_TELEMETRY_SDK_LANGUAGE as d, ATTR_SERVICE_VERSION as S, ATTR_SERVICE_NAME as v } from "@opentelemetry/semantic-conventions";
|
|
12
|
+
import { ATTR_BROWSER_PLATFORM as p, ATTR_BROWSER_MOBILE as h, ATTR_BROWSER_BRANDS as N, ATTR_DEPLOYMENT_ENVIRONMENT_NAME as M, ATTR_BROWSER_LANGUAGE as D, ATTR_HTTP_URL as s } from "@opentelemetry/semantic-conventions/incubating";
|
|
13
|
+
import * as O from "@pydantic/logfire-api";
|
|
14
|
+
import { ULIDGenerator as P } from "@pydantic/logfire-api";
|
|
12
15
|
export * from "@pydantic/logfire-api";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
|
|
16
|
+
const g = "target_xpath", G = "event_type";
|
|
17
|
+
function K(e) {
|
|
18
|
+
e.diagLogLevel !== void 0 && o.setLogger(new c(), e.diagLogLevel), e.scrubbing !== void 0 && O.configureLogfireApi({ scrubbing: e.scrubbing });
|
|
19
|
+
const r = _({
|
|
20
|
+
[D]: navigator.language,
|
|
21
|
+
[v]: e.serviceName ?? "logfire-browser",
|
|
22
|
+
[S]: e.serviceVersion ?? "0.0.1",
|
|
23
|
+
[d]: l,
|
|
24
|
+
[b]: "logfire-browser",
|
|
25
|
+
...e.environment ? { [M]: e.environment } : {},
|
|
22
26
|
// eslint-disable-next-line no-undef
|
|
23
|
-
[
|
|
27
|
+
[L]: "0.6.0",
|
|
24
28
|
...navigator.userAgentData ? {
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
29
|
+
[N]: navigator.userAgentData.brands.map((a) => `${a.brand} ${a.version}`),
|
|
30
|
+
[h]: navigator.userAgentData.mobile,
|
|
31
|
+
[p]: navigator.userAgentData.platform
|
|
28
32
|
} : {
|
|
29
|
-
[
|
|
33
|
+
[w]: navigator.userAgent
|
|
30
34
|
}
|
|
31
35
|
});
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
idGenerator: new
|
|
35
|
-
resource:
|
|
36
|
+
o.info("logfire-browser: starting");
|
|
37
|
+
const t = new m({
|
|
38
|
+
idGenerator: new P(),
|
|
39
|
+
resource: r,
|
|
36
40
|
spanProcessors: [
|
|
37
|
-
new
|
|
38
|
-
new
|
|
39
|
-
|
|
41
|
+
new x(
|
|
42
|
+
new A(
|
|
43
|
+
new R({ ...e.traceExporterConfig, url: e.traceUrl }),
|
|
44
|
+
e.batchSpanProcessorConfig
|
|
45
|
+
)
|
|
40
46
|
)
|
|
41
47
|
]
|
|
42
48
|
});
|
|
43
|
-
|
|
44
|
-
contextManager: new
|
|
49
|
+
e.enableZoneContextManager !== !1 && (o.info("logfire-browser: enable zone context manager"), t.register({
|
|
50
|
+
contextManager: new f()
|
|
45
51
|
}));
|
|
46
|
-
const
|
|
47
|
-
instrumentations:
|
|
48
|
-
tracerProvider:
|
|
52
|
+
const n = u({
|
|
53
|
+
instrumentations: e.instrumentations ?? [],
|
|
54
|
+
tracerProvider: t
|
|
49
55
|
});
|
|
50
56
|
return async () => {
|
|
51
|
-
|
|
57
|
+
o.info("logfire-browser: shutting down"), n(), await t.forceFlush(), await t.shutdown(), o.info("logfire-browser: shut down complete");
|
|
52
58
|
};
|
|
53
59
|
}
|
|
60
|
+
class x {
|
|
61
|
+
constructor(r) {
|
|
62
|
+
i(this, "wrapped");
|
|
63
|
+
this.wrapped = r;
|
|
64
|
+
}
|
|
65
|
+
async forceFlush() {
|
|
66
|
+
return this.wrapped.forceFlush();
|
|
67
|
+
}
|
|
68
|
+
onEnd(r) {
|
|
69
|
+
console.log("on end", r), this.wrapped.onEnd(r);
|
|
70
|
+
}
|
|
71
|
+
onStart(r, t) {
|
|
72
|
+
if (s in r.attributes) {
|
|
73
|
+
const n = new URL(r.attributes[s]);
|
|
74
|
+
Reflect.set(r, "name", `${r.name} ${n.pathname}`);
|
|
75
|
+
}
|
|
76
|
+
g in r.attributes && Reflect.set(r, "name", `${r.attributes[G] ?? "unknown"} ${r.attributes[g] ?? ""}`), this.wrapped.onStart(r, t);
|
|
77
|
+
}
|
|
78
|
+
async shutdown() {
|
|
79
|
+
return this.wrapped.shutdown();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
54
82
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
83
|
+
k as DiagLogLevel,
|
|
84
|
+
K as configure
|
|
57
85
|
};
|