Skip to content

Commit fd4f65a

Browse files
authored
Merge branch 'develop' into sig/import-flag-default
2 parents d09d645 + f4970f1 commit fd4f65a

File tree

42 files changed

+223
-91
lines changed

Some content is hidden

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

42 files changed

+223
-91
lines changed

dev-packages/e2e-tests/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ EOF
5757

5858
Make sure to add a `test:build` and `test:assert` command to the new app's `package.json` file.
5959

60-
Add the new test app to `test-application` matrix in `.github/workflows/build.yml` for the `job_e2e_tests` job. If you
61-
want to run a canary test, add it to the `canary.yml` workflow.
60+
Test apps in the folder `test-applications` will be automatically picked up by CI in the job `job_e2e_tests` (in `.github/workflows/build.yml`).
61+
The test matrix for CI is generated in `dev-packages/e2e-tests/lib/getTestMatrix.ts`.
62+
63+
For each test app, CI checks its dependencies (and devDependencies) to see if any of them have changed in the current PR (based on nx affected projects).
64+
For example, if something is changed in the browser package, only E2E test apps that depend on browser will run, while others will be skipped.
65+
66+
You can add additional information about the test (e.g. canary versions, optional in CI) by adding `sentryTest` in the `package.json`
67+
of a test application.
6268

6369
**An important thing to note:** In the context of the build/test commands the fake test registry is available at
6470
`http://127.0.0.1:4873`. It hosts all of our packages as if they were to be published with the state of the current

dev-packages/node-integration-tests/suites/sessions/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import express from 'express';
1313

1414
const app = express();
1515

16+
// eslint-disable-next-line deprecation/deprecation
1617
const flusher = (Sentry.getClient() as Sentry.NodeClient)['_sessionFlusher'] as SessionFlusher;
1718

1819
// Flush after 2 seconds (to avoid waiting for the default 60s)

docs/migration/draft-v9-migration-guide.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
- Deprecated `addTracingHeadersToFetchRequest` method - this was only meant for internal use and is not needed anymore.
4848
- Deprecated `generatePropagationContext()` in favor of using `generateTraceId()` directly.
4949
- Deprecated `spanId` field on `propagationContext` - this field will be removed in v9, and should neither be read or set anymore.
50+
- Deprecated `RequestSession` type. No replacements.
51+
- Deprecated `RequestSessionStatus` type. No replacements.
52+
- Deprecated `SessionFlusherLike` type. No replacements.
53+
- Deprecated `SessionFlusher`. No replacements.
5054

5155
## `@sentry/nestjs`
5256

@@ -69,6 +73,9 @@
6973
- **The `@sentry/types` package has been deprecated. Import everything from `@sentry/core` instead.**
7074

7175
- Deprecated `Request` in favor of `RequestEventData`.
76+
- Deprecated `RequestSession`. No replacements.
77+
- Deprecated `RequestSessionStatus`. No replacements.
78+
- Deprecated `SessionFlusherLike`. No replacements.
7279

7380
## `@sentry/nuxt`
7481

