I need to have access to App Insights (3rd-part library) object across different pages in Next.js app. The goal is to initialize object once and then use its methods in different pages. To check if object is the same in different pages I added date property with Date.now() value:
const appInsights = new ApplicationInsights({
config: {
instrumentationKey: <key>,
/* ...Other Configuration Options... */
},
});
appInsights.loadAppInsights();
const ai = { ai: appInsights, date: Date.now() };
I was trying with Redux custom middleware (using redux-persist), but unfortunately every page visit triggers new object creation.
Do you know any solution that could help me?