Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as Sentry from '@sentry/astro';

Sentry.init({
traceLifecycle: 'static',
dsn: import.meta.env.PUBLIC_E2E_TEST_DSN,
environment: 'qa',
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as Sentry from '@sentry/astro';

Sentry.init({
traceLifecycle: 'static',
dsn: import.meta.env.PUBLIC_E2E_TEST_DSN,
environment: 'qa',
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { expect, test } from '@playwright/test';
import { waitForError, waitForTransaction } from '@sentry-internal/test-utils';
import { getSpanOp, waitForError, waitForStreamedSpan } from '@sentry-internal/test-utils';

test.describe('server-side errors', () => {
test('captures SSR error', async ({ page }) => {
const errorEventPromise = waitForError('astro-5', errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === "Cannot read properties of undefined (reading 'x')";
});

const transactionEventPromise = waitForTransaction('astro-5', transactionEvent => {
return transactionEvent.transaction === 'GET /ssr-error';
const spanPromise = waitForStreamedSpan('astro-5', span => {
return getSpanOp(span) === 'http.server' && span.is_segment && span.name === 'GET /ssr-error';
});

// This page returns an error status code, so we need to catch the navigation error
Expand All @@ -17,19 +17,14 @@ test.describe('server-side errors', () => {
});

const errorEvent = await errorEventPromise;
const transactionEvent = await transactionEventPromise;
const span = await spanPromise;

expect(transactionEvent).toMatchObject({
transaction: 'GET /ssr-error',
spans: [],
});

const traceId = transactionEvent.contexts?.trace?.trace_id;
const spanId = transactionEvent.contexts?.trace?.span_id;
const traceId = span.trace_id;
const spanId = span.span_id;

expect(traceId).toMatch(/[a-f0-9]{32}/);
expect(spanId).toMatch(/[a-f0-9]{16}/);
expect(transactionEvent.contexts?.trace?.parent_span_id).toBeUndefined();
expect(span.parent_span_id).toBeUndefined();

expect(errorEvent).toMatchObject({
contexts: {
Expand Down Expand Up @@ -86,41 +81,30 @@ test.describe('server-side errors', () => {
const errorEventPromise = waitForError('astro-5', errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Endpoint Error';
});
const transactionEventApiPromise = waitForTransaction('astro-5', transactionEvent => {
return transactionEvent.transaction === 'GET /endpoint-error/api';
const apiSpanPromise = waitForStreamedSpan('astro-5', span => {
return getSpanOp(span) === 'http.server' && span.name === 'GET /endpoint-error/api';
});
const transactionEventEndpointPromise = waitForTransaction('astro-5', transactionEvent => {
return transactionEvent.transaction === 'GET /endpoint-error';
const endpointSpanPromise = waitForStreamedSpan('astro-5', span => {
return getSpanOp(span) === 'http.server' && span.is_segment && span.name === 'GET /endpoint-error';
});

await page.goto('/endpoint-error');
await page.getByText('Get Data').click();

const errorEvent = await errorEventPromise;
const transactionEventApi = await transactionEventApiPromise;
const transactionEventEndpoint = await transactionEventEndpointPromise;

expect(transactionEventEndpoint).toMatchObject({
transaction: 'GET /endpoint-error',
spans: [],
});
const apiSpan = await apiSpanPromise;
const endpointSpan = await endpointSpanPromise;

const traceId = transactionEventEndpoint.contexts?.trace?.trace_id;
const endpointSpanId = transactionEventApi.contexts?.trace?.span_id;
const traceId = endpointSpan.trace_id;
const endpointSpanId = apiSpan.span_id;

expect(traceId).toMatch(/[a-f0-9]{32}/);
expect(endpointSpanId).toMatch(/[a-f0-9]{16}/);

expect(transactionEventApi).toMatchObject({
transaction: 'GET /endpoint-error/api',
spans: [],
});

const spanId = transactionEventApi.contexts?.trace?.span_id;
const parentSpanId = transactionEventApi.contexts?.trace?.parent_span_id;
const spanId = apiSpan.span_id;
const parentSpanId = apiSpan.parent_span_id;

expect(spanId).toMatch(/[a-f0-9]{16}/);
// TODO: This is incorrect, for whatever reason, it should be the endpointSpanId ideally
expect(parentSpanId).toMatch(/[a-f0-9]{16}/);
expect(parentSpanId).not.toEqual(endpointSpanId);

Expand Down
Loading
Loading