- REVERT: Fix bug where this SDK incorrectly sent
$feature_flag_called
events with null values when usinggetFeatureFlagPayload
.
- Fix bug where this SDK incorrectly sent
$feature_flag_called
events with null values when usinggetFeatureFlagPayload
.
- Add Sentry v8 support to the Sentry integration
- fix: identify method allows passing a $set_once object
- fix: Shutdown will now respect the timeout and forcefully return rather than returning after the next fetch.
- fix: only log messages if debug is enabled
- Added
historicalMigration
option for use in tools that are migrating large data to PostHog
- Local evaluation returns correct results on
undefined/null
values
- chore: change host to new address.
- chore: bump axios to 1.7.4 (fixes CVE-2024-39338)
- Prevent double JSON parsing of feature flag payloads, which would convert the payload [1] into 1.
- 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 - Adds a new
featureFlagsRequestTimeoutMs
timeout parameter for feature flags which defaults to 3 seconds, updated from the default 10s for all other API calls. 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.- Flushes will now try to flush up to
maxBatchSize
(default 100) in one go - Queued events are limited up to
maxQueueSize
(default 1000) and the oldest events are dropped when the limit is reached - Sets
User-Agent
headers with SDK name and version for RN
flushAsync
andshutdownAsync
are removed withflush
andshutdown
now being the async methods.
flush
andshutdown
now being async methods.
- 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
flushAsync
andshutdownAsync
are removed withflush
andshutdown
now being the async methods.- Fixed an issue where
shutdown
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
- 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 - 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 3 seconds, updated from the default 10s for all other API calls.
- fix: using
captureMode=form
won't throw an error and retry unnecessarily
- Swapped to
uuidv7
for unique ID generation
- Remove new relative date operators, combine into regular date operators
- Adds support for overriding the event
uuid
- When local evaluation is enabled, we automatically add flag information to all events sent to PostHog, whenever possible. This makes it easier to use these events in experiments.
- Fixes a bug where in some rare cases we may drop events when send_feature_flags is enabled on capture.
- Numeric property handling for feature flags now does the expected: When passed in a number, we do a numeric comparison. When passed in a string, we do a string comparison. Previously, we always did a string comparison.
- Add support for relative date operators for local evaluation.
- Adds PostHogSentryIntegration to allow automatic capturing of exceptions reported via the @sentry/node package
- Fixes issue where a background refresh of feature flags could throw an unhandled error. It now emits to be detected by
.on('error', ...)
- Fixes issues with Axios imports for non-node environments like Cloudflare workers
- Uses the globally defined
fetch
if available, otherwise imports and uses axios as a polyfill
- Updates axios dependency
- Returns the current flag property with $feature_flag_called events, to make it easier to use in experiments
- Replace crypto library with pure-js rusha library which makes posthog-node work with Cloudflare Workers in Next.js edge runtime.
- 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.
Breaking change:
All events by default now send the $geoip_disable
property to disable geoip lookup in app. This is because usually we don't
want to update person properties to take the server's location.
The same now happens for feature flag requests, where we discard the IP address of the server for matching on geoip properties like city, country, continent.
To restore previous behaviour, you can set the default to False like so:
const posthog = new PostHog(PH_API_KEY, {
host: PH_HOST,
disableGeoip: false,
})
- Add support for all cohorts local evaluation in feature flags.
- Fix error log for local evaluation of feature flags (InconclusiveMatchError(s)) to only show during debug mode.
- Allow passing in a distinctId to
groupIdentify()
. - Fix a bug with active feature flags on capture events, where non-active flags would be added to the list as well.
- Fix issue where properties passed to
.identify
were not set correctly
- Make sure shutdown waits for pending promises to resolve. Fixes a problem with using PostHog Node in serverless environments.
- Removes shared client from
posthog-node
, getting rid of some race condition bugs when capturing events. - Sets minimum version of node.js to 15
- Adds support for overriding timestamp of capture events
- 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
- Fix issues with timeouts for local evaluation requests
- Fix issues with timeout
- Add standard 10 second timeout
- Add support for variant overrides for feature flag local evaluation.
- Add support for date operators in feature flag local evaluation.
- Swaps
unidici
foraxios
in order to support older versions of Node - The
fetch
implementation can be overridden as an option for those who wish to use an alternative implementation - Fixes the minimum Node version to >=14.17.0
- Removes references to
cli.js
- Removes default
PostHogGlobal
export, and unifies import signature fortypescript
,commonjs
andesm
builds.
Breaking changes:
- Feature flag defaults are no more. When we fail to compute any flag, we return
undefined
. All computed flags return eithertrue
,false
orString
. - Minimum PostHog version requirement is 1.38
- Default polling interval for feature flags is now set at 30 seconds. If you don't want local evaluation, don't set a personal API key in the library.
- The
callback
parameter passed as an optional last argument to most of the methods is no longer supported - The CLI is no longer supported
What's new:
- You can now evaluate feature flags locally (i.e. without sending a request to your PostHog servers) by setting a personal API key, and passing in groups and person properties to
isFeatureEnabled
andgetFeatureFlag
calls. - Introduces a
getAllFlags
method that returns all feature flags. This is useful for when you want to seed your frontend with some initial flags, given a user ID.