Skip to content

Commit

Permalink
Merge branch 'getsentry:develop' into feat/graphqlClientIntegration
Browse files Browse the repository at this point in the history
  • Loading branch information
Zen-cronic authored Feb 10, 2025
2 parents a0f7aeb + 480fa2a commit 141c67e
Show file tree
Hide file tree
Showing 22 changed files with 270 additions and 303 deletions.
27 changes: 13 additions & 14 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,19 @@ targets:
includeNames: /^sentry-internal-eslint-config-sdk-\d.*\.tgz$/

# AWS Lambda Layer target
# 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: SentryNodeServerlessSDKv9
# compatibleRuntimes:
# - name: node
# versions:
# - nodejs10.x
# - nodejs12.x
# - nodejs14.x
# - nodejs16.x
# - nodejs18.x
# - nodejs20.x
# license: MIT
- name: aws-lambda-layer
includeNames: /^sentry-node-serverless-\d+.\d+.\d+(-(beta|alpha|rc)\.\d+)?\.zip$/
layerName: SentryNodeServerlessSDKv9
compatibleRuntimes:
- name: node
versions:
- nodejs10.x
- nodejs12.x
- nodejs14.x
- nodejs16.x
- nodejs18.x
- nodejs20.x
license: MIT

# CDN Bundle Target
- name: gcs
Expand Down
12 changes: 7 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

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

### 9.0.0
## 9.0.0

Version `9.0.0` marks a release of the Sentry JavaScript SDKs that contains breaking changes.
The goal of this release is to trim down on unused and potentially confusing APIs, prepare the SDKs for future framework versions to build deeper instrumentation, and remove old polyfills to reduce the packages' size.

#### How To Upgrade
### How To Upgrade

Please carefully read through the migration guide in the Sentry docs on how to upgrade from version 8 to version 9.
Make sure to select your specific platform/framework in the top left corner: https://docs.sentry.io/platforms/javascript/migration/v8-to-v9/

A comprehensive migration guide outlining all changes for all the frameworks can be found within the Sentry JavaScript SDK Repository: https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md

#### Breaking Changes
### Breaking Changes