packages/angular/src/tracing.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ export class TraceDirective implements OnInit, AfterViewInit {
271271
* @inheritdoc
272272
*/
273273
public ngAfterViewInit(): void {
274-
if (this._tracingSpan) {
275-
runOutsideAngular(() => this._tracingSpan!.end());
274+
const span = this._tracingSpan;
275+
if (span) {
276+
runOutsideAngular(() => span.end());
276277
}
277278
}
278279
}
@@ -302,8 +303,7 @@ export function TraceClass(options?: TraceClassOptions): ClassDecorator {
302303
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
303304
return target => {
304305
const originalOnInit = target.prototype.ngOnInit;
305-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
306-
target.prototype.ngOnInit = function (...args: any[]): ReturnType<typeof originalOnInit> {
306+
target.prototype.ngOnInit = function (...args: unknown[]): ReturnType<typeof originalOnInit> {
307307
tracingSpan = runOutsideAngular(() =>
308308
startInactiveSpan({
309309
onlyIfParent: true,
@@ -321,8 +321,7 @@ export function TraceClass(options?: TraceClassOptions): ClassDecorator {
321321
};
322322

323323
const originalAfterViewInit = target.prototype.ngAfterViewInit;
324-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
325-
target.prototype.ngAfterViewInit = function (...args: any[]): ReturnType<typeof originalAfterViewInit> {
324+
target.prototype.ngAfterViewInit = function (...args: unknown[]): ReturnType<typeof originalAfterViewInit> {
326325
if (tracingSpan) {
327326
runOutsideAngular(() => tracingSpan.end());
328327
}
@@ -345,11 +344,9 @@ interface TraceMethodOptions {
345344
* Decorator function that can be used to capture a single lifecycle methods of the component.
346345
*/
347346
export function TraceMethod(options?: TraceMethodOptions): MethodDecorator {
348-
// eslint-disable-next-line @typescript-eslint/ban-types
349-
return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
347+
return (_target: unknown, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
350348
const originalMethod = descriptor.value;
351-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
352-
descriptor.value = function (...args: any[]): ReturnType<typeof originalMethod> {
349+
descriptor.value = function (...args: unknown[]): ReturnType<typeof originalMethod> {
353350
const now = timestampInSeconds();
354351

355352
runOutsideAngular(() => {

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@ function _eventFromRejectionWithPrimitive(reason: Primitive): Event {
153153
};
154154
}
155155

156-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
157-
function _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column: any): Event {
156+
function _enhanceEventWithInitialFrame(
157+
event: Event,
158+
url: string | undefined,
159+
line: number | undefined,
160+
column: number | undefined,
161+
): Event {
158162
// event.exception
159163
const e = (event.exception = event.exception || {});
160164
// event.exception.values
@@ -166,8 +170,8 @@ function _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column
166170
// event.exception.values[0].stacktrace.frames
167171
const ev0sf = (ev0s.frames = ev0s.frames || []);
168172

169-
const colno = isNaN(parseInt(column, 10)) ? undefined : column;
170-
const lineno = isNaN(parseInt(line, 10)) ? undefined : line;
173+
const colno = column;
174+
const lineno = line;
171175
const filename = isString(url) && url.length > 0 ? url : getLocationHref();
172176

173177
// event.exception.values[0].stacktrace.frames

packages/browser/src/sdk.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export function init(browserOptions: BrowserOptions = {}): Client | undefined {
198198
* All properties the report dialog supports
199199
*/
200200
export interface ReportDialogOptions {
201+
// TODO(v9): Change this to [key: string]: unknkown;
201202
// eslint-disable-next-line @typescript-eslint/no-explicit-any
202203
[key: string]: any;
203204
eventId?: string;

packages/core/src/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export function getEnvelopeEndpointWithUrlEncodedAuth(dsn: DsnComponents, tunnel
4747
export function getReportDialogEndpoint(
4848
dsnLike: DsnLike,
4949
dialogOptions: {
50+
// TODO(v9): Change this to [key: string]: unknown;
5051
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5152
[key: string]: any;
5253
user?: { name?: string; email?: string };

packages/core/src/baseclient.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
158158
/**
159159
* @inheritDoc
160160
*/
161-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
162-
public captureException(exception: any, hint?: EventHint, scope?: Scope): string {
161+
public captureException(exception: unknown, hint?: EventHint, scope?: Scope): string {
163162
const eventId = uuid4();
164163

165164
// ensure we haven't captured this very object before
@@ -915,8 +914,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
915914
/**
916915
* @inheritDoc
917916
*/
918-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
919-
public abstract eventFromException(_exception: any, _hint?: EventHint): PromiseLike<Event>;
917+
public abstract eventFromException(_exception: unknown, _hint?: EventHint): PromiseLike<Event>;
920918

921919
/**
922920
* @inheritDoc

packages/core/src/envelope.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import type {
77
Event,
88
EventEnvelope,
99
EventItem,
10+
LegacyCSPReport,
11+
RawSecurityEnvelope,
12+
RawSecurityItem,
1013
SdkInfo,
1114
SdkMetadata,
1215
Session,
@@ -24,6 +27,7 @@ import {
2427
createSpanEnvelopeItem,
2528
getSdkMetadataForEnvelopeHeader,
2629
} from './utils-hoist/envelope';
30+
import { uuid4 } from './utils-hoist/misc';
2731
import { showSpanDropWarning, spanToJSON } from './utils/spanUtils';
2832

2933
/**
@@ -141,3 +145,26 @@ export function createSpanEnvelope(spans: [SentrySpan, ...SentrySpan[]], client?
141145

142146
return createEnvelope<SpanEnvelope>(headers, items);
143147
}
148+
149+
/**
150+
* Create an Envelope from a CSP report.
151+
*/
152+
export function createRawSecurityEnvelope(
153+
report: LegacyCSPReport,
154+
dsn: DsnComponents,
155+
tunnel?: string,
156+
release?: string,
157+
environment?: string,
158+
): RawSecurityEnvelope {
159+
const envelopeHeaders = {
160+
event_id: uuid4(),
161+
...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),
162+
};
163+
164+
const eventItem: RawSecurityItem = [
165+
{ type: 'raw_security', sentry_release: release, sentry_environment: environment },
166+
report,
167+
];
168+
169+
return createEnvelope<RawSecurityEnvelope>(envelopeHeaders, [eventItem]);
170+
}

packages/core/src/exports.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ import { parseEventHintOrCaptureContext } from './utils/prepareEvent';
3434
* @param hint Optional additional data to attach to the Sentry event.
3535
* @returns the id of the captured Sentry event.
3636
*/
37-
export function captureException(
38-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
39-
exception: any,
40-
hint?: ExclusiveEventHintOrCaptureContext,
41-
): string {
37+
export function captureException(exception: unknown, hint?: ExclusiveEventHintOrCaptureContext): string {
4238
return getCurrentScope().captureException(exception, parseEventHintOrCaptureContext(hint));
4339
}
4440

@@ -73,8 +69,7 @@ export function captureEvent(event: Event, hint?: EventHint): string {
7369
* @param name of the context
7470
* @param context Any kind of data. This data will be normalized.
7571
*/
76-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
77-
export function setContext(name: string, context: { [key: string]: any } | null): void {
72+
export function setContext(name: string, context: { [key: string]: unknown } | null): void {
7873
getIsolationScope().setContext(name, context);
7974
}
8075

0 commit comments

Comments
 (0)