No setup needed. Let our cloud agents run this skill for you.
Select Provider
Select Model
Claude Sonnet 4.5
$0.20/task
Best for coding tasks
No setup required
PostHog Data Handling
Overview
Privacy-safe analytics with PostHog. Covers property sanitization to strip PII before events leave the browser, consent-based tracking (opt-in/opt-out), GDPR data subject access requests and deletion, and PostHog's built-in privacy controls (IP masking, session recording masking).
import posthog from 'posthog-js';posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, { api_host: 'https://us.i.posthog.com', // Disable autocapture to control exactly what's captured autocapture: false, // Respect browser Do Not Track setting respect_dnt: true, // Don't capture until user consents opt_out_capturing_by_default: false, // Set true for opt-in model // Sanitize ALL properties before they leave the browser sanitize_properties: (properties, eventName)
// Find a person by email and export their dataasync function handleSubjectAccessRequest(email: string) { const personalKey = process.env.POSTHOG_PERSONAL_API_KEY!
Step 4: GDPR Right to Erasure (Data Deletion)
// Delete a person and all their eventsasync function handleDeletionRequest(email: string) { const personalKey = process.env.POSTHOG_PERSONAL_API_KEY!; const projectId = process.env.POSTHOG_PROJECT_ID!
Step 5: Property Filtering for Data Exports
// Strip PII from HogQL query results before exportingconst BLOCKED_PROPERTIES = ['$ip', 'email', 'phone', 'name', 'address', 'ssn'];async function safeExport(hogql:
Error Handling
Issue
Cause
Solution
PII in autocapture events
Form data captured automatically
Disable autocapture, use manual capture
IP address in events
Not stripped by sanitize_properties
Add delete properties['$ip']
Consent not persisted
opt_out state lost on reload
Store consent in cookie, call opt_out on load
Deletion API returns 404
Wrong person ID or already deleted
Search by email first, check response
Session recordings show PII
Text not masked
Add maskAllInputs: true and maskTextSelector
GDPR Compliance Checklist
sanitize_properties strips PII before events leave browser
Consent mechanism with opt_in_capturing / opt_out_capturing
respect_dnt: true in PostHog init
Session recording masks all inputs
Subject Access Request handler implemented
Data Deletion handler implemented
Privacy policy updated to mention PostHog analytics
Output
Privacy-safe PostHog initialization with property sanitization