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
Expand Up @@ -4,7 +4,6 @@ import { httpClientIntegration } from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
Comment thread
cursor[bot] marked this conversation as resolved.
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [httpClientIntegration()],
tracesSampleRate: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as Sentry from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1,
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from '@playwright/test';
import type { Event as SentryEvent } from '@sentry/core';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../../utils/helpers';
import { envelopeRequestParser, shouldSkipTracingTest, waitForErrorRequest } from '../../../../../utils/helpers';
import { waitForStreamedSpan } from '../../../../../utils/spanUtils';

sentryTest('should handle aborted fetch calls', async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
Expand All @@ -14,7 +14,7 @@ sentryTest('should handle aborted fetch calls', async ({ getLocalTestUrl, page }
// never fulfil this route because we abort the request as part of the test
});

const transactionEventPromise = getFirstSentryEnvelopeRequest<SentryEvent>(page);
const spanPromise = waitForStreamedSpan(page, span => span.name === 'with-abort-controller');

const hasAbortedFetchPromise = new Promise<void>(resolve => {
page.on('console', msg => {
Expand All @@ -29,10 +29,13 @@ sentryTest('should handle aborted fetch calls', async ({ getLocalTestUrl, page }
await page.locator('[data-test-id=start-button]').click();
await page.locator('[data-test-id=abort-button]').click();

const transactionEvent = await transactionEventPromise;
await spanPromise;
const eventPromise = waitForErrorRequest(page);
await page.evaluate(() => (window as any).Sentry.captureMessage('After aborted fetch'));
const event = envelopeRequestParser(await eventPromise);

// assert that fetch calls do not return undefined
const fetchBreadcrumbs = transactionEvent.breadcrumbs?.filter(
const fetchBreadcrumbs = event.breadcrumbs?.filter(
({ category, data }) => category === 'fetch' && data === undefined,
);
expect(fetchBreadcrumbs).toHaveLength(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { httpClientIntegration } from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [httpClientIntegration()],
tracesSampleRate: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { httpClientIntegration } from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [httpClientIntegration()],
tracesSampleRate: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { httpClientIntegration } from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [httpClientIntegration()],
tracesSampleRate: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { httpClientIntegration } from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [httpClientIntegration()],
tracesSampleRate: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { httpClientIntegration } from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [httpClientIntegration()],
tracesSampleRate: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SENTRY_LINK_TYPE } from '@sentry/conventions/attributes';
import { expect } from '@playwright/test';
import { sentryTest } from '../../../utils/fixtures';
import { shouldSkipTracingTest } from '../../../utils/helpers';
Expand All @@ -22,7 +23,7 @@ sentryTest('beforeSendSpan applies changes to streamed span', async ({ getLocalT
spanId: '456',
},
attributes: {
'sentry.link.type': { type: 'string', value: 'custom_link' },
[SENTRY_LINK_TYPE]: { type: 'string', value: 'custom_link' },
},
},
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { expect } from '@playwright/test';
import type { Event } from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';

sentryTest('does not capture a stack trace if `attachStackTrace` is `false`', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
const eventData = envelopeRequestParser(await waitForErrorRequestOnUrl(page, url));

expect(eventData.message).toBe('foo');
expect(eventData.level).toBe('info');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import {
envelopeRequestParser,
shouldSkipTracingTest,
waitForTransactionRequestOnUrl,
} from '../../../../utils/helpers';
import { shouldSkipTracingTest } from '../../../../utils/helpers';
import { waitForStreamedSpan } from '../../../../utils/spanUtils';

sentryTest('sends an empty string attribute', async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}

sentryTest.skip(shouldSkipTracingTest());
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForTransactionRequestOnUrl(page, url);
const transaction = envelopeRequestParser(req);
const spanPromise = waitForStreamedSpan(page, span => span.name === 'child_span');
await page.goto(url);

const childSpan = transaction.spans?.[0];
expect(childSpan?.data?.someAttribute).toBe('');
const span = await spanPromise;
expect(span.attributes.someAttribute).toEqual({ type: 'string', value: '' });
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as Sentry from '@sentry/browser';

window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0,
normalizeDepth: 10,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
async function run() {
Sentry.startSpan({ name: 'parent_span' }, () => {
Sentry.startSpan({ name: 'child_span' }, () => {
// whatever a user would do here
});

// unfinished spans are filtered out
Sentry.startInactiveSpan({ name: 'span_4' });
});
}

(async () => {
await run();
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { SENTRY_SEGMENT_NAME_SOURCE, SENTRY_ORIGIN } from '@sentry/conventions/attributes';
import { expect } from '@playwright/test';
import { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE } from '@sentry/browser';
import { sentryTest } from '../../../../utils/fixtures';
import {
envelopeRequestParser,
shouldSkipTracingTest,
waitForTransactionRequestOnUrl,
} from '../../../../utils/helpers';

sentryTest(
'sends a transaction in an envelope with manual origin and custom source',
async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}

const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForTransactionRequestOnUrl(page, url);
const transaction = envelopeRequestParser(req);

const attributes = transaction.contexts?.trace?.data;
expect(attributes).toEqual({
[SENTRY_ORIGIN]: 'manual',
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
[SENTRY_SEGMENT_NAME_SOURCE]: 'custom',
});

expect(transaction.transaction_info?.source).toBe('custom');

expect(transaction.transaction).toBe('parent_span');
expect(transaction.spans).toBeDefined();
},
);

sentryTest('should report finished spans as children of the root transaction', async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}

const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForTransactionRequestOnUrl(page, url);
const transaction = envelopeRequestParser(req);

expect(transaction.spans).toHaveLength(1);

const span_1 = transaction.spans?.[0];
expect(span_1?.description).toBe('child_span');
expect(span_1?.parent_span_id).toEqual(transaction?.contexts?.trace?.span_id);
expect(span_1?.origin).toEqual('manual');
expect(span_1?.data?.[SENTRY_ORIGIN]).toEqual('manual');
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ window.Sentry = Sentry;

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [Sentry.spanStreamingIntegration()],
tracesSampleRate: 1.0,
debug: true,
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
async function run() {
Sentry.startSpan({ name: 'parent_span' }, () => {
Sentry.startSpan({ name: 'child_span' }, () => {
// whatever a user would do here
});

// unfinished spans are filtered out
Sentry.startInactiveSpan({ name: 'span_4' });
Sentry.startSpan({ name: 'test-span', op: 'test' }, () => {
Sentry.startSpan({ name: 'test-child-span', op: 'test-child' }, () => {
// noop
});
}

(async () => {
await run();
})();
const inactiveSpan = Sentry.startInactiveSpan({ name: 'test-inactive-span' });
inactiveSpan.end();

Sentry.startSpanManual({ name: 'test-manual-span' }, span => {
// 2 = SPAN_STATUS_ERROR. The message must be preserved as the `sentry.status.message`
// attribute on the streamed span, since v2 statuses are reduced to ok/error.
span.setStatus({ code: 2, message: 'Connection Refused' });
span.end();
});
});
Loading
Loading