Files
spacedrive/interface/app/onboarding/Layout.tsx
Oscar Beaumont 66fe8d1814 [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

66 lines
2.2 KiB
TypeScript

import BloomOne from '@sd/assets/images/bloom-one.png';
import clsx from 'clsx';
import { useEffect } from 'react';
import { Outlet, useNavigate } from 'react-router';
import { getOnboardingStore, useDebugState } from '@sd/client';
import { tw } from '@sd/ui';
import DragRegion from '~/components/DragRegion';
import { useOperatingSystem } from '~/hooks/useOperatingSystem';
import DebugPopover from '../$libraryId/Layout/Sidebar/DebugPopover';
import Progress from './Progress';
export const OnboardingContainer = tw.div`flex flex-col items-center`;
export const OnboardingTitle = tw.h2`mb-2 text-3xl font-bold`;
export const OnboardingDescription = tw.p`max-w-xl text-center text-ink-dull`;
export const OnboardingImg = tw.img`w-20 h-20 mb-2`;
export default () => {
const os = useOperatingSystem();
const debugState = useDebugState();
const navigate = useNavigate();
useEffect(
() => {
const obStore = getOnboardingStore();
// This is neat because restores the last active screen, but only if it is not the starting screen
// Ignoring if people navigate back to the start if progress has been made
if (obStore.unlockedScreens.length > 1) {
navigate(`/onboarding/${obStore.lastActiveScreen}`);
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
return (
<div
className={clsx(
macOnly(os, 'bg-opacity-[0.75]'),
'bg-sidebar text-ink flex h-screen flex-col'
)}
>
<DragRegion className="z-50 h-9" />
<div className="-mt-5 flex grow flex-col p-10">
<div className="flex grow flex-col items-center justify-center">
<Outlet />
</div>
<Progress />
</div>
<div className="flex justify-center p-4">
<p className="text-ink-dull text-xs opacity-50">&copy; 2022 Spacedrive Technology Inc.</p>
</div>
<div className="absolute -z-10">
<div className="relative h-screen w-screen">
<img src={BloomOne} className="absolute h-[2000px] w-[2000px]" />
{/* <img src={BloomThree} className="absolute w-[2000px] h-[2000px] -right-[200px]" /> */}
</div>
</div>
{debugState.enabled && <DebugPopover />}
</div>
);
};
const macOnly = (platform: string | undefined, classnames: string) =>
platform === 'macOS' ? classnames : '';