Skip to content

feat: Add generic configuration support to setup method for PostHog #610

@dwolfand

Description

@dwolfand

Plugin(s)

  • Accelerometer
  • Android Battery Optimization
  • Android Dark Mode Support
  • Android Edge-to-Edge Support
  • Android Foreground Service
  • App Review
  • App Shortcuts
  • App Update
  • Asset Manager
  • Audio Recorder
  • Background Task
  • Badge
  • Barometer
  • Bluetooth Low Energy
  • Cloudinary
  • Contacts
  • Datetime Picker
  • File Compressor
  • File Opener
  • File Picker
  • Live Update
  • Managed Configurations
  • NFC
  • Pedometer
  • Photo Editor
  • Posthog
  • Printer
  • Screen Orientation
  • Screenshot
  • Speech Recognition
  • Speech Synthesis
  • SQLite
  • Torch
  • Zip

Current problem

The PostHog plugin's setup() method only accepts apiKey and host parameters, preventing developers from customizing other PostHog SDK options like autocapture, enable_recording_console_log, debug mode, etc.
This forces developers to accept default behavior or implement workarounds when they need custom PostHog configurations.

Preferred solution

Add an optional config parameter to SetupOptions that accepts Record<string, any>:

interface SetupOptions {
  apiKey: string;
  host?: string;
  config?: Record<string, any>; // New parameter
}

Usage:

await Posthog.setup({
  apiKey: 'YOUR_API_KEY',
  host: 'https://eu.i.posthog.com',
  config: {
    autocapture: false,
    enable_recording_console_log: true,
    debug: true,
  },
});

Benefits:

  • Enables customization of any PostHog SDK option
  • Cross-platform support (Web, Android, iOS)
  • Backward compatible
  • Future-proof for new SDK options

Alternative options

No response

Additional context

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions