Skip to content

Commit

Permalink
Merge pull request #9915 from getsentry/prepare-release/7.89.0
Browse files Browse the repository at this point in the history
meta(changelog): Update changelog for 7.89.0
  • Loading branch information
lforst committed Dec 19, 2023
2 parents f1a677f + 9f173e1 commit 53a08bf
Show file tree
Hide file tree
Showing 254 changed files with 8,606 additions and 1,661 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Expand Up @@ -864,13 +864,16 @@ jobs:
'create-remix-app-v2',
'debug-id-sourcemaps',
'nextjs-app-dir',
'nextjs-14',
'react-create-hash-router',
'react-router-6-use-routes',
'standard-frontend-react',
'standard-frontend-react-tracing-import',
'sveltekit',
'sveltekit-2',
'generic-ts3.8',
'node-experimental-fastify-app',
'node-hapi-app',
]
build-command:
- false
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/canary.yml
Expand Up @@ -73,6 +73,12 @@ jobs:
- test-application: 'nextjs-app-dir'
build-command: 'test:build-latest'
label: 'nextjs-app-dir (latest)'
- test-application: 'nextjs-14'
build-command: 'test:build-canary'
label: 'nextjs-14 (canary)'
- test-application: 'nextjs-14'
build-command: 'test:build-latest'
label: 'nextjs-14 (latest)'
- test-application: 'react-create-hash-router'
build-command: 'test:build-canary'
label: 'react-create-hash-router (canary)'
Expand Down
68 changes: 68 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,74 @@

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

## 7.89.0

### Important Changes

#### Deprecations

