Skip to content

fix(posthog): read sessionReplayConfig from Capacitor config on Android#816

Open
ciceroapps93 wants to merge 4 commits intocapawesome-team:mainfrom
ciceroapps93:fix/android-session-replay-config
Open

fix(posthog): read sessionReplayConfig from Capacitor config on Android#816
ciceroapps93 wants to merge 4 commits intocapawesome-team:mainfrom
ciceroapps93:fix/android-session-replay-config

Conversation

@ciceroapps93
Copy link
Copy Markdown

Summary

The getPosthogConfig() method on Android does not read the sessionReplayConfig object from the Capacitor plugin configuration, causing session replay masking options (maskAllTextInputs, maskAllImages, maskAllSandboxedViews, screenshotMode, captureNetworkTelemetry, debouncerDelay) to be silently ignored during auto-initialization from capacitor.config.ts.

The iOS implementation already reads this config correctly in posthogConfig() (PosthogPlugin.swift L257-L266), and the Android setup() PluginMethod (JS-callable path) also handles it correctly (PosthogPlugin.java L298-L309). Only the Android auto-init path is missing it.

Reproduction

Configure sessionReplayConfig in capacitor.config.ts:

Posthog: {
  apiKey: '...',
  apiHost: '...',
  enableSessionReplay: true,
  sessionReplayConfig: {
    maskAllTextInputs: false,
    maskAllImages: false,
  },
},

On iOS, masking is disabled as expected. On Android, all content remains masked because sessionReplayConfig is never read from the config.

Fix

Adds the missing sessionReplayConfig parsing to getPosthogConfig(), matching the existing iOS implementation and the Android setup() method.

The `getPosthogConfig()` method on Android does not read the
`sessionReplayConfig` object from the Capacitor plugin configuration,
causing session replay masking options (maskAllTextInputs, maskAllImages,
etc.) to be silently ignored during auto-initialization. The iOS
implementation already reads this config correctly in `posthogConfig()`.

This adds the missing `sessionReplayConfig` parsing to the Android
`getPosthogConfig()` method, matching the existing behavior in:
- iOS `PosthogPlugin.swift` `posthogConfig()` method
- Android `setup()` PluginMethod (JS-callable path)
@robingenz robingenz requested a review from Copilot April 1, 2026 05:59
@robingenz robingenz self-assigned this Apr 1, 2026
@robingenz robingenz added bug/fix Something isn't working package: posthog labels Apr 1, 2026
Copy link
Copy Markdown
Member

@robingenz robingenz left a comment

Choose a reason for hiding this comment

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

Please run npm run changeset to geenrate a changeset file.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Android auto-initialization for the Posthog Capacitor plugin so that sessionReplayConfig from capacitor.config.* is actually parsed and applied (matching iOS behavior and the Android setup() method).

Changes:

  • Parse sessionReplayConfig inside Android getPosthogConfig() and map it into SessionReplayOptions.
  • Add the required JSON import for reading nested config values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@robingenz
Copy link
Copy Markdown
Member

Please also check out the GitHub Copilot review.

…js/plugins/posthog/PosthogPlugin.java


- align with documentation defaults

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread .changeset/busy-poems-warn.md Outdated
Copy link
Copy Markdown
Member

@robingenz robingenz left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Copy Markdown
Member

@robingenz robingenz left a comment

Choose a reason for hiding this comment

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

Please run npm run fmt to fix the formatting issues.

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

Labels

bug/fix Something isn't working package: posthog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants