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,12 +1,9 @@
import { expect, test } from '@playwright/test';
import { URL_PATH } from '@sentry/conventions/attributes';
import { HTTP_SERVER, PAGELOAD } from '@sentry/conventions/op';
import { getRuntime, getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
import { getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';

test('continues the server trace in the pageload', async ({ page }) => {
// On Cloudflare, nothing sends the trace to the browser yet: `addServerTimingTraceHeader` only covers Node.
test.skip(getRuntime() === 'cloudflare', 'No trace propagation to the browser on Cloudflare yet');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️


// Other tests request `/user/:id` too, so both spans are matched on a path no other test uses.
const path = `/user/trace-${Date.now()}`;

Expand Down
19 changes: 16 additions & 3 deletions packages/solid/src/solid2/server/cloudflare.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import type { CloudflareOptions } from '@sentry/cloudflare';
import { defineCloudflareOptions as defineCloudflareOptionsBase } from '@sentry/cloudflare';
import { _INTERNAL_captureOptionsSetByUser, applySdkMetadata } from '@sentry/core';
import { addServerTimingTraceHeader, defineCloudflareOptions as defineCloudflareOptionsBase } from '@sentry/cloudflare';
import type { Integration } from '@sentry/core';
import { _INTERNAL_captureOptionsSetByUser, applySdkMetadata, defineIntegration } from '@sentry/core';
import { solidServerErrorsIntegration } from './errors';
import { solidServerTracePropagationIntegration } from './tracePropagation';

// Sends the trace to the browser on every document response, so the pageload continues it, as `init` does on Node.
const serverTimingTraceHeaderIntegration = defineIntegration((): Integration => ({
name: 'SolidServerTimingTraceHeader' as const,
setup: addServerTimingTraceHeader,
}));

/**
* Defines the Sentry options for a Solid 2 app on Cloudflare Workers, like `defineCloudflareOptions` of
Expand Down Expand Up @@ -36,7 +44,12 @@ export const defineCloudflareOptions: typeof defineCloudflareOptionsBase = (
if (opts.defaultIntegrations === undefined) {
const userIntegrations = opts.integrations;
opts.integrations = defaults => {
const withSolid = [...defaults, solidServerErrorsIntegration()];
const withSolid = [
...defaults,
solidServerErrorsIntegration(),
solidServerTracePropagationIntegration(),
serverTimingTraceHeaderIntegration(),
];
return typeof userIntegrations === 'function'
? userIntegrations(withSolid)
: [...withSolid, ...(userIntegrations ?? [])];
Expand Down
9 changes: 8 additions & 1 deletion packages/solid/test/solid2/server/cloudflare.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ describe('defineCloudflareOptions', () => {
const options = defineCloudflareOptions({ dsn: 'https://public@dsn.ingest.sentry.io/1337' })({});

expect(options?.defaultIntegrations).toBeUndefined();
expect(setupIntegrationNames(options)).toEqual(expect.arrayContaining(['Dedupe', 'SolidServerErrors']));
expect(setupIntegrationNames(options)).toEqual(
expect.arrayContaining([
'Dedupe',
'SolidServerErrors',
'SolidServerTracePropagation',
'SolidServerTimingTraceHeader',
]),
);
});

it('builds the defaults from options changed after the options are defined', () => {
Expand Down
Loading