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,17 +1,23 @@
<template>
<p>{{ $route.params.param }} - {{ $route.params.param }}</p>

<ErrorButton id="errorBtn" errorText="Error thrown from Param Route Button" />
<button @click="fetchData">Fetch Server Data</button>
</template>

<script setup lang="ts">
import { useRoute, useFetch } from '#imports'

const route = useRoute();
const param = route.params.param;

const fetchData = async () => {
const fetchError = async () => {
await useFetch(`/api/param-error/${param}`);
}

const fetchData = async () => {
await useFetch(`/api/test-param/${param}`);
};
</script>

<template>
<p>Param: {{ $route.params.param }}</p>

<ErrorButton id="errorBtn" errorText="Error thrown from Param Route Button" />
<button @click="fetchData">Fetch Server Data</button>
<button @click="fetchError">Fetch Server Error</button>
</template>

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test.describe('server-side errors', async () => {
});

await page.goto(`/fetch-server-error`);
await page.getByText('Fetch Server Data').click();
await page.getByText('Fetch Server Data', { exact: true }).click();

const error = await errorPromise;

Expand All @@ -26,7 +26,7 @@ test.describe('server-side errors', async () => {
});

await page.goto(`/test-param/1234`);
await page.getByText('Fetch Server Data').click();
await page.getByRole('button', { name: 'Fetch Server Error', exact: true }).click();

const error = await errorPromise;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { expect, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';

test.describe('distributed tracing', () => {
const PARAM = 's0me-param';

test('capture a distributed pageload trace', async ({ page }) => {
const clientTxnEventPromise = waitForTransaction('nuxt-3', txnEvent => {
return txnEvent.transaction === '/test-param/:param()';
});

const serverTxnEventPromise = waitForTransaction('nuxt-3', txnEvent => {
return txnEvent.transaction.includes('GET /test-param/');
});

const [_, clientTxnEvent, serverTxnEvent] = await Promise.all([
page.goto(`/test-param/${PARAM}`),
clientTxnEventPromise,
serverTxnEventPromise,
expect(page.getByText(`Param: ${PARAM}`)).toBeVisible(),
]);

expect(clientTxnEvent).toMatchObject({
transaction: '/test-param/:param()',
transaction_info: { source: 'route' },
type: 'transaction',
contexts: {
trace: {
op: 'pageload',
origin: 'auto.pageload.vue',
},
},
});

expect(serverTxnEvent).toMatchObject({
transaction: 'GET /test-param/s0me-param', // todo: parametrize (nitro)
transaction_info: { source: 'url' },
type: 'transaction',
contexts: {
trace: {
op: 'http.server',
origin: 'auto.http.otel.http',
},
},
});

// connected trace
expect(clientTxnEvent.contexts?.trace?.trace_id).toBe(serverTxnEvent.contexts?.trace?.trace_id);
expect(clientTxnEvent.contexts?.trace?.parent_span_id).toBe(serverTxnEvent.contexts?.trace?.span_id);
});
});
Loading