Skip to content

Privacy & Compliance

Implement GDPR-compliant consent management and understand how Kitbase handles privacy.

Privacy Configuration

typescript
const kitbase = new Kitbase({
  token: '<YOUR_API_KEY>',
  privacy: {
    requireConsent: true,        // Block tracking until consent given
    respectDoNotTrack: true,     // Honor browser DNT setting
    anonymizeIp: true,           // Anonymize IP addresses
  },
});

Options

OptionDefaultDescription
requireConsentfalseBlock tracking until optIn() is called
respectDoNotTrackfalseHonor browser's Do Not Track setting
anonymizeIpfalseAnonymize IP addresses on the server
typescript
if (!kitbase.hasConsent()) {
  showConsentBanner();
}

Opt In / Opt Out

typescript
// User accepts tracking
kitbase.optIn();

// User rejects tracking (clears stored data)
await kitbase.optOut();

// Check opt-out status
if (kitbase.isOptedOut()) {
  // All tracking is blocked
}

GDPR Implementation

typescript
const kitbase = new Kitbase({
  token: '<YOUR_API_KEY>',
  privacy: {
    requireConsent: true,
  },
});

// Show consent banner on first visit
if (!kitbase.hasConsent()) {
  showConsentBanner({
    onAccept: () => {
      kitbase.optIn();
      kitbase.track({
        channel: 'engagement',
        event: 'Consent Given',
      });
    },
    onReject: async () => {
      await kitbase.optOut();
    },
  });
}

GDPR Compliance

When requireConsent: true, no events are tracked until optIn() is called. The optOut() method clears all stored identifiers including anonymous ID.

Bot Filtering

Kitbase automatically filters out bot and crawler traffic. Events are not sent when your app is opened in:

  • Headless browsers (Puppeteer, Playwright, PhantomJS)
  • Automated testing tools (Selenium, WebDriver)
  • HTTP clients (curl, wget, Postman)
  • Search engine crawlers (Googlebot, Bingbot)
  • Social media crawlers (Facebook, Twitter, Slack)

This happens automatically — no configuration needed. Your analytics will only include real user traffic.

typescript
// Initialize with consent required
const kitbase = new Kitbase({
  token: '<YOUR_API_KEY>',
  privacy: { requireConsent: true },
});

// Your cookie consent library
cookieConsent.on('accept', () => {
  kitbase.optIn();
});

cookieConsent.on('reject', async () => {
  await kitbase.optOut();
});

Privacy-First Analytics

typescript
const kitbase = new Kitbase({
  token: '<YOUR_API_KEY>',
  privacy: {
    requireConsent: false,      // Track without explicit consent...
    anonymizeIp: true,          // ...but anonymize IPs
    respectDoNotTrack: true,    // Honor DNT header
  },
});

Data Deletion

When a user requests data deletion (GDPR Article 17):

typescript
// Opt out the user
await kitbase.optOut();

// Clear any local data
kitbase.clearSuperProperties();
await kitbase.clearQueue();

Released under the MIT License.