Repository navigation
Immutable
release. Only release title and notes can be modified.
5.0.0
Major Changes
- #5990
a393b4fThanks @turnipdabeets! - - Breaking: session replay, native crash capture and push notification capture need the optional@posthog/react-native-plugin3.x.posthog-react-native-session-replayis no longer loaded, and a plugin older than 3.0 is ignored with a warning to upgrade- Breaking: remove the
PostHogProviderapiKeyprop — passprojectTokeninstead - Breaking: remove
evaluationEnvironmentsfrom thePostHogOptionstype — passevaluationContextsinstead - Breaking: remove
disableRemoteConfig, which had no effect, from thePostHogOptionstype - Breaking: remove
disable_capture_url_hashes, which had no effect, from thePostHogOptionstype - Breaking: remove
sessionReplayConfig.iOSdebouncerDelayMsandandroidDebouncerDelayMs— passthrottleDelayMsinstead - Breaking: remove
sessionReplayConfig.screenshotModeBackgroundCapture, because posthog-ios 4.0 removed background capture — delete it, or try experimentaliOSCaptureMethod: 'gpu' - Breaking: remove the
autocapture.navigationRefoption and thePostHogNavigationReftype, and drop thenavigationRefargument fromuseNavigationTracker(options, client) - Breaking:
onFeatureFlagscallbacks receive one object,{ flags, variants, errorsLoading }, like posthog-ios, posthog-android and posthog_flutter:flagslists the enabled flag keys,variantsmaps them totrueor their variant, anderrorsLoadingistruewhen the latest load failed (the values are then the last known ones). Disabled flags and flags whose variant is an empty string are left out. ReplaceonFeatureFlags((flags) => …)withonFeatureFlags(({ flags, variants, errorsLoading }) => …) - Breaking: a callback registered after flags have loaded is also called once with the current values, right after
onFeatureFlagsreturns - Breaking: a feature flag payload that isn't valid JSON, including an empty one, reads as
nullinstead of its raw string - Breaking:
reloadFeatureFlagsAsync()resolves with{ flags, variants, errorsLoading }, the objectonFeatureFlagscallbacks receive, instead of a map of every loaded flag. After a failed reload it resolves with the last known flags anderrorsLoading: trueinstead ofundefined - Breaking: a flag whose variant is an empty string reads as disabled (
enabled: false) ingetFeatureFlagResult(),getAllFeatureFlags()anduseFeatureFlagResult(), as it already did inisFeatureEnabled(), like posthog-ios and posthog-android 4.0 - Breaking: leave disabled flags and flags whose variant is an empty string out of
$active_feature_flags, like posthog-ios and posthog-android - Breaking: keep a string payload in
bootstrap.featureFlagPayloadsas a string instead of parsing it as JSON, like posthog-ios 4.0 — pass decoded values, such as{ color: 'blue' }instead of'{"color":"blue"}' - Breaking:
getAllFeatureFlags()returnsundefinedinstead of an empty list before flags first load — useposthog.getAllFeatureFlags() ?? []where you only iterate - Breaking:
getFeatureFlag()returnsundefinedinstead offalsefor a flag that isn't in the loaded flags, like posthog-ios, posthog-android and posthog_flutter — usegetFeatureFlagResult(key)?.enabled === falseto check that a flag is off - Breaking:
isFeatureEnabled()without adefaultValuereturnsfalseinstead ofundefinedwhen the flag has no value, such as before flags load, like posthog-ios, posthog-android and posthog_flutter — usegetFeatureFlagResult(key) === undefinedto check that a flag has no value yet - Breaking:
$feature_flag_calledevents carry$used_bootstrap_valueonly for a flag set inbootstrap.featureFlags, like posthog-ios and posthog-android - Breaking:
getFeatureFlagDetails()is internal and can change in any release — usegetAllFeatureFlags() - Breaking:
identify()requires a distinct ID in its type, like posthog-ios, posthog-android and posthog_flutter — replaceidentify(undefined, properties)withsetPersonProperties(properties) - Breaking:
identify()with an empty or whitespace-only distinct ID logs a warning and does nothing, like posthog-ios and posthog-android, instead of saving a blank distinct ID or sending$setfor the current one - Breaking:
PostHogextendsPostHogCoreBasefrom@posthog/coreinstead ofPostHogCore, which only matters to code that refers to those types - Breaking: rename the per-call
sendEventoption ofgetFeatureFlag(),getFeatureFlagResult()andisFeatureEnabled()tosendFeatureFlagEvent - Breaking: remove
getFeatureFlagPayload()— usegetFeatureFlagResult(key, { sendFeatureFlagEvent: false })?.payload - Breaking: remove
getFeatureFlags(),getFeatureFlagPayloads()andgetFeatureFlagsAndPayloads()— usegetAllFeatureFlags() - Breaking: remove
onFeatureFlag()— useonFeatureFlags()and read the flag withgetFeatureFlagResult() - Breaking: remove
overrideFeatureFlag()— useupdateFlags(), and setdisableRemoteFeatureFlagsto keep the values from being replaced by the next load. Overrides set with it in 4.x are cleared on upgrade - Breaking: remove the
useFeatureFlagWithPayload()hook and itsFeatureFlagWithPayloadtype — useuseFeatureFlagResult() - Breaking: remove the
useFeatureFlag()hook — useuseFeatureFlagVariantKey(key)for the value oruseFeatureFlagEnabled(key)for on/off. For a flag that isn't in the loaded flags, both returnundefined(or the default you pass touseFeatureFlagEnabled()) whereuseFeatureFlag()returnedfalse - Breaking: remove the
useFeatureFlags()hook — useuseActiveFeatureFlags()for the enabled flag keys - Breaking: a registered or caller
$is_identifiedproperty replaces the SDK's value on that event, and anullone sends the event without it, including a fatal exception the native SDK sends. A registered or caller$process_person_profiledecides whether that event processes the person, where 4.x replaced it with its own value; anullone counts as unset - Breaking: leave a registered
$process_person_profileoff$identify,$create_alias,$groupidentify,$set,$set_onceand$merge_dangerouslyevents, so registeringfalseno longer stopsidentify(),alias(),group()andsetPersonProperties()from working; abefore_sendhook can still set it - Breaking: send person processing as posthog-ios and posthog-android 4.0 do: an event that doesn't process the person gets the
process_person_profile: falsecapture v1 option, and one that does gets none. Events no longer carry a$process_person_profileproperty unless you set one, sobefore_senddoesn't see it, and removing or changing$process_person_profilethere doesn't make a personless event process the person - Breaking: add
$is_identifiedto$autocaptureevents, and send them with theprocess_person_profile: falseoption for anonymous users underpersonProfiles: 'identified_only', so anonymous autocapture follows the policy like other events - Breaking: leave
nullandundefinedproperty values off events;$set,$set_onceand$group_setkeep theirnullvalues, which clear the person or group property - Breaking: let a registered property replace the SDK's own value of the same name, such as
$os_name,$app_version,$screen_width,$feature/<key>or$active_feature_flags, like posthog-ios and posthog-android 4.0; a property passed on the call still wins over both - Breaking: fill
$liband$lib_versionas a pair after your properties, like posthog-ios and posthog-android 4.0: a$libyou pass or register without$lib_versionis sent without one, and a$lib_versionwithout$libis replaced by the SDK's - Breaking: a
$groupsyou pass tocapture(),screen()orcaptureException()adds to the groups set withgroup()for that event, the passed key winning per group type, like posthog-ios and posthog-android 4.0. It's no longer saved for later events, doesn't reload feature flags, and doesn't make an anonymous user's events process the person underpersonProfiles: 'identified_only'— callgroup()for groups that should stick. A$groupsyou pass toidentify()is no longer saved either - Breaking: send a registered or caller
$session_idon that event instead of the SDK's session id; anull, blank or non-string one counts as unset - Breaking: send
$session_idand$window_idas the top-levelsession_idandwindow_idfields of the capture v1 event, like posthog-ios and posthog-android 4.0, and drop a$window_id, or a$session_idset inbefore_send, that isn't a string, with a console warning; the rest of the event is still sent - Breaking: let a registered or caller
$geoip_disablewin over thedisableGeoipoption; a per-calldisableGeoipwins over the option and a registered value, and is sent as$geoip_disable: trueorfalse; a$geoip_disableyou pass on the call wins over all of them - Breaking: let a registered or caller
$recording_statusor$sdk_debug_*property win over the SDK's session replay debug value, except$sdk_debug_pending_queue_size - Breaking: send events to capture v1 (
/i/v1/analytics/events) instead of/batch/, authenticated withAuthorization: Bearer <projectToken>— serve this path on reverse proxies and self-hosted instances - Breaking: send
$cookieless_mode,$ignore_sent_atand$product_tour_idas the capture v1 optionscookieless_mode,disable_skew_correctionandproduct_tour_id, with their values unchanged, like posthog-ios and posthog-android 4.0. PostHog drops an event whose option value it can't read, such as$cookieless_mode: 'maybe'or$product_tour_id: 1.5, andposthog.on('error')reports it, where 4.x sent it as a property — passtrueorfalsefor$cookieless_modeand$ignore_sent_at, and a string for$product_tour_id - Breaking: a
2xxcapture response without a PostHogresultsbody drops the batch and reports it onposthog.on('error')— reverse proxies must return PostHog's response body unchanged - Breaking: on react-native-web, a reverse proxy that answers CORS preflight requests with a fixed
Access-Control-Allow-Headerslist must allowAuthorization,PostHog-Sdk-Info,PostHog-Attempt,PostHog-Request-IdandPostHog-Request-Timestamp, or the browser blocks every capture request and events stay queued - Breaking:
Authorization,User-Agent,Content-Type,Content-Encodingand thePostHog-headers the SDK sets no longer reach capture requests fromrequestHeaders; otherrequestHeadersstill do - Breaking: PostHog drops an event whose distinct ID or event name is over 200 UTF-8 bytes, such as one with a JWT as its distinct ID, and
posthog.on('error')reports it. 4.x shortened a long distinct ID and kept the event - Breaking: a
uuidyou pass tocapture()or another event method is sent in lowercase, and one that isn't a valid UUID is replaced with a new one - Breaking:
flush()andshutdown()no longer reject when a send fails: events kept for a later send stay queued, and dropped events (for example after a400or401) are reported onposthog.on('error')instead - Breaking: send queued events every 30 seconds instead of every 10, and at most 50 per request instead of 100, like posthog-ios and posthog-android — pass
flushInterval: 10000andmaxBatchSize: 100to keep the 4.x timing - Breaking:
fetchRetryCountandfetchRetryDelayno longer apply to event delivery - Breaking:
posthog.on('error')no longer fires for network errors or retryable statuses while events stay queued; it still fires for dropped events, with an error carryingdrops,requestId,retryExhaustedandcauseinstead ofresponse - Breaking: a personal API key (
phx_...) passed as the project token disables the client and logs an error, like posthog-node, posthog-ios and posthog-android, instead of being sent to PostHog - Breaking:
captureTraceFeedback()andcaptureTraceMetric()send$ai_feedbackand$ai_metricthroughcaptureAi()to the AI endpoint instead of the analytics endpoint - Breaking: a return from the background captures
Application Openedwithfrom_background: trueinstead ofApplication Became Active, like posthog-ios and posthog-android. The launchApplication Openedcarriesfrom_background: false.Application Backgroundedis captured once per trip to the background, and a return frominactivewithout going to the background, such as closing Control Center on iOS, captures nothing. A launch in the background captures itsApplication Openedat the first foreground.Application Openedcharts count more events after the upgrade: filter onfrom_backgroundis nottrueto count launches only, and ontrueinstead ofApplication Became Active - Breaking: keep each project token's stored state (distinct id, opt-out choice, queued events, session and cached feature flags) separately, like posthog-ios and posthog-android, so clients with different tokens no longer overwrite each other's. On upgrade, the first client to load takes over the state 4.x stored; clients with other tokens start with a new anonymous distinct id and the default opt-in state, so call
optOut()on any that should stay opted out. Logs 4.x queued and hadn't sent are dropped. Going back to 4.x after upgrading resets the stored state, including the opt-out choice, and upgrading again keeps what 5.0 stored before and drops what 4.x stored since - Add an optional
removeItemtoPostHogCustomStorage, which deletes the entries 4.x shared between project tokens once 5.0 no longer needs them - Add the
useFeatureFlagEnabled(),useFeatureFlagVariantKey(),useFeatureFlagPayload()anduseActiveFeatureFlags()hooks, matching@posthog/react - Fix
onFeatureFlagscallbacks and flag reads returning the previous user's flags whenreset()runs during a flag request - Fix the stored distinct id, queued events and opt-out choice resetting when the app is killed while the SDK saves them with Expo's file system
- Keep events queued when a send gets no response, a 404, 408, 429, 500, 502, 503 or 504, or a
retryresult, and send them again after a wait of 1 second doubling to 30 seconds (longer if the server'sRetry-Afterasks, up to 30 seconds), with no attempt limit.flush()during that wait resolves without sending, andshutdown()waits it out when it fits in its timeout - Drop an event that can't be serialized, such as one with a property whose
toJSON()throws, on its own and report it onposthog.on('error')withdetails: 'unserializable event'; an invalid event name or id is reported withdetails: 'invalid event' - Cap each capture request at 5 MiB of event bytes, starting a new request before a batch would pass it
- Add
captureAi(), which sends AI observability events such as$ai_generationto PostHog's AI endpoint (/i/v1/ai/events) from their own queue, with thecaptureAiCompression,captureAiMaxQueueSize,captureAiRequestTimeoutMsandcaptureAiMaxEventBytesoptions — serve/i/v1/ai/eventson reverse proxies and self-hosted instances. Unsent AI events are kept across app restarts in the app's cache directory, which isn't backed up, when the SDK uses Expo's file system; withpersistence: 'memory',customStorageor AsyncStorage they're kept only in memory - Report AI events dropped before sending (invalid, unserializable, too large, or pushed out of a full queue) on
posthog.on('error'), like posthog-node - Export
CaptureErrorand theCaptureDroppedEvent,CaptureEndpointandCaptureErrorParamstypes, like posthog-node, so aposthog.on('error')handler can checkerror instanceof CaptureError - Send a
captureAi()event overcaptureAiMaxEventByteswithout its$ai_input,$ai_output,$ai_output_choices,$ai_input_state,$ai_output_stateand$ai_tools, with$ai_content_removal_reason: 'event_too_large'and$ai_event_bytes_before_removal, like posthog-node, instead of dropping it - Keep a stored AI event whose file fails to read and read it again on the next send, dropping it after 3 failed reads, and drop and report stored AI events over a
captureAiMaxEventByteslowered since they were queued - Gzip analytics, AI and log requests on iOS and Android when
@posthog/react-native-plugin3.0 or later is installed; without it they're sent uncompressed, as in 4.x, andposthog.debug(true)logs once that they are - Send analytics events uncompressed when the plugin's gzip takes longer than
requestTimeout, and never send them aftershutdown()returns, even when a gzip still running then finishes - Send AI events again in batches half the size after a request reaches
captureAiRequestTimeoutMs, so a slow network still delivers them, and return to full-size batches as later sends get through; a single AI event that still times out is kept and sent again after the AI events queued behind it - Warn once, even without
debug: true, when the analytics or AI endpoint returns404(a reverse proxy or self-hosted instance that doesn't serve/i/v1/analytics/eventsor/i/v1/ai/events) or401(a proxy that doesn't forward theAuthorizationheader), like posthog-ios and posthog-android - Send analytics events as soon as 5 MiB of them is queued, without waiting for
flushAt, like posthog-ios and posthog-android - Send analytics events again in batches half the size after a request reaches
requestTimeout, so a slow network still delivers them, and return to full-size batches as later sends get through - Send the device time zone as
timezonewith/flagsrequests, like posthog-ios and posthog-android; set$timezonetonullincustomAppPropertiesto leave it out - Add
captureFeatureView(flag, flagVariant?)andcaptureFeatureInteraction(flag, flagVariant?), like posthog-ios and posthog-android: they capture$feature_viewand$feature_interactionwithfeature_flagandfeature_flag_variant, and set the$feature_view/<flag>or$feature_interaction/<flag>person property to the variant. WithoutflagVariantthey read the flag without capturing$feature_flag_called, and skip the event when the flag has no value - Add
resetGroupPropertiesForFlags(groupType, reloadFeatureFlags?)to reset one group type's properties for flags and keep the others, like posthog-ios and posthog-android - Debug mode logs only the name and uuid of each event, the number of events in each flush, and the type of an error
before_sendthrows, like posthog-ios, posthog-android and posthog-node, instead of the whole event - Take the random bits of event uuids from
crypto.getRandomValueswhen the runtime has it, such as withreact-native-get-random-valuesimported first, like posthog-node; otherwiseMath.random, as in 4.x - Keep a registered
$cookieless_mode,$ignore_sent_ator$product_tour_idon minimal$feature_flag_calledevents, like posthog-ios and posthog-node - Fix an event that carries its own
$session_idand matches a session replay event trigger or trigger group on an expired SDK session: it now starts a new SDK session and session replay records into it - Warn once on the console, even without
debug: true, whenenableSessionReplayis on and@posthog/react-native-pluginisn't installed, so an app with onlyposthog-react-native-session-replaysees why replay stopped recording (2026-12-03)
- Breaking: remove the
Minor Changes
- #5990
a393b4fThanks @turnipdabeets! - Add per-eventoptions, such as{ options: { process_person_profile: false } }, tocapture(),screen(),identify(),setPersonProperties(),unsetPersonProperties(),alias(),group(),groupIdentify(),captureException()andcaptureAi(), like posthog-ios and posthog-android 4.0
(2026-12-03)