From 0624132e7cf04d50c43c392a0aeefb0820da8235 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 30 Dec 2024 16:32:08 +0100 Subject: [PATCH 1/2] ref(core): Cleanup internal types --- package.json | 2 +- packages/browser-utils/src/metrics/inp.ts | 3 +-- packages/browser/src/sdk.ts | 4 +--- packages/core/src/api.ts | 4 +--- packages/core/src/types-hoist/wrappedfunction.ts | 2 -- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 3cca23c174fe..bf053a5c7c4d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "circularDepCheck": "lerna run circularDepCheck", "clean": "run-s clean:build clean:caches", "clean:build": "lerna run clean", - "clean:caches": "yarn rimraf eslintcache .nxcache && yarn jest --clearCache", + "clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache", "clean:deps": "lerna clean --yes && rm -rf node_modules && yarn", "clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz", "clean:watchman": "watchman watch-del \".\"", diff --git a/packages/browser-utils/src/metrics/inp.ts b/packages/browser-utils/src/metrics/inp.ts index 7ef99b4d32fd..924104c28b6a 100644 --- a/packages/browser-utils/src/metrics/inp.ts +++ b/packages/browser-utils/src/metrics/inp.ts @@ -127,9 +127,8 @@ function _trackINP(): () => void { /** * Register a listener to cache route information for INP interactions. - * TODO(v9): `latestRoute` no longer needs to be passed in and will be removed in v9. */ -export function registerInpInteractionListener(_latestRoute?: unknown): void { +export function registerInpInteractionListener(): void { const handleEntries = ({ entries }: { entries: PerformanceEntry[] }): void => { const activeSpan = getActiveSpan(); const activeRootSpan = activeSpan && getRootSpan(activeSpan); diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts index a698111c5baa..70c22370b8c1 100644 --- a/packages/browser/src/sdk.ts +++ b/packages/browser/src/sdk.ts @@ -204,9 +204,7 @@ export function init(browserOptions: BrowserOptions = {}): Client | undefined { * All properties the report dialog supports */ export interface ReportDialogOptions { - // TODO(v9): Change this to [key: string]: unknkown; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; + [key: string]: unknown; eventId?: string; dsn?: DsnLike; user?: { diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index 23b0306d2e27..8d209eace1e7 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -47,9 +47,7 @@ export function getEnvelopeEndpointWithUrlEncodedAuth(dsn: DsnComponents, tunnel export function getReportDialogEndpoint( dsnLike: DsnLike, dialogOptions: { - // TODO(v9): Change this to [key: string]: unknown; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; + [key: string]: unknown; user?: { name?: string; email?: string }; }, ): string { diff --git a/packages/core/src/types-hoist/wrappedfunction.ts b/packages/core/src/types-hoist/wrappedfunction.ts index 91960b0d59fb..991e05d43a4b 100644 --- a/packages/core/src/types-hoist/wrappedfunction.ts +++ b/packages/core/src/types-hoist/wrappedfunction.ts @@ -3,8 +3,6 @@ */ // eslint-disable-next-line @typescript-eslint/ban-types export type WrappedFunction = T & { - // TODO(v9): Remove this - [key: string]: any; __sentry_wrapped__?: WrappedFunction; __sentry_original__?: T; }; From 3bfcc1adca0f1bfee20265cae49ee49b0b183305 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 3 Jan 2025 13:01:58 +0100 Subject: [PATCH 2/2] move report dialog options type to core & add to changelog --- docs/migration/v8-to-v9.md | 1 + packages/browser/src/exports.ts | 3 +-- packages/browser/src/sdk.ts | 31 +----------------------------- packages/core/src/api.ts | 9 ++------- packages/core/src/index.ts | 1 + packages/core/src/report-dialog.ts | 29 ++++++++++++++++++++++++++++ 6 files changed, 35 insertions(+), 39 deletions(-) create mode 100644 packages/core/src/report-dialog.ts diff --git a/docs/migration/v8-to-v9.md b/docs/migration/v8-to-v9.md index 56bf9c8bf9c4..a3f08fa9f8f1 100644 --- a/docs/migration/v8-to-v9.md +++ b/docs/migration/v8-to-v9.md @@ -226,6 +226,7 @@ Since v9, the types have been merged into `@sentry/core`, which removed some of - The `IntegrationClass` type is no longer exported - it was not used anymore. Instead, use `Integration` or `IntegrationFn`. - The `samplingContext.request` attribute in the `tracesSampler` has been removed. Use `samplingContext.normalizedRequest` instead. Note that the type of `normalizedRequest` differs from `request`. - `Client` now always expects the `BaseClient` class - there is no more abstract `Client` that can be implemented! Any `Client` class has to extend from `BaseClient`. +- `ReportDialogOptions` now extends `Record` instead of `Record` - this should not affect most users. # No Version Support Timeline diff --git a/packages/browser/src/exports.ts b/packages/browser/src/exports.ts index 0eed33b48349..289643a6c6c0 100644 --- a/packages/browser/src/exports.ts +++ b/packages/browser/src/exports.ts @@ -13,12 +13,11 @@ export type { Thread, User, Session, + ReportDialogOptions, } from '@sentry/core'; export type { BrowserOptions } from './client'; -export type { ReportDialogOptions } from './sdk'; - export { addEventProcessor, addBreadcrumb, diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts index 70c22370b8c1..c2665c678497 100644 --- a/packages/browser/src/sdk.ts +++ b/packages/browser/src/sdk.ts @@ -1,4 +1,4 @@ -import type { Client, DsnLike, Integration, Options } from '@sentry/core'; +import type { Client, Integration, Options, ReportDialogOptions } from '@sentry/core'; import { consoleSandbox, dedupeIntegration, @@ -200,35 +200,6 @@ export function init(browserOptions: BrowserOptions = {}): Client | undefined { return initAndBind(BrowserClient, clientOptions); } -/** - * All properties the report dialog supports - */ -export interface ReportDialogOptions { - [key: string]: unknown; - eventId?: string; - dsn?: DsnLike; - user?: { - email?: string; - name?: string; - }; - lang?: string; - title?: string; - subtitle?: string; - subtitle2?: string; - labelName?: string; - labelEmail?: string; - labelComments?: string; - labelClose?: string; - labelSubmit?: string; - errorGeneric?: string; - errorFormEntry?: string; - successMessage?: string; - /** Callback after reportDialog showed up */ - onLoad?(this: void): void; - /** Callback after reportDialog closed */ - onClose?(this: void): void; -} - /** * Present the user with a report dialog. * diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index 8d209eace1e7..0c0e75176c61 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -1,3 +1,4 @@ +import type { ReportDialogOptions } from './report-dialog'; import type { DsnComponents, DsnLike, SdkInfo } from './types-hoist'; import { dsnToString, makeDsn } from './utils-hoist/dsn'; @@ -44,13 +45,7 @@ export function getEnvelopeEndpointWithUrlEncodedAuth(dsn: DsnComponents, tunnel } /** Returns the url to the report dialog endpoint. */ -export function getReportDialogEndpoint( - dsnLike: DsnLike, - dialogOptions: { - [key: string]: unknown; - user?: { name?: string; email?: string }; - }, -): string { +export function getReportDialogEndpoint(dsnLike: DsnLike, dialogOptions: ReportDialogOptions): string { const dsn = makeDsn(dsnLike); if (!dsn) { return ''; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 1cd8fcb6c2f3..4db93399d550 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -111,6 +111,7 @@ export { } from './fetch'; export { trpcMiddleware } from './trpc'; export { captureFeedback } from './feedback'; +export type { ReportDialogOptions } from './report-dialog'; // eslint-disable-next-line deprecation/deprecation export { getCurrentHubShim, getCurrentHub } from './getCurrentHubShim'; diff --git a/packages/core/src/report-dialog.ts b/packages/core/src/report-dialog.ts new file mode 100644 index 000000000000..fb91aec441b2 --- /dev/null +++ b/packages/core/src/report-dialog.ts @@ -0,0 +1,29 @@ +import type { DsnLike } from './types-hoist/dsn'; + +/** + * All properties the report dialog supports + */ +export interface ReportDialogOptions extends Record { + eventId?: string; + dsn?: DsnLike; + user?: { + email?: string; + name?: string; + }; + lang?: string; + title?: string; + subtitle?: string; + subtitle2?: string; + labelName?: string; + labelEmail?: string; + labelComments?: string; + labelClose?: string; + labelSubmit?: string; + errorGeneric?: string; + errorFormEntry?: string; + successMessage?: string; + /** Callback after reportDialog showed up */ + onLoad?(this: void): void; + /** Callback after reportDialog closed */ + onClose?(this: void): void; +}