Skip to content

Add implementation plan for linking PostHog to anonymous extension usage#128

Open
pedroheyerdahl wants to merge 5 commits intomainfrom
feat/link-posthog-distinct-id-to-anon-usage
Open

Add implementation plan for linking PostHog to anonymous extension usage#128
pedroheyerdahl wants to merge 5 commits intomainfrom
feat/link-posthog-distinct-id-to-anon-usage

Conversation

@pedroheyerdahl
Copy link

No description provided.

@vercel
Copy link

vercel bot commented Feb 11, 2026

Deployment failed with the following error:

The value for maxDuration must be between 1 second and 300 seconds, in order to increase this limit upgrade your plan: https://vercel.com/pricing

Learn More: https://vercel.com/docs/functions/limitations

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 11, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue

WARNING

File Line Issue
plans/link-posthog-to-anon-extension-usage.md 89 trim() can produce an empty string that still gets persisted
plans/link-posthog-to-anon-extension-usage.md 130 Using vscode.env.machineId (even hashed) can still be treated as personal data / a stable identifier
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
Files Reviewed (1 files)
  • plans/link-posthog-to-anon-extension-usage.md - 2 issues

Fix these issues in Kilo Cloud

@pedroheyerdahl pedroheyerdahl force-pushed the feat/link-posthog-distinct-id-to-anon-usage branch from f9a5576 to 15286b3 Compare February 11, 2026 14:34
…sers

Add security note explaining that PostHog's distinct_id uses email for
authenticated users (set via posthog.identify()) and header value for
anonymous users. Documents that PostHog links both states via alias()
call for cross-state query support.
let anonymousId = context.globalState.get<string>(STORAGE_KEY);

if (!anonymousId) {
const machineId = vscode.env.machineId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Using vscode.env.machineId (even hashed) can still be treated as personal data / a stable identifier

machineId is designed to be stable across time and can enable long-lived tracking. Even though you hash and truncate it, it’s still a deterministic per-machine identifier and may raise privacy / store-policy concerns. If the goal is just to correlate anonymous sessions, consider generating a random UUID once (stored in globalState) instead of deriving it from machineId, unless you explicitly need cross-reinstall stability and have confirmed policy compliance.

Remove regex character restrictions from distinct_id validation, keeping only length limit (255 chars) to prevent DB bloat. This supports all PostHog distinct_id formats including ULIDs (e.g., "01JFKX...") while maintaining security against malicious payloads.

Also fix SQL query to prevent division by zero in coverage calculation.
// NEW - line ~250
// Validate PostHog distinct_id from header (length limit only to prevent bloat)
const rawDistinctId = request.headers.get('x-posthog-distinct-id');
const posthogDistinctIdFromHeader = rawDistinctId && rawDistinctId.length <= 255
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: trim() can produce an empty string that still gets persisted

In the suggested backend parsing, rawDistinctId.trim() can become "" (e.g., header value is only whitespace). Because "" is not nullish, the later posthogDistinctIdFromHeader ?? undefined keeps it, so you can end up storing empty posthog_distinct_id values. Consider treating "" as undefined after trimming to avoid polluting analytics/coverage queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant