Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: remove TelemetryConsentBanner from onboarding (#1831)

Hiep Lec2373f98e3d6
diff --git a/AGENTS.md b/AGENTS.md
index 2e1e0f2b1e..021c9c54a5 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -39,7 +39,7 @@ One Canvas-owned PostHog client owns telemetry and app analytics.
- `subscribeTelemetryConsent` is the sole React-facing consent store. Hooks that render consent state must use `useSyncExternalStore`; do not mirror consent in component state or gate events outside `telemetry.ts`.
- `canvas_install` fires once, pre-consent, with the client's anonymous distinct ID. After consent, Cloud `identify()` follows PostHog's normal anonymous-to-identified lifecycle, so install, Cloud-funnel, and app events remain queryable as one user journey. Account changes and logout reset identity inside `telemetry.ts`, which immediately restores the canonical consent state that the PostHog SDK reset clears.
- `telemetry.ts` adds immutable `client_source`, `client_version`, `package_name`, and `package_version` properties in `before_send`, so reset cannot remove attribution and event producers cannot override it. Repeated business milestones use deterministic PostHog `$insert_id` values instead of process-local caches.
-- `trackEvent`, `useTelemetry`, and `TelemetryConsentBanner` remain the public library telemetry API for npm consumers. Non-React state machines use typed functions in `cloud-funnel-analytics.ts`; they do not call `trackEvent` directly.
+- `trackEvent` and `useTelemetry` remain the public library telemetry API for npm consumers (the `TelemetryConsentBanner` component was removed; hosts needing a consent UI build their own on `useTelemetry`). Non-React state machines use typed functions in `cloud-funnel-analytics.ts`; they do not call `trackEvent` directly.
- React app events use typed functions in `src/hooks/use-tracking.ts`; components never call `posthog.capture()` raw. The hook attaches `current_url` and `user_email` automatically and captures through the telemetry service. It may read backend settings for event properties, but must never gate capture on a settings snapshot: `useSyncTelemetryConsent` has already mirrored the authoritative decision to the telemetry service, and settings can be stale during a backend transition.
- A business milestone has one canonical event capture. Do not conditionally switch between telemetry and app clients or emit duplicate events.
diff --git a/src/components/features/analytics/telemetry-consent-banner.tsx b/src/components/features/analytics/telemetry-consent-banner.tsx
deleted file mode 100644
index e463e8e518..0000000000
--- a/src/components/features/analytics/telemetry-consent-banner.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-import React, { useEffect, useState } from "react";
-import { useTranslation } from "react-i18next";
-import { useTelemetry } from "#/hooks/use-telemetry";
-import { I18nKey } from "#/i18n/declaration";
-import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";
-import { ModalBody } from "#/components/shared/modals/modal-body";
-import {
- BaseModalTitle,
- BaseModalDescription,
-} from "#/components/shared/modals/confirmation-modals/base-modal";
-import { BrandButton } from "#/components/features/settings/brand-button";
-
-interface TelemetryConsentBannerProps {
- /** Called after user makes a choice */
- onChoice?: (granted: boolean) => void;
-}
-
-/**
- * A consent modal for telemetry/analytics that appears on first use.
- *
- * This component:
- * - Shows as a full-screen modal overlay when consent is pending
- * - Waits for translations to load before displaying (prevents key flashing)
- * - Allows users to accept or decline tracking via checkbox
- * - Respects DO_NOT_TRACK environment variable
- * - Persists choice in localStorage
- * - Styled to match the OpenHands analytics consent modal
- *
- * @example
- * ```tsx
- * function App() {
- * return (
- * <>
- * <TelemetryConsentBanner />
- * <MainContent />
- * </>
- * );
- * }
- * ```
- */
-export function TelemetryConsentBanner({
- onChoice,
-}: TelemetryConsentBannerProps) {
- const { t, ready } = useTranslation("openhands");
- const { showConsentPrompt, grantConsent, denyConsent } = useTelemetry();
-
- // Delay showing the modal slightly to ensure smooth rendering
- // This prevents the modal from flashing during initial hydration
- const [isReady, setIsReady] = useState(false);
- useEffect(() => {
- if (ready && showConsentPrompt) {
- // Small delay to ensure DOM is fully hydrated and translations loaded
- const timer = setTimeout(() => setIsReady(true), 50);
- return () => clearTimeout(timer);
- }
- setIsReady(false);
- return undefined;
- }, [ready, showConsentPrompt]);
-
- const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
- e.preventDefault();
- const formData = new FormData(e.currentTarget);
- const analytics = formData.get("analytics") === "on";
-
- if (analytics) {
- grantConsent();
- } else {
- denyConsent();
- }
- onChoice?.(analytics);
- };
-
- // Don't render until translations are ready and component has stabilized
- if (!isReady) {
- return null;
- }
-
- return (
- <ModalBackdrop elevated aria-label={t(I18nKey.TELEMETRY$CONSENT_TITLE)}>
- <form
- data-testid="telemetry-consent-form"
- onSubmit={handleSubmit}
- className="flex flex-col gap-2"
- >
- <ModalBody className="border border-[var(--oh-border)]">
- <BaseModalTitle title={t(I18nKey.TELEMETRY$CONSENT_TITLE)} />
- <BaseModalDescription>
- {t(I18nKey.TELEMETRY$CONSENT_DESCRIPTION)}
- </BaseModalDescription>
-
- <label className="flex gap-2 items-center self-start text-sm cursor-pointer">
- <input
- name="analytics"
- type="checkbox"
- defaultChecked
- className="w-4 h-4 cursor-pointer"
- />
- {t(I18nKey.TELEMETRY$SEND_ANONYMOUS_DATA)}
- </label>
-
- <BrandButton
- testId="confirm-telemetry-preferences"
- type="submit"
- variant="primary"
- className="w-full"
- >
- {t(I18nKey.TELEMETRY$CONFIRM_PREFERENCES)}
- </BrandButton>
- </ModalBody>
- </form>
- </ModalBackdrop>
- );
-}
diff --git a/src/lib/index.ts b/src/lib/index.ts
index dba0547322..c352d69a43 100644
--- a/src/lib/index.ts
+++ b/src/lib/index.ts
@@ -41,7 +41,6 @@ export {
} from "../styles/agent-server-ui-style-scope";
// Telemetry exports
-export { TelemetryConsentBanner } from "../components/features/analytics/telemetry-consent-banner";
export { useTelemetry, type UseTelemetryReturn } from "../hooks/use-telemetry";
export {
configureTelemetry,
diff --git a/src/root.tsx b/src/root.tsx
index 006a6c0847..769ec6a4ac 100644
--- a/src/root.tsx
+++ b/src/root.tsx
@@ -39,7 +39,6 @@ import {
useBackendsHealth,
} from "#/hooks/query/use-backends-health";
import { TOAST_OPTIONS } from "#/utils/custom-toast-handlers";
-import { TelemetryConsentBanner } from "#/components/features/analytics/telemetry-consent-banner";
import { LoadingSpinner } from "#/components/shared/loading-spinner";
import { useConfig } from "#/hooks/query/use-config";
import { QUERY_KEYS } from "#/hooks/query/query-keys";
@@ -103,7 +102,6 @@ export function Layout({ children }: { children: React.ReactNode }) {
<ColorThemeApplier />
{children}
<Toaster toastOptions={TOAST_OPTIONS} />
- <TelemetryConsentBanner />
<div id="modal-portal-exit" />
</AgentServerUIRoot>
<ScrollRestoration />