@posthog/react-native-plugin 2.7.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/build.gradle
CHANGED
|
@@ -91,7 +91,7 @@ dependencies {
|
|
|
91
91
|
//noinspection GradleDynamicVersion
|
|
92
92
|
implementation "com.facebook.react:react-native:+"
|
|
93
93
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
94
|
-
implementation "com.posthog:posthog-android:3.
|
|
94
|
+
implementation "com.posthog:posthog-android:3.63.1"
|
|
95
95
|
|
|
96
96
|
testImplementation "junit:junit:4.13.2"
|
|
97
97
|
}
|
package/android/src/main/java/com/posthogreactnativeplugin/PosthogReactNativePluginModule.kt
CHANGED
|
@@ -17,6 +17,8 @@ import com.posthog.PostHog
|
|
|
17
17
|
import com.posthog.PostHogConfig
|
|
18
18
|
import com.posthog.android.PostHogAndroid
|
|
19
19
|
import com.posthog.android.PostHogAndroidConfig
|
|
20
|
+
import com.posthog.android.replay.PostHogScreenshotColorMode
|
|
21
|
+
import com.posthog.android.replay.PostHogSessionReplayConfig
|
|
20
22
|
import com.posthog.internal.PostHogPreferences
|
|
21
23
|
import com.posthog.internal.PostHogPreferences.Companion.ANONYMOUS_ID
|
|
22
24
|
import com.posthog.internal.PostHogPreferences.Companion.DISTINCT_ID
|
|
@@ -183,6 +185,7 @@ class PosthogReactNativePluginModule(
|
|
|
183
185
|
sessionReplayConfig.sampleRate = getDoubleOrNull(sdkReplayConfig, "sampleRate")
|
|
184
186
|
sessionReplayConfig.verifyScreenshotMaskAlignment =
|
|
185
187
|
getBoolean(sdkReplayConfig, "verifyScreenshotMaskAlignment", false)
|
|
188
|
+
applyScreenshotConfig(sdkReplayConfig, sessionReplayConfig)
|
|
186
189
|
|
|
187
190
|
val endpoint = getString(decideReplayConfig, "endpoint", "")
|
|
188
191
|
if (endpoint.isNotEmpty()) {
|
|
@@ -399,23 +402,12 @@ class PosthogReactNativePluginModule(
|
|
|
399
402
|
}
|
|
400
403
|
}.getOrNull()
|
|
401
404
|
|
|
402
|
-
private fun getString(
|
|
403
|
-
map: ReadableMap?,
|
|
404
|
-
key: String,
|
|
405
|
-
default: String,
|
|
406
|
-
): String = runCatching { if (hasKey(map, key)) map?.getString(key) ?: default else default }.getOrDefault(default)
|
|
407
|
-
|
|
408
405
|
private fun getInt(
|
|
409
406
|
map: ReadableMap?,
|
|
410
407
|
key: String,
|
|
411
408
|
default: Int,
|
|
412
409
|
): Int = runCatching { if (hasKey(map, key)) map?.getInt(key) ?: default else default }.getOrDefault(default)
|
|
413
410
|
|
|
414
|
-
private fun getDoubleOrNull(
|
|
415
|
-
map: ReadableMap?,
|
|
416
|
-
key: String,
|
|
417
|
-
): Double? = runCatching { if (hasKey(map, key)) map?.getDouble(key) else null }.getOrNull()
|
|
418
|
-
|
|
419
411
|
private fun logError(
|
|
420
412
|
method: String,
|
|
421
413
|
error: Throwable,
|
|
@@ -660,3 +652,32 @@ internal fun getBoolean(
|
|
|
660
652
|
key: String,
|
|
661
653
|
default: Boolean,
|
|
662
654
|
): Boolean = runCatching { if (hasKey(map, key)) map?.getBoolean(key) ?: default else default }.getOrDefault(default)
|
|
655
|
+
|
|
656
|
+
private fun getString(
|
|
657
|
+
map: ReadableMap?,
|
|
658
|
+
key: String,
|
|
659
|
+
default: String,
|
|
660
|
+
): String = runCatching { if (hasKey(map, key)) map?.getString(key) ?: default else default }.getOrDefault(default)
|
|
661
|
+
|
|
662
|
+
private fun getDoubleOrNull(
|
|
663
|
+
map: ReadableMap?,
|
|
664
|
+
key: String,
|
|
665
|
+
): Double? = runCatching { if (hasKey(map, key)) map?.getDouble(key) else null }.getOrNull()
|
|
666
|
+
|
|
667
|
+
internal fun applyScreenshotConfig(
|
|
668
|
+
map: ReadableMap?,
|
|
669
|
+
config: PostHogSessionReplayConfig,
|
|
670
|
+
) {
|
|
671
|
+
getDoubleOrNull(map, "screenshotScale")?.let { scale ->
|
|
672
|
+
// Keep finite values within Float range; the native setter clamps to its supported range.
|
|
673
|
+
val floatMax = Float.MAX_VALUE.toDouble()
|
|
674
|
+
config.screenshotScale = if (scale.isFinite()) scale.coerceIn(-floatMax, floatMax).toFloat() else 1f
|
|
675
|
+
}
|
|
676
|
+
getDoubleOrNull(map, "screenshotCompressionQuality")?.takeIf { it.isFinite() }?.let { quality ->
|
|
677
|
+
config.screenshotCompressionQuality = quality.toInt()
|
|
678
|
+
}
|
|
679
|
+
when (getString(map, "screenshotColorMode", "")) {
|
|
680
|
+
"ARGB_8888" -> config.screenshotColorMode = PostHogScreenshotColorMode.ARGB_8888
|
|
681
|
+
"RGB_565" -> config.screenshotColorMode = PostHogScreenshotColorMode.RGB_565
|
|
682
|
+
}
|
|
683
|
+
}
|
package/ios/Package.swift
CHANGED
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1
|
|
|
6
6
|
# Single source of truth for the posthog-ios native dependency version.
|
|
7
7
|
# Used by both the SPM and CocoaPods resolution paths below; bump this
|
|
8
8
|
# line when picking up a new posthog-ios release.
|
|
9
|
-
posthog_ios_version = '3.
|
|
9
|
+
posthog_ios_version = '3.73.3'
|
|
10
10
|
|
|
11
11
|
Pod::Spec.new do |s|
|
|
12
12
|
s.name = "posthog-react-native-plugin"
|