Skip to content

Commit 9d1ebce

Browse files
committed
log addition info for public search demo
1 parent 9a204b9 commit 9d1ebce

File tree

7 files changed

+14
-10
lines changed

7 files changed

+14
-10
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ENV NEXT_TELEMETRY_DISABLED=1
2626
# @see: https://phase.dev/blog/nextjs-public-runtime-variables/
2727
ARG NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED=BAKED_NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED
2828
ARG NEXT_PUBLIC_SOURCEBOT_VERSION=BAKED_NEXT_PUBLIC_SOURCEBOT_VERSION
29-
ENV NEXT_PUBLIC_SEARCH_DEMO=BAKED_NEXT_PUBLIC_SEARCH_DEMO
29+
ENV NEXT_PUBLIC_PUBLIC_SEARCH_DEMO=BAKED_NEXT_PUBLIC_PUBLIC_SEARCH_DEMO
3030
ENV NEXT_PUBLIC_POSTHOG_PAPIK=BAKED_NEXT_PUBLIC_POSTHOG_PAPIK
3131
# @note: leading "/" is required for the basePath property. @see: https://nextjs.org/docs/app/api-reference/next-config-js/basePath
3232
ARG NEXT_PUBLIC_DOMAIN_SUB_PATH=/BAKED_NEXT_PUBLIC_DOMAIN_SUB_PATH

entrypoint.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m"
9393
export NEXT_PUBLIC_SOURCEBOT_VERSION="$SOURCEBOT_VERSION"
9494
fi
9595

96-
# Infer NEXT_PUBLIC_SEARCH_DEMO if it is not set
97-
if [ -z "$NEXT_PUBLIC_SEARCH_DEMO" ] && [ ! -z "$PUBLIC_SEARCH_DEMO" ]; then
98-
export NEXT_PUBLIC_SEARCH_DEMO="$PUBLIC_SEARCH_DEMO"
96+
# Infer NEXT_PUBLIC_PUBLIC_SEARCH_DEMO if it is not set
97+
if [ -z "$NEXT_PUBLIC_PUBLIC_SEARCH_DEMO" ] && [ ! -z "$PUBLIC_SEARCH_DEMO" ]; then
98+
export NEXT_PUBLIC_PUBLIC_SEARCH_DEMO="$PUBLIC_SEARCH_DEMO"
9999
fi
100100

101101
# Always infer NEXT_PUBLIC_POSTHOG_PAPIK
@@ -108,7 +108,7 @@ echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m"
108108
sed -i "s|BAKED_NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED|${NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED}|g" "$file"
109109
sed -i "s|BAKED_NEXT_PUBLIC_SOURCEBOT_VERSION|${NEXT_PUBLIC_SOURCEBOT_VERSION}|g" "$file"
110110
sed -i "s|BAKED_NEXT_PUBLIC_POSTHOG_PAPIK|${NEXT_PUBLIC_POSTHOG_PAPIK}|g" "$file"
111-
sed -i "s|BAKED_NEXT_PUBLIC_SEARCH_DEMO|${NEXT_PUBLIC_SEARCH_DEMO}|g" "$file"
111+
sed -i "s|BAKED_NEXT_PUBLIC_PUBLIC_SEARCH_DEMO|${NEXT_PUBLIC_PUBLIC_SEARCH_DEMO}|g" "$file"
112112
done
113113
}
114114

packages/web/src/app/components/registrationCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useState } from "react"
44
import Link from "next/link"
55
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
66
import { Button } from "@/components/ui/button"
7-
import { ArrowRight, Code, Database, Search } from "lucide-react"
7+
import { ArrowRight, Database, Search } from "lucide-react"
88
import useCaptureEvent from "@/hooks/useCaptureEvent"
99

