Skip to content

Commit 85ff926

Browse files
authored
Merge pull request getsentry#9684 from getsentry/prepare-release/7.83.0
meta: Update Changelog for 7.83.0
2 parents f5ad00b + ab318e5 commit 85ff926

File tree

178 files changed

+760
-1837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+760
-1837
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

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

7+
## 7.83.0
8+
9+
- chore(astro): Allow Astro 4.0 in peer dependencies (#9683)
10+
- feat(astro): Add `assets` option to source maps upload options (#9668)
11+
- feat(react): Support `exactOptionalPropertyTypes` on `ErrorBoundary` (#9098)
12+
- fix: Don't depend on browser types in `types` (#9682)
13+
- fix(astro): Configure sourcemap assets directory for Vercel adapter (#9665)
14+
- fix(remix): Check the error data before spreading. (#9664)
15+
716
## 7.82.0
817

918
- feat(astro): Automatically add Sentry middleware in Astro integration (#9532)

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Pro tip: If any of your breakpoints are in code run by multiple tests, and you r
6969

7070
## Debug Build Flags
7171

72-
Throughout the codebase, you will find the `__DEBUG_BUILD__` flag guarding various code sections. This flag serves two purposes:
72+
Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
7373

7474
1. It enables us to remove debug code from our minified CDN bundles during build, by replacing the flag with `false` before tree-shaking occurs.
7575
2. It enables users to remove Sentry debug code from their production bundles during their own build. When we build our npm packages, we replace the flag with `(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)`. If the user does nothing, this evaluates to `true` and logging is included. But if the user runs their own replacement during build (again replacing the flag with `false`), the build will tree-shake the logging away, just as our bundle builds do.

packages/astro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"access": "public"
4141
},
4242
"peerDependencies": {
43-
"astro": "3.x"
43+
"astro": ">=3.x"
4444
},
4545
"dependencies": {
4646
"@sentry/browser": "7.82.0",

packages/astro/src/integration/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
4242
authToken: uploadOptions.authToken ?? env.SENTRY_AUTH_TOKEN,
4343
telemetry: uploadOptions.telemetry ?? true,
4444
sourcemaps: {
45-
assets: [getSourcemapsAssetsGlob(config)],
45+
assets: uploadOptions.assets ?? [getSourcemapsAssetsGlob(config)],
4646
},
4747
debug: options.debug ?? false,
4848
}),
@@ -100,9 +100,19 @@ function findDefaultSdkInitFile(type: 'server' | 'client'): string | undefined {
100100
}
101101

102102
function getSourcemapsAssetsGlob(config: AstroConfig): string {
103+
// The vercel adapter puts the output into its .vercel directory
104+
// However, the way this adapter is written, the config.outDir value is update too late for
105+
// us to reliably detect it. Also, server files are first temporarily written to <root>/dist and then
106+
// only copied over to <root>/.vercel. This seems to happen too late though.
107+
// So we glob on both of these directories.
108+
// Another case of "it ain't pretty but it works":(
109+
if (config.adapter?.name?.startsWith('@astrojs/vercel')) {
110+
return '{.vercel,dist}/**/*';
111+
}
112+
103113
// paths are stored as "file://" URLs
104114
const outDirPathname = config.outDir && path.resolve(config.outDir.pathname);
105-
const rootDirName = path.resolve((config.root && config.root.pathname) || process.cwd());
115+
const rootDirName = path.resolve(config.root?.pathname || process.cwd());
106116

107117
if (outDirPathname) {
108118
const relativePath = path.relative(rootDirName, outDirPathname);

packages/astro/src/integration/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ type SourceMapsOptions = {
6868
* @default true
6969
*/
7070
telemetry?: boolean;
71+
72+
/**
73+
* A glob or an array of globs that specify the build artifacts and source maps that will uploaded to Sentry.
74+
*
75+
* If this option is not specified, sensible defaults based on your `outDir`, `rootDir` and `adapter`
76+
* config will be used. Use this option to override these defaults, for instance if you have a
77+
* customized build setup that diverges from Astro's defaults.
78+
*
79+
* The globbing patterns must follow the implementation of the `glob` package.
80+
* @see https://www.npmjs.com/package/glob#glob-primer
81+
*/
82+
assets?: string | Array<string>;
7183
};
7284
};
7385

packages/astro/test/integration/index.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,65 @@ describe('sentryAstro integration', () => {
8383
});
8484
});
8585

86+
it('sets the correct assets glob for vercel if the Vercel adapter is used', async () => {
87+
const integration = sentryAstro({
88+
sourceMapsUploadOptions: { enabled: true, org: 'my-org', project: 'my-project', telemetry: false },
89+
});
90+
// @ts-expect-error - the hook exists and we only need to pass what we actually use
91+
await integration.hooks['astro:config:setup']({
92+
updateConfig,
93+
injectScript,
94+
config: {
95+
// @ts-expect-error - we only need to pass what we actually use
96+
adapter: { name: '@astrojs/vercel/serverless' },
97+
},
98+
});
99+
100+
expect(sentryVitePluginSpy).toHaveBeenCalledTimes(1);
101+
expect(sentryVitePluginSpy).toHaveBeenCalledWith({
102+
authToken: 'my-token',
103+
org: 'my-org',
104+
project: 'my-project',
105+
telemetry: false,
106+
debug: false,
107+
sourcemaps: {
108+
assets: ['{.vercel,dist}/**/*'],
109+
},
110+
});
111+
});
112+
113+
it('prefers user-specified assets-globs over the default values', async () => {
114+
const integration = sentryAstro({
115+
sourceMapsUploadOptions: {
116+
enabled: true,
117+
org: 'my-org',
118+
project: 'my-project',
119+
assets: ['dist/server/**/*, dist/client/**/*'],
120+
},
121+
});
122+
// @ts-expect-error - the hook exists and we only need to pass what we actually use
123+
await integration.hooks['astro:config:setup']({
124+
updateConfig,
125+
injectScript,
126+
// @ts-expect-error - only passing in partial config
127+
config: {
128+
outDir: new URL('file://path/to/project/build'),
129+
},
130+
});
131+
132+
expect(sentryVitePluginSpy).toHaveBeenCalledTimes(1);
133+
expect(sentryVitePluginSpy).toHaveBeenCalledWith({
134+
authToken: 'my-token',
135+
org: 'my-org',
136+
project: 'my-project',
137+
telemetry: true,
138+
debug: false,
139+
sourcemaps: {
140+
assets: ['dist/server/**/*, dist/client/**/*'],
141+
},
142+
});
143+
});
144+
86145
it("doesn't enable source maps if `sourceMapsUploadOptions.enabled` is `false`", async () => {
87146
const integration = sentryAstro({
88147
sourceMapsUploadOptions: { enabled: false },

packages/browser/src/client.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
} from '@sentry/types';
1414
import { createClientReportEnvelope, dsnToString, getSDKSource, logger } from '@sentry/utils';
1515

16+
import { DEBUG_BUILD } from './debug-build';
1617
import { eventFromException, eventFromMessage } from './eventbuilder';
1718
import { WINDOW } from './helpers';
1819
import type { BrowserTransportOptions } from './transports/types';
@@ -96,7 +97,7 @@ export class BrowserClient extends BaseClient<BrowserClientOptions> {
9697
*/
9798
public captureUserFeedback(feedback: UserFeedback): void {
9899
if (!this._isEnabled()) {
99-
__DEBUG_BUILD__ && logger.warn('SDK not enabled, will not capture user feedback.');
100+
DEBUG_BUILD && logger.warn('SDK not enabled, will not capture user feedback.');
100101
return;
101102
}
102103

@@ -123,17 +124,17 @@ export class BrowserClient extends BaseClient<BrowserClientOptions> {
123124
const outcomes = this._clearOutcomes();
124125

125126
if (outcomes.length === 0) {
126-
__DEBUG_BUILD__ && logger.log('No outcomes to send');
127+
DEBUG_BUILD && logger.log('No outcomes to send');
127128
return;
128129
}
129130

130131
// This is really the only place where we want to check for a DSN and only send outcomes then
131132
if (!this._dsn) {
132-
__DEBUG_BUILD__ && logger.log('No dsn provided, will not send outcomes');
133+
DEBUG_BUILD && logger.log('No dsn provided, will not send outcomes');
133134
return;
134135
}
135136

136-
__DEBUG_BUILD__ && logger.log('Sending outcomes:', outcomes);
137+
DEBUG_BUILD && logger.log('Sending outcomes:', outcomes);
137138

138139
const envelope = createClientReportEnvelope(outcomes, this._options.tunnel && dsnToString(this._dsn));
139140
void this._sendEnvelope(envelope);

packages/browser/src/debug-build.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare const __DEBUG_BUILD__: boolean;
2+
3+
/**
4+
* This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
5+
*
6+
* ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
7+
*/
8+
export const DEBUG_BUILD = __DEBUG_BUILD__;

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
severityLevelFromString,
3131
} from '@sentry/utils';
3232

33+
import { DEBUG_BUILD } from '../debug-build';
3334
import { getClient } from '../exports';
3435
import { WINDOW } from '../helpers';
3536

@@ -148,7 +149,7 @@ function _domBreadcrumb(dom: BreadcrumbsOptions['dom']): (handlerData: HandlerDa
148149
let maxStringLength =
149150
typeof dom === 'object' && typeof dom.maxStringLength === 'number' ? dom.maxStringLength : undefined;
150151
if (maxStringLength && maxStringLength > MAX_ALLOWED_STRING_LENGTH) {
151-
__DEBUG_BUILD__ &&
152+
DEBUG_BUILD &&
152153
logger.warn(
153154
`\`dom.maxStringLength\` cannot exceed ${MAX_ALLOWED_STRING_LENGTH}, but a value of ${maxStringLength} was configured. Sentry will use ${MAX_ALLOWED_STRING_LENGTH} instead.`,
154155
);

packages/browser/src/integrations/dedupe.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { Event, Exception, Integration, StackFrame } from '@sentry/types';
22
import { logger } from '@sentry/utils';
33

4+
import { DEBUG_BUILD } from '../debug-build';
5+
46
/** Deduplication filter */
57
export class Dedupe implements Integration {
68
/**
@@ -40,7 +42,7 @@ export class Dedupe implements Integration {
4042
// Juuust in case something goes wrong
4143
try {
4244
if (_shouldDropEvent(currentEvent, this._previousEvent)) {
43-
__DEBUG_BUILD__ && logger.warn('Event dropped due to being a duplicate of previously captured event.');
45+
DEBUG_BUILD && logger.warn('Event dropped due to being a duplicate of previously captured event.');
4446
return null;
4547
}
4648
} catch (_oO) {} // eslint-disable-line no-empty

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '@sentry/utils';
1313

1414
import type { BrowserClient } from '../client';
15+
import { DEBUG_BUILD } from '../debug-build';
1516
import { eventFromUnknownInput } from '../eventbuilder';
1617
import { shouldIgnoreOnError } from '../helpers';
1718

@@ -254,7 +255,7 @@ function _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column
254255
}
255256

256257
function globalHandlerLog(type: string): void {
257-
__DEBUG_BUILD__ && logger.log(`Global Handler attached: ${type}`);
258+
DEBUG_BUILD && logger.log(`Global Handler attached: ${type}`);
258259
}
259260

260261
function getHubAndOptions(): [Hub, StackParser, boolean | undefined] {

packages/browser/src/profiling/hubextensions.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { Transaction } from '@sentry/types';
33
import { logger, timestampInSeconds, uuid4 } from '@sentry/utils';
44

5+
import { DEBUG_BUILD } from '../debug-build';
56
import { WINDOW } from '../helpers';
67
import type { JSSelfProfile } from './jsSelfProfiling';
78
import {
@@ -21,7 +22,7 @@ import {
2122
*/
2223
export function onProfilingStartRouteTransaction(transaction: Transaction | undefined): Transaction | undefined {
2324
if (!transaction) {
24-
if (__DEBUG_BUILD__) {
25+
if (DEBUG_BUILD) {
2526
logger.log('[Profiling] Transaction is undefined, skipping profiling');
2627
}
2728
return transaction;
@@ -54,7 +55,7 @@ export function startProfileForTransaction(transaction: Transaction): Transactio
5455
return transaction;
5556
}
5657

57-
if (__DEBUG_BUILD__) {
58+
if (DEBUG_BUILD) {
5859
logger.log(`[Profiling] started profiling transaction: ${transaction.name || transaction.description}`);
5960
}
6061

@@ -85,7 +86,7 @@ export function startProfileForTransaction(transaction: Transaction): Transactio
8586
return null;
8687
}
8788
if (processedProfile) {
88-
if (__DEBUG_BUILD__) {
89+
if (DEBUG_BUILD) {
8990
logger.log(
9091
'[Profiling] profile for:',
9192
transaction.name || transaction.description,
@@ -103,13 +104,13 @@ export function startProfileForTransaction(transaction: Transaction): Transactio
103104
maxDurationTimeoutID = undefined;
104105
}
105106

106-
if (__DEBUG_BUILD__) {
107+
if (DEBUG_BUILD) {
107108
logger.log(`[Profiling] stopped profiling of transaction: ${transaction.name || transaction.description}`);
108109
}
109110

110111
// In case of an overlapping transaction, stopProfiling may return null and silently ignore the overlapping profile.
111112
if (!profile) {
112-
if (__DEBUG_BUILD__) {
113+
if (DEBUG_BUILD) {
113114
logger.log(
114115
`[Profiling] profiler returned null profile for: ${transaction.name || transaction.description}`,
115116
'this may indicate an overlapping transaction or a call to stopProfiling with a profile title that was never started',
@@ -122,7 +123,7 @@ export function startProfileForTransaction(transaction: Transaction): Transactio
122123
return null;
123124
})
124125
.catch(error => {
125-
if (__DEBUG_BUILD__) {
126+
if (DEBUG_BUILD) {
126127
logger.log('[Profiling] error while stopping profiler:', error);
127128
}
128129
return null;
@@ -131,7 +132,7 @@ export function startProfileForTransaction(transaction: Transaction): Transactio
131132

132133
// Enqueue a timeout to prevent profiles from running over max duration.
133134
let maxDurationTimeoutID: number | undefined = WINDOW.setTimeout(() => {
134-
if (__DEBUG_BUILD__) {
135+
if (DEBUG_BUILD) {
135136
logger.log(
136137
'[Profiling] max profile duration elapsed, stopping profiling for:',
137138
transaction.name || transaction.description,

packages/browser/src/profiling/integration.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { EventProcessor, Hub, Integration, Transaction } from '@sentry/type
22
import type { Profile } from '@sentry/types/src/profiling';
33
import { logger } from '@sentry/utils';
44

5+
import { DEBUG_BUILD } from '../debug-build';
56
import { startProfileForTransaction } from './hubextensions';
67
import type { ProfiledEvent } from './utils';
78
import {
@@ -78,14 +79,12 @@ export class BrowserProfilingIntegration implements Integration {
7879
const start_timestamp = context && context['profile'] && context['profile']['start_timestamp'];
7980

8081
if (typeof profile_id !== 'string') {
81-
__DEBUG_BUILD__ &&
82-
logger.log('[Profiling] cannot find profile for a transaction without a profile context');
82+
DEBUG_BUILD && logger.log('[Profiling] cannot find profile for a transaction without a profile context');
8383
continue;
8484
}
8585

8686
if (!profile_id) {
87-
__DEBUG_BUILD__ &&
88-
logger.log('[Profiling] cannot find profile for a transaction without a profile context');
87+
DEBUG_BUILD && logger.log('[Profiling] cannot find profile for a transaction without a profile context');
8988
continue;
9089
}
9190

@@ -96,7 +95,7 @@ export class BrowserProfilingIntegration implements Integration {
9695

9796
const profile = takeProfileFromGlobalCache(profile_id);
9897
if (!profile) {
99-
__DEBUG_BUILD__ && logger.log(`[Profiling] Could not retrieve profile for transaction: ${profile_id}`);
98+
DEBUG_BUILD && logger.log(`[Profiling] Could not retrieve profile for transaction: ${profile_id}`);
10099
continue;
101100
}
102101

0 commit comments

Comments
 (0)