Skip to content

Commit

Permalink
Merge branch 'develop' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
SG60 committed Jan 21, 2025
2 parents 609a75e + a017048 commit 61d18a9
Show file tree
Hide file tree
Showing 875 changed files with 20,342 additions and 19,896 deletions.
11 changes: 1 addition & 10 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ targets:
# NPM Targets
## 1. Base Packages, node or browser SDKs depend on
## 1.1 Types
# TODO(v9): Remove
- name: npm
id: '@sentry/types'
includeNames: /^sentry-types-\d.*\.tgz$/
Expand Down Expand Up @@ -78,14 +77,6 @@ targets:
- name: npm
id: '@sentry/deno'
includeNames: /^sentry-deno-\d.*\.tgz$/
- name: commit-on-git-repository
# This will publish on the Deno registry
id: getsentry/deno
archive: /^sentry-deno-\d.*\.tgz$/
repositoryUrl: https://github.com/getsentry/sentry-deno.git
stripComponents: 1
branch: main
createTag: true

## 5. Node-based Packages
- name: npm
Expand Down Expand Up @@ -141,7 +132,7 @@ targets:
# TODO(v9): Once stable, re-add this target to publish the AWS Lambda layer
# - name: aws-lambda-layer
# includeNames: /^sentry-node-serverless-\d+.\d+.\d+(-(beta|alpha|rc)\.\d+)?\.zip$/
# layerName: SentryNodeServerlessSDK
# layerName: SentryNodeServerlessSDKv9
# compatibleRuntimes:
# - name: node
# versions:
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ jobs:
run: yarn lint:lerna
- name: Lint C++ files
run: yarn lint:clang
- name: Lint for ES compatibility
run: yarn lint:es-compatibility

job_check_format:
name: Check file formatting
Expand Down Expand Up @@ -440,7 +442,7 @@ jobs:
- name: Set up Deno
uses: denoland/[email protected]
with:
deno-version: v1.38.5
deno-version: v2.1.5
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
Expand Down Expand Up @@ -745,7 +747,7 @@ jobs:
run: yarn test

job_remix_integration_tests:
name: Remix v${{ matrix.remix }} (Node ${{ matrix.node }}) Tests
name: Remix (Node ${{ matrix.node }}) Tests
needs: [job_get_metadata, job_build]
if: needs.job_build.outputs.changed_remix == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-20.04
Expand All @@ -754,7 +756,6 @@ jobs:
fail-fast: false
matrix:
node: [18, 20, 22]
remix: [1, 2]
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v4
Expand All @@ -777,7 +778,6 @@ jobs:
- name: Run integration tests
env:
NODE_VERSION: ${{ matrix.node }}
REMIX_VERSION: ${{ matrix.remix }}
run: |
cd packages/remix
yarn test:integration:ci
Expand Down Expand Up @@ -1200,7 +1200,8 @@ jobs:
- name: Run E2E test
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
timeout-minutes: 10
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:assert
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:assert
job_required_jobs_passed:
name: All required jobs passed or were skipped
Expand Down
46 changes: 45 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,51 @@

- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott

Work in this release was contributed by @aloisklink, @arturovt, @benjick and @maximepvrt. Thank you for your contributions!
Work in this release was contributed by @tjhiggins, @GrizliK1988, @davidturissini, @nwalters512, @aloisklink, @arturovt, @benjick, @maximepvrt, @mstrokin, and @kunal-511. Thank you for your contributions!

