Skip to content

Commit

Permalink
Log the fronend debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarah committed Dec 8, 2023
1 parent 4077e9f commit d95ceec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/researcher/src/app/[locale]/debug/backend.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
'use server';

import {auth} from '@clerk/nextjs';
Expand All @@ -8,13 +9,14 @@ const dateTimeFormat = new Intl.DateTimeFormat('nl', {
timeStyle: 'long',
});

export async function backendLogAction() {
export async function backendLogAction(frontendLog: any) {
const {getToken, sessionId, session, userId} = await auth();
const token = await getToken();
const tokenDecoded = token ? jwtDecode(token) : null;
const date = tokenDecoded?.exp
? dateTimeFormat.format(tokenDecoded?.exp * 1000)
: null;
console.log('DEBUG BUTTON CLICKED: FRONTEND', frontendLog);
console.log('DEBUG BUTTON CLICKED: BACKEND', {
date,
token,
Expand Down
4 changes: 2 additions & 2 deletions apps/researcher/src/app/[locale]/debug/frontend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export function DebugButton() {
const date = tokenDecoded?.exp
? dateTimeFormat.format(tokenDecoded?.exp * 1000)
: null;
console.log('DEBUG BUTTON CLICKED: FRONTEND', {
// Send the frontend data to the backend, so we can log it in Vercel
backendLogAction({
date,
isSignedIn,
token,
tokenDecoded,
sessionId,
});
backendLogAction();
addNotification({
id: 'debugButtonClicked',
message: 'Your data has been logged, please let Barbara know.',
Expand Down

2 comments on commit d95ceec

@vercel
Copy link

@vercel vercel bot commented on d95ceec Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d95ceec Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.