Migrate from PostHog

Move flags, experiments, cohorts, actions, dashboards, insights, persons and event history from PostHog to Lucida with lucida import posthog, what maps and what does not, and what works when you point a PostHog SDK at Lucida.

Embed
Preview of the card
<a href="https://lucidace.com/help/migrate-from-posthog"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/47767b6e-0308-4489-9598-f4976500bdd7/social-card.svg?v=3e7ae33eec8b" alt="Migrate from PostHog" width="600" height="315"></a>

lucida import posthog reads a PostHog project through PostHog's public REST API and writes it into a Lucida project. It is safe to re-run: definitions are matched by flag key or name, and persons and events keep their original uuid and timestamp, so Lucida's at-least-once ingest dedupes them.

Run it

export POSTHOG_PERSONAL_API_KEY=phx_...      # or: ... | lucida import posthog --key-stdin
export LC_SECRET_KEY=lc_sk_...               # capture key, needed for persons, groups and events

# 1. see the plan first: counts per kind and everything that will not be imported
lucida import posthog --project 12345 --dry-run --since 2025-01-01 --report plan.json

# 2. definitions only
lucida import posthog --project 12345 --only groups,cohorts,actions,flags,experiments,insights,dashboards

# 3. persons and a backfill window, resumable
lucida import posthog --project 12345 --only persons,events \
  --since 2025-01-01 --until 2025-11-01 --checkpoint ph.checkpoint --report report.json

Flag

Meaning

--project

The PostHog project id (the number in your PostHog URL). Required.

--host

https://us.posthog.com (default), https://eu.posthog.com or your self-hosted URL.

--lucida-project

The Lucida project to write to. Default: $LC_PROJECT_ID or the lucida login default.

--only

Any of groups,cohorts,actions,flags,experiments,insights,dashboards,persons,events. Default: all. dashboards also imports the insights on them.

--since, --until

Event backfill window, RFC 3339 or YYYY-MM-DD. --since is required with events; --until is exclusive and defaults to now.

--checkpoint

File that remembers the last event sent and the next persons page. Re-run the same command after an interruption and it continues.

--dry-run

Reads PostHog (and Lucida, to count creates and updates), writes nothing.

--report

Also write the final report as JSON. Exit code 1 when any kind recorded an error.

--capture-key, --gateway

Secret capture key (default $LC_SECRET_KEY) and gateway URL (default $LC_GATEWAY_URL; with the hosted API at https://lucidace.com it is https://capture.lucidace.com, otherwise the API URL).

The PostHog key is never taken from a flag, so it stays out of shell history. It needs read access to the project.

Persons, groups and events go through the gateway's server-side batch route (/v1/s2s/batch) with a secret capture key, because public keys clamp old timestamps. The command retries network errors, 5xx and 429, honours Retry-After and the Ratelimit-* headers from both PostHog and Lucida, and sends events in batches of --batch (default 500).

What maps

PostHog

Lucida

Notes

Feature flags

Flags with the same key

Condition sets, property filters, rollout percentage, multivariate variants and their payloads, JSON payloads, group aggregation, flag dependencies and cohort filters (re-pointed at the imported cohort). Tagged imported, posthog.

Experiments

Draft experiments linked to their flag

Name, hypothesis, variants and traffic. Never started: nothing is exposed until you start them in Lucida. Results and metrics are not copied.

Cohorts

Cohorts

Person-property criteria and "performed event" (with count and a relative window) become dynamic cohorts. Static cohorts are created and filled with their members.

Actions

Actions

Event, selector, tag, text, href and URL steps with their match modes, and property filters.

Groups and group types

$groupidentify events

One per group, with its properties.

Dashboards

Dashboards

With the translated insight tiles and text tiles. Tile layout (size, position on the grid) is not copied; tiles keep their order.

Insights

Insights

Trends, funnels (ordered, steps view), retention (on events), paths, stickiness and lifecycle over events, with property filters, breakdowns, compare and relative date ranges.

Persons

$identify per person, $create_alias per extra distinct id

All properties.

Events

Events

uuid, event, distinct_id, timestamp and properties unchanged. Lucida strips client $lc_* properties at the gateway as for any event.

What does not map (and is reported)

Every item below is listed in the report with the reason, never silently changed. A flag or insight is imported whole or not at all.

  • Flags: super conditions (use Lucida early access), behavioral filters, is_date_exact and *_multi operators.

  • Experiments: fewer than two variants or a rollout that does not sum to 100. Metrics, results and running state.

  • Cohorts: sequences, stopped/restarted/first-time/regular behaviors, lifecycle, cohorts of cohorts, criteria on actions, absolute time windows, mixed AND/OR nesting.

  • Actions: regex text matching.

  • Insights: HogQL / SQL insights, formulas, series over actions or data warehouse tables or "all events", unordered and strict funnels, funnel time-to-convert and trends views, first-time retention, cohort breakdowns, absolute-looking relative dates such as -1dStart, math types without a Lucida equivalent, and legacy filters-only insights (re-save them in PostHog first).

  • Not read at all: session recordings, surveys, annotations, alerts, data pipelines/destinations, notebooks, web analytics settings, warehouse tables. Replay history cannot be moved; new recordings start when the Lucida SDK is installed.

Check before you rely on it

The tool was written against PostHog's documented response shapes and tested against a fake PostHog server; it has not been run against a live PostHog project. The events export uses the documented query API (HogQLQuery). Run --dry-run first (it counts events in the window) and try a one-day window before the full backfill.

PostHog SDK compatibility

The Lucida gateway accepts PostHog's wire format on PostHog's own paths, so an existing PostHog SDK can send to Lucida by changing two settings: the host and the project key. Put your Lucida public key (lc_pk_...) where the PostHog project token went, and set the SDK's api_host to your Lucida gateway.

What works:

  • Capture: POST /e, /e/, /i/v0/e, /capture and /batch (a body with batch), single events, arrays and {"batch": [...]}, gzip and base64 bodies. The api_key, or properties.token, is read as the Lucida key. $set and $set_once inside properties are lifted out. Events without a uuid get a deterministic one, so SDK retries dedupe.

  • Flags: POST /decide (and ?v=4) answers from Lucida's flag evaluation: values, variants and payloads (payloads as JSON strings, as PostHog sends them), disable_flags, group and person properties. PostHog's local-evaluation endpoint is not served: SDKs that evaluate locally must call /decide instead.

  • Identity calls: $identify, $create_alias, $groupidentify, $set / $set_once and group properties arrive as events and are handled like Lucida's own.

What must change or does not work:

  • The key. A PostHog project token (phc_...) is rejected. Create a public key with lucida keys create --kind public.

  • Session replay. /decide reports sessionRecording: false; posthog-js recording does not upload to Lucida. Install the Lucida SDK for replay.

  • Anything outside capture and /decide. There is no PostHog-compatible /flags (the newer path) route, no surveys, toolbar, web experiments config, error tracking or /s/ recording routes. SDK features that call them get a 404 and the SDK carries on without them.

  • Server SDK admin calls. The personal-API-key endpoints (/api/projects/...) are PostHog's management API and are not served; Lucida's management API is under /v1.

  • Autocapture parity. posthog-js autocapture events are ingested, but an event's element chain is read by Lucida's own query model, so queries copied from PostHog's HogQL need a rewrite.

Switching the SDK host first, then running the import for history, keeps one continuous series: new events arrive live while the import fills in everything before the cutover. Set --until to the moment you switched.

Updated