Skip to content

Commit 15ab9a1

Browse files
feat: include sentry baggage when initializing web components
1 parent 069c7b6 commit 15ab9a1

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"devDependencies": {
5454
"@eslint/compat": "^1.4.0",
5555
"@eslint/js": "^9.37.0",
56-
"@imagine.dev/web-components": "^0.0.138",
56+
"@imagine.dev/web-components": "^0.0.139",
5757
"@melt-ui/pp": "^0.3.2",
5858
"@melt-ui/svelte": "^0.86.6",
5959
"@playwright/test": "^1.56.0",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/sentry.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ export function identify(userId: string) {
1919
}
2020
}
2121

22-
export function getTraceId(): string | undefined {
22+
export function getTraceData(): {
23+
sentryTraceId?: string;
24+
sentryBaggage?: string;
25+
} {
2326
const traceData = Sentry.getTraceData();
24-
return traceData['sentry-trace'];
27+
return {
28+
sentryTraceId: traceData['sentry-trace'],
29+
sentryBaggage: traceData.baggage
30+
};
2531
}
2632

2733
export function setupSentry({ withSessionReplay }: { withSessionReplay: boolean }) {

src/lib/studio/studio-widget.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { goto } from '$app/navigation';
55
import { resolve } from '$app/paths';
66
import { ensureMonacoStyles } from './monaco-style-manager';
77
import DEV_CSS_URL from '@imagine.dev/web-components/imagine-web-components.css?url';
8-
import { getSessionId, getTraceId } from '$lib/sentry';
8+
import { getSessionId, getTraceData } from '$lib/sentry';
99
import type * as WebComponentsType from '@imagine.dev/web-components/web-components';
1010

1111
const COMPONENT_SELECTOR = 'imagine-web-components-wrapper[data-appwrite-studio]';
@@ -285,6 +285,7 @@ export async function initImagine(
285285
const { initImagineConfig, initImagineRouting } = await getWebComponents();
286286

287287
if (!configInitialized) {
288+
const { sentryTraceId, sentryBaggage } = getTraceData();
288289
initImagineConfig(
289290
{
290291
AI_SERVICE_ENDPOINT: env.PUBLIC_AI_SERVICE_BASE_URL,
@@ -294,7 +295,8 @@ export async function initImagine(
294295
{
295296
initialTheme: get(app).themeInUse,
296297
consoleSessionId: getSessionId(userId),
297-
sentryTraceId: getTraceId(),
298+
sentryTraceId,
299+
sentryBaggage,
298300
callbacks
299301
}
300302
);

0 commit comments

Comments
 (0)