@@ -64,8 +64,45 @@ The core libraries are required to enable Signals and real-time analytics. Use t
64
64
65
65
Only add the plugins you plan to use. You can add or remove them later without reinitializing your source.
66
66
67
+ ## Step 2: Initialize the SDK
67
68
69
+ After you add dependencies, you'll need to initialize the Analytics client and configure the Signals plugin.
68
70
71
+ Start by creating the ` Analytics ` instance using your source's write key. Then add the Signals plugin and configure its settings separately.
72
+
73
+ ``` kotlin
74
+ // Create the Analytics instance with your configuration
75
+ val analytics = Analytics (Configuration (writeKey = " <WRITE_KEY>" ))
76
+
77
+ // Add the live plugin for real-time event handling
78
+ analytics.add(LivePlugins ())
79
+
80
+ // Add the Signals plugin
81
+ analytics.add(Signals )
82
+
83
+ // Configure Signals settings
84
+ Signals .configuration = Configuration (
85
+ maximumBufferSize = 1000 , // Number of signals to keep in memory
86
+ broadcastInterval = 60 , // Send signals every 60 seconds
87
+ broadcasters = listOf (WebhookBroadcaster (" YOUR_WEBHOOK" )), // Optional
88
+ debugMode = true // For development use only
89
+ )
90
+
91
+ // Optional: Add the Compose plugin to track UI events and interactions
92
+ analytics.add(SignalsComposeTrackingPlugin ())
93
+
94
+ // Optional: Track screen transitions using Navigation
95
+ analytics.add(SignalsActivityTrackingPlugin ())
96
+ navController.turnOnScreenTracking()
97
+ ```
98
+
99
+ When you run this code, keep the following in mind:
100
+
101
+ - You'll need to replace <WRITE_KEY> with the key from your Android Source in Segment.
102
+ - ` debugMode ` sends signals to Segment for use in the Event Builder. Only enable it in development environments.
103
+ - If your app doesn't use Jetpack Compose or Navigation, you can skip those plugin lines.
104
+
105
+ For more options, see [ Configuration options reference] .
69
106
70
107
<!-- >
71
108
2 . Add the initialization code and configuration options:
0 commit comments