Skip to content

Commit

Permalink
Merge pull request #10131 from getsentry/prepare-release/7.93.0
Browse files Browse the repository at this point in the history
meta: Update CHANGELOG for 7.93.0
  • Loading branch information
Lms24 committed Jan 10, 2024
2 parents 0f20667 + 0fb8b64 commit 226bbcc
Show file tree
Hide file tree
Showing 276 changed files with 4,966 additions and 1,703 deletions.
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,71 @@

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

## 7.93.0

### Important Changes

#### Deprecations

As we're moving closer to the next major version of the SDK, more public APIs were deprecated.

To get a head start on migrating to the replacement APIs, please take a look at our
[migration guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md).

- feat(core): Deprecate `getActiveTransaction()` & `scope.getTransaction()` (#10098)
- feat(core): Deprecate `Hub.shouldSendDefaultPii` (#10062)
- feat(core): Deprecate `new Transaction()` (#10125)
- feat(core): Deprecate `scope.getSpan()` & `scope.setSpan()` (#10114)
- feat(core): Deprecate `scope.setTransactionName()` (#10113)
- feat(core): Deprecate `span.startChild()` (#10091)
- feat(core): Deprecate `startTransaction()` (#10073)
- feat(core): Deprecate `Transaction.getDynamicSamplingContext` in favor of `getDynamicSamplingContextFromSpan` (#10094)
- feat(core): Deprecate arguments for `startSpan()` (#10101)
- feat(core): Deprecate hub capture APIs and add them to `Scope` (#10039)
- feat(core): Deprecate session APIs on hub and add global replacements (#10054)
- feat(core): Deprecate span `name` and `description` (#10056)
- feat(core): Deprecate span `tags`, `data`, `context` & setters (#10053)
- feat(core): Deprecate transaction metadata in favor of attributes (#10097)
- feat(core): Deprecate `span.sampled` in favor of `span.isRecording()` (#10034)
- ref(node-experimental): Deprecate `lastEventId` on scope (#10093)

#### Cron Monitoring Support for `node-schedule` library

This release adds auto instrumented check-ins for the `node-schedule` library.

```ts
import * as Sentry from '@sentry/node';
import * as schedule from 'node-schedule';

const scheduleWithCheckIn = Sentry.cron.instrumentNodeSchedule(schedule);

const job = scheduleWithCheckIn.scheduleJob('my-cron-job', '* * * * *', () => {
console.log('You will see this message every minute');
});
```

- feat(node): Instrumentation for `node-schedule` library (#10086)

### Other Changes

- feat(core): Add `span.spanContext()` (#10037)
- feat(core): Add `spanToJSON()` method to get span properties (#10074)
- feat(core): Allow to pass `scope` to `startSpan` APIs (#10076)
- feat(core): Allow to pass start/end timestamp for spans flexibly (#10060)
- feat(node): Make `getModuleFromFilename` compatible with ESM (#10061)
- feat(replay): Update rrweb to 2.7.3 (#10072)
- feat(utils): Add `parameterize` function (#9145)
- fix(astro): Use correct package name for CF (#10099)
- fix(core): Do not run `setup` for integration on client multiple times (#10116)
- fix(core): Ensure we copy passed in span data/tags/attributes (#10105)
- fix(cron): Make name required for instrumentNodeCron option (#10070)
- fix(nextjs): Don't capture not-found and redirect errors in generation functions (#10057)
- fix(node): `LocalVariables` integration should have correct name (#10084)
- fix(node): Anr events should have an `event_id` (#10068)
- fix(node): Revert to only use sync debugger for `LocalVariables` (#10077)
- fix(node): Update ANR min node version to v16.17.0 (#10107)


## 7.92.0

### Important Changes
Expand Down
95 changes: 94 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,89 @@ npx @sentry/migr8@latest

This will let you select which updates to run, and automatically update your code. Make sure to still review all code changes!

## Deprecate `Hub`

The `Hub` has been a very important part of the Sentry SDK API up until now.
Hubs were the SDK's "unit of concurrency" to keep track of data across threads and to scope data to certain parts of your code.
Because it is overly complicated and confusing to power users, it is going to be replaced by a set of new APIs: the "new Scope API".

`Scope`s have existed before in the SDK but we are now expanding on them because we have found them powerful enough to fully cover the `Hub` API.

If you are using the `Hub` right now, see the following table on how to migrate to the new API:

| Old `Hub` API | New `Scope` API |
| --- | --- |
| `new Hub()` | `withScope()`, `withIsolationScope()` or `new Scope()` |
| hub.isOlderThan() | REMOVED - Was used to compare `Hub` instances, which are gonna be removed |
| hub.bindClient() | A combination of `scope.setClient()` and `client.setupIntegrations()` |
| hub.pushScope() | `Sentry.withScope()` |
| hub.popScope() | `Sentry.withScope()` |
| hub.withScope() | `Sentry.withScope()` |
| getClient() | `Sentry.getClient()` |
| getScope() | `Sentry.getCurrentScope()` to get the currently active scope |
| getIsolationScope() | `Sentry.getIsolationScope()` |
| getStack() | REMOVED - The stack used to hold scopes. Scopes are used directly now |
| getStackTop() | REMOVED - The stack used to hold scopes. Scopes are used directly now |
| captureException() | `Sentry.captureException()` |
| captureMessage() | `Sentry.captureMessage()` |
| captureEvent() | `Sentry.captureEvent()` |
| lastEventId() | REMOVED - Use event processors or beforeSend instead |
| addBreadcrumb() | `Sentry.addBreadcrumb()` |
| setUser() | `Sentry.setUser()` |
| setTags() | `Sentry.setTags()` |
| setExtras() | `Sentry.setExtras()` |
| setTag() | `Sentry.setTag()` |
| setExtra() | `Sentry.setExtra()` |
| setContext() | `Sentry.setContext()` |
| configureScope() | REMOVED - Scopes are now the unit of concurrency |
| run() | `Sentry.withScope()` or `Sentry.withIsolationScope()` |
| getIntegration() | `client.getIntegration()` |
| startTransaction() | `Sentry.startSpan()`, `Sentry.startInactiveSpan()` or `Sentry.startSpanManual()` |
| traceHeaders() | REMOVED - The closest equivalent is now `spanToTraceHeader(getActiveSpan())` |
| captureSession() | `Sentry.captureSession()` |
| startSession() | `Sentry.startSession()` |
| endSession() | `Sentry.endSession()` |
| shouldSendDefaultPii() | REMOVED - The closest equivalent is `Sentry.getClient().getOptions().sendDefaultPii` |

## Deprecate `scope.getSpan()` and `scope.setSpan()`

Instead, you can get the currently active span via `Sentry.getActiveSpan()`.
Setting a span on the scope happens automatically when you use the new performance APIs `startSpan()` and `startSpanManual()`.

## Deprecate `scope.setTransactionName()`

Instead, either set this as attributes or tags, or use an event processor to set `event.transaction`.

## Deprecate `scope.getTransaction()` and `getActiveTransaction()`

Instead, you should not rely on the active transaction, but just use `startSpan()` APIs, which handle this for you.

## Deprecate arguments for `startSpan()` APIs

In v8, the API to start a new span will be reduced from the currently available options.
Going forward, only these argument will be passable to `startSpan()`, `startSpanManual()` and `startInactiveSpan()`:

* `name`
* `attributes`
* `origin`
* `op`
* `startTime`
* `scope`

## Deprecate `startTransaction()` & `span.startChild()`

In v8, the old performance API `startTransaction()` (and `hub.startTransaction()`), as well as `span.startChild()`, will be removed.
Instead, use the new performance APIs:

* `startSpan()`
* `startSpanManual()`
* `startInactiveSpan()`

You can [read more about the new performance APIs here](./docs/v8-new-performance-apis.md).

## Deprecate `Sentry.lastEventId()` and `hub.lastEventId()`

`Sentry.lastEventId()` sometimes causes race conditons, so we are deprecating it in favour of the `beforeSend` callback.
`Sentry.lastEventId()` sometimes causes race conditions, so we are deprecating it in favour of the `beforeSend` callback.

```js
// Before
Expand Down Expand Up @@ -46,6 +126,19 @@ In v8, the Span class is heavily reworked. The following properties & methods ar
* `span.setName(newName)`: Use `span.updateName(newName)` instead.
* `span.toTraceparent()`: use `spanToTraceHeader(span)` util instead.
* `span.getTraceContext()`: Use `spanToTraceContext(span)` utility function instead.
* `span.sampled`: Use `span.isRecording()` instead.
* `span.spanId`: Use `span.spanContext().spanId` instead.
* `span.traceId`: Use `span.spanContext().traceId` instead.
* `span.name`: Use `spanToJSON(span).description` instead.
* `span.description`: Use `spanToJSON(span).description` instead.
* `span.getDynamicSamplingContext`: Use `getDynamicSamplingContextFromSpan` utility function instead.
* `transaction.setMetadata()`: Use attributes instead, or set data on the scope.
* `transaction.metadata`: Use attributes instead, or set data on the scope.
* `span.tags`: Set tags on the surrounding scope instead, or use attributes.
* `span.data`: Use `spanToJSON(span).data` instead.
* `span.setTag()`: Use `span.setAttribute()` instead or set tags on the surrounding scope.
* `span.setData()`: Use `span.setAttribute()` instead.
* `transaction.setContext()`: Set context on the surrounding scope instead.

## Deprecate `pushScope` & `popScope` in favor of `withScope`

Expand Down
2 changes: 1 addition & 1 deletion dev-packages/browser-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@babel/preset-typescript": "^7.16.7",
"@playwright/test": "^1.31.1",
"@sentry-internal/rrweb": "2.6.0",
"@sentry-internal/rrweb": "2.7.3",
"@sentry/browser": "7.92.0",
"@sentry/tracing": "7.92.0",
"axios": "1.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,62 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers';

sentryTest('captures Breadcrumb for clicks & debounces them for a second', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route('**/foo', route => {
return route.fulfill({
status: 200,
body: JSON.stringify({
userNames: ['John', 'Jane'],
}),
headers: {
'Content-Type': 'application/json',
},
sentryTest(
'captures Breadcrumb for clicks & debounces them for a second',
async ({ getLocalTestUrl, page, browserName }) => {
sentryTest.skip(browserName === 'chromium', 'This consistently flakes on chrome.');

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

await page.route('**/foo', route => {
return route.fulfill({
status: 200,
body: JSON.stringify({
userNames: ['John', 'Jane'],
}),
headers: {
'Content-Type': 'application/json',
},
});
});
});

const promise = getFirstSentryEnvelopeRequest<Event>(page);

await page.goto(url);

await page.click('#button1');
// not debounced because other target
await page.click('#button2');
// This should be debounced
await page.click('#button2');

// Wait a second for the debounce to finish
await page.waitForTimeout(1000);
await page.click('#button2');

const [eventData] = await Promise.all([promise, page.evaluate('Sentry.captureException("test exception")')]);

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

expect(eventData.breadcrumbs).toEqual([
{
timestamp: expect.any(Number),
category: 'ui.click',
message: 'body > button#button1[type="button"]',
},
{
timestamp: expect.any(Number),
category: 'ui.click',
message: 'body > button#button2[type="button"]',
},
{
timestamp: expect.any(Number),
category: 'ui.click',
message: 'body > button#button2[type="button"]',
},
]);
});

const promise = getFirstSentryEnvelopeRequest<Event>(page);

await page.goto(url);

await page.click('#button1');
// not debounced because other target
await page.click('#button2');
// This should be debounced
await page.click('#button2');

// Wait a second for the debounce to finish
await page.waitForTimeout(1000);
await page.click('#button2');

const [eventData] = await Promise.all([promise, page.evaluate('Sentry.captureException("test exception")')]);

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

expect(eventData.breadcrumbs).toEqual([
{
timestamp: expect.any(Number),
category: 'ui.click',
message: 'body > button#button1[type="button"]',
},
{
timestamp: expect.any(Number),
category: 'ui.click',
message: 'body > button#button2[type="button"]',
},
{
timestamp: expect.any(Number),
category: 'ui.click',
message: 'body > button#button2[type="button"]',
},
]);
},
);

sentryTest(
'uses the annotated component name in the breadcrumb messages and adds it to the data object',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Sentry.captureMessage('a');

Sentry.captureException(new Error('test_simple_breadcrumb_error'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect } from '@playwright/test';
import type { Event } from '@sentry/types';

import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest(
'should capture recorded transactions as breadcrumbs for the following event sent',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const events = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url });

const errorEvent = events.find(event => event.exception?.values?.[0].value === 'test_simple_breadcrumb_error')!;

expect(errorEvent.breadcrumbs).toHaveLength(1);
expect(errorEvent.breadcrumbs?.[0]).toMatchObject({
category: 'sentry.event',
event_id: expect.any(String),
level: expect.any(String),
});
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Sentry.captureEvent({
event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2',
message: 'someMessage',
transaction: 'wat',
type: 'transaction',
});

Sentry.captureException(new Error('test_simple_breadcrumb_error'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect } from '@playwright/test';
import type { Event } from '@sentry/types';

import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest(
'should capture recorded transactions as breadcrumbs for the following event sent',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const events = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url });

const errorEvent = events.find(event => event.exception?.values?.[0].value === 'test_simple_breadcrumb_error')!;

expect(errorEvent.breadcrumbs).toHaveLength(1);
expect(errorEvent.breadcrumbs?.[0]).toMatchObject({
category: 'sentry.transaction',
message: expect.any(String),
});
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { parameterize } from '@sentry/utils';

const x = 'first';
const y = 'second';

Sentry.captureMessage(parameterize`This is a log statement with ${x} and ${y} params`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect } from '@playwright/test';
import type { Event } from '@sentry/types';

import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should capture a parameterized representation of the message', async ({ getLocalTestPath, page }) => {
const bundle = process.env.PW_BUNDLE;

if (bundle && bundle.startsWith('bundle_')) {
sentryTest.skip();
}

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

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

expect(eventData.logentry).toStrictEqual({
message: 'This is a log statement with %s and %s params',
params: ['first', 'second'],
});
});

0 comments on commit 226bbcc

Please sign in to comment.