Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ContextFort-AI/ContextFort/llms.txt

Use this file to discover all available pages before exploring further.

ContextFort uses PostHog for analytics to track extension usage, agent sessions, and security events. Analytics can be completely disabled with a single configuration change.

Quick Disable

To disable all analytics tracking, change the ENABLE_POSTHOG flag in the background script:
background.js:2
const ENABLE_POSTHOG = false;  // Set to false to disable
When set to false, all tracking stops immediately. No other changes are needed.

Configuration Flag

The analytics system is controlled by a feature flag at the top of the background script:
background.js:1-4
// ============================================================================
const ENABLE_POSTHOG = true;
const ENABLE_AUTH = false;
// ============================================================================
This flag must be changed before building the extension. After changing, run ./build-all.sh to rebuild.

Initialization

PostHog is conditionally initialized based on the flag:
background.js:9-14
// POSTHOG
// ============================================================================
import { initPostHog, trackEvent, identifyUser } from './posthog-config.js';
if (ENABLE_POSTHOG) {
  initPostHog();
}

Wrapper Functions

All tracking calls use wrapper functions that check the feature flag:

Safe Track Event

background.js:16-21
function safeTrackEvent(eventName, properties) {
  if (ENABLE_POSTHOG) {
    trackEvent(eventName, properties);
  }
}

Safe Identify User

background.js:23-27
function safeIdentifyUser(userId, userProperties) {
  if (ENABLE_POSTHOG) {
    identifyUser(userId, userProperties);
  }
}
Always use safeTrackEvent() and safeIdentifyUser() instead of calling PostHog directly. This ensures tracking respects the feature flag.

Events Tracked

When analytics is enabled, the following events are tracked:

Extension Lifecycle

Extension Installed:
background.js:33-37
chrome.runtime.onInstalled.addListener((details) => {
  if (details.reason === 'install') {
    safeTrackEvent('extension_installed', {
      version: chrome.runtime.getManifest().version
    });
  }
});
Extension Updated:
background.js:38-42
else if (details.reason === 'update') {
  safeTrackEvent('extension_updated', {
    version: chrome.runtime.getManifest().version,
    previousVersion: details.previousVersion
  });
}
Extension Started:
background.js:46-48
safeTrackEvent('extension_started', {
  version: chrome.runtime.getManifest().version
});

Agent Activity

Agent detection, navigation blocking, and action blocking events are tracked to help understand how security rules are being used.

Data Collected

When analytics is enabled, PostHog collects:
  1. Session Events - When agent mode starts/stops
  2. Blocking Events - When navigation or actions are blocked
  3. Rule Changes - When users update blocking/governance rules
  4. Extension Lifecycle - Install, update, startup events
  5. User Identification - Email (only if authentication is enabled)
No personal browsing data is collected. Only metadata about agent sessions and rule usage is tracked.

PostHog Configuration

The PostHog configuration is stored in a separate file:
posthog-config.js
import { initPostHog, trackEvent, identifyUser } from './posthog-config.js';
This file contains:
  • PostHog API host: https://us.i.posthog.com
  • PostHog initialization settings
  • Event tracking functions
  • User identification functions

Permissions

The extension’s Content Security Policy includes PostHog:
manifest.json:51
"connect-src 'self' https://*.posthog.com"
If you disable analytics, you can optionally remove this CSP entry.

Complete Removal (Optional)

If you want to completely remove PostHog from the codebase:
1

Set Feature Flag

Change ENABLE_POSTHOG = false in background.js:2
2

Delete Config File

Remove chrome-extension/posthog-config.js
3

Remove Import

Delete the PostHog import statement from background.js:10
4

Remove CSP Entry

Remove https://*.posthog.com from manifest.json Content Security Policy
5

Remove Dependency

Remove posthog-js from package.json dependencies
6

Rebuild Extension

Run ./build-all.sh to rebuild the extension
Just setting ENABLE_POSTHOG = false is sufficient to disable all tracking. Complete removal is optional.

Privacy Considerations

What is NOT Tracked

  • Specific URLs visited during agent sessions
  • Page content or screenshots
  • Personal data from web pages
  • Browsing history
  • Cookies or authentication tokens

What IS Tracked

  • Extension version numbers
  • Number of agent sessions started/stopped
  • Number of blocking rules configured
  • Types of blocking events (URL, action, governance)
  • User email (only if authentication is enabled)

Data Storage

  • Data is stored on PostHog’s servers (US region)
  • PostHog is self-hosted analytics (not Google Analytics)
  • No third-party cookies are used
  • Users can disable analytics with one line change

Testing Analytics

To test that analytics is properly disabled:
1

Set Flag to False

Change ENABLE_POSTHOG = false in background.js
2

Rebuild Extension

Run ./build-all.sh
3

Load Extension

Load the rebuilt extension in Chrome
4

Check Network Tab

Open Chrome DevTools Network tab and verify no requests to posthog.com
5

Trigger Events

Start agent mode, create rules, etc. and verify still no PostHog requests

Environment-Specific Configuration

You can use different analytics settings for development vs. production:
const ENABLE_POSTHOG = process.env.NODE_ENV === 'production';
This enables analytics only in production builds.

Best Practices

  1. Disclose to Users: Include analytics disclosure in your privacy policy
  2. Respect Privacy: Only enable analytics if you need usage insights
  3. Test Disabled State: Verify the extension works properly with analytics off
  4. Document Changes: Keep notes on why analytics is enabled/disabled
  5. Review Events: Periodically review what events are being tracked
  • PostHog Documentation - Official PostHog docs
  • Source: chrome-extension/background.js - Feature flag location
  • Source: chrome-extension/posthog-config.js - PostHog initialization
  • Source: POSTHOG.md - Detailed PostHog implementation guide

Build docs developers (and LLMs) love