Merge pull request #2103 from continuedev/pe/onboarding-telemetry

fix: onboarding telemetry bug
This commit is contained in:
Patrick Erichsen 2024-08-25 22:22:18 -07:00 • committed by GitHub
commit cc84e0dcff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 30 additions and 54 deletions

View file

@ -12,7 +12,7 @@ import {
} from ".";
import { IdeMessengerContext } from "../context/IdeMessenger";
import { useWebviewListener } from "../hooks/useWebviewListener";
import { shouldBeginOnboarding } from "../pages/onboarding/utils";
import { isNewUserOnboarding } from "../pages/onboarding/utils";
import { defaultModelSelector } from "../redux/selectors/modelSelectors";
import {
setBottomMessage,
@ -30,7 +30,6 @@ import ProgressBar from "./loaders/ProgressBar";
import PostHogPageView from "./PosthogPageView";
import ProfileSwitcher from "./ProfileSwitcher";
// #region Styled Components
const FOOTER_HEIGHT = "1.8em";
const LayoutTopDiv = styled(CustomScrollbarDiv)`
@ -105,8 +104,6 @@ const ProfileDropdownPortalDiv = styled.div`
font-size: ${getFontSize() - 2};
`;
// #endregion
const HIDE_FOOTER_ON_PAGES = [
"/onboarding",
"/localOnboarding",
@ -127,7 +124,6 @@ const Layout = () => {
);
const defaultModel = useSelector(defaultModelSelector);
// #region Selectors
const bottomMessage = useSelector(
(state: RootState) => state.uiState.bottomMessage,
@ -138,8 +134,6 @@ const Layout = () => {
const timeline = useSelector((state: RootState) => state.state.history);
// #endregion
useEffect(() => {
const handleKeyDown = (event: any) => {
if (isMetaEquivalentKeyPressed(event) && event.code === "KeyC") {
@ -231,7 +225,7 @@ const Layout = () => {
useEffect(() => {
if (
shouldBeginOnboarding() &&
isNewUserOnboarding() &&
(location.pathname === "/" || location.pathname === "/index.html")
) {
navigate("/onboarding");

View file

@ -102,18 +102,6 @@ function HelpPage() {
className="no-underline"
>
<SecondaryButton className="grid grid-flow-col items-center gap-2">
<svg
viewBox="0 0 98 96"
height={24}
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
fill={vscForeground}
/>
</svg>
Create a GitHub issue
</SecondaryButton>
</a>
@ -132,15 +120,6 @@ function HelpPage() {
className="no-underline"
>
<SecondaryButton className="grid grid-flow-col items-center gap-2 w-full">
<svg
width="42px"
height="42px"
xmlns="http://www.w3.org/2000/svg"
viewBox="-5 -5.5 60 60"
fill={vscForeground}
>
<path d="M 41.625 10.769531 C 37.644531 7.566406 31.347656 7.023438 31.078125 7.003906 C 30.660156 6.96875 30.261719 7.203125 30.089844 7.589844 C 30.074219 7.613281 29.9375 7.929688 29.785156 8.421875 C 32.417969 8.867188 35.652344 9.761719 38.578125 11.578125 C 39.046875 11.867188 39.191406 12.484375 38.902344 12.953125 C 38.710938 13.261719 38.386719 13.429688 38.050781 13.429688 C 37.871094 13.429688 37.6875 13.378906 37.523438 13.277344 C 32.492188 10.15625 26.210938 10 25 10 C 23.789063 10 17.503906 10.15625 12.476563 13.277344 C 12.007813 13.570313 11.390625 13.425781 11.101563 12.957031 C 10.808594 12.484375 10.953125 11.871094 11.421875 11.578125 C 14.347656 9.765625 17.582031 8.867188 20.214844 8.425781 C 20.0625 7.929688 19.925781 7.617188 19.914063 7.589844 C 19.738281 7.203125 19.34375 6.960938 18.921875 7.003906 C 18.652344 7.023438 12.355469 7.566406 8.320313 10.8125 C 6.214844 12.761719 2 24.152344 2 34 C 2 34.175781 2.046875 34.34375 2.132813 34.496094 C 5.039063 39.605469 12.972656 40.941406 14.78125 41 C 14.789063 41 14.800781 41 14.8125 41 C 15.132813 41 15.433594 40.847656 15.621094 40.589844 L 17.449219 38.074219 C 12.515625 36.800781 9.996094 34.636719 9.851563 34.507813 C 9.4375 34.144531 9.398438 33.511719 9.765625 33.097656 C 10.128906 32.683594 10.761719 32.644531 11.175781 33.007813 C 11.234375 33.0625 15.875 37 25 37 C 34.140625 37 38.78125 33.046875 38.828125 33.007813 C 39.242188 32.648438 39.871094 32.683594 40.238281 33.101563 C 40.601563 33.515625 40.5625 34.144531 40.148438 34.507813 C 40.003906 34.636719 37.484375 36.800781 32.550781 38.074219 L 34.378906 40.589844 C 34.566406 40.847656 34.867188 41 35.1875 41 C 35.199219 41 35.210938 41 35.21875 41 C 37.027344 40.941406 44.960938 39.605469 47.867188 34.496094 C 47.953125 34.34375 48 34.175781 48 34 C 48 24.152344 43.785156 12.761719 41.625 10.769531 Z M 18.5 30 C 16.566406 30 15 28.210938 15 26 C 15 23.789063 16.566406 22 18.5 22 C 20.433594 22 22 23.789063 22 26 C 22 28.210938 20.433594 30 18.5 30 Z M 31.5 30 C 29.566406 30 28 28.210938 28 26 C 28 23.789063 29.566406 22 31.5 22 C 33.433594 22 35 23.789063 35 26 C 35 28.210938 33.433594 30 31.5 30 Z"></path>
</svg>
Continue Discord
</SecondaryButton>
</a>

View file

@ -6,7 +6,7 @@ import Toggle from "../../components/modelSelection/Toggle";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { getLocalStorage } from "../../util/localStorage";
import DefaultModelConfigForm from "./DefaultModelConfigForm";
import { useOnboarding } from "./utils";
import { useCompleteOnboarding } from "./utils";
function ApiKeysOnboarding() {
const ideMessenger = useContext(IdeMessengerContext);
@ -14,7 +14,7 @@ function ApiKeysOnboarding() {
const [isBestToggle, setIsBestToggle] = useState(true);
const { completeOnboarding } = useOnboarding();
const { completeOnboarding } = useCompleteOnboarding();
return (
<div className="p-8 overflow-y-scroll">

View file

@ -7,7 +7,7 @@ import { setDefaultModel } from "../../redux/slices/stateSlice";
import { models } from "../AddNewModel/configs/models";
import { providers } from "../AddNewModel/configs/providers";
import { StyledButton } from "./components";
import { useOnboarding } from "./utils";
import { useCompleteOnboarding } from "./utils";
const HelperText = styled.p`
font-size: 0.8rem;
@ -23,7 +23,7 @@ function DefaultModelConfigForm() {
const [mistralApiKey, setMistralApiKey] = useState("");
const [anthropicApiKey, setAnthropicApiKey] = useState("");
const { completeOnboarding } = useOnboarding();
const { completeOnboarding } = useCompleteOnboarding();
const isFormComplete = !!mistralApiKey && !!anthropicApiKey;

View file

@ -6,7 +6,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger";
import { CheckMarkHeader } from "./CheckMarkHeader";
import { StyledButton } from "./components";
import { CopyToTerminalButton } from "./CopyToTerminalButton";
import { useOnboarding } from "./utils";
import { useCompleteOnboarding } from "./utils";
type OllamaConnectionStatuses =
| "waiting_to_download"
@ -35,7 +35,7 @@ function LocalOnboarding() {
const [hasLoadedChatModel, setHasLoadedChatModel] = useState(false);
const { completeOnboarding } = useOnboarding();
const { completeOnboarding } = useCompleteOnboarding();
const isOllamaConnected = ollamaConnectionStatus === "verified";

View file

@ -5,7 +5,7 @@ import {
GiftIcon,
} from "@heroicons/react/24/outline";
import { ToCoreFromIdeOrWebviewProtocol } from "core/protocol/core";
import { useContext, useState } from "react";
import { useContext, useEffect, useState } from "react";
import { useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";
import { lightGray } from "../../components";
@ -19,7 +19,9 @@ import {
import { isJetBrains } from "../../util";
import { FREE_TRIAL_LIMIT_REQUESTS, hasPassedFTL } from "../../util/freeTrial";
import { Div, StyledButton } from "./components";
import { useOnboarding } from "./utils";
import { isNewUserOnboarding, useCompleteOnboarding } from "./utils";
import { setLocalStorage } from "../../util/localStorage";
import { usePostHog } from "posthog-js/react";
type OnboardingMode =
ToCoreFromIdeOrWebviewProtocol["completeOnboarding"][0]["mode"];
@ -27,6 +29,7 @@ type OnboardingMode =
function Onboarding() {
const navigate = useNavigate();
const dispatch = useDispatch();
const posthog = usePostHog();
const ideMessenger = useContext(IdeMessengerContext);
const [hasSignedIntoGh, setHasSignedIntoGh] = useState(false);
@ -34,7 +37,7 @@ function Onboarding() {
OnboardingMode | undefined
>(undefined);
const { completeOnboarding } = useOnboarding();
const { completeOnboarding } = useCompleteOnboarding();
function onSubmit() {
ideMessenger.post("completeOnboarding", {
@ -68,8 +71,15 @@ function Onboarding() {
}
}
useEffect(() => {
if (isNewUserOnboarding()) {
posthog.capture("Onboarding Step", { status: "Started" });
setLocalStorage("onboardingStatus", "Started");
}
}, []);
return (
<div className="max-w-96 mx-auto leading-normal">
<div className="max-w-96 mx-auto leading-normal">
<div className="leading-relaxed">
<h1 className="text-center">Welcome to Continue</h1>
<p className="text-center ">

View file

@ -13,7 +13,7 @@ import {
StyledListboxOptions,
} from "../../components/modelSelection/quickSetup/StyledListbox";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { useOnboarding } from "./utils";
import { useCompleteOnboarding } from "./utils";
interface AutocompleteOption {
provider: ModelProvider;
@ -124,7 +124,7 @@ function ApiKeyAutocompleteOnboarding() {
const [apiKeyValue, setApiKeyValue] = useState<string>("");
const { completeOnboarding } = useOnboarding();
const { completeOnboarding } = useCompleteOnboarding();
return (
<div className="p-2 max-w-96 mt-16 mx-auto">

View file

@ -1,5 +1,4 @@
import { usePostHog } from "posthog-js/react";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
@ -9,15 +8,16 @@ export type OnboardingStatus = "Started" | "Completed";
// If there is no value in local storage for "onboardingStatus",
// it implies that the user has not begun or completed onboarding.
export function shouldBeginOnboarding() {
export function isNewUserOnboarding() {
// We used to use "onboardingComplete", but switched to "onboardingStatus"
const onboardingCompleteLegacyValue =
localStorage.getItem("onboardingComplete");
if (onboardingCompleteLegacyValue === "true") {
setLocalStorage("onboardingStatus", "Completed");
localStorage.removeItem("onboardingComplete");
return false;
}
const onboardingStatus = getLocalStorage("onboardingStatus");
return onboardingStatus === undefined;
@ -26,11 +26,11 @@ export function shouldBeginOnboarding() {
/**
* Telemetry, status tracking, and routing logic for new user onboarding.
*/
export function useOnboarding() {
export function useCompleteOnboarding() {
const posthog = usePostHog();
const navigate = useNavigate();
const completeOnboarding = () => {
function completeOnboarding() {
const onboardingStatus = getLocalStorage("onboardingStatus");
if (onboardingStatus === "Started") {
@ -40,14 +40,7 @@ export function useOnboarding() {
}
navigate("/");
};
useEffect(() => {
if (shouldBeginOnboarding()) {
setLocalStorage("onboardingStatus", "Started");
posthog.capture("Onboarding Step", { status: "Started" });
}
}, []);
}
return {
completeOnboarding,