Skip to content

feat: Add Browserless rendering backend for image exports#60793

Merged
jordanm-posthog merged 5 commits into
masterfrom
jordanm-posthog/imageExportBrowserless
Jun 1, 2026
Merged

feat: Add Browserless rendering backend for image exports#60793
jordanm-posthog merged 5 commits into
masterfrom
jordanm-posthog/imageExportBrowserless

Conversation

@jordanm-posthog
Copy link
Copy Markdown
Contributor

@jordanm-posthog jordanm-posthog commented May 31, 2026

Problem

Move image export to Browserless behind a feature flag

Changes

Add a Playwright/browserless rendering backend for PNG image exports (insights, dashboards, replays, heatmaps) alongside the existing Selenium path.

How did you test this code?

Locally, new tests

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

🤖 Agent context

@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team May 31, 2026 00:29
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 31, 2026

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
posthog/settings/exports.py:3-4
Inconsistent env var naming will confuse operators. Two of the four settings read from `HEATMAP_BROWSERLESS_*` env vars (which belong to the Heatmap feature), while the two timeout settings read from `BROWSERLESS_*` env vars. A deployer who reads `BROWSERLESS_SESSION_TIMEOUT_MS` and logically tries to set `BROWSERLESS_CDP_URL` will have no effect — the actual env var that matters is `HEATMAP_BROWSERLESS_URL`. If re-using the existing Heatmap instance is intentional, the variable names or comments should make that explicit; otherwise the env var names should match their Python setting names.

```suggestion
BROWSERLESS_CDP_URL: str = get_from_env("BROWSERLESS_CDP_URL", "")
BROWSERLESS_TOKEN: str = get_from_env("BROWSERLESS_TOKEN", "")
```

### Issue 2 of 2
posthog/tasks/exports/image_exporter.py:597
The page-load timeout re-raise drops the exception cause chain. The original `PlaywrightTimeoutError` has already been sent to Sentry via `capture_exception`, but Python's chained-exception context is lost, which makes it harder to trace the root error in local logs or wherever the re-raised exception is caught upstream. Adding `from e` preserves the chain at zero cost.

```suggestion
                raise PlaywrightTimeoutError("Timeout while waiting for the page to load") from e
```

Reviews (1): Last reviewed commit: "Add Browserless rendering backend for im..." | Re-trigger Greptile

Comment thread posthog/tasks/exports/image_exporter.py Outdated
Comment thread posthog/settings/exports.py Outdated
Comment thread posthog/tasks/exports/image_exporter.py Outdated
@jordanm-posthog jordanm-posthog merged commit 5bff6fc into master Jun 1, 2026
198 checks passed
@jordanm-posthog jordanm-posthog deleted the jordanm-posthog/imageExportBrowserless branch June 1, 2026 14:15
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented Jun 1, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-06-01 15:00 UTC Run
prod-us ✅ Deployed 2026-06-01 15:26 UTC Run
prod-eu ✅ Deployed 2026-06-01 15:32 UTC Run

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants