PromucFlow_constructor/app/client/src/pages/common/AppRoute.tsx

41 lines
890 B
TypeScript
Raw Normal View History

2020-03-11 13:59:46 +00:00
import React, { useEffect } from "react";
2019-12-16 08:49:10 +00:00
import { Route } from "react-router-dom";
2020-03-11 13:59:46 +00:00
import AnalyticsUtil from "utils/AnalyticsUtil";
import * as Sentry from "@sentry/react";
const SentryRoute = Sentry.withSentryRouting(Route);
2020-03-11 13:59:46 +00:00
const AppRoute = ({
component: Component,
...rest
}: {
2020-03-11 13:59:46 +00:00
path?: string;
component: React.ReactType;
exact?: boolean;
2020-03-11 13:59:46 +00:00
logDisable?: boolean;
name: string;
location?: any;
}) => {
2020-03-11 13:59:46 +00:00
useEffect(() => {
if (!rest.logDisable) {
AnalyticsUtil.logEvent("NAVIGATE_EDITOR", {
page: rest.name,
path: rest.location.pathname,
});
}
}, [rest.name, rest.logDisable, rest.location.pathname]);
return (
<SentryRoute
{...rest}
2020-03-11 13:59:46 +00:00
render={props => {
return <Component {...props}></Component>;
2020-03-11 13:59:46 +00:00
}}
/>
);
};
2019-09-02 14:50:01 +00:00
AppRoute.whyDidYouRender = {
logOnDifferentValues: false,
};
2020-03-11 13:59:46 +00:00
export default AppRoute;