Screen Tracking
The Hackle SDK collects screen information at the Activity level. For apps using a SAA (Single Activity Architecture) or Compose UI, it is difficult to automatically collect screen information.
To properly collect $page_view and $engagement events, you must call the setCurrentScreen method manually whenever the screen changes.
setCurrentScreen
Use the setCurrentScreen(screen) method to track screens.
The minimum tracking time unit is 1 second.
$engagementfor pages changed within 1 second is not measured.
name
string
Required
The name of the current screen.
className
string
Required
If you do not need a separate class name, you can enter the same value as name.
Example
When using Compose UI, it is recommended to track screens when the ON_RESUME event occurs.
val hackleApp = Hackle.app
val screen = Screen.builder("screenName", "className")
.build()
Hackle.app.setCurrentScreen(screen)HackleApp hackleApp = HackleApp.getInstance();
Screen screen = Screen.builder("screenName", "className")
.build();
hackleApp.setCurrentScreen(screen);@Composable
fun TrackScreen(screenName: String, className: String) {
val lifecycleOwner = LocalLifecycleOwner.current
DisposableEffect(lifecycleOwner, screenName, className) {
val observer = LifecycleEventObserver { _, event ->
// 뷰가 나타날 때 & 백그라운드 -> 포그라운드 전환될 때 화면 추적
if (event == Lifecycle.Event.ON_RESUME) {
val screen = Screen.builder(screenName, className).build()
hackleApp.setCurrentScreen(screen)
}
}
lifecycleOwner.lifecycle.addObserver(observer)
onDispose {
lifecycleOwner.lifecycle.removeObserver(observer)
}
}
}
@Composable
fun MainScreen() {
TrackScreen("Main", "MainScreen")
}Property
The Hackle SDK supports adding properties to Event objects.
A maximum of 64 properties can be added to an event object.
Property Key
string
Character limit is 128 characters.
Case-insensitive.
For example, AGE and age are recognized as the same Property Key.
Property Value
boolean, string, number, array
For string type, the character limit is 1024 characters.
String type is case-sensitive.
For example, APPLE and apple are recognized as different Property Values.
For number type, up to 15 integer digits and up to 6 decimal places are supported.
Example
Disable automaticScreenTracking
By default, automaticScreenTracking is enabled in the SDK.
If you do not want automatic screen information collection at the Activity level, you must disable automaticScreenTracking.
You can configure automaticScreenTracking when initializing the SDK.
Example
Last updated