Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ module.exports = [
// Browser SDK (ESM)
{
name: '@sentry/browser',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init'),
gzip: true,
limit: '25 KB',
},
{
name: '@sentry/browser - with treeshaking flags',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init'),
gzip: true,
limit: '24.1 KB',
Expand All @@ -35,28 +35,28 @@ module.exports = [
},
{
name: '@sentry/browser (incl. Tracing)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init', 'browserTracingIntegration'),
gzip: true,
limit: '41.3 KB',
},
{
name: '@sentry/browser (incl. Tracing, Profiling)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init', 'browserTracingIntegration', 'browserProfilingIntegration'),
gzip: true,
limit: '48 KB',
},
{
name: '@sentry/browser (incl. Tracing, Replay)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init', 'browserTracingIntegration', 'replayIntegration'),
gzip: true,
limit: '80 KB',
},
{
name: '@sentry/browser (incl. Tracing, Replay) - with treeshaking flags',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init', 'browserTracingIntegration', 'replayIntegration'),
gzip: true,
limit: '75 KB',
Expand All @@ -79,35 +79,35 @@ module.exports = [
},
{
name: '@sentry/browser (incl. Tracing, Replay with Canvas)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'replayCanvasIntegration'),
gzip: true,
limit: '85 KB',
},
{
name: '@sentry/browser (incl. Tracing, Replay, Feedback)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration'),
gzip: true,
limit: '97 KB',
},
{
name: '@sentry/browser (incl. Feedback)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init', 'feedbackIntegration'),
gzip: true,
limit: '42 KB',
},
{
name: '@sentry/browser (incl. sendFeedback)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init', 'sendFeedback'),
gzip: true,
limit: '30 KB',
},
{
name: '@sentry/browser (incl. FeedbackAsync)',
path: 'packages/browser/build/npm/esm/index.js',
path: 'packages/browser/build/npm/esm/prod/index.js',
import: createImport('init', 'feedbackAsyncIntegration'),
gzip: true,
limit: '35 KB',
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@

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

## 10.25.0

- feat(browser): Include Spotlight in development bundles ([#18078](https://github.com/getsentry/sentry-javascript/pull/18078))
- feat(cloudflare): Add metrics exports ([#18147](https://github.com/getsentry/sentry-javascript/pull/18147))
- feat(core): Truncate request string inputs in OpenAI integration ([#18136](https://github.com/getsentry/sentry-javascript/pull/18136))
- feat(metrics): Add missing metric node exports ([#18149](https://github.com/getsentry/sentry-javascript/pull/18149))
- feat(node): Add `maxCacheKeyLength` to Redis integration (remove truncation) ([#18045](https://github.com/getsentry/sentry-javascript/pull/18045))
- feat(vercel-edge): Add metrics export ([#18148](https://github.com/getsentry/sentry-javascript/pull/18148))
- fix(core): Only consider exception mechanism when updating session status from event with exceptions ([#18137](https://github.com/getsentry/sentry-javascript/pull/18137))
- ref(browser): Remove truncation when not needed ([#18051](https://github.com/getsentry/sentry-javascript/pull/18051))

<details>
<summary> <strong>Internal Changes</strong> </summary>

- chore(build): Fix incorrect versions after merge ([#18154](https://github.com/getsentry/sentry-javascript/pull/18154))
</details>

## 10.24.0

### Important Changes
Expand Down
12 changes: 6 additions & 6 deletions dev-packages/browser-integration-tests/utils/generatePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const IMPORTED_INTEGRATION_CDN_BUNDLE_PATHS: Record<string, string> = {

const BUNDLE_PATHS: Record<string, Record<string, string>> = {
browser: {
cjs: 'build/npm/cjs/index.js',
esm: 'build/npm/esm/index.js',
cjs: 'build/npm/cjs/prod/index.js',
esm: 'build/npm/esm/prod/index.js',
bundle: 'build/bundles/bundle.js',
bundle_min: 'build/bundles/bundle.min.js',
bundle_replay: 'build/bundles/bundle.replay.js',
Expand All @@ -67,8 +67,8 @@ const BUNDLE_PATHS: Record<string, Record<string, string>> = {
loader_tracing_replay: 'build/bundles/bundle.tracing.replay.debug.min.js',
},
integrations: {
cjs: 'build/npm/cjs/index.js',
esm: 'build/npm/esm/index.js',
cjs: 'build/npm/cjs/prod/index.js',
esm: 'build/npm/esm/prod/index.js',
bundle: 'build/bundles/[INTEGRATION_NAME].js',
bundle_min: 'build/bundles/[INTEGRATION_NAME].min.js',
},
Expand All @@ -77,8 +77,8 @@ const BUNDLE_PATHS: Record<string, Record<string, string>> = {
bundle_min: 'build/bundles/[INTEGRATION_NAME].min.js',
},
wasm: {
cjs: 'build/npm/cjs/index.js',
esm: 'build/npm/esm/index.js',
cjs: 'build/npm/cjs/prod/index.js',
esm: 'build/npm/esm/prod/index.js',
bundle: 'build/bundles/wasm.js',
bundle_min: 'build/bundles/wasm.min.js',
},
Expand Down
6 changes: 6 additions & 0 deletions dev-packages/bundler-tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['../../.eslintrc.js'],
parserOptions: {
sourceType: 'module',
},
};
6 changes: 6 additions & 0 deletions dev-packages/bundler-tests/fixtures/basic/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!doctype html>
<html lang="en">
<body>
<script type="module" src="/index.js"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions dev-packages/bundler-tests/fixtures/basic/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { init } from '@sentry/browser';

init({
dsn: 'https://00000000000000000000000000000000@o000000.ingest.sentry.io/0000000',
});
26 changes: 26 additions & 0 deletions dev-packages/bundler-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@sentry-internal/bundler-tests",
"version": "10.24.0",
"description": "Bundler tests for Sentry Browser SDK",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/bundler-tests",
"author": "Sentry",
"license": "MIT",
"private": true,
"main": "./index.mjs",
"scripts": {
"test": "vitest run"
},
"dependencies": {
"@sentry/browser": "10.24.0",
"webpack": "^5.0.0",
"rollup": "^4.0.0",
"vite": "^5.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"vitest": "^3.2.4"
},
"volta": {
"extends": "../../package.json"
},
"type": "module"
}
144 changes: 144 additions & 0 deletions dev-packages/bundler-tests/tests/bundling.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import { describe, expect, beforeAll, test } from 'vitest';
import * as path from 'node:path';
import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';

import webpack from 'webpack';
import { rollup } from 'rollup';
import { build as viteBuild } from 'vite';
import nodeResolve from '@rollup/plugin-node-resolve';

// Helper functions
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

function distDir(name: string): string {
const dir = path.join(__dirname, '..', 'dist', name);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
return dir;
}

function rimraf(dir: string): void {
if (fs.existsSync(dir)) {
fs.rmSync(dir, { recursive: true, force: true });
}
}

function readAllJs(outDir: string): string {
let contents = '';
const stack = [outDir];
while (stack.length) {
const current = stack.pop()!;
for (const entry of fs.readdirSync(current)) {
const full = path.join(current, entry);
const stat = fs.statSync(full);
if (stat.isDirectory()) {
stack.push(full);
} else if (entry.endsWith('.js') || entry.endsWith('.mjs')) {
contents += fs.readFileSync(full, 'utf8');
}
}
}
return contents;
}

function fixtureEntry(name: string): string {
return path.resolve(__dirname, '..', 'fixtures', name, 'index.js');
}

function rootDir(): string {
return path.join(__dirname, '../../..');
}

const SPOTLIGHT_URL = 'localhost:8969';

type BundleMode = 'development' | 'production';

function bundleWithWebpack(mode: BundleMode): Promise<string> {
return new Promise((resolve, reject) => {
const outDir = distDir(`webpack-${mode}`);
rimraf(outDir);
const compiler = webpack({
mode,
entry: fixtureEntry('basic'),
output: { path: outDir, filename: 'bundle.js' },
});
compiler?.run((err: Error | null | undefined, stats: webpack.Stats | undefined) => {
try {
if (err) throw err;
if (stats?.hasErrors()) {
throw new Error(stats.toString('errors-only'));
}
resolve(readAllJs(outDir));
} catch (e) {
reject(e);
} finally {
compiler.close(() => {});
}
});
});
}

async function bundleWithRollup(mode: BundleMode): Promise<string> {
const outDir = distDir(`rollup-${mode}`);
rimraf(outDir);

const bundle = await rollup({
input: fixtureEntry('basic'),
plugins: [
nodeResolve({
// There should really be a default where these get specified automatically
exportConditions: [mode === 'production' ? 'production' : 'development'],
}),
],
});
await bundle.write({ dir: outDir, format: 'esm' });
await bundle.close();
return readAllJs(outDir);
}

async function bundleWithVite(mode: BundleMode): Promise<string> {
const outDir = distDir(`vite-${mode}`);
rimraf(outDir);

// In Vitest, NODE_ENV is always 'test', so we need to override it here
const prev = process.env.NODE_ENV;
process.env.NODE_ENV = mode;

await viteBuild({
mode,
root: path.dirname(fixtureEntry('basic')),
build: { outDir, minify: mode === 'production' },
});

process.env.NODE_ENV = prev;

return readAllJs(outDir);
}

describe('spotlight', () => {
beforeAll(() => {
const distRoot = path.join(rootDir(), 'dist');
rimraf(distRoot);
});

const cases: [string, (mode: BundleMode) => Promise<string>][] = [
['webpack', bundleWithWebpack],
['rollup', bundleWithRollup],
['vite', bundleWithVite],
];

for (const [name, bundler] of cases) {
test(`${name} development bundle contains spotlight`, async () => {
const code = await bundler('development');
expect(code).toContain(SPOTLIGHT_URL);
});

test(`${name} production bundle does not contain spotlight`, async () => {
const code = await bundler('production');
expect(code).not.toContain(SPOTLIGHT_URL);
});
}
});
9 changes: 9 additions & 0 deletions dev-packages/bundler-tests/vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
include: ['tests/**/*.test.*s'],
timeout: 10000,
hookTimeout: 10000,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ const DEPENDENTS: Dependent[] = [
ignoreExports: [
// Not needed for Astro
'setupFastifyErrorHandler',
// Todo(metrics): Add metrics exports for beta
'metrics',
],
},
{
Expand All @@ -56,8 +54,6 @@ const DEPENDENTS: Dependent[] = [
'childProcessIntegration',
'systemErrorIntegration',
'pinoIntegration',
// Todo(metrics): Add metrics exports for beta
'metrics',
],
},
{
Expand All @@ -79,8 +75,6 @@ const DEPENDENTS: Dependent[] = [
ignoreExports: [
// Not needed for Serverless
'setupFastifyErrorHandler',
// Todo(metrics): Add metrics exports for beta
'metrics',
],
},
{
Expand All @@ -90,8 +84,6 @@ const DEPENDENTS: Dependent[] = [
ignoreExports: [
// Not needed for Serverless
'setupFastifyErrorHandler',
// Todo(metrics): Add metrics exports for beta
'metrics',
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MockOpenAI {
await new Promise(resolve => setTimeout(resolve, 10));

return {
id: 'chatcmpl-truncation-test',
id: 'chatcmpl-completions-truncation-test',
object: 'chat.completion',
created: 1677652288,
model: params.model,
Expand Down
Loading
Loading