PluginProbe
Extendify / 0.9.3
Extendify v0.9.3
3.2.3 3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 All 129 releases
extendify / src / Onboarding / hooks / useSentry.js

useSentry.js in Extendify 0.9.3, at src/Onboarding/hooks/useSentry.js

51 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useEffect } from '@wordpress/element'
2 import * as Sentry from '@sentry/react'
3 import { BrowserTracing } from '@sentry/tracing'
4 import { useGlobalStore } from '@onboarding/state/Global'
5 import { usePagesStore } from '@onboarding/state/Pages'
6
7 if (window.extOnbData.insightsEnabled) {
8 Sentry.init({
9 dsn: 'https://[email protected]/6633543',
10 integrations: [new BrowserTracing()],
11 release: window.extOnbData?.version,
12 environment: window?.extOnbData?.devbuild ? 'dev' : 'production',
13
14 // TODO: consider lowering this in production to reduce the amount of data sent
15 tracesSampleRate: 1.0,
16 beforeSend(event) {
17 // Check if it is an exception, and if so, show the report dialog
18 if (event.exception) {
19 Sentry.showReportDialog({ eventId: event.event_id })
20 }
21 return event
22 },
23 })
24 }
25 export { Sentry }
26 export const useSentry = () => {
27 const orderId = useGlobalStore((state) => state.orderId)
28 const { pages, currentPageIndex } = usePagesStore()
29
30 useEffect(() => {
31 Sentry.setUser({ id: window.extOnbData?.insightsId })
32 Sentry.configureScope((scope) => {
33 scope.setExtra('Partner', window.extOnbData?.partnerName)
34 scope.setExtra('Site', window.extOnbData?.home)
35 scope.setExtra('Order ID', orderId)
36 scope.setExtra('Insights ID', window.extOnbData?.insightsId)
37 })
38 }, [orderId])
39
40 useEffect(() => {
41 const p = [...pages].map((p) => p[0])
42 Sentry.addBreadcrumb({
43 type: 'navigation',
44 category: 'step',
45 message: `Navigated to ${p[currentPageIndex]}`,
46 })
47 }, [currentPageIndex, pages])
48
49 return { Sentry }
50 }
51