Files
spacedrive/interface/ErrorFallback.tsx
Oscar Beaumont 1f1a2b019b [ENG-227] Desktop app and landing page telemetry using Plausible Analytics (#583)
* add Plausible analytics to landing page

* proxy plausible through vercel

* fix typo & add other options

* add plausible to `sd/client`

* add telemetry sharing option into library config

* add telemetry config option to lib creation dialog

* revert error message change but keep the typo fix

* add telemetry sharing & error handling to client context

* add important note about requiring the tracker component in root/base layouts

* add the `PlausibleTracker`

* grammatical tweaks

* some TS cleanup

* disable analytics in debug mode

* further component improvements and use custom event props

* more cleanup

* remove tracking from onboarding (no telemetry sharing config option)

* update comment

* add fancy new plausible hooks/tracking

* add `pageview` monitoring hook to `$libraryId` layout

* add library creation events to onboarding and creation dialog

* revert `useCurrentLibraryId()` error handling & add important comment

* minor comment tweaks

* replace `usage` with `telemetry`

* add missing newline

* add location create & delete events

* add tag create & delete events

* add/update library create & delete events

* add fn for getting telemetry settings for library by uuid

* add more events + fix a few bugs

* update generics

* add `telemetryState` `valtio` store

* use new telemetry state

* remove old artifacts from `ClientContext`

* Revert "add telemetry sharing option into library config"

This reverts commit afb9f892ab.

* update events, docs & generics

* add `tagAssign` event

* light comment updates

* const names, comments, etc

* add additional info to props and update comment

* add telemetry sharing to debug state (for sharing telemetry in debug mode)

* update `debugState` item name

* change how `Switch` updates the store in privacy settings

* remove `getTelemetryState` from `telemetryState`

* cleanup library creation event handling/telemetry config updating

* add `DebugPopover` to onboarding in debug mode

* improve code quality/comments

* remove useless comment

* rename `ob_store` and `shareTelemetryDataWithDevelopers`

* fix typo

* add `telemetryLogger` and prevent multiple of the same events from firing consecutively

* add more unique path matching and fix an issue with events

* rename `telemetryLogger` -> `telemetryLogging`

---------

Co-authored-by: brxken128 <77554505+brxken128@users.noreply.github.com>
2023-03-09 08:37:57 +00:00

57 lines
1.4 KiB
TypeScript

import { captureException } from '@sentry/browser';
import { FallbackProps } from 'react-error-boundary';
import { useDebugState } from '@sd/client';
import { Button } from '@sd/ui';
export default ({ error, resetErrorBoundary }: FallbackProps) => (
<ErrorPage
message={error.message}
sendReportBtn={() => {
captureException(error);
resetErrorBoundary();
}}
reloadBtn={resetErrorBoundary}
/>
);
export function ErrorPage({
reloadBtn,
sendReportBtn,
message
}: {
reloadBtn?: () => void;
sendReportBtn?: () => void;
message: string;
}) {
const debug = useDebugState();
return (
<div
data-tauri-drag-region
role="alert"
className="border-app-divider bg-app flex h-screen w-screen flex-col items-center justify-center rounded-lg border p-4"
>
<p className="text-ink-faint m-3 text-sm font-bold">APP CRASHED</p>
<h1 className="text-ink text-2xl font-bold">We're past the event horizon...</h1>
<pre className="text-ink m-2">Error: {message}</pre>
{debug.enabled && (
<pre className="text-ink-dull m-2 text-sm">
Check the console (CMD/CTRL + OPTION + i) for stack trace.
</pre>
)}
<div className="text-ink flex flex-row space-x-2">
{reloadBtn && (
<Button variant="accent" className="mt-2" onClick={reloadBtn}>
Reload
</Button>
)}
{sendReportBtn && (
<Button variant="gray" className="mt-2" onClick={sendReportBtn}>
Send report
</Button>
)}
</div>
</div>
);
}