Skip to content

Commit e075812

Browse files
authored
refactor: remove telemetry (#41)
- Removed the canvas_saved event tracking from the save_canvas function in canvas.py to streamline the code. - Updated the App component to eliminate the app_loaded event tracking. - Integrated PostHog capture in ExcalidrawWrapper for user sign-in events. - Refactored ActionButton to update event names for better clarity and removed redundant tracking calls. - Simplified PostHog initialization by removing unnecessary session recording options.
1 parent 8055112 commit e075812

File tree

5 files changed

+3
-68
lines changed

5 files changed

+3
-68
lines changed

src/backend/routers/canvas.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,6 @@ async def save_canvas(data: Dict[str, Any], auth: SessionData = Depends(require_
4040
success = await store_canvas_data(user_id, data)
4141
if not success:
4242
raise HTTPException(status_code=500, detail="Failed to save canvas data")
43-
# PostHog analytics: capture canvas_saved event
44-
try:
45-
app_state = data.get("appState", {})
46-
width = app_state.get("width")
47-
height = app_state.get("height")
48-
zoom = app_state.get("zoom", {}).get("value")
49-
full_url = None
50-
if request:
51-
full_url = str(request.base_url).rstrip("/") + str(request.url.path)
52-
full_url = full_url.replace("http://", "https://")
53-
posthog.capture(
54-
distinct_id=user_id,
55-
event="canvas_saved",
56-
properties={
57-
"pad_width": width,
58-
"pad_height": height,
59-
"pad_zoom": zoom,
60-
"$current_url": full_url,
61-
}
62-
)
63-
except Exception as e:
64-
print(f"Error capturing canvas_saved event: {str(e)}")
65-
pass
6643
return {"status": "success"}
6744

6845
@canvas_router.get("")

src/frontend/src/App.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useState, useCallback, useEffect, useRef } from "react";
22
import { useCanvas, useDefaultCanvas, useUserProfile } from "./api/hooks";
33
import { ExcalidrawWrapper } from "./ExcalidrawWrapper";
44
import { debounce } from "./utils/debounce";
5-
import { capture } from "./utils/posthog";
65
import posthog from "./utils/posthog";
76
import { normalizeCanvasData } from "./utils/canvasUtils";
87
import { useSaveCanvas } from "./api/hooks";
@@ -56,16 +55,6 @@ export default function App({
5655
}
5756
});
5857

59-
useEffect(() => {
60-
if (excalidrawAPI) {
61-
(window as any).excalidrawAPI = excalidrawAPI;
62-
capture('app_loaded');
63-
}
64-
return () => {
65-
(window as any).excalidrawAPI = null;
66-
};
67-
}, [excalidrawAPI]);
68-
6958
const lastSentCanvasDataRef = useRef<string>("");
7059

7160
const debouncedLogChange = useCallback(

src/frontend/src/ExcalidrawWrapper.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { lockEmbeddables, renderCustomEmbeddable } from './CustomEmbeddableRende
99
import AuthDialog from './ui/AuthDialog';
1010
import BackupsModal from './ui/BackupsDialog';
1111
import SettingsDialog from './ui/SettingsDialog';
12+
import { capture } from './utils/posthog';
1213

1314
const defaultInitialData = {
1415
elements: [],
@@ -56,6 +57,7 @@ export const ExcalidrawWrapper: React.FC<ExcalidrawWrapperProps> = ({
5657
useEffect(() => {
5758
if (isAuthenticated === true) {
5859
setIsExiting(true);
60+
capture('signed_in');
5961
}
6062
}, [isAuthenticated]);
6163

src/frontend/src/pad/buttons/ActionButton.tsx

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,7 @@ const ActionButton: React.FC<ActionButtonProps> = ({
311311

312312

313313
const executeAction = () => {
314-
// Track button click event with PostHog
315-
capture('custom_button_clicked', {
314+
capture('action_button_clicked', {
316315
target: selectedTarget,
317316
action: selectedAction,
318317
codeVariant: selectedTarget === 'code' ? selectedCodeVariant : null
@@ -345,11 +344,6 @@ const ActionButton: React.FC<ActionButtonProps> = ({
345344

346345
console.debug(`[pad.ws] Embedded ${selectedTarget} at URL: ${baseUrl}`);
347346

348-
// Track successful embed action
349-
capture('embed_created', {
350-
target: selectedTarget,
351-
url: baseUrl
352-
});
353347
} else if (selectedAction === 'open-tab') {
354348
const baseUrl = getUrl();
355349
if (!baseUrl) {
@@ -360,11 +354,6 @@ const ActionButton: React.FC<ActionButtonProps> = ({
360354
console.debug(`[pad.ws] Opening ${selectedTarget} in new tab from ${baseUrl}`);
361355
window.open(baseUrl, '_blank');
362356

363-
// Track tab open action
364-
capture('tab_opened', {
365-
target: selectedTarget,
366-
url: baseUrl
367-
});
368357
} else if (selectedAction === 'magnet') {
369358
if (!workspaceState) {
370359
console.error('Workspace state not available for magnet link');
@@ -386,13 +375,6 @@ const ActionButton: React.FC<ActionButtonProps> = ({
386375
magnetLink = `${prefix}://coder.coder-remote/open?owner=${owner}&workspace=${workspace}&url=${url}&token=&openRecent=true&agent=${agent}`;
387376
console.debug(`[pad.ws] Opening ${selectedCodeVariant} desktop app with magnet link: ${magnetLink}`);
388377
window.open(magnetLink, '_blank');
389-
390-
// Track desktop app open action
391-
capture('desktop_app_opened', {
392-
target: selectedTarget,
393-
codeVariant: selectedCodeVariant,
394-
workspace: workspace
395-
});
396378
}
397379
}
398380
};
@@ -426,14 +408,6 @@ const ActionButton: React.FC<ActionButtonProps> = ({
426408
const newShowOptions = !showOptions;
427409
setShowOptions(newShowOptions);
428410

429-
// Track settings toggle event
430-
capture('custom_button_edit_settings', {
431-
target: selectedTarget,
432-
action: selectedAction,
433-
codeVariant: selectedTarget === 'code' ? selectedCodeVariant : null,
434-
showOptions: newShowOptions
435-
});
436-
437411
if (onSettingsToggle) {
438412
onSettingsToggle(newShowOptions);
439413
}

src/frontend/src/utils/posthog.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ import posthog from 'posthog-js';
44
if (import.meta.env.VITE_PUBLIC_POSTHOG_KEY) {
55
posthog.init(import.meta.env.VITE_PUBLIC_POSTHOG_KEY, {
66
api_host: import.meta.env.VITE_PUBLIC_POSTHOG_HOST,
7-
debug: false,
8-
session_recording: {
9-
recordCrossOriginIframes: true,
10-
captureCanvas: {
11-
recordCanvas: false,
12-
}
13-
},
147
});
158
console.debug('[pad.ws] PostHog initialized successfully');
169
} else {

0 commit comments

Comments
 (0)