diff --git a/packages/remix/test/integration/app/root.tsx b/packages/remix/test/integration/app/root.tsx index 53e82e0e391e..cbc85172bdfb 100644 --- a/packages/remix/test/integration/app/root.tsx +++ b/packages/remix/test/integration/app/root.tsx @@ -2,10 +2,12 @@ import type { MetaFunction } from '@remix-run/node'; import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react'; import { withSentry } from '@sentry/remix'; -export const meta: MetaFunction = () => ({ +export const meta: MetaFunction = ({ data }) => ({ charset: 'utf-8', title: 'New Remix App', viewport: 'width=device-width,initial-scale=1', + 'sentry-trace': data.sentryTrace, + baggage: data.sentryBaggage, }); function App() { diff --git a/packages/remix/test/integration/test/client/meta-tags.test.ts b/packages/remix/test/integration/test/client/meta-tags.test.ts index 9ae66122f705..f956787b35c6 100644 --- a/packages/remix/test/integration/test/client/meta-tags.test.ts +++ b/packages/remix/test/integration/test/client/meta-tags.test.ts @@ -1,4 +1,6 @@ import { test, expect } from '@playwright/test'; +import { getFirstSentryEnvelopeRequest } from './utils/helpers'; +import { Event } from '@sentry/types'; test('should inject `sentry-trace` and `baggage` meta tags inside the root page.', async ({ page }) => { await page.goto('/'); @@ -27,3 +29,35 @@ test('should inject `sentry-trace` and `baggage` meta tags inside a parameterize expect(sentryBaggageContent).toEqual(expect.any(String)); }); + +test('should send transactions with corresponding `sentry-trace` and `baggage` inside root page', async ({ page }) => { + const envelope = await getFirstSentryEnvelopeRequest(page, '/'); + + const sentryTraceTag = await page.$('meta[name="sentry-trace"]'); + const sentryTraceContent = await sentryTraceTag?.getAttribute('content'); + const sentryBaggageTag = await page.$('meta[name="baggage"]'); + const sentryBaggageContent = await sentryBaggageTag?.getAttribute('content'); + + expect(sentryTraceContent).toContain( + `${envelope.contexts?.trace.trace_id}-${envelope.contexts?.trace.parent_span_id}-`, + ); + + expect(sentryBaggageContent).toContain(envelope.contexts?.trace.trace_id); +}); + +test('should send transactions with corresponding `sentry-trace` and `baggage` inside a parameterized route', async ({ + page, +}) => { + const envelope = await getFirstSentryEnvelopeRequest(page, '/loader-json-response/0'); + + const sentryTraceTag = await page.$('meta[name="sentry-trace"]'); + const sentryTraceContent = await sentryTraceTag?.getAttribute('content'); + const sentryBaggageTag = await page.$('meta[name="baggage"]'); + const sentryBaggageContent = await sentryBaggageTag?.getAttribute('content'); + + expect(sentryTraceContent).toContain( + `${envelope.contexts?.trace.trace_id}-${envelope.contexts?.trace.parent_span_id}-`, + ); + + expect(sentryBaggageContent).toContain(envelope.contexts?.trace.trace_id); +});