next-axiom
next-axiom copied to clipboard
How to i set up axiom with getServerSideProps while using Next-Redux-Wrapper ??
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 The code looks fine, what is the problem you are facing? receiving an error?
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 ?
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.
i have implemented what you suggested and its working now, Thank you vert much @schehata
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.