From 9a204b9557f528a371585b88448fefbb8316d953 Mon Sep 17 00:00:00 2001 From: msukkari Date: Wed, 5 Mar 2025 17:27:23 -0800 Subject: [PATCH] add sourcebot cloud card to public search demo --- .github/workflows/ghcr-publish.yml | 3 +- Dockerfile | 5 ++ demo-site-config.json | 15 ++++ entrypoint.sh | 6 ++ .../src/app/components/editorContextMenu.tsx | 2 +- .../src/app/components/registrationCard.tsx | 49 ++++++++++++ packages/web/src/app/page.tsx | 7 ++ packages/web/src/components/ui/card.tsx | 79 +++++++++++++++++++ packages/web/src/lib/environment.ts | 3 +- packages/web/src/lib/posthogEvents.ts | 3 +- 10 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 packages/web/src/app/components/registrationCard.tsx create mode 100644 packages/web/src/components/ui/card.tsx diff --git a/.github/workflows/ghcr-publish.yml b/.github/workflows/ghcr-publish.yml index ef805a8a..164cd7a5 100644 --- a/.github/workflows/ghcr-publish.yml +++ b/.github/workflows/ghcr-publish.yml @@ -81,7 +81,8 @@ jobs: build-args: | SOURCEBOT_VERSION=${{ github.ref_name }} POSTHOG_PAPIK=${{ secrets.POSTHOG_PAPIK }} - + PUBLIC_SEARCH_DEMO=${{ secrets.PUBLIC_SEARCH_DEMO }} + - name: Export digest run: | mkdir -p /tmp/digests diff --git a/Dockerfile b/Dockerfile index 766586c6..6fa4411a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,7 @@ ENV NEXT_TELEMETRY_DISABLED=1 # @see: https://phase.dev/blog/nextjs-public-runtime-variables/ ARG NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED=BAKED_NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED ARG NEXT_PUBLIC_SOURCEBOT_VERSION=BAKED_NEXT_PUBLIC_SOURCEBOT_VERSION +ENV NEXT_PUBLIC_SEARCH_DEMO=BAKED_NEXT_PUBLIC_SEARCH_DEMO ENV NEXT_PUBLIC_POSTHOG_PAPIK=BAKED_NEXT_PUBLIC_POSTHOG_PAPIK # @note: leading "/" is required for the basePath property. @see: https://nextjs.org/docs/app/api-reference/next-config-js/basePath ARG NEXT_PUBLIC_DOMAIN_SUB_PATH=/BAKED_NEXT_PUBLIC_DOMAIN_SUB_PATH @@ -54,6 +55,10 @@ ARG SOURCEBOT_VERSION=unknown ENV SOURCEBOT_VERSION=$SOURCEBOT_VERSION RUN echo "Sourcebot Version: $SOURCEBOT_VERSION" +ARG PUBLIC_SEARCH_DEMO=false +ENV PUBLIC_SEARCH_DEMO=$PUBLIC_SEARCH_DEMO +RUN echo "Public Search Demo: $PUBLIC_SEARCH_DEMO" + # Valid values are: debug, info, warn, error ENV SOURCEBOT_LOG_LEVEL=info diff --git a/demo-site-config.json b/demo-site-config.json index 8adbb703..4e89038c 100644 --- a/demo-site-config.json +++ b/demo-site-config.json @@ -96,6 +96,21 @@ "flameshot-org/flameshot", "envoyproxy/envoy" ] + }, + { + "type": "gitlab", + "token": { + "env": "GITLAB_TOKEN" + }, + "groups": [ + "fdroid" + ], + "exclude": { + "projects": [ + "fdroid/wiki", + "Matrixcoffee/internal-twif-preview" + ] + } } ] } \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 2ed5ec20..830c8fd7 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -93,6 +93,11 @@ echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m" export NEXT_PUBLIC_SOURCEBOT_VERSION="$SOURCEBOT_VERSION" fi + # Infer NEXT_PUBLIC_SEARCH_DEMO if it is not set + if [ -z "$NEXT_PUBLIC_SEARCH_DEMO" ] && [ ! -z "$PUBLIC_SEARCH_DEMO" ]; then + export NEXT_PUBLIC_SEARCH_DEMO="$PUBLIC_SEARCH_DEMO" + fi + # Always infer NEXT_PUBLIC_POSTHOG_PAPIK export NEXT_PUBLIC_POSTHOG_PAPIK="$POSTHOG_PAPIK" @@ -103,6 +108,7 @@ echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m" sed -i "s|BAKED_NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED|${NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED}|g" "$file" sed -i "s|BAKED_NEXT_PUBLIC_SOURCEBOT_VERSION|${NEXT_PUBLIC_SOURCEBOT_VERSION}|g" "$file" sed -i "s|BAKED_NEXT_PUBLIC_POSTHOG_PAPIK|${NEXT_PUBLIC_POSTHOG_PAPIK}|g" "$file" + sed -i "s|BAKED_NEXT_PUBLIC_SEARCH_DEMO|${NEXT_PUBLIC_SEARCH_DEMO}|g" "$file" done } diff --git a/packages/web/src/app/components/editorContextMenu.tsx b/packages/web/src/app/components/editorContextMenu.tsx index 3e7b6286..c6874c64 100644 --- a/packages/web/src/app/components/editorContextMenu.tsx +++ b/packages/web/src/app/components/editorContextMenu.tsx @@ -116,7 +116,7 @@ export const EditorContextMenu = ({ description: "✅ Copied link to selection", }); - captureEvent('share_link_created', {}); + captureEvent('wa_share_link_created', {}); // Reset the selection view.dispatch( diff --git a/packages/web/src/app/components/registrationCard.tsx b/packages/web/src/app/components/registrationCard.tsx new file mode 100644 index 00000000..af64db86 --- /dev/null +++ b/packages/web/src/app/components/registrationCard.tsx @@ -0,0 +1,49 @@ +"use client" + +import { useState } from "react" +import Link from "next/link" +import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" +import { Button } from "@/components/ui/button" +import { ArrowRight, Code, Database, Search } from "lucide-react" +import useCaptureEvent from "@/hooks/useCaptureEvent" + +export default function RegistrationCard() { + const [isHovered, setIsHovered] = useState(false) + const captureEvent = useCaptureEvent() + + return ( + setIsHovered(true)} + onMouseLeave={() => setIsHovered(false)} + > + + Try Sourcebot Cloud + Index and search your own code repositories + + +
+
+ +