- **feat(core): Deprecate `configureScope` (#9887)**
- **feat(core): Deprecate `pushScope` & `popScope` (#9890)**

This release deprecates `configureScope`, `pushScope`, and `popScope`, which will be removed in the upcoming v8 major release.

#### Hapi Integration

- **feat(node): Add Hapi Integration (#9539)**

This release adds an integration for Hapi. It can be used as follows:

```ts
const Sentry = require('@sentry/node');
const Hapi = require('@hapi/hapi');

const init = async () => {
const server = Hapi.server({
// your server configuration ...
});

Sentry.init({
dsn: '__DSN__',
tracesSampleRate: 1.0,
integrations: [
new Sentry.Integrations.Hapi({ server }),
],
});

server.route({
// your route configuration ...
});

await server.start();
};
```

#### SvelteKit 2.0

- **chore(sveltekit): Add SvelteKit 2.0 to peer dependencies (#9861)**

This release adds support for SvelteKit 2.0 in the `@sentry/sveltekit` package. If you're upgrading from SvelteKit 1.x to 2.x and already use the Sentry SvelteKit SDK, no changes apart from upgrading to this (or a newer) version are necessary.

### Other Changes

- feat(core): Add type & utility for function-based integrations (#9818)
- feat(core): Update `withScope` to return callback return value (#9866)
- feat(deno): Support `Deno.CronSchedule` for cron jobs (#9880)
- feat(nextjs): Auto instrument generation functions (#9781)
- feat(nextjs): Connect server component transactions if there is no incoming trace (#9845)
- feat(node-experimental): Update to new Scope APIs (#9799)
- feat(replay): Add `canvas.type` setting (#9877)
- fix(nextjs): Export `createReduxEnhancer` (#9854)
- fix(remix): Do not capture thrown redirect responses. (#9909)
- fix(sveltekit): Add conditional exports (#9872)
- fix(sveltekit): Avoid capturing 404 errors on client side (#9902)
- fix(utils): Do not use `Event` type in worldwide (#9864)
- fix(utils): Support crypto.getRandomValues in old Chromium versions (#9251)
- fix(utils): Update `eventFromUnknownInput` to avoid scope pollution & `getCurrentHub` (#9868)
- ref: Use `addBreadcrumb` directly & allow to pass hint (#9867)

Work in this release contributed by @adam187, and @jghinestrosa. Thank you for your contributions!

## 7.88.0

### Important Changes
Expand Down
12 changes: 12 additions & 0 deletions MIGRATION.md
Expand Up @@ -8,6 +8,18 @@ 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 `pushScope` & `popScope` in favor of `withScope`

Instead of manually pushing/popping a scope, you should use `Sentry.withScope(callback: (scope: Scope))` instead.

## Deprecate `configureScope` in favor of using `getCurrentScope()`

Instead of updating the scope in a callback via `configureScope()`, you should access it via `getCurrentScope()` and configure it directly:

```js
Sentry.getCurrentScope().setTag('xx', 'yy');
```

## Deprecate `addGlobalEventProcessor` in favor of `addEventProcessor`

Instead of using `addGlobalEventProcessor`, you should use `addEventProcessor` which does not add the event processor globally, but to the current client.
Expand Down
5 changes: 5 additions & 0 deletions codecov.yml
Expand Up @@ -3,6 +3,11 @@ codecov:
notify:
require_ci_to_pass: no

ai_pr_review:
enabled: true
method: "label"
label_name: "ci-codecov-ai-review"

coverage:
precision: 2
round: down
Expand Down
11 changes: 2 additions & 9 deletions packages/angular/src/tracing.ts
Expand Up @@ -7,7 +7,7 @@ import type { ActivatedRouteSnapshot, Event, RouterState } from '@angular/router
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import { NavigationCancel, NavigationError, Router } from '@angular/router';
import { NavigationEnd, NavigationStart, ResolveEnd } from '@angular/router';
import { WINDOW, getCurrentHub } from '@sentry/browser';
import { WINDOW, getCurrentScope } from '@sentry/browser';
import type { Span, Transaction, TransactionContext } from '@sentry/types';
import { logger, stripUrlQueryAndFragment, timestampInSeconds } from '@sentry/utils';
import type { Observable } from 'rxjs';
Expand Down Expand Up @@ -50,14 +50,7 @@ export const instrumentAngularRouting = routingInstrumentation;
* Grabs active transaction off scope
*/
export function getActiveTransaction(): Transaction | undefined {
const currentHub = getCurrentHub();

if (currentHub) {
const scope = currentHub.getScope();
return scope.getTransaction();
}

return undefined;
return getCurrentScope().getTransaction();
}

/**
Expand Down
12 changes: 4 additions & 8 deletions packages/angular/test/tracing.test.ts
Expand Up @@ -21,16 +21,12 @@ jest.mock('@sentry/browser', () => {
const original = jest.requireActual('@sentry/browser');
return {
...original,
getCurrentHub: () => {
getCurrentScope() {
return {
getScope: () => {
return {
getTransaction: () => {
return transaction;
},
};
getTransaction: () => {
return transaction;
},
} as unknown as Hub;
};
},
};
});
Expand Down
6 changes: 2 additions & 4 deletions packages/astro/src/client/sdk.ts
@@ -1,6 +1,6 @@
import type { BrowserOptions } from '@sentry/browser';
import { BrowserTracing, init as initBrowserSdk } from '@sentry/browser';
import { configureScope, hasTracingEnabled } from '@sentry/core';
import { getCurrentScope, hasTracingEnabled } from '@sentry/core';
import { addOrUpdateIntegration } from '@sentry/utils';

import { applySdkMetadata } from '../common/metadata';
Expand All @@ -20,9 +20,7 @@ export function init(options: BrowserOptions): void {

initBrowserSdk(options);

configureScope(scope => {
scope.setTag('runtime', 'browser');
});
getCurrentScope().setTag('runtime', 'browser');
}

function addClientIntegrations(options: BrowserOptions): void {
Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/index.server.ts
Expand Up @@ -17,6 +17,7 @@ export {
captureMessage,
captureCheckIn,
withMonitor,
// eslint-disable-next-line deprecation/deprecation
configureScope,
createTransport,
// eslint-disable-next-line deprecation/deprecation
Expand Down
10 changes: 6 additions & 4 deletions packages/astro/src/server/meta.ts
@@ -1,5 +1,5 @@
import { getDynamicSamplingContextFromClient } from '@sentry/core';
import type { Hub, Span } from '@sentry/types';
import type { Client, Scope, Span } from '@sentry/types';
import {
TRACEPARENT_REGEXP,
dynamicSamplingContextToSentryBaggageHeader,
Expand All @@ -22,9 +22,11 @@ import {
*
* @returns an object with the two serialized <meta> tags
*/
export function getTracingMetaTags(span: Span | undefined, hub: Hub): { sentryTrace: string; baggage?: string } {
const scope = hub.getScope();
const client = hub.getClient();
export function getTracingMetaTags(
span: Span | undefined,
scope: Scope,
client: Client | undefined,
): { sentryTrace: string; baggage?: string } {
const { dsc, sampled, traceId } = scope.getPropagationContext();
const transaction = span?.transaction;

Expand Down
22 changes: 10 additions & 12 deletions packages/astro/src/server/middleware.ts
@@ -1,12 +1,12 @@
import {
captureException,
configureScope,
continueTrace,
getCurrentHub,
getClient,
getCurrentScope,
runWithAsyncContext,
startSpan,
} from '@sentry/node';
import type { Hub, Span } from '@sentry/types';
import type { Client, Scope, Span } from '@sentry/types';
import { addNonEnumerableProperty, objectify, stripUrlQueryAndFragment } from '@sentry/utils';
import type { APIContext, MiddlewareResponseHandler } from 'astro';

Expand Down Expand Up @@ -69,7 +69,7 @@ export const handleRequest: (options?: MiddlewareOptions) => MiddlewareResponseH
// if there is an active span, we know that this handle call is nested and hence
// we don't create a new domain for it. If we created one, nested server calls would
// create new transactions instead of adding a child span to the currently active span.
if (getCurrentHub().getScope().getSpan()) {
if (getCurrentScope().getSpan()) {
return instrumentRequest(ctx, next, handlerOptions);
}
return runWithAsyncContext(() => {
Expand Down Expand Up @@ -106,9 +106,7 @@ async function instrumentRequest(
}

if (options.trackClientIp) {
configureScope(scope => {
scope.setUser({ ip_address: ctx.clientAddress });
});
getCurrentScope().setUser({ ip_address: ctx.clientAddress });
}

try {
Expand Down Expand Up @@ -141,8 +139,8 @@ async function instrumentRequest(
span.setHttpStatus(originalResponse.status);
}

const hub = getCurrentHub();
const client = hub.getClient();
const scope = getCurrentScope();
const client = getClient();
const contentType = originalResponse.headers.get('content-type');

const isPageloadRequest = contentType && contentType.startsWith('text/html');
Expand All @@ -165,7 +163,7 @@ async function instrumentRequest(
start: async controller => {
for await (const chunk of originalBody) {
const html = typeof chunk === 'string' ? chunk : decoder.decode(chunk);
const modifiedHtml = addMetaTagToHead(html, hub, span);
const modifiedHtml = addMetaTagToHead(html, scope, client, span);
controller.enqueue(new TextEncoder().encode(modifiedHtml));
}
controller.close();
Expand All @@ -187,12 +185,12 @@ async function instrumentRequest(
* This function optimistically assumes that the HTML coming in chunks will not be split
* within the <head> tag. If this still happens, we simply won't replace anything.
*/
function addMetaTagToHead(htmlChunk: string, hub: Hub, span?: Span): string {
function addMetaTagToHead(htmlChunk: string, scope: Scope, client: Client, span?: Span): string {
if (typeof htmlChunk !== 'string') {
return htmlChunk;
}

const { sentryTrace, baggage } = getTracingMetaTags(span, hub);
const { sentryTrace, baggage } = getTracingMetaTags(span, scope, client);
const content = `<head>\n${sentryTrace}\n${baggage}\n`;
return htmlChunk.replace('<head>', content);
}
Expand Down
6 changes: 2 additions & 4 deletions packages/astro/src/server/sdk.ts
@@ -1,4 +1,4 @@
import { configureScope } from '@sentry/core';
import { getCurrentScope } from '@sentry/core';
import type { NodeOptions } from '@sentry/node';
import { init as initNodeSdk } from '@sentry/node';

Expand All @@ -13,7 +13,5 @@ export function init(options: NodeOptions): void {

initNodeSdk(options);

configureScope(scope => {
scope.setTag('runtime', 'node');
});
getCurrentScope().setTag('runtime', 'node');
}
39 changes: 18 additions & 21 deletions packages/astro/test/server/meta.test.ts
Expand Up @@ -10,22 +10,20 @@ const mockedSpan = {
environment: 'production',
}),
},
};
} as any;

const mockedHub = {
getScope: () => ({
getPropagationContext: () => ({
traceId: '123',
}),
const mockedClient = {} as any;

const mockedScope = {
getPropagationContext: () => ({
traceId: '123',
}),
getClient: () => ({}),
};
} as any;

describe('getTracingMetaTags', () => {
it('returns the tracing tags from the span, if it is provided', () => {
{
// @ts-expect-error - only passing a partial span object
const tags = getTracingMetaTags(mockedSpan, mockedHub);
const tags = getTracingMetaTags(mockedSpan, mockedScope, mockedClient);

expect(tags).toEqual({
sentryTrace: '<meta name="sentry-trace" content="12345678901234567890123456789012-1234567890123456-1"/>',
Expand All @@ -35,10 +33,9 @@ describe('getTracingMetaTags', () => {
});

it('returns propagationContext DSC data if no span is available', () => {
const tags = getTracingMetaTags(undefined, {
...mockedHub,
// @ts-expect-error - only passing a partial scope object
getScope: () => ({
const tags = getTracingMetaTags(
undefined,
{
getPropagationContext: () => ({
traceId: '12345678901234567890123456789012',
sampled: true,
Expand All @@ -49,8 +46,9 @@ describe('getTracingMetaTags', () => {
trace_id: '12345678901234567890123456789012',
},
}),
}),
});
} as any,
mockedClient,
);

expect(tags).toEqual({
sentryTrace: expect.stringMatching(
Expand All @@ -73,7 +71,8 @@ describe('getTracingMetaTags', () => {
toTraceparent: () => '12345678901234567890123456789012-1234567890123456-1',
transaction: undefined,
},
mockedHub,
mockedScope,
mockedClient,
);

expect(tags).toEqual({
Expand All @@ -93,10 +92,8 @@ describe('getTracingMetaTags', () => {
toTraceparent: () => '12345678901234567890123456789012-1234567890123456-1',
transaction: undefined,
},
{
...mockedHub,
getClient: () => undefined,
},
mockedScope,
undefined,
);

expect(tags).toEqual({
Expand Down

0 comments on commit 53a08bf

Please sign in to comment.