Skip to content

Commit

Permalink
Merge branch 'develop' into sig/nuxt-reexport-firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
s1gr1d authored Oct 28, 2024
2 parents 511f7f2 + ff8e780 commit 2cf3ef7
Show file tree
Hide file tree
Showing 129 changed files with 2,381 additions and 1,292 deletions.
7 changes: 7 additions & 0 deletions .github/dependency-review-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fail-on-severity: 'high'
allow-ghsas:
# dependency review does not allow specific file exclusions
# we use an older version of NextJS in our tests and thus need to
# exclude this
# once our minimum supported version is over 14.1.1 this can be removed
- GHSA-fr5h-rqp8-mj6g
46 changes: 35 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ jobs:
'nextjs-13',
'nextjs-14',
'nextjs-15',
'nextjs-turbo',
'nextjs-t3',
'react-17',
'react-19',
Expand Down Expand Up @@ -1018,12 +1019,12 @@ jobs:

- name: Build E2E app
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
timeout-minutes: 7
run: pnpm ${{ matrix.build-command || 'test:build' }}

- name: Run E2E test
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
timeout-minutes: 10
run: pnpm test:assert

- name: Upload Playwright Traces
Expand All @@ -1035,14 +1036,20 @@ jobs:
overwrite: true
retention-days: 7

- name: Pre-process E2E Test Dumps
if: always()
run: |
node ./scripts/normalize-e2e-test-dump-transaction-events.js
- name: Upload E2E Test Event Dumps
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-event-dumps-job_e2e_playwright_tests-${{ matrix.test-application }}
name: E2E Test Dump (${{ matrix.label || matrix.test-application }})
path: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/event-dumps
overwrite: true
retention-days: 7
if-no-files-found: ignore

- name: Upload test results to Codecov
if: cancelled() == false
Expand Down Expand Up @@ -1083,10 +1090,6 @@ jobs:
'react-send-to-sentry',
'node-express-send-to-sentry',
'debug-id-sourcemaps',
'nextjs-app-dir',
'nextjs-13',
'nextjs-14',
'nextjs-15',
]
build-command:
- false
Expand Down Expand Up @@ -1125,6 +1128,12 @@ jobs:
- test-application: 'nextjs-15'
build-command: 'test:build-latest'
label: 'nextjs-15 (latest)'
- test-application: 'nextjs-turbo'
build-command: 'test:build-canary'
label: 'nextjs-turbo (canary)'
- test-application: 'nextjs-turbo'
build-command: 'test:build-latest'
label: 'nextjs-turbo (latest)'

steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
Expand Down Expand Up @@ -1176,14 +1185,29 @@ jobs:

- name: Build E2E app
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
timeout-minutes: 7
run: pnpm ${{ matrix.build-command || 'test:build' }}

- name: Run E2E test
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
timeout-minutes: 10
run: pnpm ${{ matrix.assert-command || 'test:assert' }}

- name: Pre-process E2E Test Dumps
if: always()
run: |
node ./scripts/normalize-e2e-test-dump-transaction-events.js
- name: Upload E2E Test Event Dumps
uses: actions/upload-artifact@v4
if: always()
with:
name: E2E Test Dump (${{ matrix.label || matrix.test-application }})
path: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/event-dumps
overwrite: true
retention-days: 7
if-no-files-found: ignore

- name: Deploy Astro to Cloudflare
uses: cloudflare/pages-action@v1
if: matrix.test-application == 'cloudflare-astro'
Expand Down Expand Up @@ -1282,12 +1306,12 @@ jobs:

- name: Build E2E app
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
timeout-minutes: 7
run: yarn ${{ matrix.build-command || 'test:build' }}

- name: Run E2E test
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
timeout-minutes: 10
run: yarn test:assert

job_required_jobs_passed:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ jobs:
- test-application: 'nextjs-15'
build-command: 'test:build-latest'
label: 'nextjs-15 (latest)'
- test-application: 'nextjs-turbo'
build-command: 'test:build-canary'
label: 'nextjs-turbo (canary)'
- test-application: 'nextjs-turbo'
build-command: 'test:build-latest'
label: 'nextjs-turbo (latest)'
- test-application: 'react-create-hash-router'
build-command: 'test:build-canary'
label: 'react-create-hash-router (canary)'
Expand Down Expand Up @@ -140,7 +146,7 @@ jobs:

- name: Build E2E app
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 5
timeout-minutes: 7
run: yarn ${{ matrix.build-command }}