Search your private and public repositories

+
+
+ +

Index your own codebase in minutes

+
+
+
+ + captureEvent("wa_demo_try_card_pressed", {})}> + + +

+ 14 day free trial. No credit card required. +

+
+
+ ) +} diff --git a/packages/web/src/app/page.tsx b/packages/web/src/app/page.tsx index 85f63490..4a4a1465 100644 --- a/packages/web/src/app/page.tsx +++ b/packages/web/src/app/page.tsx @@ -12,6 +12,8 @@ import { SymbolIcon } from "@radix-ui/react-icons"; import { UpgradeToast } from "./components/upgradeToast"; import Link from "next/link"; import { KeyboardShortcutHint } from "./components/keyboardShortcutHint"; +import RegistrationCard from "./components/registrationCard"; +import { PUBLIC_SEARCH_DEMO } from "@/lib/environment"; export default async function Home() { return ( @@ -38,6 +40,11 @@ export default async function Home() { autoFocus={true} className="mt-4 w-full max-w-[800px]" /> + {PUBLIC_SEARCH_DEMO && ( +
+ +
+ )}
...
}> diff --git a/packages/web/src/components/ui/card.tsx b/packages/web/src/components/ui/card.tsx new file mode 100644 index 00000000..f62edea5 --- /dev/null +++ b/packages/web/src/components/ui/card.tsx @@ -0,0 +1,79 @@ +import * as React from "react" + +import { cn } from "@/lib/utils" + +const Card = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +Card.displayName = "Card" + +const CardHeader = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardHeader.displayName = "CardHeader" + +const CardTitle = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardTitle.displayName = "CardTitle" + +const CardDescription = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardDescription.displayName = "CardDescription" + +const CardContent = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardContent.displayName = "CardContent" + +const CardFooter = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardFooter.displayName = "CardFooter" + +export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } diff --git a/packages/web/src/lib/environment.ts b/packages/web/src/lib/environment.ts index 7f23b0a5..a10e7a8d 100644 --- a/packages/web/src/lib/environment.ts +++ b/packages/web/src/lib/environment.ts @@ -1,9 +1,10 @@ import 'server-only'; -import { getEnv, getEnvNumber } from "./utils"; +import { getEnv, getEnvBoolean, getEnvNumber } from "./utils"; export const ZOEKT_WEBSERVER_URL = getEnv(process.env.ZOEKT_WEBSERVER_URL, "http://localhost:6070")!; export const SHARD_MAX_MATCH_COUNT = getEnvNumber(process.env.SHARD_MAX_MATCH_COUNT, 10000); export const TOTAL_MAX_MATCH_COUNT = getEnvNumber(process.env.TOTAL_MAX_MATCH_COUNT, 100000); export const SOURCEBOT_VERSION = getEnv(process.env.SOURCEBOT_VERSION, 'unknown')!; export const NODE_ENV = process.env.NODE_ENV; +export const PUBLIC_SEARCH_DEMO = getEnvBoolean(process.env.PUBLIC_SEARCH_DEMO, false); diff --git a/packages/web/src/lib/posthogEvents.ts b/packages/web/src/lib/posthogEvents.ts index 114cf106..e73d9483 100644 --- a/packages/web/src/lib/posthogEvents.ts +++ b/packages/web/src/lib/posthogEvents.ts @@ -24,7 +24,8 @@ export type PosthogEventMap = { flushReason: number, fileLanguages: string[] }, - share_link_created: {}, + wa_demo_try_card_pressed: {}, + wa_share_link_created: {}, } export type PosthogEvent = keyof PosthogEventMap; \ No newline at end of file