mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
chore(demo): add posthog events and link to docs
This commit is contained in:
parent
2ab0b988e4
commit
be9979f18a
2 changed files with 139 additions and 97 deletions
|
|
@ -9,6 +9,7 @@ import { ContextItem, RepoContextItem, SearchContextItem } from "@/features/chat
|
||||||
import { DemoExamples, DemoSearchExample, DemoSearchContextExample, DemoSearchContext } from "@/types";
|
import { DemoExamples, DemoSearchExample, DemoSearchContextExample, DemoSearchContext } from "@/types";
|
||||||
import { cn, getCodeHostIcon } from "@/lib/utils";
|
import { cn, getCodeHostIcon } from "@/lib/utils";
|
||||||
import { RepositoryQuery, SearchContextQuery } from "@/lib/types";
|
import { RepositoryQuery, SearchContextQuery } from "@/lib/types";
|
||||||
|
import useCaptureEvent from "@/hooks/useCaptureEvent";
|
||||||
|
|
||||||
interface AskSourcebotDemoCardsProps {
|
interface AskSourcebotDemoCardsProps {
|
||||||
demoExamples: DemoExamples;
|
demoExamples: DemoExamples;
|
||||||
|
|
@ -25,7 +26,14 @@ export const AskSourcebotDemoCards = ({
|
||||||
searchContexts,
|
searchContexts,
|
||||||
repos,
|
repos,
|
||||||
}: AskSourcebotDemoCardsProps) => {
|
}: AskSourcebotDemoCardsProps) => {
|
||||||
|
const captureEvent = useCaptureEvent();
|
||||||
|
|
||||||
const handleExampleClick = (example: DemoSearchExample) => {
|
const handleExampleClick = (example: DemoSearchExample) => {
|
||||||
|
captureEvent('wa_demo_search_example_card_pressed', {
|
||||||
|
exampleTitle: example.title,
|
||||||
|
exampleUrl: example.url || '',
|
||||||
|
});
|
||||||
|
|
||||||
if (example.url) {
|
if (example.url) {
|
||||||
window.open(example.url, '_blank');
|
window.open(example.url, '_blank');
|
||||||
}
|
}
|
||||||
|
|
@ -63,6 +71,12 @@ export const AskSourcebotDemoCards = ({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
captureEvent('wa_demo_search_context_card_pressed', {
|
||||||
|
contextType: context.type,
|
||||||
|
contextName: context.value,
|
||||||
|
contextDisplayName: context.displayName,
|
||||||
|
});
|
||||||
|
|
||||||
const isDemoMode = process.env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT === "demo";
|
const isDemoMode = process.env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT === "demo";
|
||||||
const isSelected = selectedItems.some((item) => item.value === context.value);
|
const isSelected = selectedItems.some((item) => item.value === context.value);
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
|
|
@ -109,6 +123,22 @@ export const AskSourcebotDemoCards = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
{process.env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT === "demo" && (
|
||||||
|
<p className="text-sm text-muted-foreground text-center mt-6">
|
||||||
|
Interested in using Sourcebot on your code? Check out our{' '}
|
||||||
|
<a
|
||||||
|
href="https://docs.sourcebot.dev/docs/overview"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="text-primary hover:underline"
|
||||||
|
onClick={() => captureEvent('wa_demo_docs_link_pressed', {})}
|
||||||
|
>
|
||||||
|
docs
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="w-full mt-8 space-y-12 px-4 max-w-[1000px]">
|
<div className="w-full mt-8 space-y-12 px-4 max-w-[1000px]">
|
||||||
{/* Search Context Row */}
|
{/* Search Context Row */}
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
|
|
@ -216,5 +246,6 @@ export const AskSourcebotDemoCards = ({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
@ -282,5 +282,16 @@ export type PosthogEventMap = {
|
||||||
chatId: string,
|
chatId: string,
|
||||||
messageId: string,
|
messageId: string,
|
||||||
},
|
},
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
wa_demo_docs_link_pressed: {},
|
||||||
|
wa_demo_search_context_card_pressed: {
|
||||||
|
contextType: string,
|
||||||
|
contextName: string,
|
||||||
|
contextDisplayName: string,
|
||||||
|
},
|
||||||
|
wa_demo_search_example_card_pressed: {
|
||||||
|
exampleTitle: string,
|
||||||
|
exampleUrl: string,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
export type PosthogEvent = keyof PosthogEventMap;
|
export type PosthogEvent = keyof PosthogEventMap;
|
||||||
Loading…
Reference in a new issue