Skip to content

Commit d2ac2e6

Browse files
committed
add flags to NextApiHandler and WrappedNextApiHandler types
1 parent 98b83df commit d2ac2e6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/nextjs/src/utils/withSentry.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,18 @@ import { NextApiRequest, NextApiResponse } from 'next';
2828
// the test app would refer to the other version of the type (from the test app's `node_modules`). By using a custom
2929
// version of the type compatible with both the old and new official versions, we can use any Next version we want in
3030
// a test app without worrying about type errors.
31-
type NextApiHandler = (req: NextApiRequest, res: NextApiResponse) => void | Promise<void> | unknown | Promise<unknown>;
32-
export type WrappedNextApiHandler = (req: NextApiRequest, res: NextApiResponse) => Promise<void> | Promise<unknown>;
31+
32+
// TODO: fix the comments above and explain extra properties
33+
export type NextApiHandler = {
34+
__sentry_route__?: string;
35+
(req: NextApiRequest, res: NextApiResponse): void | Promise<void> | unknown | Promise<unknown>;
36+
};
37+
38+
export type WrappedNextApiHandler = {
39+
__sentry_route__?: string;
40+
__sentry_wrapped__?: boolean;
41+
(req: NextApiRequest, res: NextApiResponse): Promise<void> | Promise<unknown>;
42+
};
3343

3444
export type AugmentedNextApiResponse = NextApiResponse & {
3545
__sentryTransaction?: Transaction;

0 commit comments

Comments
 (0)