Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Reorder onboarding around website setup (#876)
Ben Senescub1cd479ec970
diff --git a/src/client/features/ai-mcp/AgentSetup.tsx b/src/client/features/ai-mcp/AgentSetup.tsxindex 1654e75c..f1c62d39 100644--- a/src/client/features/ai-mcp/AgentSetup.tsx+++ b/src/client/features/ai-mcp/AgentSetup.tsx@@ -7,11 +7,11 @@ import { WizardFooter } from "@/client/features/onboarding/WizardFooter";import { Button } from "@/client/components/ui/button";export function AgentSetup({- onComplete,+ onNext,onBack,disabled = false,}: {- onComplete: () => void;+ onNext: () => void;onBack: () => void;disabled?: boolean;}) {@@ -41,9 +41,9 @@ export function AgentSetup({type="button"variant="ghost"className="h-8 gap-2 px-3 text-xs font-semibold"- onClick={onComplete}+ onClick={onNext}>- Finish <ArrowRight className="size-4" />+ Continue <ArrowRight className="size-4" /></Button>}/>diff --git a/src/client/features/dashboard/DashboardCards.tsx b/src/client/features/dashboard/DashboardCards.tsxindex c7a5117b..520ad058 100644--- a/src/client/features/dashboard/DashboardCards.tsx+++ b/src/client/features/dashboard/DashboardCards.tsx@@ -3,6 +3,7 @@ import { startAudit } from "@/serverFunctions/audit";import { QueryError } from "@/client/components/QueryState";import { LoaderCircle, ScanSearch } from "lucide-react";import { CardShell } from "@/client/components/CardShell";+import { Progress } from "@/client/components/ui/progress";import { Button } from "@/client/components/ui/button";import { Link } from "@tanstack/react-router";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";@@ -211,6 +212,39 @@ export function AuditHealthCard({</CardShell>);+ if (audit.status === "running")+ // A running crawl has at most a partial issue list, and an empty one is+ // not the same as a healthy site, so show progress instead.+ return (+ <CardShell+ title="Site health"+ action={+ <Link+ to="/p/$projectId/audit"+ params={{ projectId }}+ search={{ auditId: audit.id }}+ className={moreDetailsClass}+ >+ View progress+ </Link>+ }+ >+ <div className="flex flex-1 flex-col items-center justify-center gap-3 py-6 text-center">+ <LoaderCircle className="size-7 animate-spin text-muted-foreground" />+ <h3 className="font-medium">Scanning your website</h3>+ <Progress+ className="w-full max-w-xs"+ value={audit.pagesCrawled}+ max={audit.pagesTotal || 1}+ aria-label="Pages checked"+ />+ <p className="text-sm text-muted-foreground tabular-nums">+ {audit.pagesCrawled} of up to {audit.pagesTotal} pages checked+ </p>+ </div>+ </CardShell>+ );+return (<CardShelltitle="Site health"@@ -225,7 +259,7 @@ export function AuditHealthCard({</Link>}>- {audit.status !== "completed" && audit.status !== "running" && (+ {audit.status === "failed" && (<p className="mb-4 text-sm text-destructive">The latest scan didn’t finish. Review the results or try again.</p>@@ -235,14 +269,7 @@ export function AuditHealthCard({{audit.pagesCrawled} pages checked · {formatDay(audit.startedAt)}</p>)}- {audit.status === "running" ? (- // A running crawl has at most a partial issue list, and an empty one- // is not the same as a healthy site.- <p className="text-sm text-muted-foreground">- <LoaderCircle className="mb-3 size-6 animate-spin" />- Scanning your website… {audit.pagesCrawled} pages checked.- </p>- ) : audit.topIssues.length === 0 ? (+ {audit.topIssues.length === 0 ? (audit.status === "completed" ? (<div className="flex items-center gap-2 text-sm text-muted-foreground"><Check className="size-4 text-success" />diff --git a/src/client/features/onboarding/PostSignupOnboarding.tsx b/src/client/features/onboarding/PostSignupOnboarding.tsxindex 4ceb6662..84b86c57 100644--- a/src/client/features/onboarding/PostSignupOnboarding.tsx+++ b/src/client/features/onboarding/PostSignupOnboarding.tsx@@ -8,11 +8,13 @@ import {INTEREST_OPTIONS,ONBOARDING_LAST_STEP,ONBOARDING_OPTION_LABELS,+ ONBOARDING_STEPS,type OnboardingAnswers,SOURCE_OPTIONS,WORK_FOR_OPTIONS,} from "@/client/features/onboarding/onboardingModel";import { AgentSetup } from "@/client/features/ai-mcp/AgentSetup";+import { WebsiteOnboardingStep } from "@/client/features/onboarding/WebsiteOnboardingStep";import { SearchConsoleOnboardingStep } from "@/client/features/onboarding/SearchConsoleOnboardingStep";import { WizardFooter } from "@/client/features/onboarding/WizardFooter";import { Input } from "@/client/components/ui/input";@@ -41,14 +43,14 @@ export function PostSignupOnboarding({isSaving,accountMenu,}: PostSignupOnboardingProps) {+ const stepName = ONBOARDING_STEPS[step];+ const isLastStep = step === ONBOARDING_LAST_STEP;const canContinue =- step === 0+ stepName === "interests"? answers.selectedInterests.length > 0- : step === 1+ : stepName === "work_for"? Boolean(answers.workFor)- : step === 2- ? Boolean(answers.source)- : true;+ : Boolean(answers.source);const updateAnswers = (patch: Partial<OnboardingAnswers>) =>onAnswersChange({ ...answers, ...patch });@@ -58,7 +60,17 @@ export function PostSignupOnboarding({{accountMenu}<OnboardingCard step={step + 1} total={ONBOARDING_LAST_STEP + 1}><fieldset disabled={isSaving} className="min-w-0">- {step === 0 ? (+ {stepName === "website" ? (+ <WebsiteOnboardingStep onNext={onNext} onSkip={onSkip} />+ ) : stepName === "search_console" ? (+ <SearchConsoleOnboardingStep+ onNext={onNext}+ onBack={onBack}+ onSkip={onSkip}+ />+ ) : stepName === "agent_setup" ? (+ <AgentSetup onNext={onNext} onBack={onBack} disabled={isSaving} />+ ) : stepName === "interests" ? (<OnboardingChoiceGrouptitle="What brings you here?"description="Pick up to three things you want to work on."@@ -78,7 +90,7 @@ export function PostSignupOnboarding({}multiple/>- ) : step === 1 ? (+ ) : stepName === "work_for" ? (<OnboardingChoiceGrouptitle="Who are you doing SEO for?"options={[...WORK_FOR_OPTIONS]}@@ -95,7 +107,7 @@ export function PostSignupOnboarding({/>}/>- ) : step === 2 ? (+ ) : (<OnboardingChoiceGrouptitle="How did you find OpenSEO?"options={[...SOURCE_OPTIONS]}@@ -104,25 +116,14 @@ export function PostSignupOnboarding({otherValue={answers.sourceOther}onOtherChange={(sourceOther) => updateAnswers({ sourceOther })}/>- ) : step === 3 ? (- <SearchConsoleOnboardingStep- onNext={onNext}- onBack={onBack}- onSkip={onSkip}- />- ) : (- <AgentSetup- onComplete={onFinish}- onBack={onBack}- disabled={isSaving}- />)}- {step < 3 && (+ {step > ONBOARDING_STEPS.indexOf("agent_setup") && (<WizardFooter- onBack={step > 0 ? onBack : undefined}- onSkip={onSkip}- onContinue={onNext}+ onBack={onBack}+ onSkip={isLastStep ? onFinish : onSkip}+ onContinue={isLastStep ? onFinish : onNext}+ continueLabel={isLastStep ? "Finish" : "Continue"}continueDisabled={!canContinue || isSaving}/>)}diff --git a/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx b/src/client/features/onboarding/SearchConsoleOnboardingStep.tsxindex 443cfa31..e643af8c 100644--- a/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx+++ b/src/client/features/onboarding/SearchConsoleOnboardingStep.tsx@@ -28,8 +28,7 @@ const GRANT_STATUS_KEY = ["gscGrantStatus"];/*** Onboarding step for connecting Google Search Console: link the account-level* OAuth grant, then bind a verified property to the user's first project — the- * same binding the project's Integrations page does. The step lives before the- * agent-setup screen because most users leave onboarding from that screen.+ * same binding the project's Integrations page does.*/type NavigationProps = {onNext: () => void;diff --git a/src/client/features/onboarding/WebsiteOnboardingStep.tsx b/src/client/features/onboarding/WebsiteOnboardingStep.tsxnew file mode 100644index 00000000..da08caea--- /dev/null+++ b/src/client/features/onboarding/WebsiteOnboardingStep.tsx@@ -0,0 +1,181 @@+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import { revalidateLogic } from "@tanstack/react-form";+import { ArrowRight } from "lucide-react";+import { toast } from "sonner";+import { z } from "zod";+import { useAppForm } from "@/client/components/form/useAppForm";+import { QueryError } from "@/client/components/QueryState";+import { Spinner } from "@/client/components/Spinner";+import { Button } from "@/client/components/ui/button";+import { WizardFooter } from "@/client/features/onboarding/WizardFooter";+import { toastInitialAudit } from "@/client/features/projects/initialAuditToast";+import { ProjectMarketFields } from "@/client/features/projects/ProjectMarketFields";+import { projectsQueryOptions } from "@/client/features/projects/projectQueries";+import type { ProjectSummary } from "@/client/features/projects/types";+import {+ getErrorCode,+ getStandardErrorMessage,+} from "@/client/lib/error-messages";+import { captureClientEvent } from "@/client/lib/posthog";+import { updateProject } from "@/serverFunctions/projects";++/**+ * First onboarding step: save the website and country on the user's first+ * project. Saving a new website starts its first site audit server-side, so+ * the dashboard has results by the time the user reaches it.+ */+export function WebsiteOnboardingStep({+ onNext,+ onSkip,+}: {+ onNext: () => void;+ onSkip: () => void;+}) {+ const projectsQuery = useQuery(projectsQueryOptions());+ const project = projectsQuery.data?.[0];++ return (+ <div>+ <div className="mb-8">+ <h1 className="text-2xl font-semibold tracking-tight">+ What’s your website?+ </h1>+ <p className="mt-3 text-sm leading-relaxed text-muted-foreground">+ We’ll start a site audit for you.+ </p>+ </div>+ {project ? (+ <WebsiteForm+ key={project.id}+ project={project}+ onNext={onNext}+ onSkip={onSkip}+ />+ ) : projectsQuery.isError ? (+ <QueryError+ error={projectsQuery.error}+ fallback="Couldn't load your project."+ onRetry={() => void projectsQuery.refetch()}+ isRetrying={projectsQuery.isFetching}+ />+ ) : (+ <Spinner size="sm" label="Checking…" />+ )}+ </div>+ );+}++const websiteSchema = z.object({+ domain: z.string().trim().min(1, "Enter your website."),+ market: z.object({ locationCode: z.number(), languageCode: z.string() }),+});++function WebsiteForm({+ project,+ onNext,+ onSkip,+}: {+ project: ProjectSummary;+ onNext: () => void;+ onSkip: () => void;+}) {+ const queryClient = useQueryClient();+ const saveMutation = useMutation({+ mutationFn: (values: z.infer<typeof websiteSchema>) =>+ updateProject({+ data: {+ projectId: project.id,+ // Name the auto-created project after the site it now tracks.+ name:+ project.name === "Default" ? values.domain.trim() : project.name,+ domain: values.domain.trim(),+ ...values.market,+ },+ }),+ // The form shows the domain error inline and toasts the rest itself.+ meta: { errorToast: false },+ onSuccess: async (saved) => {+ await queryClient.invalidateQueries({+ queryKey: projectsQueryOptions().queryKey,+ });+ captureClientEvent("onboarding:website_saved", {+ audit_status: saved.initialAudit?.status ?? "existing",+ });+ toastInitialAudit(saved.initialAudit);+ onNext();+ },+ });++ const form = useAppForm({+ defaultValues: {+ domain: project.domain ?? "",+ // New projects default to the United States.+ market: {+ locationCode: project.locationCode,+ languageCode: project.languageCode,+ },+ },+ validationLogic: revalidateLogic(),+ validators: { onDynamic: websiteSchema },+ onSubmit: async ({ value, formApi }) => {+ try {+ await saveMutation.mutateAsync(value);+ } catch (error) {+ if (getErrorCode(error) === "VALIDATION_ERROR")+ formApi.setErrorMap({+ onSubmit: {+ fields: { domain: "Enter a valid domain, like acme.com." },+ },+ });+ else toast.error(getStandardErrorMessage(error));+ }+ },+ });++ return (+ <form.AppForm>+ <form.Form className="flex flex-col gap-4">+ <form.AppField name="domain">+ {(field) => (+ <field.TextField+ label="Website"+ placeholder="example.com"+ maxLength={255}+ />+ )}+ </form.AppField>+ <form.Field name="market">+ {(field) => (+ <ProjectMarketFields+ value={field.state.value}+ onChange={field.handleChange}+ />+ )}+ </form.Field>+ <WizardFooter+ className="mt-4"+ onSkip={onSkip}+ skipLabel="Skip for now"+ continueAction={+ <form.Subscribe+ selector={(state) => ({+ empty: !state.values.domain.trim(),+ submitting: state.isSubmitting,+ })}+ >+ {({ empty, submitting }) => (+ <Button+ type="submit"+ className="font-semibold disabled:bg-foreground/10 disabled:text-foreground/20 disabled:opacity-100"+ disabled={empty || submitting}+ >+ Save and continue <ArrowRight className="size-4" />+ </Button>+ )}+ </form.Subscribe>+ }+ />+ </form.Form>+ </form.AppForm>+ );+}diff --git a/src/client/features/onboarding/WizardFooter.tsx b/src/client/features/onboarding/WizardFooter.tsxindex efe90865..4c316528 100644--- a/src/client/features/onboarding/WizardFooter.tsx+++ b/src/client/features/onboarding/WizardFooter.tsx@@ -38,18 +38,11 @@ export function WizardFooter({><ArrowLeft className="size-3.5" /> Back</Button>- ) : onSkip ? (- <Button- type="button"- variant="ghost"- className="font-semibold"- onClick={onSkip}- >- {skipLabel}- </Button>- ) : null}+ ) : (+ <span />+ )}<div className="flex items-center gap-2">- {onBack && onSkip ? (+ {onSkip ? (<Buttontype="button"variant="ghost"diff --git a/src/client/features/onboarding/onboardingModel.test.ts b/src/client/features/onboarding/onboardingModel.test.tsindex 889d2efd..d1045158 100644--- a/src/client/features/onboarding/onboardingModel.test.ts+++ b/src/client/features/onboarding/onboardingModel.test.ts@@ -1,6 +1,7 @@import { describe, expect, it, vi } from "vitest";import {buildOnboardingPayload,+ ONBOARDING_LAST_STEP,restoreOnboardingAnswers,} from "./onboardingModel";@@ -23,7 +24,9 @@ describe("historical onboarding values", () => {const answers = restoreOnboardingAnswers({ ...saved, workFor });expect(answers.workFor).toBe(workFor);expect(answers.workForOther).toBe("");- expect(buildOnboardingPayload(answers, 4).workFor).toBe(workFor);+ expect(+ buildOnboardingPayload(answers, ONBOARDING_LAST_STEP).workFor,+ ).toBe(workFor);},);@@ -34,7 +37,7 @@ describe("historical onboarding values", () => {expect(answers.sourceOther).toBe("");expect(answers.selectedInterests).toEqual(interestedFeatures);expect(answers.interestOther).toBe("");- const payload = buildOnboardingPayload(answers, 4);+ const payload = buildOnboardingPayload(answers, ONBOARDING_LAST_STEP);expect(payload.foundVia).toBe("Google");expect(payload.interestedFeatures).toEqual(interestedFeatures);});diff --git a/src/client/features/onboarding/onboardingModel.ts b/src/client/features/onboarding/onboardingModel.tsindex ab4e8d35..59034b61 100644--- a/src/client/features/onboarding/onboardingModel.ts+++ b/src/client/features/onboarding/onboardingModel.ts@@ -1,8 +1,17 @@import { queryOptions } from "@tanstack/react-query";import { getOnboardingAnswers } from "@/serverFunctions/onboarding";-// 0 interests · 1 who for · 2 source · 3 Search Console · 4 agent setup-export const ONBOARDING_LAST_STEP = 4;+// Step names go to analytics alongside the index, so reports survive reorders.+export const ONBOARDING_STEPS = [+ "website",+ "search_console",+ "agent_setup",+ "interests",+ "work_for",+ "source",+] as const;+export const ONBOARDING_LAST_STEP = ONBOARDING_STEPS.length - 1;+const INTERESTS_STEP = ONBOARDING_STEPS.indexOf("interests");// Option values below are persisted and used by analytics. Change display copy// here instead of renaming those values, so historical answers stay comparable.@@ -141,9 +150,9 @@ export function buildOnboardingPayload(: answers.source || undefined;return {- ...(step >= 0 ? { interestedFeatures } : {}),- ...(step >= 1 ? { workFor, clientWebsiteCount } : {}),- ...(step >= 2 ? { foundVia } : {}),+ ...(step >= INTERESTS_STEP ? { interestedFeatures } : {}),+ ...(step >= INTERESTS_STEP + 1 ? { workFor, clientWebsiteCount } : {}),+ ...(step >= INTERESTS_STEP + 2 ? { foundVia } : {}),...extra,};}diff --git a/src/client/features/projects/CreateProjectModal.tsx b/src/client/features/projects/CreateProjectModal.tsxindex 1d186698..d88d3d4e 100644--- a/src/client/features/projects/CreateProjectModal.tsx+++ b/src/client/features/projects/CreateProjectModal.tsx@@ -24,6 +24,7 @@ import {getLanguageCode,} from "@/client/features/keywords/locations";import { ProjectMarketFields } from "@/client/features/projects/ProjectMarketFields";+import { toastInitialAudit } from "@/client/features/projects/initialAuditToast";import { createProject } from "@/serverFunctions/projects";const createProjectSchema = z.object({@@ -65,14 +66,7 @@ export function CreateProjectModal({ onClose }: { onClose: () => void }) {});onClose();toast.success("Project created");- if (created.initialAudit?.status === "unavailable")- toast.warning("Website saved. The first scan could not start.", {- description: getStandardErrorMessage(- new Error(created.initialAudit.code),- ),- });- else if (created.initialAudit?.status === "started")- toast.success("Your 50-page site scan is running");+ toastInitialAudit(created.initialAudit);// Continue setup through the new project’s dashboard.void navigate({to: "/p/$projectId",diff --git a/src/client/features/projects/ProjectGeneralSettings.tsx b/src/client/features/projects/ProjectGeneralSettings.tsxindex 2eb6b9cf..d085ccc1 100644--- a/src/client/features/projects/ProjectGeneralSettings.tsx+++ b/src/client/features/projects/ProjectGeneralSettings.tsx@@ -1,4 +1,3 @@-import { getStandardErrorMessage } from "@/client/lib/error-messages";import { projectsQueryOptions } from "@/client/features/projects/projectQueries";import { useNavigate } from "@tanstack/react-router";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";@@ -14,6 +13,7 @@ import {clearLastProjectId,getLastProjectId,} from "@/client/lib/active-project";+import { toastInitialAudit } from "@/client/features/projects/initialAuditToast";import { archiveProject, updateProject } from "@/serverFunctions/projects";import type { ProjectSummary } from "./types";@@ -72,14 +72,7 @@ function GeneralSection({ project }: { project: ProjectSummary }) {queryKey: ["dashboardOverview", project.id],});toast.success("Project updated");- if (saved.initialAudit?.status === "unavailable")- toast.warning("Website saved. The first scan could not start.", {- description: getStandardErrorMessage(- new Error(saved.initialAudit.code),- ),- });- else if (saved.initialAudit?.status === "started")- toast.success("Your 50-page site scan is running");+ toastInitialAudit(saved.initialAudit);},});diff --git a/src/client/features/projects/initialAuditToast.ts b/src/client/features/projects/initialAuditToast.tsnew file mode 100644index 00000000..cd38164e--- /dev/null+++ b/src/client/features/projects/initialAuditToast.ts@@ -0,0 +1,17 @@+import { toast } from "sonner";+import { getStandardErrorMessage } from "@/client/lib/error-messages";++/** Tells the user whether saving a website started its first site scan. */+export function toastInitialAudit(+ initialAudit:+ | { status: "started" | "pending" }+ | { status: "unavailable"; code: string }+ | null,+) {+ if (initialAudit?.status === "unavailable")+ toast.warning("Website saved. The first scan could not start.", {+ description: getStandardErrorMessage(new Error(initialAudit.code)),+ });+ else if (initialAudit?.status === "started")+ toast.success("Your 50-page site scan is running");+}diff --git a/src/routes/_authenticated.onboarding.index.tsx b/src/routes/_authenticated.onboarding.index.tsxindex fcc60418..1f12f383 100644--- a/src/routes/_authenticated.onboarding.index.tsx+++ b/src/routes/_authenticated.onboarding.index.tsx@@ -6,6 +6,7 @@ import { PostSignupOnboarding } from "@/client/features/onboarding/PostSignupOnbimport {buildOnboardingPayload,ONBOARDING_LAST_STEP,+ ONBOARDING_STEPS,type OnboardingAnswers,onboardingAnswersQueryOptions,restoreOnboardingAnswers,@@ -84,7 +85,7 @@ function OnboardingFlow({} catch {return;}- if (step === 0) {+ if (ONBOARDING_STEPS[step] === "interests") {captureClientEvent("onboarding:interests_selected", {interests: answers.selectedInterests,interest_other: answers.interestOther.trim() || undefined,@@ -99,7 +100,10 @@ function OnboardingFlow({} catch {return;}- captureClientEvent("onboarding:step_skipped", { step });+ captureClientEvent("onboarding:step_skipped", {+ step,+ step_name: ONBOARDING_STEPS[step],+ });goToStep(step + 1);};@@ -118,7 +122,6 @@ function OnboardingFlow({work_for: answers.workFor,source: answers.source,});- // The dashboard's onboarding checklist owns MCP coaching now.void navigate({ to: "/", replace: true });};diff --git a/src/server/features/dashboard/services/DashboardService.ts b/src/server/features/dashboard/services/DashboardService.tsindex b6da79d9..81f1d5e3 100644--- a/src/server/features/dashboard/services/DashboardService.ts+++ b/src/server/features/dashboard/services/DashboardService.ts@@ -32,6 +32,8 @@ export type DashboardAuditSummary = {id: string;status: "running" | "completed" | "failed";pagesCrawled: number;+ // The crawl's page limit; small sites finish below it.+ pagesTotal: number;startedAt: string;// Top issue types by severity then affected-page count, for the card's list.topIssues: {@@ -128,6 +130,7 @@ async function getAuditSummary(id: audit.id,status: audit.status,pagesCrawled: audit.pagesCrawled,+ pagesTotal: audit.pagesTotal,startedAt: audit.startedAt,topIssues: sorted.slice(0, 3),};