Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ android {
applicationId "com.betterrail"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 153
versionName "2.6.1"
versionCode 154
versionName "2.6.2"
missingDimensionStrategy "store", "play"

// API Configuration
Expand Down
12 changes: 5 additions & 7 deletions app/navigators/root-navigator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { POSTHOG_API_KEY } from "@env"
import React from "react"
import { useColorScheme } from "react-native"
import { NavigationContainer, type NavigationContainerRef, DefaultTheme, DarkTheme } from "@react-navigation/native"
Expand All @@ -10,8 +9,8 @@ import { WidgetOnboardingNavigator } from "./widget-onboarding/widget-onboarding
import { PaywallNavigator } from "./paywall/paywall-navigator"
import { LiveAnnouncementNavigator } from "./live-activity-announcement/live-activity-announcement-stack"
import { AnnouncementsNavigator } from "./announcements/announcements-navigator"
import { PostHogProvider, usePostHog } from "posthog-react-native"
import { posthogOptions } from "../services/analytics"
import { PostHogProvider } from "posthog-react-native"
import { posthog } from "../services/analytics"
import { useForceUpdate } from "../hooks/use-force-update"
import { ForceUpdateScreen } from "../screens/force-update/force-update-screen"

Expand Down Expand Up @@ -54,31 +53,30 @@ const RootStack = () => {

export const RootNavigator = React.forwardRef<NavigationContainerRef<RootParamList>, Partial<React.ComponentProps<typeof NavigationContainer>>>(
(props, ref) => {
const posthog = usePostHog()
const colorScheme = useColorScheme()
const navigationRef = React.useRef<NavigationContainerRef<RootParamList>>(null)
const routeNameRef = React.useRef<string>()

React.useImperativeHandle(ref, () => navigationRef.current!)

return (
<PostHogProvider apiKey={POSTHOG_API_KEY} options={posthogOptions} autocapture={{ captureScreens: false }}>
<PostHogProvider client={posthog} autocapture={{ captureScreens: false }}>
<NavigationContainer<RootParamList>
{...props}
ref={navigationRef}
theme={colorScheme === "dark" ? DarkTheme : DefaultTheme}
onReady={() => {
routeNameRef.current = navigationRef.current?.getCurrentRoute()?.name
if (routeNameRef.current) {
posthog?.screen(routeNameRef.current)
posthog.screen(routeNameRef.current)
}
}}
onStateChange={() => {
const previousRouteName = routeNameRef.current
const currentRouteName = navigationRef.current?.getCurrentRoute()?.name

if (previousRouteName !== currentRouteName && currentRouteName) {
posthog?.screen(currentRouteName)
posthog.screen(currentRouteName)
}

routeNameRef.current = currentRouteName
Expand Down
12 changes: 5 additions & 7 deletions app/services/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { POSTHOG_API_KEY } from "@env"
import { getAnalytics } from "@react-native-firebase/analytics"
import PostHog, { PostHogOptions } from "posthog-react-native"
import PostHog from "posthog-react-native"
import AsyncStorage from "@react-native-async-storage/async-storage"
import { ensurePosthogPropertiesHydrated, getCachedPosthogProperties, setCachedPosthogProperties, setCachedPosthogProperty } from "./posthog-user-properties"

export const posthogOptions: PostHogOptions = {
export const posthog = new PostHog(POSTHOG_API_KEY, {
host: "https://eu.i.posthog.com",
persistence: "file" as const,
persistence: "file",
customStorage: AsyncStorage,
enableSessionReplay: true
}

export const posthog = new PostHog(POSTHOG_API_KEY, posthogOptions)
enableSessionReplay: true,
})
Comment on lines +7 to +12
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better configuration management and to avoid hardcoded URLs, consider moving the PostHog host URL to your environment variables file (.env), similar to how POSTHOG_API_KEY is handled. This makes it easier to switch between different PostHog environments (e.g., development, staging, production) or regions if needed in the future.

Here is a potential implementation:

  1. Add POSTHOG_HOST=https://eu.i.posthog.com to your .env file.
  2. Update the import in this file to include POSTHOG_HOST.
  3. Update the posthog initialization to use the new environment variable:
export const posthog = new PostHog(POSTHOG_API_KEY, {
  host: POSTHOG_HOST,
  persistence: "file",
  customStorage: AsyncStorage,
  enableSessionReplay: true,
});


type AnalyticsParams = Record<string, string | number | boolean | null | undefined>

Expand Down
12 changes: 7 additions & 5 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 22 additions & 20 deletions ios/BetterRail.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@
"${PODS_CONFIGURATION_BUILD_DIR}/GoogleDataTransport/GoogleDataTransport_Privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/GoogleUtilities/GoogleUtilities_Privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/PostHog/PostHog.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/PostHog/PHPLCrashReporter.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/PromisesObjC/FBLPromises_Privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RCT-Folly/RCT-Folly_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNCAsyncStorage/RNCAsyncStorage_resources.bundle",
Expand Down Expand Up @@ -978,6 +979,7 @@
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleDataTransport_Privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleUtilities_Privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/PostHog.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/PHPLCrashReporter.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FBLPromises_Privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCT-Folly_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNCAsyncStorage_resources.bundle",
Expand Down Expand Up @@ -1304,7 +1306,7 @@
CODE_SIGN_ENTITLEMENTS = BetterRail/BetterRailDebug.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
ENABLE_BITCODE = NO;
Expand All @@ -1314,7 +1316,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1348,7 +1350,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
INFOPLIST_FILE = BetterRail/Info.plist;
Expand All @@ -1357,7 +1359,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1565,7 +1567,7 @@
CODE_SIGN_ENTITLEMENTS = BetterRailWidgetExtensionDebug.entitlements;
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
Expand All @@ -1577,7 +1579,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -1614,7 +1616,7 @@
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
Expand All @@ -1626,7 +1628,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.watchkitapp.BetterRailWidget";
Expand Down Expand Up @@ -1659,7 +1661,7 @@
CODE_SIGN_ENTITLEMENTS = BetterRailWatch.entitlements;
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
Expand All @@ -1678,7 +1680,7 @@
"@executable_path/Frameworks",
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -1716,7 +1718,7 @@
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
Expand All @@ -1735,7 +1737,7 @@
"@executable_path/Frameworks",
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.watchkitapp";
Expand Down Expand Up @@ -1766,7 +1768,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = BetterRailWidgetExtensionDebug.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
Expand All @@ -1778,7 +1780,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -1811,7 +1813,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
Expand All @@ -1823,7 +1825,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.BetterRailWidget";
Expand All @@ -1849,7 +1851,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = StationIntent/StationIntentDebug.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
Expand All @@ -1861,7 +1863,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -1892,7 +1894,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
Expand All @@ -1904,7 +1906,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.6.2;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.StationIntent";
Expand Down
10 changes: 5 additions & 5 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1571,15 +1571,15 @@ PODS:
- SocketRocket
- Yoga
- openiap (1.2.26)
- PostHog (3.42.1)
- posthog-react-native-session-replay (1.5.2):
- PostHog (3.57.3)
- posthog-react-native-session-replay (1.5.6):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- PostHog (~> 3.42.0)
- PostHog (~> 3.57.1)
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
Expand Down Expand Up @@ -5054,8 +5054,8 @@ SPEC CHECKSUMS:
NitroIap: 4dc018bd561764a28408eac1a3795646fcf90726
NitroModules: 8f30b6fd4290c8b8ecc079ccef195085b7f83774
openiap: 6b09e05908b9536a0466a56ff763d21d71094077
PostHog: 148d2d62bac68c6da50a2325030b3fb2d6bca95b
posthog-react-native-session-replay: 79efc1a399fb775790010abe704e4061c0e35b0c
PostHog: c33925273e18b9c6bf3b33401416b08fa3db578e
posthog-react-native-session-replay: 6e278629c40e8aa15fab8c34cd57b5614690fec9
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
RCTDeprecation: c0ed3249a97243002615517dff789bf4666cf585
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
"fuse.js": "6.4.6",
"i18n-js": "3.8.0",
"lodash": "4.17.21",
"posthog-react-native": "^4.39.4",
"posthog-react-native-session-replay": "^1.5.2",
"posthog-react-native": "4.44.1",
"posthog-react-native-session-replay": "1.5.6",
"ramda": "0.27.1",
"react": "19.1.0",
"react-native": "0.81.4",
Expand Down
Loading