@obtrace/browser 2.3.0 → 2.4.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/browser/console.js +7 -0
- package/dist/browser/errors.js +13 -0
- package/dist/browser/index.js +4 -2
- package/dist/browser/resources.js +14 -9
- package/dist/browser/supabase-intercept.js +133 -0
- package/dist/browser/supabase.js +104 -0
- package/dist/browser_entry.bundle.js +280 -13
- package/dist/browser_entry.bundle.js.map +4 -4
- package/dist/core/otel-web-setup.js +14 -2
- package/dist/types/browser/supabase-intercept.d.ts +2 -0
- package/dist/types/browser/supabase.d.ts +12 -0
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ import { DocumentLoadInstrumentation } from "@opentelemetry/instrumentation-docu
|
|
|
14
14
|
import { UserInteractionInstrumentation } from "@opentelemetry/instrumentation-user-interaction";
|
|
15
15
|
import { ZoneContextManager } from "@opentelemetry/context-zone";
|
|
16
16
|
import { registerInstrumentations } from "@opentelemetry/instrumentation";
|
|
17
|
+
import { enrichSupabaseSpan, isSupabaseURL } from "../browser/supabase";
|
|
17
18
|
export function setupOtelWeb(config) {
|
|
18
19
|
const baseUrl = (config.ingestBaseUrl || "https://ingest.obtrace.ai").replace(/\/$/, "");
|
|
19
20
|
const authHeaders = {
|
|
@@ -74,11 +75,22 @@ export function setupOtelWeb(config) {
|
|
|
74
75
|
});
|
|
75
76
|
const ingestPattern = new RegExp(`^${baseUrl.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`);
|
|
76
77
|
const instrumentations = [];
|
|
78
|
+
const applySupabaseAttrs = (span, req, _result) => {
|
|
79
|
+
try {
|
|
80
|
+
const url = typeof req === "string" ? req : req instanceof URL ? req.href : req?.url || "";
|
|
81
|
+
const method = req?.method || "GET";
|
|
82
|
+
if (url && isSupabaseURL(url)) {
|
|
83
|
+
enrichSupabaseSpan(span, url, method);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch { }
|
|
87
|
+
};
|
|
77
88
|
if (config.instrumentGlobalFetch !== false) {
|
|
78
89
|
instrumentations.push(new FetchInstrumentation({
|
|
79
90
|
propagateTraceHeaderCorsUrls: /.*/,
|
|
80
91
|
ignoreUrls: [ingestPattern],
|
|
81
92
|
clearTimingResources: true,
|
|
93
|
+
applyCustomAttributesOnSpan: applySupabaseAttrs,
|
|
82
94
|
}));
|
|
83
95
|
}
|
|
84
96
|
if (config.instrumentXHR !== false) {
|
|
@@ -94,8 +106,8 @@ export function setupOtelWeb(config) {
|
|
|
94
106
|
tracerProvider,
|
|
95
107
|
instrumentations,
|
|
96
108
|
});
|
|
97
|
-
const tracer = trace.getTracer("@obtrace/sdk-browser", "2.
|
|
98
|
-
const meter = metrics.getMeter("@obtrace/sdk-browser", "2.
|
|
109
|
+
const tracer = trace.getTracer("@obtrace/sdk-browser", "2.4.0");
|
|
110
|
+
const meter = metrics.getMeter("@obtrace/sdk-browser", "2.4.0");
|
|
99
111
|
const forceFlush = async () => {
|
|
100
112
|
try {
|
|
101
113
|
await tracerProvider.forceFlush();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Span } from "@opentelemetry/api";
|
|
2
|
+
interface SupabaseParsed {
|
|
3
|
+
ref: string;
|
|
4
|
+
service: string;
|
|
5
|
+
operation: string;
|
|
6
|
+
table: string;
|
|
7
|
+
detail: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function isSupabaseURL(url: string): boolean;
|
|
10
|
+
export declare function parseSupabaseURL(url: string, method: string): SupabaseParsed | null;
|
|
11
|
+
export declare function enrichSupabaseSpan(span: Span, url: string, method: string): void;
|
|
12
|
+
export {};
|