next-axiom icon indicating copy to clipboard operation
next-axiom copied to clipboard

How to i set up axiom with getServerSideProps while using Next-Redux-Wrapper ??

Open DevYemi opened this issue 3 years ago • 1 comments

i'm using next-redux-wrapper to get redux store on the server side., i'm trying to console.log() the token in production to debug an issue i'm having So i'm using axiom like this

import { wrapper } from '../redux/store'
import { log } from 'next-axiom';

export const getServerSideProps = wrapper.getServerSideProps((store) => async () => {

  const token = store.getState().auth.token;
  console.log(token);
 log.info('CONSOLE.LOGGING MY TOKEN', { Type: 'YOUR TOKEN ', Token: token })
  if (token) return {
    redirect: { destination: '/dashboard', permanent: false, }
  } // Redirect to Dashboard if there is a token

  return { props: {} }
})

But i don't think i'm going about it the right way, please can you help me out

DevYemi avatar Sep 02 '22 14:09 DevYemi

@DevYemi The code looks fine, what is the problem you are facing? receiving an error?

thesollyz avatar Sep 05 '22 08:09 thesollyz

No actually I'm not and everything works fine except i thought i would be able to log out server side information in production app and view them in the axiom dashboard-streams.

I'm trying to debug an issue on my app which is token seems to become null in production, so i want to send the token value in my getServerSideProps function and view it in axiom-dashboad-streams but when ever i deploy and route to my website i only see the request informations in my axiom dashboard-streams.

so how can i send information from my getServerSideProps function to axiom-dashboard-streams page on each visit ?

DevYemi avatar Sep 06 '22 19:09 DevYemi

No actually I'm not and everything works fine except i thought i would be able to log out server side information in production app and view them in the axiom dashboard-streams.

I'm trying to debug an issue on my app which is token seems to become null in production, so i want to send the token value in my getServerSideProps function and view it in axiom-dashboad-streams but when ever i deploy and route to my website i only see the request informations in my axiom dashboard-streams.

so how can i send information from my getServerSideProps function to axiom-dashboard-streams page on each visit ?

can you try to use the same code you mentioned above but call await log.flush() at the end of the function? I think the code should work, but because the requests are async, probably the function is ending before the request is sent.

thesollyz avatar Sep 07 '22 09:09 thesollyz

i have implemented what you suggested and its working now, Thank you vert much @schehata

DevYemi avatar Sep 07 '22 12:09 DevYemi

i have implemented what you suggested and its working now, Thank you vert much @schehata

awesome! Glad it worked out for you, let us know if you face any more issues, glad to help any time.

thesollyz avatar Sep 07 '22 12:09 thesollyz