@stack-spot/portal-observability
v0.1.2
Published
Implements the general observability for a Stackspot web application.
Downloads
1,804
Maintainers
Keywords
Readme
Observability
Implements the general observability for a Stackspot web application.
Datadog
datadogInit({ applicationId, clientToken, env, service })
Use this function when you want to init Datadog. Usually we use this function on App.tsx
.
If you are using Portal MFE. You don't need to use this.
useDatadogSetUser()
Use this function when you want to set user on Datadog. Usually we use this function on main.tsx
.
If you are using Portal MFE. You don't need to use this.
trackError(error: unknown, context?: object | undefined)
Use this function when you want to set errors on Datadog.
import { trackError } from '@stack-spot/portal-observability'
<RawLayout
header={<Header />}
menuSections={<SectionMenu />}
menuContent={<ContentMenu />}
onError={(error) => trackError(error, { scope: 'error-boundary' })}
>
{content}
</RawLayout>
trackPageLoaded(routeDetails: EventPageDetails)
Use this function when you want to track pages on Datadog.
export interface EventPageDetails {
pathNameWithParams: string,
searchParamsWithVariableName?: string,
searchParams?: string,
routeParams?: Record<string, string | string[] | undefined>,
}
getRouteForAnalytics({ route, params }: { route: Record<string, any>, params: Record<string, any> })
This function generates information to about route, usually we use this information combined with trackPageLoaded
function.
import { useRouteData } from 'navigation'
import { getRouteForAnalytics, trackPageLoaded } from '@stack-spot/portal-observability'
const routeInfo = useRouteData()
useEffect(() => {
const routeForAnalytics = getRouteForAnalytics(routeInfo)
trackPageLoaded(routeForAnalytics)
}, [routeInfo.route.$path, routeInfo.params])