diff --git a/packages/integration-tests/suites/public-api/setExtra/init.js b/packages/integration-tests/suites/public-api/setExtra/init.js new file mode 100644 index 000000000000..d8c94f36fdd0 --- /dev/null +++ b/packages/integration-tests/suites/public-api/setExtra/init.js @@ -0,0 +1,7 @@ +import * as Sentry from '@sentry/browser'; + +window.Sentry = Sentry; + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', +}); diff --git a/packages/integration-tests/suites/public-api/setExtra/multiple_extras/subject.js b/packages/integration-tests/suites/public-api/setExtra/multiple_extras/subject.js new file mode 100644 index 000000000000..2c3771360b03 --- /dev/null +++ b/packages/integration-tests/suites/public-api/setExtra/multiple_extras/subject.js @@ -0,0 +1,10 @@ +Sentry.setExtra('extra_1', { + foo: 'bar', + baz: { + qux: 'quux', + }, +}); + +Sentry.setExtra('extra_2', false); + +Sentry.captureMessage('multiple_extras'); diff --git a/packages/integration-tests/suites/public-api/setExtra/multiple_extras/test.ts b/packages/integration-tests/suites/public-api/setExtra/multiple_extras/test.ts new file mode 100644 index 000000000000..13d8aa83d9c4 --- /dev/null +++ b/packages/integration-tests/suites/public-api/setExtra/multiple_extras/test.ts @@ -0,0 +1,13 @@ +import { expect } from '@playwright/test'; + +import { sentryTest } from '../../../../utils/fixtures'; +import { getSentryRequest } from '../../../../utils/helpers'; + +sentryTest('should record multiple extras of different types', async ({ getLocalTestPath, page }) => { + const url = await getLocalTestPath({ testDir: __dirname }); + + const eventData = await getSentryRequest(page, url); + + expect(eventData.message).toBe('multiple_extras'); + expect(eventData.extra).toMatchObject({ extra_1: { foo: 'bar', baz: { qux: 'quux' } }, extra_2: false }); +}); diff --git a/packages/integration-tests/suites/public-api/setExtra/non_serializable_extra/subject.js b/packages/integration-tests/suites/public-api/setExtra/non_serializable_extra/subject.js new file mode 100644 index 000000000000..722cd095abb3 --- /dev/null +++ b/packages/integration-tests/suites/public-api/setExtra/non_serializable_extra/subject.js @@ -0,0 +1,5 @@ +const el = document.querySelector('body'); + +Sentry.setExtra('non_serializable', el); + +Sentry.captureMessage('non_serializable'); diff --git a/packages/integration-tests/suites/public-api/setExtra/non_serializable_extra/test.ts b/packages/integration-tests/suites/public-api/setExtra/non_serializable_extra/test.ts new file mode 100644 index 000000000000..eaa9d342e4e8 --- /dev/null +++ b/packages/integration-tests/suites/public-api/setExtra/non_serializable_extra/test.ts @@ -0,0 +1,13 @@ +import { expect } from '@playwright/test'; + +import { sentryTest } from '../../../../utils/fixtures'; +import { getSentryRequest } from '../../../../utils/helpers'; + +sentryTest('should normalize non-serializable extra', async ({ getLocalTestPath, page }) => { + const url = await getLocalTestPath({ testDir: __dirname }); + + const eventData = await getSentryRequest(page, url); + + expect(eventData.message).toBe('non_serializable'); + expect(eventData.extra).toMatchObject({}); +}); diff --git a/packages/integration-tests/suites/public-api/setExtra/simple_extra/subject.js b/packages/integration-tests/suites/public-api/setExtra/simple_extra/subject.js new file mode 100644 index 000000000000..62d89873ab62 --- /dev/null +++ b/packages/integration-tests/suites/public-api/setExtra/simple_extra/subject.js @@ -0,0 +1,8 @@ +Sentry.setExtra('simple_extra', { + foo: 'bar', + baz: { + qux: 'quux', + }, +}); + +Sentry.captureMessage('simple_extra'); diff --git a/packages/integration-tests/suites/public-api/setExtra/simple_extra/test.ts b/packages/integration-tests/suites/public-api/setExtra/simple_extra/test.ts new file mode 100644 index 000000000000..352b01191e6e --- /dev/null +++ b/packages/integration-tests/suites/public-api/setExtra/simple_extra/test.ts @@ -0,0 +1,13 @@ +import { expect } from '@playwright/test'; + +import { sentryTest } from '../../../../utils/fixtures'; +import { getSentryRequest } from '../../../../utils/helpers'; + +sentryTest('should record a simple extra object', async ({ getLocalTestPath, page }) => { + const url = await getLocalTestPath({ testDir: __dirname }); + + const eventData = await getSentryRequest(page, url); + + expect(eventData.message).toBe('simple_extra'); + expect(eventData.extra).toMatchObject({ simple_extra: { foo: 'bar', baz: { qux: 'quux' } } }); +}); diff --git a/packages/integration-tests/suites/public-api/setExtra/template.hbs b/packages/integration-tests/suites/public-api/setExtra/template.hbs new file mode 100644 index 000000000000..a28a09b7b485 --- /dev/null +++ b/packages/integration-tests/suites/public-api/setExtra/template.hbs @@ -0,0 +1,11 @@ + + +
+ +