Skip to content

Commit 7e52d15

Browse files
committed
update initialization section
1 parent 965365f commit 7e52d15

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/connections/auto-instrumentation/kotlin-setup.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,45 @@ The core libraries are required to enable Signals and real-time analytics. Use t
6464

6565
Only add the plugins you plan to use. You can add or remove them later without reinitializing your source.
6666

67+
## Step 2: Initialize the SDK
6768

69+
After you add dependencies, you'll need to initialize the Analytics client and configure the Signals plugin.
6870

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].
69106

70107
<!-->
71108
2. Add the initialization code and configuration options:

0 commit comments

Comments
 (0)