- name: Run E2E test
Expand Down
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ module.exports = [
import: createImport('init'),
ignore: ['next/router', 'next/constants'],
gzip: true,
limit: '39 KB',
limit: '39.1 KB',
},
// SvelteKit SDK (ESM)
{
Expand Down
10 changes: 4 additions & 6 deletions dev-packages/e2e-tests/publish-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ const packageTarballPaths = glob.sync('packages/*/sentry-*.tgz', {

// Publish built packages to the fake registry
packageTarballPaths.forEach(tarballPath => {
// eslint-disable-next-line no-console
console.log(`Publishing tarball ${tarballPath} ...`);
// `--userconfig` flag needs to be before `publish`
childProcess.exec(
`npm --userconfig ${__dirname}/test-registry.npmrc publish ${tarballPath}`,
{
cwd: repositoryRoot, // Can't use __dirname here because npm would try to publish `@sentry-internal/e2e-tests`
encoding: 'utf8',
},
(err, stdout, stderr) => {
// eslint-disable-next-line no-console
console.log(stdout);
// eslint-disable-next-line no-console
console.log(stderr);
err => {
if (err) {
// eslint-disable-next-line no-console
console.error(err);
console.error(`Error publishing tarball ${tarballPath}`, err);
process.exit(1);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"devDependencies": {
"rollup": "^4.0.2",
"vitest": "^0.34.6",
"@sentry/rollup-plugin": "2.22.3"
"@sentry/rollup-plugin": "2.22.6"
},
"volta": {
"extends": "../../package.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ next-env.d.ts
!*.d.ts

test-results
event-dumps

.vscode
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"next": "13.2.0",
"next": "13.5.7",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.9.5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import * as fs from 'fs';
import * as path from 'path';
import { startEventProxyServer } from '@sentry-internal/test-utils';

const packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json')));

startEventProxyServer({
port: 3031,
proxyServerName: 'nextjs-13',
envelopeDumpPath: path.join(
process.cwd(),
`event-dumps/next-13-v${packageJson.dependencies.next}-${process.env.TEST_ENV}.dump`,
),
});
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,38 @@ test('should create a pageload transaction when the `pages` directory is used',
type: 'transaction',
});
});

test('should create a pageload transaction with correct name when an error occurs in getServerSideProps', async ({
page,
}) => {
const transactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
return (
transactionEvent.transaction === '/[param]/error-getServerSideProps' &&
transactionEvent.contexts?.trace?.op === 'pageload'
);
});

await page.goto(`/something/error-getServerSideProps`, { waitUntil: 'networkidle' });

const transaction = await transactionPromise;

expect(transaction).toMatchObject({
contexts: {
trace: {
data: {
'sentry.op': 'pageload',
'sentry.origin': 'auto.pageload.nextjs.pages_router_instrumentation',
'sentry.source': 'route',
},
op: 'pageload',
origin: 'auto.pageload.nextjs.pages_router_instrumentation',
},
},
transaction: '/[param]/error-getServerSideProps',
transaction_info: { source: 'route' },
type: 'transaction',
});

// Ensure the transaction name is not '/_error'
expect(transaction.transaction).not.toBe('/_error');
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('should propagate serverside `getInitialProps` trace to client', async ({ p

const serverTransactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
return (
transactionEvent.transaction === '/[param]/withInitialProps' &&
transactionEvent.transaction === 'GET /[param]/withInitialProps' &&
transactionEvent.contexts?.trace?.op === 'http.server'
);
});
Expand Down Expand Up @@ -47,7 +47,7 @@ test('should propagate serverside `getInitialProps` trace to client', async ({ p
status: 'ok',
},
},
transaction: '/[param]/withInitialProps',
transaction: 'GET /[param]/withInitialProps',
transaction_info: {
source: 'route',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('Should record performance for getServerSideProps', async ({ page }) => {

const serverTransactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
return (
transactionEvent.transaction === '/[param]/withServerSideProps' &&
transactionEvent.transaction === 'GET /[param]/withServerSideProps' &&
transactionEvent.contexts?.trace?.op === 'http.server'
);
});
Expand Down Expand Up @@ -47,7 +47,7 @@ test('Should record performance for getServerSideProps', async ({ page }) => {
status: 'ok',
},
},
transaction: '/[param]/withServerSideProps',
transaction: 'GET /[param]/withServerSideProps',
transaction_info: {
source: 'route',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';

test('should not automatically create transactions for routes that were excluded from auto wrapping (string)', async ({
test('should not apply build-time instrumentation for routes that were excluded from auto wrapping (string)', async ({
request,
}) => {
const transactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
Expand All @@ -13,17 +13,13 @@ test('should not automatically create transactions for routes that were excluded

expect(await (await request.get(`/api/endpoint-excluded-with-string`)).text()).toBe('{"success":true}');

let transactionPromiseReceived = false;
transactionPromise.then(() => {
transactionPromiseReceived = true;
});

await new Promise(resolve => setTimeout(resolve, 5_000));
const transaction = await transactionPromise;

expect(transactionPromiseReceived).toBe(false);
expect(transaction.contexts?.trace?.data?.['sentry.origin']).toBeDefined();
expect(transaction.contexts?.trace?.data?.['sentry.origin']).not.toBe('auto.http.nextjs'); // This is the origin set by the build time instrumentation
});

test('should not automatically create transactions for routes that were excluded from auto wrapping (regex)', async ({
test('should not apply build-time instrumentation for routes that were excluded from auto wrapping (regex)', async ({
request,
}) => {
const transactionPromise = waitForTransaction('nextjs-13', async transactionEvent => {
Expand All @@ -35,12 +31,8 @@ test('should not automatically create transactions for routes that were excluded

expect(await (await request.get(`/api/endpoint-excluded-with-regex`)).text()).toBe('{"success":true}');

let transactionPromiseReceived = false;
transactionPromise.then(() => {
transactionPromiseReceived = true;
});

await new Promise(resolve => setTimeout(resolve, 5_000));
const transaction = await transactionPromise;

expect(transactionPromiseReceived).toBe(false);
expect(transaction.contexts?.trace?.data?.['sentry.origin']).toBeDefined();
expect(transaction.contexts?.trace?.data?.['sentry.origin']).not.toBe('auto.http.nextjs'); // This is the origin set by the build time instrumentation
});
Loading

0 comments on commit 2cf3ef7

Please sign in to comment.