mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* essential dapps config: switch to concurrent request and and add worker termination * fix rollbar error logging and enable it for server errors * fix for tokens request on address page * update generator script for multichain config * fix hot contracts interval select * update screenshot * update screenshots * pass chainId to trackTransaction for essential dapps * fix vertical alignment in hot contracts table * bump next.js to v15.5.10 --------- Co-authored-by: isstuev <[email protected]> Co-authored-by: Max Alekseenko <[email protected]>
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import type { NextPageContext } from 'next';
|
|
import NextErrorComponent from 'next/error';
|
|
import React from 'react';
|
|
import Rollbar from 'rollbar';
|
|
|
|
import type { Props as ServerSidePropsCommon } from 'nextjs/getServerSideProps/handlers';
|
|
|
|
import config from 'configs/app';
|
|
import * as cookies from 'lib/cookies';
|
|
|
|
const rollbarFeature = config.features.rollbar;
|
|
const rollbar = rollbarFeature.isEnabled ? new Rollbar({
|
|
accessToken: rollbarFeature.clientToken,
|
|
environment: rollbarFeature.environment,
|
|
payload: {
|
|
code_version: rollbarFeature.codeVersion,
|
|
app_instance: rollbarFeature.instance,
|
|
},
|
|
maxItems: 10,
|
|
captureUncaught: true,
|
|
captureUnhandledRejections: true,
|
|
}) : undefined;
|
|
|
|
type Props = ServerSidePropsCommon & {
|
|
statusCode: number;
|
|
};
|
|
|
|
const CustomErrorComponent = (props: Props) => {
|
|
const colorModeCookie = cookies.getFromCookieString(props.cookies || '', cookies.NAMES.COLOR_MODE);
|
|
return <NextErrorComponent statusCode={ props.statusCode } withDarkMode={ colorModeCookie === 'dark' }/>;
|
|
};
|
|
|
|
CustomErrorComponent.getInitialProps = async(context: NextPageContext) => {
|
|
const { res, err, req } = context;
|
|
|
|
const baseProps = await NextErrorComponent.getInitialProps(context); // Extract cookies from the request headers
|
|
const statusCode = res?.statusCode ?? err?.statusCode;
|
|
const cookies = req?.headers?.cookie || '';
|
|
|
|
if (rollbar) {
|
|
rollbar.error(err?.message ?? 'Unknown error', {
|
|
cause: err?.cause,
|
|
stack: err?.stack,
|
|
});
|
|
}
|
|
|
|
return {
|
|
...baseProps,
|
|
statusCode,
|
|
cookies,
|
|
};
|
|
};
|
|
|
|
export default CustomErrorComponent;
|