diff --git a/src/app/components/telemetry-consent/TelemetryConsentBanner.css.ts b/src/app/components/telemetry-consent/TelemetryConsentBanner.css.ts new file mode 100644 index 00000000..70d9ba0b --- /dev/null +++ b/src/app/components/telemetry-consent/TelemetryConsentBanner.css.ts @@ -0,0 +1,82 @@ +import { keyframes, style } from '@vanilla-extract/css'; +import { color, config, toRem } from 'folds'; + +const slideUp = keyframes({ + from: { + opacity: 0, + transform: 'translateY(100%)', + }, + to: { + opacity: 1, + transform: 'translateY(0)', + }, +}); + +const slideDown = keyframes({ + from: { + opacity: 1, + transform: 'translateY(0)', + }, + to: { + opacity: 0, + transform: 'translateY(100%)', + }, +}); + +export const Container = style({ + position: 'fixed', + bottom: 'env(safe-area-inset-bottom, 0)', + left: '50%', + transform: 'translateX(-50%)', + zIndex: 9998, + width: `min(100%, ${toRem(520)})`, + padding: config.space.S400, + pointerEvents: 'none', +}); + +export const Banner = style({ + pointerEvents: 'all', + display: 'flex', + flexDirection: 'column', + gap: config.space.S300, + backgroundColor: color.Surface.Container, + color: color.Surface.OnContainer, + border: `${config.borderWidth.B300} solid ${color.Surface.ContainerLine}`, + borderRadius: toRem(16), + padding: config.space.S400, + boxShadow: `0 ${toRem(8)} ${toRem(32)} rgba(0, 0, 0, 0.45), 0 ${toRem(2)} ${toRem(8)} rgba(0, 0, 0, 0.3)`, + animationName: slideUp, + animationDuration: '300ms', + animationTimingFunction: 'cubic-bezier(0.22, 0.8, 0.6, 1)', + animationFillMode: 'both', + + selectors: { + '&[data-dismissing=true]': { + animationName: slideDown, + animationDuration: '220ms', + animationTimingFunction: 'cubic-bezier(0.4, 0, 1, 1)', + animationFillMode: 'both', + }, + }, +}); + +export const Header = style({ + display: 'flex', + alignItems: 'flex-start', + gap: config.space.S300, +}); + +export const HeaderText = style({ + flex: 1, + minWidth: 0, + display: 'flex', + flexDirection: 'column', + gap: toRem(4), +}); + +export const Actions = style({ + display: 'flex', + gap: config.space.S200, + justifyContent: 'flex-end', + flexWrap: 'wrap', +}); diff --git a/src/app/components/telemetry-consent/TelemetryConsentBanner.tsx b/src/app/components/telemetry-consent/TelemetryConsentBanner.tsx new file mode 100644 index 00000000..17b4fd30 --- /dev/null +++ b/src/app/components/telemetry-consent/TelemetryConsentBanner.tsx @@ -0,0 +1,81 @@ +import { useEffect, useRef, useState } from 'react'; +import { Box, Button, Icon, IconButton, Icons, Text } from 'folds'; +import * as css from './TelemetryConsentBanner.css'; + +const SENTRY_KEY = 'sable_sentry_enabled'; + +export function TelemetryConsentBanner() { + const isSentryConfigured = Boolean(import.meta.env.VITE_SENTRY_DSN); + const [visible, setVisible] = useState( + isSentryConfigured && localStorage.getItem(SENTRY_KEY) === null + ); + const [dismissing, setDismissing] = useState(false); + const dismissTimerRef = useRef | null>(null); + + useEffect( + () => () => { + if (dismissTimerRef.current) clearTimeout(dismissTimerRef.current); + }, + [] + ); + + if (!visible) return null; + + const handleAcknowledge = () => { + localStorage.setItem(SENTRY_KEY, 'true'); + setDismissing(true); + dismissTimerRef.current = setTimeout(() => setVisible(false), 220); + }; + + const handleOptOut = () => { + localStorage.setItem(SENTRY_KEY, 'false'); + window.location.reload(); + }; + + return ( +
+
+
+ +
+ Crash reporting is enabled + + Sable sends anonymous crash reports to help us fix bugs faster. No messages, room + names, or personal data are included.{' '} + + Learn more + + +
+ + + +
+ + + + +
+
+ ); +} diff --git a/src/app/components/telemetry-consent/index.ts b/src/app/components/telemetry-consent/index.ts new file mode 100644 index 00000000..644d8bda --- /dev/null +++ b/src/app/components/telemetry-consent/index.ts @@ -0,0 +1 @@ +export * from './TelemetryConsentBanner'; diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx index 5a802eed..446ce37d 100644 --- a/src/app/features/settings/general/General.tsx +++ b/src/app/features/settings/general/General.tsx @@ -1068,7 +1068,7 @@ function DiagnosticsAndPrivacy() { const handleSentryToggle = (enabled: boolean) => { setSentryEnabled(enabled); if (enabled) { - localStorage.removeItem('sable_sentry_enabled'); + localStorage.setItem('sable_sentry_enabled', 'true'); } else { localStorage.setItem('sable_sentry_enabled', 'false'); } diff --git a/src/app/pages/client/ClientNonUIFeatures.tsx b/src/app/pages/client/ClientNonUIFeatures.tsx index a5e78e60..9a5e89d5 100644 --- a/src/app/pages/client/ClientNonUIFeatures.tsx +++ b/src/app/pages/client/ClientNonUIFeatures.tsx @@ -48,6 +48,7 @@ import { mobileOrTablet } from '$utils/user-agent'; import { useSlidingSyncActiveRoom } from '$hooks/useSlidingSyncActiveRoom'; import { getSlidingSyncManager } from '$client/initMatrix'; import { NotificationBanner } from '$components/notification-banner'; +import { TelemetryConsentBanner } from '$components/telemetry-consent'; import { useCallSignaling } from '$hooks/useCallSignaling'; import { getBlobCacheStats } from '$hooks/useBlobCache'; import { lastVisitedRoomIdAtom } from '$state/room/lastRoom'; @@ -766,6 +767,7 @@ export function ClientNonUIFeatures({ children }: ClientNonUIFeaturesProps) { + diff --git a/src/instrument.ts b/src/instrument.ts index b79a414a..cd3f5586 100644 --- a/src/instrument.ts +++ b/src/instrument.ts @@ -23,7 +23,7 @@ const release = import.meta.env.VITE_APP_VERSION; let sessionErrorCount = 0; const SESSION_ERROR_LIMIT = 50; -// Check user preferences +// Default on: Sentry runs unless the user has opted out via the banner or Settings. const sentryEnabled = localStorage.getItem('sable_sentry_enabled') !== 'false'; const replayEnabled = localStorage.getItem('sable_sentry_replay_enabled') === 'true';