@@ -11,6 +11,8 @@ import * as url from 'url';
11
11
12
12
import * as Sentry from '../index.server' ;
13
13
14
+ console . log ( 'logger: ' , logger ) ;
15
+
14
16
// eslint-disable-next-line @typescript-eslint/no-explicit-any
15
17
type PlainObject < T = any > = { [ key : string ] : T } ;
16
18
@@ -96,6 +98,8 @@ export function instrumentServer(): void {
96
98
// handled and the wrapped `Server.findPageComponents` is called:
97
99
// Replace URL in transaction name with parameterized version
98
100
101
+ console . log ( 'in instrumentServer()' ) ;
102
+
99
103
const nextServerPrototype = Object . getPrototypeOf ( createNextServer ( { } ) ) ;
100
104
fill ( nextServerPrototype , 'getServerRequestHandler' , makeWrappedHandlerGetter ) ;
101
105
}
@@ -108,9 +112,12 @@ export function instrumentServer(): void {
108
112
* @returns A wrapped version of the same method, to monkeypatch in at server startup
109
113
*/
110
114
function makeWrappedHandlerGetter ( origHandlerGetter : HandlerGetter ) : WrappedHandlerGetter {
115
+ console . log ( 'in makeWrappedHandlerGetter' ) ;
111
116
// We wrap this purely in order to be able to grab data and do further monkeypatching the first time it runs.
112
117
// Otherwise, it's just a pass-through to the original method.
113
118
const wrappedHandlerGetter = async function ( this : NextServer ) : Promise < ReqHandler > {
119
+ console . log ( 'in wrappedHandlerGetter' ) ;
120
+
114
121
if ( ! sdkSetupComplete ) {
115
122
try {
116
123
// `SENTRY_SERVER_INIT_PATH` is set at build time, and points to a webpack-processed version of the user's
@@ -157,7 +164,11 @@ function makeWrappedHandlerGetter(origHandlerGetter: HandlerGetter): WrappedHand
157
164
* @returns A wrapped version of that logger
158
165
*/
159
166
function makeWrappedErrorLogger ( origErrorLogger : ErrorLogger ) : WrappedErrorLogger {
167
+ console . log ( 'in makeWrappedErrorLogger' ) ;
168
+
160
169
return function ( this : Server , err : Error ) : void {
170
+ console . log ( 'in wrappedErrorLogger' ) ;
171
+
161
172
// TODO add context data here
162
173
Sentry . captureException ( err ) ;
163
174
return origErrorLogger . call ( this , err ) ;
@@ -188,6 +199,8 @@ function getPublicDirFiles(): Set<string> {
188
199
* @returns A wrapped version of that handler
189
200
*/
190
201
function makeWrappedReqHandler ( origReqHandler : ReqHandler ) : WrappedReqHandler {
202
+ console . log ( 'in makeWrappedReqHandler' ) ;
203
+
191
204
const publicDirFiles = getPublicDirFiles ( ) ;
192
205
// add transaction start and stop to the normal request handling
193
206
const wrappedReqHandler = async function (
@@ -196,6 +209,8 @@ function makeWrappedReqHandler(origReqHandler: ReqHandler): WrappedReqHandler {
196
209
res : NextResponse ,
197
210
parsedUrl ?: url . UrlWithParsedQuery ,
198
211
) : Promise < void > {
212
+ console . log ( 'in wrappedReqHandler' ) ;
213
+
199
214
// wrap everything in a domain in order to prevent scope bleed between requests
200
215
const local = domain . create ( ) ;
201
216
local . add ( req ) ;
@@ -204,6 +219,7 @@ function makeWrappedReqHandler(origReqHandler: ReqHandler): WrappedReqHandler {
204
219
// local.on('error', Sentry.captureException);
205
220
206
221
local . run ( ( ) => {
222
+ console . log ( 'in domain callback' ) ;
207
223
const currentScope = Sentry . getCurrentHub ( ) . getScope ( ) ;
208
224
209
225
if ( currentScope ) {
@@ -274,8 +290,12 @@ function makeWrappedReqHandler(origReqHandler: ReqHandler): WrappedReqHandler {
274
290
function makeWrappedMethodForGettingParameterizedPath (
275
291
origMethod : ApiPageEnsurer | PageComponentFinder ,
276
292
) : WrappedApiPageEnsurer | WrappedPageComponentFinder {
293
+ console . log ( 'in makeWrappedMethodForGettingParameterizedPath' ) ;
294
+ console . log ( 'orig method:' , origMethod ) ;
295
+
277
296
// eslint-disable-next-line @typescript-eslint/no-explicit-any
278
297
const wrappedMethod = async function ( this : Server , parameterizedPath : string , ...args : any [ ] ) : Promise < any > {
298
+ console . log ( 'in wrapped paramaterized path getter' ) ;
279
299
const transaction = getActiveTransaction ( ) ;
280
300
281
301
// replace specific URL with parameterized version
0 commit comments