From 6bb82192f6ca24f70c0ad0a0dcedbc6d4072c901 Mon Sep 17 00:00:00 2001 From: Danny Miller Date: Sat, 9 Dec 2023 14:20:22 -0500 Subject: [PATCH] disable newrelic when in test --- lib/withAuth.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/withAuth.ts b/lib/withAuth.ts index 0b963ebf1..2ba91db07 100644 --- a/lib/withAuth.ts +++ b/lib/withAuth.ts @@ -45,10 +45,10 @@ export async function getUserFromToken( const decoded = verifiedSignature; const userId = decoded.userId as string; // dynamically import newrelic - const newrelic = await import('newrelic'); + const newrelic = process.env.NODE_ENV === 'test' ? undefined : await import('newrelic'); if (!isLocal()) { - newrelic.addCustomAttribute && newrelic.addCustomAttribute('userId', userId); + newrelic?.addCustomAttribute && newrelic.addCustomAttribute('userId', userId); } await dbConnect();