- **feat(solidstart)!: Default to `--import` setup and add `autoInjectServerSentry` ([#14862](https://github.com/getsentry/sentry-javascript/pull/14862))**

To enable the SolidStart SDK, wrap your SolidStart Config with `withSentry`. The `sentrySolidStartVite` plugin is now automatically
added by `withSentry` and you can pass the Sentry build-time options like this:

```js
import { defineConfig } from '@solidjs/start/config';
import { withSentry } from '@sentry/solidstart';

export default defineConfig(
withSentry(
{
/* Your SolidStart config options... */
},
{
// Options for setting up source maps
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
},
),
);
```

With the `withSentry` wrapper, the Sentry server config should not be added to the `public` directory anymore.
Add the Sentry server config in `src/instrument.server.ts`. Then, the server config will be placed inside the server build output as `instrument.server.mjs`.

Now, there are two options to set up the SDK:

1. **(recommended)** Provide an `--import` CLI flag to the start command like this (path depends on your server setup):
`node --import ./.output/server/instrument.server.mjs .output/server/index.mjs`
2. Add `autoInjectServerSentry: 'top-level-import'` and the Sentry config will be imported at the top of the server entry (comes with tracing limitations)
```js
withSentry(
{
/* Your SolidStart config options... */
},
{
// Optional: Install Sentry with a top-level import
autoInjectServerSentry: 'top-level-import',
},
);
```

## 8.45.0

Expand Down
54 changes: 18 additions & 36 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -870,53 +870,35 @@ or look at the TypeScript type definitions of `withSentryConfig`.
#### Updated the recommended way of calling `Sentry.init()`
With version 8 of the SDK we will no longer support the use of `sentry.server.config.ts` and `sentry.edge.config.ts`
files. Instead, please initialize the Sentry Next.js SDK for the serverside in a
[Next.js instrumentation hook](https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation).
**`sentry.client.config.ts|js` is still supported and encouraged for initializing the clientside SDK.**
Version 8 of the Next.js SDK will require an additional `instrumentation.ts` file to execute the `sentry.server.config.js|ts` and `sentry.edge.config.js|ts` modules to initialize the SDK for the server-side.
The `instrumentation.ts` file is a Next.js native API called [instrumentation hook](https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation).
The following is an example of how to initialize the serverside SDK in a Next.js instrumentation hook:
To start using the Next.js instrumentation hook, follow these steps:
1. First, enable the Next.js instrumentation hook by setting the `experimental.instrumentationHook` to `true` in your
`next.config.js`.
2. Next, create a `instrumentation.ts|js` file in the root directory of your project (or in the `src` folder if you have
have one).
3. Now, export a `register` function from the `instrumentation.ts|js` file and call `Sentry.init()` inside of it:
1. First, enable the Next.js instrumentation hook by setting the [`experimental.instrumentationHook`](https://nextjs.org/docs/app/api-reference/next-config-js/instrumentationHook) to true in your `next.config.js`. (This step is no longer required with Next.js 15)
```ts
import * as Sentry from '@sentry/nextjs';

export function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
Sentry.init({
dsn: 'YOUR_DSN',
// Your Node.js Sentry configuration...
});
}

if (process.env.NEXT_RUNTIME === 'edge') {
Sentry.init({
dsn: 'YOUR_DSN',
// Your Edge Runtime Sentry configuration...
});
}
```JavaScript {filename:next.config.js} {2-4}
module.exports = {
experimental: {
instrumentationHook: true, // Not required on Next.js 15+
},
}
```
If you need to import a Node.js specific integration (like for example `@sentry/profiling-node`), you will have to
import the package using a dynamic import to prevent Next.js from bundling Node.js APIs into bundles for other
runtime environments (like the Browser or the Edge runtime). You can do so as follows:
2. Next, create a `instrumentation.ts|js` file in the root directory of your project (or in the src folder if you have have one).
3. Now, export a register function from the `instrumentation.ts|js` file and import your `sentry.server.config.js|ts` and `sentry.edge.config.js|ts` modules:
```ts
```JavaScript {filename:instrumentation.js}
import * as Sentry from '@sentry/nextjs';

export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
const { nodeProfilingIntegration } = await import('@sentry/profiling-node');
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [nodeProfilingIntegration()],
});
await import('./sentry.server.config');
}

if (process.env.NEXT_RUNTIME === 'edge') {
await import('./sentry.edge.config');
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const oldOnError = window.onerror;

window.onerror = function () {
console.log('custom error');
oldOnError && oldOnError.apply(this, arguments);
oldOnError?.apply(this, arguments);
};

window.doSomethingWrong();
3 changes: 1 addition & 2 deletions dev-packages/browser-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@
"@sentry/browser": "8.45.0",
"axios": "1.7.7",
"babel-loader": "^8.2.2",
"fflate": "0.8.2",
"html-webpack-plugin": "^5.5.0",
"pako": "^2.1.0",
"webpack": "^5.95.0"
},
"devDependencies": {
"@types/glob": "8.0.0",
"@types/node": "^18.19.1",
"@types/pako": "^2.0.0",
"glob": "8.0.3"
},
"volta": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ sentryTest('should capture feedback with custom button', async ({ getLocalTestUr
event_id: expect.stringMatching(/\w{32}/),
environment: 'production',
tags: {},
user: {
ip_address: '{{auto}}',
},
sdk: {
integrations: expect.arrayContaining(['Feedback']),
version: expect.any(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
'User-Agent': expect.stringContaining(''),
},
},
user: {
ip_address: '{{auto}}',
},
platform: 'javascript',
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ sentryTest('should capture feedback', async ({ forceFlushReplay, getLocalTestUrl
'User-Agent': expect.stringContaining(''),
},
},
user: {
ip_address: '{{auto}}',
},
platform: 'javascript',
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
'User-Agent': expect.stringContaining(''),
},
},
user: {
ip_address: '{{auto}}',
},
platform: 'javascript',
});
const cspViolation = await page.evaluate<boolean>('window.__CSPVIOLATION__');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ window.Sentry = Sentry;
Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [captureConsoleIntegration()],
autoSessionTracking: false,
attachStacktrace: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ sentryTest(
const errorEvent = events.find(event => event.message === 'console error');
const traceEvent = events.find(event => event.message === 'console trace');
const errorWithErrorEvent = events.find(
event => event.exception && event.exception.values?.[0].value === 'console error with error object',
event => event.exception?.values?.[0].value === 'console error with error object',
);
const traceWithErrorEvent = events.find(
event => event.exception && event.exception.values?.[0].value === 'console trace with error object',
event => event.exception?.values?.[0].value === 'console trace with error object',
);

expect(logEvent).toEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ window.Sentry = Sentry;
Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [captureConsoleIntegration()],
autoSessionTracking: false,
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ sentryTest('it captures console messages correctly', async ({ getLocalTestUrl, p
const errorEvent = events.find(event => event.message === 'console error');
const traceEvent = events.find(event => event.message === 'console trace');
const errorWithErrorEvent = events.find(
event => event.exception && event.exception.values?.[0].value === 'console error with error object',
event => event.exception?.values?.[0].value === 'console error with error object',
);
const traceWithErrorEvent = events.find(
event => event.exception && event.exception.values?.[0].value === 'console trace with error object',
event => event.exception?.values?.[0].value === 'console trace with error object',
);

expect(logEvent).toEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ sentryTest('Flag evaluations in forked scopes are stored separately.', async ({
const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

const forkedReqPromise = waitForErrorRequest(page, event => !!event.tags && event.tags.isForked === true);
const mainReqPromise = waitForErrorRequest(page, event => !!event.tags && event.tags.isForked === false);
const forkedReqPromise = waitForErrorRequest(page, event => !!event.tags?.isForked === true);
const mainReqPromise = waitForErrorRequest(page, event => !!event.tags?.isForked === false);

await page.evaluate(() => {
const Sentry = (window as any).Sentry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Sentry.init({
// Also, no SDK has mock utils for FlagUsedHandler's.
const MockLaunchDarkly = {
initialize(_clientId, context, options) {
const flagUsedHandler = options && options.inspectors ? options.inspectors[0].method : undefined;
const flagUsedHandler = options.inspectors ? options.inspectors[0].method : undefined;

return {
variation(key, defaultValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ sentryTest('Flag evaluations in forked scopes are stored separately.', async ({
const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

const forkedReqPromise = waitForErrorRequest(page, event => !!event.tags && event.tags.isForked === true);
const mainReqPromise = waitForErrorRequest(page, event => !!event.tags && event.tags.isForked === false);
const forkedReqPromise = waitForErrorRequest(page, event => !!event.tags?.isForked === true);
const mainReqPromise = waitForErrorRequest(page, event => !!event.tags?.isForked === false);

await page.evaluate(() => {
const Sentry = (window as any).Sentry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ sentryTest('Flag evaluations in forked scopes are stored separately.', async ({
const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

const forkedReqPromise = waitForErrorRequest(page, event => !!event.tags && event.tags.isForked === true);
const mainReqPromise = waitForErrorRequest(page, event => !!event.tags && event.tags.isForked === false);
const forkedReqPromise = waitForErrorRequest(page, event => !!event.tags?.isForked === true);
const mainReqPromise = waitForErrorRequest(page, event => !!event.tags?.isForked === false);

await page.evaluate(() => {
const Sentry = (window as any).Sentry;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as Sentry from '@sentry/browser';

import { moduleMetadataIntegration } from '@sentry/browser';

Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [Sentry.moduleMetadataIntegration()],
integrations: [moduleMetadataIntegration()],
beforeSend(event) {
const moduleMetadataEntries = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should provide module_metadata on stack frames in beforeSend', async ({ getLocalTestUrl, page }) => {
// moduleMetadataIntegration is not included in any CDN bundles
if (process.env.PW_BUNDLE?.startsWith('bundle')) {
sentryTest.skip();
}

const url = await getLocalTestUrl({ testDir: __dirname });

const errorEvent = await getFirstSentryEnvelopeRequest<Event>(page, url);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import * as Sentry from '@sentry/browser';

import { moduleMetadataIntegration } from '@sentry/browser';
import { rewriteFramesIntegration } from '@sentry/browser';

Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [
Sentry.moduleMetadataIntegration(),
Sentry.rewriteFramesIntegration({
moduleMetadataIntegration(),
rewriteFramesIntegration({
iteratee: frame => {
return {
...frame,
Expand Down
Loading

0 comments on commit 61d18a9

Please sign in to comment.