Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto committed Mar 25, 2024
1 parent 546d6fe commit c5939b7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions posthog-react-native/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Next

1. If `captureNativeAppLifecycleEvents` is enabled, the event `Application Opened` with the property `from_background: true` is moved to its own event called `Application Became Active`. This event is triggered when the app is opened from the background. The `Application Opened` event is now only triggered when the app is opened from a cold start, aligning with the other integrations such as the `PostHogProvider` with the `captureLifecycleEvents` option and `initReactNativeNavigation` with the `captureLifecycleEvents` option.

# 3.0.0 - 2024-03-18

## Added
Expand Down
1 change: 1 addition & 0 deletions posthog-react-native/src/frameworks/wix-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const withReactNativeNavigation = (posthog: PostHog, options: PostHogAuto
const appBuild = appProperties.$app_build
const appVersion = appProperties.$app_version

// TODO: add missing initialUrl
posthog.capture('Application Opened', {
version: appVersion,
build: appBuild,
Expand Down
1 change: 1 addition & 0 deletions posthog-react-native/src/hooks/useLifecycleTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function useLifecycleTracker(client?: PostHog): void {

if (!openTrackedRef.current) {
openTrackedRef.current = true
// TODO: add missing initialUrl
posthog.capture('Application Opened', {
version: appVersion,
build: appBuild,
Expand Down
4 changes: 2 additions & 2 deletions posthog-react-native/src/posthog-rn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type PostHogOptions = PostHogCoreOptions & {
customStorage?: PostHogCustomStorage

// customAsyncStorage?: PostHogCustomAsyncStorage
/** Captures native app lifecycle events such as Application Installed, Application Updated, Application Opened and Application Backgrounded.
/** Captures native app lifecycle events such as Application Installed, Application Updated, Application Opened, Application Became Active and Application Backgrounded.
* By default is false.
* If you're already using the 'captureLifecycleEvents' options with 'withReactNativeNavigation' or 'PostHogProvider, you should not set this to true, otherwise you may see duplicated events.
*/
Expand Down Expand Up @@ -146,7 +146,7 @@ export class PostHog extends PostHogCore {
getCommonEventProperties(): any {
return {
...super.getCommonEventProperties(),
...getAppProperties(),
...this._appProperties,
$screen_height: Dimensions.get('screen').height,
$screen_width: Dimensions.get('screen').width,
}
Expand Down
2 changes: 1 addition & 1 deletion posthog-react-native/test/posthog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe('PostHog React Native', () => {
},
})
expect(onCapture.mock.calls[3][0]).toMatchObject({
event: 'Application Opened',
event: 'Application Became Active',
properties: {
$app_build: '1',
$app_version: '1.0.0',
Expand Down

0 comments on commit c5939b7

Please sign in to comment.