- doc(deno)!: Make Deno v2 the minimum supported version (#15085)
- feat!: Bump typescript to `~5.0.0` (#14758)
Expand Down Expand Up @@ -101,7 +101,7 @@ A comprehensive migration guide outlining all changes for all the frameworks can
- ref(core)!: Remove `Scope` type interface in favor of using `Scope` class (#14721)
- ref(core)!: Remove backwards compatible SentryCarrier type (#14697)

#### Other Changes
### Other Changes

- chore(browser): Export ipAddress helpers for use in other SDKs (#15079)
- deps(node): Bump `import-in-the-middle` to `1.12.0` (#14796)
Expand All @@ -126,12 +126,14 @@ A comprehensive migration guide outlining all changes for all the frameworks can
- feat(deps): bump @opentelemetry/instrumentation-mongodb from 0.50.0 to 0.51.0 (#14871)
- feat(deps): bump @opentelemetry/instrumentation-tedious from 0.17.0 to 0.18.0 (#14868)
- feat(deps): bump @sentry/cli from 2.39.1 to 2.41.1 (#15173)
- feat(flags): Add Statsig browser integration (#15319)
- feat(gatsby): Preserve user-provided source map settings (#15006)
- feat(nestjs): Remove `SentryTracingInterceptor`, `SentryGlobalGraphQLFilter`, `SentryGlobalGenericFilter` (#14761)
- feat(nextjs): Directly forward `sourcemaps.disable` to webpack plugin (#15109)
- feat(node): Add missing `vercelAIIntegration` export (#15318)
- feat(node): Add `processSessionIntegration` (#15081)
- feat(node): Add missing `vercelAIIntegration` export (#15318)
- feat(node): Capture exceptions from `worker_threads` (#15105)
- feat(nuxt): Add enabled to disable Sentry module (#15337)
- feat(nuxt): add `silent`, `errorHandler`, `release` to `SourceMapsOptions` (#15246)
- feat(profiling-node): Use `@sentry-internal/node-cpu-profiler` (#15208)
- feat(replay): Update fflate to 0.8.2 (#14867)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Flag evaluation error hook', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { expect } from '@playwright/test';

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

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
sentryTest.skip();
}

await page.route('https://dsn.ingest.sentry.io/**/*', route => {
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
});
});

const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

await page.evaluate(bufferSize => {
const client = (window as any).statsigClient;
for (let i = 1; i <= bufferSize; i++) {
client.checkGate(`feat${i}`); // values default to false
}

client.setMockGateValue(`feat${bufferSize + 1}`, true);
client.checkGate(`feat${bufferSize + 1}`); // eviction

client.setMockGateValue('feat3', true);
client.checkGate('feat3'); // update
}, FLAG_BUFFER_SIZE);

const reqPromise = waitForErrorRequest(page);
await page.locator('#error').click();
const req = await reqPromise;
const event = envelopeRequestParser(req);

const expectedFlags = [{ flag: 'feat2', result: false }];
for (let i = 4; i <= FLAG_BUFFER_SIZE; i++) {
expectedFlags.push({ flag: `feat${i}`, result: false });
}
expectedFlags.push({ flag: `feat${FLAG_BUFFER_SIZE + 1}`, result: true });
expectedFlags.push({ flag: 'feat3', result: true });

expect(event.contexts?.flags?.values).toEqual(expectedFlags);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as Sentry from '@sentry/browser';

class MockStatsigClient {
constructor() {
this._gateEvaluationListeners = [];
this._mockGateValues = {};
}

on(event, listener) {
this._gateEvaluationListeners.push(listener);
}

checkGate(name) {
const value = this._mockGateValues[name] || false; // unknown features default to false.
this._gateEvaluationListeners.forEach(listener => {
listener({ gate: { name, value } });
});
return value;
}

setMockGateValue(name, value) {
this._mockGateValues[name] = value;
}
}

window.statsigClient = new MockStatsigClient();

window.Sentry = Sentry;
window.sentryStatsigIntegration = Sentry.statsigIntegration({ featureFlagClient: window.statsigClient });

Sentry.init({
dsn: 'https://[email protected]/1337',
sampleRate: 1.0,
integrations: [window.sentryStatsigIntegration],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
document.getElementById('error').addEventListener('click', () => {
throw new Error('Button triggered error');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<button id="error">Throw Error</button>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { expect } from '@playwright/test';

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

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

import type { Scope } from '@sentry/browser';

sentryTest('Flag evaluations in forked scopes are stored separately.', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
sentryTest.skip();
}

await page.route('https://dsn.ingest.sentry.io/**/*', route => {
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
});
});

const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });
await page.goto(url);

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;
const errorButton = document.querySelector('#error') as HTMLButtonElement;
const client = (window as any).statsigClient;

client.setMockGateValue('shared', true);
client.setMockGateValue('main', true);

client.checkGate('shared');

Sentry.withScope((scope: Scope) => {
client.setMockGateValue('forked', true);
client.setMockGateValue('shared', false); // override the value in the parent scope.

client.checkGate('forked');
client.checkGate('shared');
scope.setTag('isForked', true);
errorButton.click();
});

client.checkGate('main');
Sentry.getCurrentScope().setTag('isForked', false);
errorButton.click();
return true;
});

const forkedReq = await forkedReqPromise;
const forkedEvent = envelopeRequestParser(forkedReq);

const mainReq = await mainReqPromise;
const mainEvent = envelopeRequestParser(mainReq);

expect(forkedEvent.contexts?.flags?.values).toEqual([
{ flag: 'forked', result: true },
{ flag: 'shared', result: false },
]);

expect(mainEvent.contexts?.flags?.values).toEqual([
{ flag: 'shared', result: true },
{ flag: 'main', result: true },
]);
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../../utils/fixtures';

import { envelopeRequestParser, shouldSkipFeatureFlagsTest, waitForErrorRequest } from '../../../../../utils/helpers';

const FLAG_BUFFER_SIZE = 100; // Corresponds to constant in featureFlags.ts, in browser utils.
import { FLAG_BUFFER_SIZE } from '../../constants';

sentryTest('Basic test with eviction, update, and no async tasks', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeatureFlagsTest()) {
Expand Down

This file was deleted.

Loading

0 comments on commit 141c67e

Please sign in to comment.