Skip to content
Draft
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 @@ -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',
enhanceFetchErrorMessages: false,
});
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',
enhanceFetchErrorMessages: 'report-only',
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ import * as Sentry from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ window.Sentry = Sentry;
window.feedback = feedback;

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

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

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { feedbackIntegration } from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [
feedbackIntegration({ tags: { from: 'integration init' }, styleNonce: 'foo1234', scriptNonce: 'foo1234' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { feedbackIntegration } from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [
Sentry.browserTracingIntegration(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect } from '@playwright/test';
import { getSpanOp, waitForStreamedSpan } from '../../../utils/spanUtils';
import { sentryTest } from '../../../utils/fixtures';
import {
envelopeRequestParser,
getEnvelopeType,
shouldSkipFeedbackTest,
shouldSkipTracingTest,
waitForTransactionRequest,
} from '../../../utils/helpers';

sentryTest(
Expand All @@ -21,8 +21,8 @@ sentryTest(
responseHeaders: { 'Document-Policy': 'js-profiling' },
});

// Wait for the pageload transaction to be sent (idle span ended)
const pageloadRequestPromise = waitForTransactionRequest(page, event => event.contexts?.trace?.op === 'pageload');
// Wait for the idle pageload span to end.
const pageloadSpanPromise = waitForStreamedSpan(page, span => span.is_segment && getSpanOp(span) === 'pageload');

const feedbackRequestPromise = page.waitForResponse(res => {
const req = res.request();
Expand All @@ -40,7 +40,7 @@ sentryTest(
await page.goto(url);

// Wait for the idle page load span to finish
const pageLoadEvent = envelopeRequestParser(await pageloadRequestPromise);
const pageloadSpan = await pageloadSpanPromise;

// Submit feedback after idle span ended — no active span
await page.getByText('Report a Bug').waitFor({ state: 'visible' });
Expand All @@ -55,11 +55,10 @@ sentryTest(
expect(feedbackEvent.contexts?.trace?.trace_id).toMatch(/\w{32}/);
expect(feedbackEvent.contexts?.trace?.span_id).toMatch(/\w{16}/);

// contexts.trace.data must include thread.id to identify which thread is associated with the transaction
expect(pageLoadEvent.contexts?.trace?.data?.['thread.id']).toBe('0');
expect(pageLoadEvent.contexts?.trace?.data?.['thread.name']).toBe('main');
expect(pageloadSpan.attributes['thread.id']).toEqual({ type: 'string', value: '0' });
expect(pageloadSpan.attributes['thread.name']).toEqual({ type: 'string', value: 'main' });

const profilerId = pageLoadEvent.contexts?.profile?.profiler_id;
const profilerId = pageloadSpan.attributes['sentry.profiler_id']?.value;
expect(profilerId).toMatch(/^[a-f\d]{32}$/);
expect(feedbackEvent.contexts?.profile?.profiler_id).toBe(profilerId);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ window.Sentry = Sentry;
window.feedback = feedback;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
debug: true,
integrations: [feedback],
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',
defaultIntegrations: false,
integrations: [Sentry.breadcrumbsIntegration(), Sentry.consoleIntegration()],
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',
defaultIntegrations: false,
integrations: [Sentry.breadcrumbsIntegration()],
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',
defaultIntegrations: false,
integrations: [Sentry.breadcrumbsIntegration()],
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',
defaultIntegrations: false,
integrations: [Sentry.breadcrumbsIntegration()],
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',
defaultIntegrations: false,
integrations: [Sentry.breadcrumbsIntegration()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { contextLinesIntegration } from '@sentry/browser';
window.Sentry = Sentry;

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [contextLinesIntegration()],
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const myClickListener = () => {
btn.addEventListener('click', myClickListener);

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const myClickListener = () => {
btn.addEventListener('click', myClickListener);

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

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

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [captureConsoleIntegration()],
attachStacktrace: false,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,8 @@ import * as Sentry from '@sentry/browser';

window.Sentry = Sentry;

const integrations = Sentry.getDefaultIntegrations({}).filter(
defaultIntegration => defaultIntegration.name === 'CultureContext',
);

const client = new Sentry.BrowserClient({
Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
transport: Sentry.makeFetchTransport,
stackParser: Sentry.defaultStackParser,
integrations: integrations,
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1.0,
});

const scope = new Sentry.Scope();
scope.setClient(client);
client.init();

window._sentryScope = scope;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
window._sentryScope.captureException(new Error('test error'));
window.Sentry.captureException(new Error('test error'));
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { expect } from '@playwright/test';
import type { Event } from '@sentry/core';
import { sentryTest } from '../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers';
import { envelopeRequestParser, shouldSkipTracingTest, waitForErrorRequest } from '../../../utils/helpers';
import { getSpanOp, waitForStreamedSpan } from '../../../utils/spanUtils';

sentryTest('cultureContextIntegration captures locale, timezone, and calendar', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
const errorRequestPromise = waitForErrorRequest(page);
await page.goto(url);
const eventData = envelopeRequestParser(await errorRequestPromise);

expect(eventData.exception?.values).toHaveLength(1);

Expand All @@ -16,3 +18,21 @@ sentryTest('cultureContextIntegration captures locale, timezone, and calendar',
calendar: expect.any(String),
});
});

sentryTest(
'cultureContextIntegration adds locale, timezone, and calendar to spans',
async ({ getLocalTestUrl, page }) => {
sentryTest.skip(shouldSkipTracingTest());
const url = await getLocalTestUrl({ testDir: __dirname });

const spanPromise = waitForStreamedSpan(page, span => span.is_segment && getSpanOp(span) === 'pageload');

await page.goto(url);

const pageloadSpan = await spanPromise;

expect(pageloadSpan.attributes['culture.locale']).toEqual({ type: 'string', value: expect.any(String) });
expect(pageloadSpan.attributes['culture.timezone']).toEqual({ type: 'string', value: expect.any(String) });
expect(pageloadSpan.attributes['culture.calendar']).toEqual({ type: 'string', value: expect.any(String) });
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ window.Sentry = Sentry;
// window.sentryFeatureFlagsIntegration = Sentry.featureFlagsIntegration();

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
sampleRate: 1.0,
integrations: [Sentry.featureFlagsIntegration()],
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',
sampleRate: 1.0,
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { expect } from '@playwright/test';
import { _INTERNAL_MAX_FLAGS_PER_SPAN as MAX_FLAGS_PER_SPAN } from '@sentry/core';
import { waitForStreamedSpan } from '../../../../../utils/spanUtils';
import { sentryTest } from '../../../../../utils/fixtures';
import {
type EventAndTraceHeader,
eventAndTraceHeaderRequestParser,
getMultipleSentryEnvelopeRequests,
shouldSkipFeatureFlagsTest,
shouldSkipTracingTest,
} from '../../../../../utils/helpers';
import { shouldSkipFeatureFlagsTest, shouldSkipTracingTest } from '../../../../../utils/helpers';

sentryTest("Feature flags are added to active span's attributes on span end.", async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest() || shouldSkipTracingTest()) {
Expand All @@ -25,14 +20,9 @@ sentryTest("Feature flags are added to active span's attributes on span end.", a
const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

const envelopeRequestPromise = getMultipleSentryEnvelopeRequests<EventAndTraceHeader>(
page,
1,
{},
eventAndTraceHeaderRequestParser,
);
const innerSpanPromise = waitForStreamedSpan(page, span => span.name === 'test-nested-span');
const outerSpanPromise = waitForStreamedSpan(page, span => span.name === 'test-span');

// withNestedSpans is a util used to start 3 nested spans: root-span (not recorded in transaction_event.spans), span, and nested-span.
await page.evaluate(maxFlags => {
(window as any).withNestedSpans(() => {
const flagsIntegration = (window as any).Sentry.getClient().getIntegrationByName('FeatureFlags');
Expand All @@ -45,22 +35,20 @@ sentryTest("Feature flags are added to active span's attributes on span end.", a
return true;
}, MAX_FLAGS_PER_SPAN);

const event = (await envelopeRequestPromise)[0][0];
const innerSpan = event.spans?.[0];
const outerSpan = event.spans?.[1];
const outerSpanFlags = Object.entries(outerSpan?.data ?? {}).filter(([key, _val]) =>
const [innerSpan, outerSpan] = await Promise.all([innerSpanPromise, outerSpanPromise]);
const outerSpanFlags = Object.entries(outerSpan.attributes).filter(([key, _val]) =>
key.startsWith('flag.evaluation'),
);
const innerSpanFlags = Object.entries(innerSpan?.data ?? {}).filter(([key, _val]) =>
const innerSpanFlags = Object.entries(innerSpan.attributes).filter(([key, _val]) =>
key.startsWith('flag.evaluation'),
);

expect(innerSpanFlags).toEqual([]);
expect(outerSpanFlags).toEqual([]);

const expectedOuterSpanFlags = [];
const expectedInnerSpanFlags = [];
for (let i = 1; i <= MAX_FLAGS_PER_SPAN; i++) {
expectedOuterSpanFlags.push([`flag.evaluation.feat${i}`, i === 3]);
expectedInnerSpanFlags.push([`flag.evaluation.feat${i}`, { type: 'boolean', value: i === 3 }]);
}
// Order agnostic (attribute dict is unordered).
expect(outerSpanFlags.sort()).toEqual(expectedOuterSpanFlags.sort());
expect(innerSpanFlags.sort()).toEqual(expectedInnerSpanFlags.sort());
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ window.Sentry = Sentry;
window.sentryGrowthBookIntegration = Sentry.growthbookIntegration({ growthbookClass: window.GrowthBook });

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
sampleRate: 1.0,
integrations: [window.sentryGrowthBookIntegration],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ window.Sentry = Sentry;
window.sentryGrowthBookIntegration = Sentry.growthbookIntegration({ growthbookClass: window.GrowthBook });

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
sampleRate: 1.0,
tracesSampleRate: 1.0,
Expand Down
Loading
Loading