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
Copy file name to clipboardExpand all lines: src/connections/auto-instrumentation/configuration.md
+157-6Lines changed: 157 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,11 @@ hidden: true
4
4
---
5
5
6
6
7
-
## Configure Signals
7
+
## Signals Configuration
8
8
9
+
Using the Signals Configuration object, you can control the destination, frequency, and types of signals that Segment automatically tracks within your application. The following tables detail the configuration options for both Signals-Swift and Signals-Kotlin.
|`broadcasters`| No |`List<SignalBroadcaster>`| An array of broadcasters. These objects forward signal data to their destinations, like `WebhookBroadcaster` or `DebugBroadcaster` writing to the developer console. Default is `SegmentBroadcaster`. |
36
35
37
36
38
-
## Converting Signals to events
37
+
## Converting signals to events
38
+
39
+
After you set up the Signals SDK to capture the signals you want to target, you can create rules in your Segment workspace to translate the captured signals into traditional Segment analytics events. These rules are deployed in your application the next time a user launches your app.
40
+
41
+
### Getting started with rule creation
42
+
43
+
1. In your Segment workspace, go to to **Connections > Auto-Instrumentation** and click on a source.
44
+
2. Click **Create Rules**.
45
+
46
+
### Using the Rules Editor
47
+
48
+
The Rules Editor is where you define rules that transform raw signal data into analytics events. In the editor, you write functions that convert signals into events and then call them in the `processSignal()` function.
49
+
50
+
The Rules Editor also lets you test your rules with recent signals to verify that they produce the data you need before you deploy.
51
+
52
+
The following example tracks all Screen events:
53
+
54
+
```javascript
55
+
functionscreenCall(currentSignal) {
56
+
if (currentSignal.type==SignalType.Navigation&¤tSignal.data.action==NavigationAction.Entering) {
Signals come in various types, each associated with specific data that you can use to create analytics events. This section contains code samples that detail each signal type. Because Segment has standardized these definitions across both the Signals-Swift and Signals Kotlin libraries, they're useful when you create rules in your Segment workspace.
69
+
70
+
### Base Signal
71
+
72
+
The Base Signal serves as the foundation for all other signal types. It's defined by the `RawSignal<T>` interface, where `T` represents the data type associated with the signal.
73
+
74
+
This interface ensures that every signal inherits essential properties:
75
+
76
+
```java
77
+
interfaceRawSignal<T> {
78
+
var anonymousId:String// A unique identifier for the user.
79
+
var type:SignalType// Specifies the signal category.
80
+
var timestamp:String// The exact time when the signal was generated.
81
+
var index:Int// An integer representing the signal's position.
82
+
var data:T// The specific data of type `T` associated with the signal.
83
+
}
84
+
```
85
+
86
+
### Signal Types
87
+
88
+
The Signal Type enum defines the different types of signals the SDK can collect:
89
+
90
+
```java
91
+
enumSignalType {
92
+
Interaction, // User interactions like clicks or touches
93
+
Navigation, // Navigation events.
94
+
Network, // Network requests and responses.
95
+
LocalData, // Data loaded from local or other external sources
96
+
Instrumentation, // Events generated from Segment Track/Screen/... events.
97
+
UserDefined// Custom events defined by the user.
98
+
}
99
+
```
100
+
101
+
### Interaction Signals
102
+
103
+
The SDK collects Interaction Signals when you enable one of the "UI autoSignal" options, like `useSwiftUIAutoSignal: true`. These signals primarily track user interactions with UI components:
104
+
105
+
```java
106
+
classInteractionData {
107
+
var component:String// The type of UI component interacted with, like "Button" or "Image".
108
+
var title:String?// Optional title of the component, if applicable.
109
+
var data:Object?// Additional data related to the interaction, if any.
type =SignalType.UIInteraction// Sets the signal type to UI Interaction.
114
+
}
115
+
```
116
+
117
+
### Navigation Signals
118
+
119
+
The SDK collects Navigation Signals when you enable one of the "UI autoSignal" options, like `useSwiftUIAutoSignal: true`. These signals are generated when a user interacts with navigation components in your application's UI, giving you insight into how users move through and interact with your application:
120
+
121
+
```java
122
+
enumNavigationAction {
123
+
Forward, // Navigation to the next item or page
124
+
Backward, // Navigation to the previous item or page
125
+
Modal, // Opening a modal window
126
+
Entering, // Entering a new screen
127
+
Leaving, // Leaving a screen
128
+
Page, // Navigation involving a full page
129
+
Popup// Interaction with a popup
130
+
}
131
+
132
+
classNavigationData {
133
+
var action:NavigationAction// The type of navigation action performed
134
+
var screen:String// The screen or component name involved in the navigation.
type =SignalType.Navigation// Sets the signal type to Navigation.
139
+
}
140
+
```
141
+
142
+
### Network Signals
143
+
144
+
The SDK collects Network Signals when you enable the `useNetworkAutoSignal` option in your Signals Configuration, like `useNetworkAutoSignal: true`. These signals are generated when your application makes network requests:
39
145
146
+
```java
147
+
enumNetworkAction {
148
+
Request, // A network request is made.
149
+
Response// A response is received.
150
+
}
151
+
152
+
classNetworkData {
153
+
var action:NetworkAction// The type of network action, either Request or Response.
154
+
var url:String// The URL involved in the network action.
155
+
var statusCode:Int?// The HTTP status code of the response, if applicable.
156
+
var data:Object?// Additional data associated with the network action.
157
+
}
158
+
159
+
classNetworkSignalextendsRawSignal<NetworkData> {
160
+
type =SignalType.Network// Sets the signal type to Network.
161
+
}
162
+
```
163
+
164
+
### LocalData Signals
165
+
166
+
The SDK collects Local Data Signals when data gets loaded from local soures, like SQLite databases or local caches. These signals help track how your application manages local data:
167
+
168
+
```java
169
+
enumLocalDataAction {
170
+
Loaded, // Data was loaded from a local source.
171
+
Updated, // Existing data was updated.
172
+
Saved, // New data was saved locally.
173
+
Deleted, // Data was deleted from a local source.
174
+
Undefined// Any other unspecified local data action.
175
+
}
176
+
177
+
classLocalData {
178
+
var action:LocalDataAction// The type of action performed on the local data.
179
+
var identifier:String// A unique identifier for the data, like "Loaded User Info".
180
+
var data:Object?// Additional details or data associated with the action.
181
+
}
182
+
183
+
classLocalDataSignalextendsRawSignal<LocalData> {
184
+
type =SignalType.LocalData// Sets the signal type to LocalData.
0 commit comments