Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respects the flushAt flag #13

Merged
merged 2 commits into from
Nov 19, 2024
Merged
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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Next

## 0.1.7 - 2024-11-19

- fix: respects the flushAt flag

## 0.1.6 - 2024-10-25

- chore: forces the SDK to be initialized on the main thread
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.posthog:posthog-android:3.8.3"
implementation "com.posthog:posthog-android:3.9.2"
}

Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ class PosthogReactNativeSessionReplayModule(reactContext: ReactApplicationContex
val anonymousId = sdkOptions.getString("anonymousId") ?: ""
val theSdkVersion = sdkOptions.getString("sdkVersion")

var theFlushAt = 20
if (sdkOptions.hasKey("flushAt")) {
theFlushAt = sdkOptions.getInt("flushAt")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this throw here if not an Int?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes but this is passed by the SDK and declared as a number so it's safe, similar to androidDebouncerDelayMs, the JS code always swallows exceptions and logs to the console as well.

}

val config = PostHogAndroidConfig(apiKey, host).apply {
debug = debugValue
captureDeepLinks = false
captureApplicationLifecycleEvents = false
captureScreenViews = false
flushAt = theFlushAt
sessionReplay = true
sessionReplayConfig.screenshot = true
sessionReplayConfig.captureLogcat = captureLog
Expand Down
3 changes: 3 additions & 0 deletions ios/PosthogReactNativeSessionReplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class PosthogReactNativeSessionReplay: NSObject {

let sdkVersion = sdkOptions["sdkVersion"] as? String ?? ""

let flushAt = sdkOptions["flushAt"] as? Int ?? 20
config.flushAt = flushAt

if !sdkVersion.isEmpty {
postHogSdkName = "posthog-react-native"
postHogVersion = sdkVersion
Expand Down
Loading