You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -17,167 +17,180 @@ This guide shows how to install and configure the library, as well as how to ena
17
17
To use Signals with Android, you need:
18
18
19
19
- An active Segment workspace with Auto-Instrumentation enabled.
20
-
- A Kotlin-based Android project.
21
20
- Android Gradle Plugin version 7.0 or later.
22
21
- A minimum compile SDK version of 21.
23
22
24
23
Signals supports [Jetpack Compose](https://developer.android.com/compose){:target="_blank"} and traditional Android UI frameworks. It also includes optional plugins for network tracking using [OkHttp3](https://square.github.io/okhttp/){:target="_blank"}, [Retrofit](https://square.github.io/retrofit/){:target="_blank"}, or [HttpURLConnection](https://developer.android.com/reference/java/net/HttpURLConnection){:target="_blank"}.
25
24
26
-
Segment recommends testing in a development environment before deploying Signals in production. For more information, see [Debug mode](#step-4-enable-debug-mode).
25
+
Segment recommends testing in a development environment before deploying Signals in production. For more information, see [Debug mode](#step-3-enable-debug-mode).
27
26
28
-
## Step 1: Install dependencies
27
+
## Prerequisites
29
28
30
-
To install Signals, add the following dependencies to your app-level Gradle build file.
29
+
Auto-Instrumentation (also known as Signals) works on top of Analytics and Live Plugins. Make sure to add the following dependencies to your module's Gradle file if you don't have them already.
The core libraries are required to enable Signals and real-time analytics. Use the following optional plugins to track additional activity based on your app's architecture:
58
-
59
-
-**Compose**: Tracks user interface events in Jetpack Compose.
60
-
-**OkHttp3**: Captures requests sent through OkHttp3 or Retrofit.
61
-
-**Navigation**: Tracks route changes when using Jetpack Navigation.
62
-
-**JavaNet**: Tracks network activity sent through `HttpURLConnection`.
63
-
64
-
Only add the plugins you plan to use. You can add or remove them later without reinitializing your source.
65
-
66
-
## Step 2: Initialize the SDK
67
-
68
-
After you add dependencies, you need to initialize the Analytics client and configure the Signals plugin.
69
-
70
-
Start by creating the `Analytics` instance using your source's write key. Then add the Signals plugin and configure its settings separately.
71
-
72
-
```kotlin
73
-
// Create the Analytics instance with your configuration
74
-
val analytics =Analytics(Configuration(writeKey ="<WRITE_KEY>"))
75
-
76
-
// Add the live plugin for real-time event handling
77
-
analytics.add(LivePlugins())
38
+
## Step 1: Getting started
78
39
79
-
// Add the Signals plugin
80
-
analytics.add(Signals)
81
-
82
-
// Configure Signals settings
83
-
Signals.configuration =Configuration(
84
-
maximumBufferSize =1000, // Number of signals to keep in memory
85
-
broadcastInterval =60, // Send signals every 60 seconds
3. (**Optional**): Add `SignalsActivityTrackingPlugin` to analytics to track Activity/Fragment navigation. **This is not required for Compose Navigation**.
122
128
```kotlin
123
-
val okHttpClient = OkHttpClient.Builder()
124
-
.addInterceptor(SignalsOkHttp3TrackingPlugin())
125
-
.build()
129
+
analytics.add(SignalsActivityTrackingPlugin())
126
130
```
127
131
128
-
### Retrofit
129
-
130
-
Retrofit is built on top of OkHttp, so the setup is similar.
131
-
132
-
1. Add the same OkHttp3 plugin shown in the previous sectiion:
2. Install the `JavaNetTrackingPlugin` on where you initialize analytics:
173
+
```kotlin
174
+
JavaNetTrackingPlugin.install()
175
+
```
176
+
166
177
167
-
## Step 4: Enable debug mode
178
+
## Step 3: Enable debug mode
168
179
169
180
By default, Signals stores captured data on the device and doesn't forward it to Segment. This process prevents unnecessary bandwidth use and helps support privacy compliance requirements.
170
181
171
-
To view captured signals in the Event Builder and create event generation rules, you need to enable `debugMode`. This setting temporarily lets the SDK send signal data to Segment while you're testing.
182
+
To view captured signals in the Event Builder and create event generation rules, enable `sendDebugSignalsToSegment`. This setting temporarily lets the SDK send signal data to Segment while you're testing.
183
+
184
+
In addition, the SDK obfuscates signals sent to Segment by default. To view the completed data, you need to turn off `obfuscateDebugSignals`.
172
185
173
186
> warning ""
174
-
> Only enable `debugMode` in development environments. Avoid using `debugMode` in production apps.
187
+
> Only enable `sendDebugSignalsToSegment` in development environments. Avoid using `sendDebugSignalsToSegment` in production apps.
175
188
176
-
You can enable `debugMode` in one of two ways.
189
+
You can enable `sendDebugSignalsToSegment` and turn off `obfuscateDebugSignals` in one of two ways.
177
190
178
191
### Option 1: Use build flavors
179
192
180
-
Configure `debugMode` at build time using [Android product flavors](https://developer.android.com/build/build-variants#product-flavors){:target="_blank"}.
193
+
Configure `sendDebugSignalsToSegment` and `obfuscateDebugSignals` at build time using [Android product flavors](https://developer.android.com/build/build-variants#product-flavors){:target="_blank"}.
181
194
182
195
1. In your `build.gradle` file, define two flavors:
183
196
@@ -186,10 +199,12 @@ Configure `debugMode` at build time using [Android product flavors](https://deve
If your app uses [Firebase Remote Config](https://firebase.google.com/docs/remote-config){:target="_blank"} or a similar system, you can control `debugMode` remotely.
225
+
If your app uses [Firebase Remote Config](https://firebase.google.com/docs/remote-config){:target="_blank"} or a similar system, you can control `sendDebugSignalsToSegment` and `obfuscateDebugSignals` remotely.
## Step 4: Turn on Auto-Instrumentation in your source
236
+
237
+
Next, return to the source settings to turn on Auto-Instrumentation:
238
+
239
+
1. Go to **Connections > Sources**.
240
+
2. Select the source you used in [Step 1](#step-1-getting-started).
241
+
3. From the source's overview tab, go to **Settings > Advanced**.
242
+
4. Toggle Auto-Instrumention on.
243
+
218
244
## Step 5: Verify event collection
219
245
220
246
After you build and run your app, use the [Event Builder](/docs/connections/auto-instrumentation/event-builder/) to confirm that Signals are being collected correctly.
221
247
222
248
1. In your Segment workspace, go to **Connections > Sources** and select the Android Source you configured.
223
249
2. Open the **Event Builder** tab.
224
-
3. Interact with your app on a simulator or test device:
225
-
- Navigate between screens.
226
-
- Tap buttons and UI elements.
227
-
- Trigger network requests.
228
-
229
-
If `debugMode` is enabled, Signals appear in real time as you interact with the app.
230
-
250
+
3. Interact with your app on a simulator or test device:
251
+
> - Navigate between screens.
252
+
> - Tap buttons and UI elements.
253
+
> - Trigger network requests.
254
+
>
255
+
> If `sendDebugSignalsToSegment` is enabled, Signals appear in real time as you interact with the app.
231
256
4. In the Event Builder, select a signal and click **Configure event** to define a new event.
232
257
5. After you add any event mappings, click **Publish event rules** to save them.
233
258
234
259
> info "What if I don't see the Event Builder tab?"
235
-
> If you don't see the Event Builder tab, confirm that the SDK is installed correctly and make sure `debugMode` is enabled. Verify that Auto-Instrumentation is enabled in **Settings > Advanced**. If you still don't see it, reach out to your CSM.
260
+
> If you don't see the Event Builder tab, confirm that the SDK is installed correctly and make sure `sendDebugSignalsToSegment` is enabled. Verify that Auto-Instrumentation is enabled in **Settings > Advanced**. If you still don't see it, reach out to your CSM.
236
261
237
262
## Configuration options
238
263
239
264
Use the `Signals.configuration` object to control how captured signals are stored, relayed, and displayed.
|`maximumBufferSize`| No |`Int`|`1000`| The number of captured signals to keep in memory before relaying them. Signals get stored in a first-in, first-out buffer. |
246
-
|`broadcastInterval`| No |`Int` (seconds) |`60`| The interval, in seconds, at which buffered signals are sent to broadcasters. |
247
-
|`broadcasters`| No |`List<SignalBroadcaster>`| N/A | A list of broadcasters that forward signal data to external destinations. `SegmentBroadcaster` is included by default, and you can add others like `WebhookBroadcaster` or a custom implementation. |
248
-
|`debugMode`| No |`Boolean`|`false`| When `true`, relays signals to Segment so they appear in the Event Builder. Only enable this in development environments. |
|**maximumBufferSize**| No | Integer | The number of signals to be kept for JavaScript inspection. This buffer is first-in, first-out. Default is **1000**. |
271
+
|**relayCount**| No | Integer | Relays every X signals to Segment. Default is **20**. |
272
+
|**relayInterval**| No | Integer | Relays signals to Segment every X seconds. Default is **60**. |
273
+
|**broadcasters**| No | List<SignalBroadcaster> | An array of broadcasters. These objects forward signal data to their destinations, like **WebhookBroadcaster**, or you could write your own **DebugBroadcaster** that writes logs to the developer console. **SegmentBroadcaster** is always added by the SDK. |
274
+
|**sendDebugSignalsToSegment**| No | Boolean | Turns on debug mode and allows the SDK to relay Signals to Segment server. Default is **false**. It should only be set to true for development purposes. |
275
+
|**obfuscateDebugSignals**| No | Boolean | Obfuscates signals being relayed to Segment. Default is **true**. |
0 commit comments