PostHog / posthog-js-lite

Reimplementation of posthog-js to be as light and modular as possible.
https://posthog.com/docs/libraries
MIT License
70 stars 36 forks source link

feat: Add react native autocapture lifecycle events #108

Closed robbie-c closed 1 year ago

robbie-c commented 1 year ago

Problem

Fixes https://github.com/PostHog/posthog-js-lite/issues/107

~Note: please merge https://github.com/PostHog/posthog-js-lite/pull/109 first, as this depends upon that.~

Changes

Adds these events that were present in v1. I put it behind an options flag, so that users will need to opt-in. This will prevent people from getting an unexpected surge of these events when updating the sdk.

Note: I found that due to ignoring the returned promise on line https://github.com/PostHog/posthog-js-lite/blob/54178fc167362f550c7f5703f2931abc487f8134/posthog-react-native/src/posthog-rn.ts#L108 , initAsync would return before setupAsync had completed. This is something that is a bit awkward to get right, when there in a constructor which needs to do something async. I fixed this by storing the promise and awaiting it in initAsync.

Release info Sub-libraries affected

Bump level

Libraries affected

Changelog notes