1010
export default function RegistrationCard() {

packages/web/src/app/posthogProvider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use client'
2-
import { NEXT_PUBLIC_POSTHOG_PAPIK, NEXT_PUBLIC_POSTHOG_UI_HOST, NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED } from '@/lib/environment.client'
2+
import { NEXT_PUBLIC_POSTHOG_PAPIK, NEXT_PUBLIC_POSTHOG_UI_HOST, NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED, NEXT_PUBLIC_PUBLIC_SEARCH_DEMO } from '@/lib/environment.client'
33
import posthog from 'posthog-js'
44
import { PostHogProvider } from 'posthog-js/react'
55
import { resolveServerPath } from './api/(client)/client'
@@ -14,10 +14,10 @@ if (typeof window !== 'undefined') {
1414
api_host: posthogHostPath,
1515
ui_host: NEXT_PUBLIC_POSTHOG_UI_HOST,
1616
person_profiles: 'identified_only',
17-
capture_pageview: false, // Disable automatic pageview capture
17+
capture_pageview: NEXT_PUBLIC_PUBLIC_SEARCH_DEMO, // @nocheckin Disable automatic pageview capture if we're not in public demo mode
1818
autocapture: false, // Disable automatic event capture
1919
// eslint-disable-next-line @typescript-eslint/no-explicit-any
20-
sanitize_properties: (properties: Record<string, any>, _event: string) => {
20+
sanitize_properties: !NEXT_PUBLIC_PUBLIC_SEARCH_DEMO ? (properties: Record<string, any>, _event: string) => {
2121
// https://posthog.com/docs/libraries/js#config
2222
if (properties['$current_url']) {
2323
properties['$current_url'] = null;
@@ -27,7 +27,7 @@ if (typeof window !== 'undefined') {
2727
}
2828

2929
return properties;
30-
}
30+
} : undefined
3131
});
3232
} else {
3333
console.log("PostHog telemetry disabled");

packages/web/src/app/search/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { TopBar } from "../components/topBar";
2121
import { CodePreviewPanel } from "./components/codePreviewPanel";
2222
import { FilterPanel } from "./components/filterPanel";
2323
import { SearchResultsPanel } from "./components/searchResultsPanel";
24+
import { NEXT_PUBLIC_PUBLIC_SEARCH_DEMO } from "@/lib/environment.client";
2425

2526
const DEFAULT_MAX_MATCH_DISPLAY_COUNT = 10000;
2627

@@ -86,6 +87,7 @@ export default function SearchPage() {
8687
const fileLanguages = searchResponse.Result.Files?.map(file => file.Language) || [];
8788

8889
captureEvent("search_finished", {
90+
query: NEXT_PUBLIC_PUBLIC_SEARCH_DEMO ? searchQuery : null, // @nocheckin
8991
contentBytesLoaded: searchResponse.Result.ContentBytesLoaded,
9092
indexBytesLoaded: searchResponse.Result.IndexBytesLoaded,
9193
crashes: searchResponse.Result.Crashes,

packages/web/src/lib/environment.client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ export const NEXT_PUBLIC_POSTHOG_ASSET_HOST = getEnv(process.env.NEXT_PUBLIC_POS
99
export const NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED = getEnvBoolean(process.env.NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED, false);
1010
export const NEXT_PUBLIC_SOURCEBOT_VERSION = getEnv(process.env.NEXT_PUBLIC_SOURCEBOT_VERSION, "unknown")!;
1111
export const NEXT_PUBLIC_DOMAIN_SUB_PATH = getEnv(process.env.NEXT_PUBLIC_DOMAIN_SUB_PATH, "")!;
12+
export const NEXT_PUBLIC_PUBLIC_SEARCH_DEMO = getEnvBoolean(process.env.NEXT_PUBLIC_PUBLIC_SEARCH_DEMO, false);

packages/web/src/lib/posthogEvents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
export type PosthogEventMap = {
44
search_finished: {
5+
query: string | null,
56
contentBytesLoaded: number,
67
indexBytesLoaded: number,
78
crashes: number,

0 commit comments

Comments
 (0)