Skip to content

Commit c5b53c2

Browse files
authored
Sanitize posthog data and add more info in README (#4)
* remove page view provider * sanatize current_url and ip properties in all posthog events * add posthog usage info in README * remove unneccessary ip property removal since we disable ip collection on posthog side * add back ip sanitization on client side (we disabled it on server side but may as well also clear it on client) and revise README on telemetry * add typo with asterisks in readme * small grammar fix in README
1 parent 9dec454 commit c5b53c2

File tree

4 files changed

+20
-39
lines changed

4 files changed

+20
-39
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Sourcebot also supports indexing GitLab & BitBucket. Checkout the [index.json](.
115115

116116
zoekt will now index your repositories (at `HEAD`). By default, it will re-index existing repositories every hour, and discover new repositories every 24 hours.
117117

118-
4. Go to `http://localhost:3000` - once a index has been created, you can start searching.
118+
4. Go to `http://localhost:3000` - once an index has been created, you can start searching.
119119

120120
## Building Sourcebot
121121

@@ -182,14 +182,16 @@ The zoekt binaries and web dependencies are placed into `bin` and `node_modules`
182182

183183
A `.sourcebot` directory will be created and zoekt will begin to index the repositories found given `config.json`.
184184

185-
6. Go to `http://localhost:3000` - once a index has been created, you can start searching.
185+
6. Go to `http://localhost:3000` - once an index has been created, you can start searching.
186186

187187

188-
## Disabling Telemetry
188+
## Telemetry
189189

190-
By default, Sourcebot collects anonymous usage data using [PostHog](https://posthog.com/). You can disable this by setting the environment variable `SOURCEBOT_TELEMETRY_DISABLED` to `1` in the docker run command:
190+
By default, Sourcebot collects anonymized usage data through [PostHog](https://posthog.com/) to help us improve the performance and reliability of our tool. We do not collect or transmit [any information related to your codebase](https://github.com/search?q=repo:TaqlaAI/sourcebot++captureEvent&type=code). All events are [sanitized](https://github.com/TaqlaAI/sourcebot/blob/main/src/app/posthogProvider.tsx) to ensure that no sensitive or identifying details leave your machine. The data we collect includes general usage statistics and metadata such as query performance (e.g., search duration, error rates) to monitor the application's health and functionality. This information helps us better understand how Sourcebot is used and where improvements can be made :)
191+
192+
If you'd like to disable all telemetry, you can do so by setting the environment variable `SOURCEBOT_TELEMETRY_DISABLED` to `1` in the docker run command:
191193
```sh
192-
docker run -e SOURCEBOT_TELEMETRY_DISABLED=1 ...stuff... ghcr.io/taqlaai/sourcebot:main
194+
docker run -e SOURCEBOT_TELEMETRY_DISABLED=1 /* additional args */ ghcr.io/taqlaai/sourcebot:main
193195
```
194196

195197
Or if you are building locally, add the following to your [.env](./.env) file:

src/app/layout.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import dynamic from "next/dynamic";
99

1010
const inter = Inter({ subsets: ["latin"] });
1111

12-
const PostHogPageView = dynamic(() => import('./posthogPageView'), {
13-
ssr: false,
14-
})
15-
1612
export const metadata: Metadata = {
1713
title: "Sourcebot",
1814
description: "Sourcebot",
@@ -31,7 +27,6 @@ export default function RootLayout({
3127
>
3228
<body className={inter.className}>
3329
<PHProvider>
34-
<PostHogPageView />
3530
<ThemeProvider
3631
attribute="class"
3732
defaultTheme="system"

src/app/posthogPageView.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/app/posthogProvider.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@ if (typeof window !== 'undefined') {
99
api_host: "/ingest",
1010
ui_host: NEXT_PUBLIC_POSTHOG_UI_HOST,
1111
person_profiles: 'identified_only',
12-
capture_pageview: false, // Disable automatic pageview capture, as we capture manually
12+
capture_pageview: false, // Disable automatic pageview capture
13+
autocapture: false, // Disable automatic event capture
14+
sanitize_properties: (properties: Record<string, any>, _event: string) => {
15+
// https://posthog.com/docs/libraries/js#config
16+
if (properties['$current_url']) {
17+
properties['$current_url'] = null;
18+
}
19+
if (properties['$ip']) {
20+
properties['$ip'] = null;
21+
}
22+
23+
return properties;
24+
}
1325
});
1426
} else {
1527
console.log("PostHog telemetry disabled");

0 commit comments

Comments
 (0)