- fix: handle cases when non Error is passed to
captureException
- fix: Autocapture native app lifecycle events
- the
captureNativeAppLifecycleEvents
client option now takes priority over thecaptureLifecycleEvents
autocapture option. - the
captureLifecycleEvents
autocapture option now captures Application Installed and Application Updated events. - If you don't want to capture these events, set the
captureLifecycleEvents
autocapture option tofalse
and capture the events manually, example below.
- the
AppState.addEventListener('change', (state) => {
if (state === 'active') {
posthog.capture('Application Became Active')
} else if (state === 'background') {
posthog.capture('Application Backgrounded')
}
})
- Adds the ability to capture user feedback in LLM Observability using the
captureTraceFeedback
andcaptureTraceMetric
methods.
- fix: ensure feature flags are reloaded after reset() to prevent undefined values
- chore: Session Replay - GA
- Adds
captureException
function to allow basic manual capture of JavaScript exceptions
- chore: set locale and timezone using the react-native-localize library
- fix: improve session replay linked flag type handling
- fix: session replay respect linked feature flags
- fix: Set initial currentSessionId, log only with debug flag on
- fix: os_name was not being set correctly for some devices using expo-device
- Add new debugging property
$feature_flag_bootstrapped_response
,$feature_flag_bootstrapped_payload
and$used_bootstrap_value
to$feature_flag_called
event
- fix: deprecate maskPhotoLibraryImages due to unintended masking issues
- feat: automatically mask out user photos and sandboxed views like photo picker (iOS Only)
- To disable masking set
maskAllSandboxedViews
andmaskPhotoLibraryImages
to false
- To disable masking set
export const posthog = new PostHog(
'apiKey...',
sessionReplayConfig: {
maskAllSandboxedViews: false,
maskPhotoLibraryImages: false,
);
- fix: identify method allows passing a $set_once object
- fix: session replay respects the flushAt flag
- fix: session replay forces the session id if the SDK is already enabled
- fix: respect the given propsToCapture autocapture option
- fix: capture customLabelProp if set
- fix: rollback module to ESNext
- chore: change androidDebouncerDelayMs default from 500ms to 1000ms (1s)
- fix: session replay respects the
disabled
flag
- fix: all sdkReplayConfig should have a default value
- fix: only tries to read device context from react-native-device-info if expo libs are not available
- fix: only log messages if debug is enabled
- fix: bootstrap flags do not overwrite the current values
- fix: clear flagCallReported if there are new flags
- fix: set the right sdk name and version for recordings
- chore: session id will be rotate on app restart.
- To keep the session id across restarts, set the
enablePersistSessionIdAcrossRestart
option totrue
when initializing the PostHog client.
- To keep the session id across restarts, set the
export const posthog = new PostHog('apiKey...', {
// ...
enablePersistSessionIdAcrossRestart: true,
})
- recording: session replay plugin isn't properly identifying users already identified
- chore: default
captureMode
changed tojson
.- To keep using the
form
mode, just set thecaptureMode
option toform
when initializing the PostHog client.
- To keep using the
- chore: Session Replay for React-Native - Experimental support
Install Session Replay for React-Native:
yarn add posthog-react-native-session-replay
# or npm
npm i -s posthog-react-native-session-replay
Enable Session Replay for React-Native:
export const posthog = new PostHog('apiKey...', {
// ...
enableSessionReplay: true,
})
Or using the PostHogProvider
<PostHogProvider
apiKey="apiKey..."
options={{
enableSessionReplay: true,
}}
>
- chore: change host to new address.
- Prevent double JSON parsing of feature flag payloads, which would convert the payload [1] into 1.
- If
captureNativeAppLifecycleEvents
is enabled, the eventApplication Opened
with the propertyfrom_background: true
is moved to its own event calledApplication Became Active
. This event is triggered when the app is opened from the background. TheApplication Opened
event is now only triggered when the app is opened from a cold start, aligning with the other integrations such as thePostHogProvider
with thecaptureLifecycleEvents
option andinitReactNativeNavigation
with thecaptureLifecycleEvents
option.
- Adds a
disabled
option and the ability to change it later viaposthog.disabled = true
. Useful for disabling PostHog tracking for example in a testing environment without having complex conditional checking shutdown
takes ashutdownTimeoutMs
param with a default of 30000 (30s). This is the time to wait for flushing events before shutting down the client. If the timeout is reached, the client will be shut down regardless of pending events.- Adds a new
featureFlagsRequestTimeoutMs
timeout parameter for feature flags which defaults to 10 seconds. - Flushes will now try to flush up to
maxBatchSize
(default 100) in one go - Sets
User-Agent
headers with SDK name and version for RN - Queued events are limited up to
maxQueueSize
(default 1000) and the oldest events are dropped when the limit is reached
flushAsync
andshutdownAsync
are removed withflush
andshutdown
now being the async methods.- Removes the
enable
option. You can now specifydefaultOptIn: false
to start the SDK opted out of tracking PostHog.initAsync
is no more! You can now initialize PostHog as you would any other classconst posthog = new PostHog(...)
- PostHogProvider now requires either an
apiKey
orclient
property andusePostHog
now always returns aPostHog
instance instead ofPostHog | undefined
. Thedisabled
option can be used when initializing thePostHogProvider
if desired and all subsequent calls toposthog
will work but without actually doing anything. flush
andshutdown
now being async methods.- Replaces the option
customAsyncStorage
withcustomStorage
to allow for custom synchronous or asynchronous storage implementations.
- Many methods such as
capture
andidentify
no longer return thethis
object instead returning nothing - Fixed an issue where
shutdown
would potentially exit early if a flush was already in progress - Fixes some typos in types
- Sets
User-Agent
headers with SDK name and version for RN - fix: PostHogProvider initialization that requires client
or
apiKey and notand
.
flushAsync
andshutdownAsync
are removed withflush
andshutdown
now being the async methods.- Fixed an issue where
shutdownAsync
would potentially exit early if a flush was already in progress - Flushes will now try to flush up to
maxBatchSize
(default 100) in one go
PostHog.initAsync
is no more! You can now initialize PostHog as you would any other classconst posthog = new PostHog(...)
- PostHogProvider now requires either an
apiKey
orclient
property andusePostHog
now always returns aPostHog
instance instead ofPostHog | undefined
. Thedisabled
option can be used when initializing thePostHogProvider
if desired and all subsequent calls toposthog
will work but without actually doing anything. - Removes the
enable
option. You can now specifydefaultOptIn: false
to start the SDK opted out of tracking - Adds a
disabled
option and the ability to change it later viaposthog.disabled = true
. Useful for disabling PostHog tracking for example in a testing environment without having complex conditional checking - Many methods such as
capture
andidentify
no longer return thethis
object instead returning nothing - Fixes some typos in types
shutdown
andshutdownAsync
takes ashutdownTimeoutMs
param with a default of 30000 (30s). This is the time to wait for flushing events before shutting down the client. If the timeout is reached, the client will be shut down regardless of pending events.- Adds a new
featureFlagsRequestTimeoutMs
timeout parameter for feature flags which defaults to 10 seconds. - Replaces the option
customAsyncStorage
withcustomStorage
to allow for custom synchronous or asynchronous storage implementations.
$device_name
was set to the device's user name (eg Max's iPhone) for all events wrongly, it's now set to the device's name (eg iPhone 12), this happened only if usingreact-native-device-info
library.- Fixes an issue related to other dependencies patching the global Promise object that could lead to crashes
- fix: undefined posthog in hooks
- fix: using
captureMode=form
won't throw an error and retry unnecessarily $app_build
was returning the OS internal build number instead of the app's build number.- This flag was used to track app versions, you might experience a sudden increase of
Application Updated
events, but only if you're using thereact-native-device-info
library.
- Vendor
uuidv7
instead of using peer dependency to avoid the missing crypto issue
- Swapped to
uuidv7
for unique ID generation
- Do not try to load packages on the macOS target that are not supported.
- Use
Platform.select
insteadPlatform.OS
for conditional imports which avoids issues such asUnable to resolve module
.
- Adds support for overriding the event
uuid
via capture options
- Do not try to load the
expo-file-system
package on the Web target since it's not supported. - if
react-native-device-info
is available for the Web target, do not setunknown
for all properties.
- The
tag_name
property of auto-captured events now uses the nearestph-label
from parent elements, if present.
$device_type
is now set toMobile
,Desktop
, orWeb
for all events
- If
async-storage
orexpo-file-system
is not installed, the SDK will fallback topersistence: memory
and log a warning
getPersistedProperty
uses Nullish Coalescing operator to fallback toundefined
only if the property is not found
- Renamed
personProperties
tosetPersonPropertiesForFlags
to matchposthog-js
and more clearly indicated what it does - Renamed
groupProperties
tosetGroupPropertiesForFlags
to matchposthog-js
and more clearly indicated what it does
- Fixes a type generation issue
- Added new
const [flag, payload] = useFeatureFlagWithPayload('my-flag-name')
hook that returns the flag result and it's payload if it has one.
- The
$screen_name
property will be registered for all events wheneverscreen
is called
- Fixes a race condition that could occur when initialising PostHog
- Fixes an issue where feature flags would not be reloaded after a reset
- PostHog should always be initialized via .initAsync and will now warn if this is not the case
- Some small fixes to incorrect types
- Fixed fetch compatibility by aligning error handling
- Added two errors: PostHogFetchHttpError (non-2xx status) and PostHogFetchNetworkError (fetch network error)
- Added .on('error', (err) => void)
- shutdownAsync now ignores fetch errors. They should be handled with .on('error', ...) from now on.
- Fixes an issue where background network errors would trigger unhandled promise warnings
- Added support for customising the default app properties by passing a function to
options.customAppProperties
- Adds support for overriding timestamp of capture events
- Adds support for https://github.com/wix/react-native-navigation
- Allows passing of promise based
PostHog.initAsync
to<PostHogProvider client={...} />
- Captures text content in autocapture (configurable via autocapture option
propsToCapture
)
- uses v3 decide endpoint
- JSON payloads will be returned with feature flags
- Feature flags will gracefully fail and optimistically save evaluated flags if server is down
- Ensures the distinctId used in
.groupIdentify
is the same as the currently identified user
- Fixes an issue with PostHogProvider where autocapture={false} would still capture lifecycle and navigation events.
- Fixes an issue with async storage selection while installing PostHog React Native
- Fixes an issue where React Hooks for feature flags were conditionally loaded
- Expo modules are no longer required. Expo apps work as before and standalone React Native apps can use the more common native dependencies or roll their own implementation of the necessary functions. See the official docs for more information.
- PostHog should now be initialised via the async helper
PostHog.initAsync
to ensure persisted data is loaded before any tracking takes place
Also include the fix in the compiled lib
folder.
Actually include the fix.
Fix bug where all values set while stored data was being loaded would get overwritten once the data was done loading.
Support for bootstrapping feature flags and distinctIDs. This allows you to initialise the library with a set of feature flags and distinctID that are immediately available.
PostHogProvider autocapture
can be configured with captureLifecycleEvents: false
and captureScreens: false
if you want do disable these autocapture elements. Both of these default to true