Skip to content

Commit a4d51b3

Browse files
authored
fixes + edits
1 parent 43d6e37 commit a4d51b3

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

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

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Segment recommends testing in a development environment before deploying Signals
2525

2626
## Prerequisites
2727

28-
Auto-Instrumentation (aka Signals) works on top of Analytics. Make sure to add the following dependency to your project if you don't have analytics-swift already.
28+
Auto-Instrumentation (also known as Signals) works on top of Analytics. Make sure to add the following dependency to your project if you don't have analytics-swift already.
2929

3030
```swift
3131
dependencies: [
@@ -42,11 +42,10 @@ dependencies: [
4242
]
4343
```
4444

45-
2. Import and initialize with your Analytics instance:
46-
47-
> success ""
48-
> See [configuration options](#configuration-options) for a complete list.
49-
>
45+
2. Import and initialize with your Analytics instance:
46+
> success ""
47+
> See [configuration options](#configuration-options) for a complete list.
48+
>
5049
```swift
5150
import Segment
5251
import AnalyticsLive
@@ -75,14 +74,14 @@ dependencies: [
7574
```
7675

7776
3. Set up capture for the UI framework(s) you're using:
78-
* [Capture SwiftUI Interactions](#swiftui)
79-
* [Capture UIKit Interactions](#uikit)
80-
* [Capture Network Activity](#capture-network)
77+
* [Capture SwiftUI interactions](#swiftui).
78+
* [Capture UIKit interactions](#uikit).
79+
* [Capture network activity](#capture-network).
8180

8281

8382
## Step 2: Additional setup
8483

85-
### Capture Interactions
84+
### Capture interactions
8685

8786
#### SwiftUI
8887

@@ -119,25 +118,25 @@ SwiftUI automatic signal capture requires adding typealiases to your code. This
119118
typealias List = SignalList
120119
```
121120

122-
3. Use the controls normally in your SwiftUI code:
121+
3. Use the controls in your SwiftUI code:
123122
```swift
124123
struct ContentView: View {
125124
var body: some View {
126125
NavigationStack {
127126
VStack {
128127
Button("Click Me") {
129-
// Button tap will automatically generate a signal
128+
// Button tap automatically generates a signal
130129
}
131130

132131
TextField("Enter text", text: $text)
133-
// Text changes will automatically generate signals
132+
// Text changes automatically generates signals
134133
}
135134
}
136135
}
137136
}
138137
```
139138

140-
> **Note:** The typealiases replace SwiftUI's native controls with signal-generating versions. Your code remains unchanged, but interactions are now automatically captured.
139+
The typealiases replace SwiftUI's native controls with signal-generating versions. Your code remains unchanged, but interactions are now automatically captured.
141140

142141
#### UIKit
143142

@@ -152,7 +151,7 @@ UIKit automatic signal capture uses method swizzling and requires no code change
152151
))
153152
```
154153

155-
2. That's it! The following UIKit interactions and navigation events are automatically captured via method swizzling:
154+
2. The following UIKit interactions and navigation events are automatically captured via method swizzling:
156155

157156
**Interactions:**
158157
- `UIButton` taps
@@ -167,16 +166,16 @@ UIKit automatic signal capture uses method swizzling and requires no code change
167166
- `UIViewController` modal presentations and dismissals
168167
- `UITabBarController` tab switches
169168

170-
### Capture Navigation
169+
### Capture navigation
171170

172171
Navigation capture is handled automatically when you enable SwiftUI or UIKit auto-signals:
173172

174-
- **SwiftUI**: Captured through `SignalNavigationLink` and `SignalNavigationStack` when you add the typealiases
175-
- **UIKit**: Captured automatically via `UINavigationController`, `UIViewController`, and `UITabBarController` swizzling
173+
- **SwiftUI**: Captured through `SignalNavigationLink` and `SignalNavigationStack` when you add the typealiases.
174+
- **UIKit**: Captured automatically via `UINavigationController`, `UIViewController`, and `UITabBarController` swizzling.
176175

177-
No additional setup required beyond enabling the appropriate auto-signal flags.
176+
No additional setup is required beyond enabling the appropriate auto-signal flags.
178177

179-
### Capture Network
178+
### Capture network
180179

181180
Network capture automatically tracks URLSession requests and responses.
182181

@@ -192,13 +191,13 @@ Network capture automatically tracks URLSession requests and responses.
192191
```
193192

194193
2. Network requests made via URLSession are automatically captured, including:
195-
- Request URL, method, headers, and body
196-
- Response status, headers, and body
197-
- Request/response correlation via request ID
194+
- Request URL, method, headers, and body.
195+
- Response status, headers, and body.
196+
- Request or response correlation via request ID.
198197

199-
> **Note:** Third-party networking libraries that use URLSession underneath (like Alamofire) should work automatically. Segment API endpoints are automatically blocked to prevent recursive tracking.
198+
Third-party networking libraries that use URLSession underneath (like Alamofire) should work automatically. Segment API endpoints are automatically blocked to prevent recursive tracking.
200199

201-
#### Configuring Network Hosts
200+
#### Configuring network hosts
202201

203202
You can control which network requests are tracked:
204203

@@ -226,7 +225,7 @@ The following hosts are automatically blocked to prevent recursive tracking:
226225

227226
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.
228227

229-
To view captured signals in the Event Builder and create event generation rules, you need to enable `sendDebugSignalsToSegment`. This setting temporarily lets the SDK send signal data to Segment while you're testing.
228+
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.
230229

231230
In addition, the SDK obfuscates signals sent to Segment by default. To view the completed data, you need to turn off `obfuscateDebugSignals`.
232231

@@ -235,9 +234,9 @@ In addition, the SDK obfuscates signals sent to Segment by default. To view the
235234
236235
You can enable `sendDebugSignalsToSegment` and turn off `obfuscateDebugSignals` in one of three ways.
237236

238-
### Option 1: Use Build Configurations to Toggle Debug Mode
237+
### Option 1: Use build configurations to toggle debug mode
239238

240-
1. Define different configurations in your project settings (Debug, Release, etc.)
239+
1. Define different configurations in your project settings (for example, Debug or Release).
241240

242241
2. Use compiler flags to control the setting:
243242
```swift
@@ -254,7 +253,7 @@ You can enable `sendDebugSignalsToSegment` and turn off `obfuscateDebugSignals`
254253
))
255254
```
256255

257-
### Option 2: Use a Feature Flag System
256+
### Option 2: Use a Feature Flag system
258257
If you're using Firebase Remote Config or a similar feature flag system, you can dynamically control `sendDebugSignalsToSegment` and `obfuscateDebugSignals` without requiring a new app build:
259258
```swift
260259
let remoteConfig = RemoteConfig.remoteConfig()
@@ -267,7 +266,7 @@ You can enable `sendDebugSignalsToSegment` and turn off `obfuscateDebugSignals`
267266
))
268267
```
269268

270-
### Option 3: Use Environment Variables (for debugging/testing)
269+
### Option 3: Use environment variables (for debugging or testing)
271270
You can check for environment variables or launch arguments during development:
272271
```swift
273272
let isDebugEnabled = ProcessInfo.processInfo.environment["SIGNALS_DEBUG"] != nil
@@ -285,7 +284,7 @@ You can enable `sendDebugSignalsToSegment` and turn off `obfuscateDebugSignals`
285284
Next, return to the source settings to turn on Auto-Instrumentation:
286285

287286
1. Go to **Connections > Sources**.
288-
2. Select the source you used in Step 1.
287+
2. Select the source you used in [Step 1](#Step-1-Getting-started).
289288
3. From the source's overview tab, go to **Settings > Advanced**.
290289
4. Toggle Auto-Instrumention on.
291290

@@ -303,7 +302,7 @@ After integrating the SDK and running your app, verify that Segment is collectin
303302

304303
## Configuration options
305304

306-
Using the Signals Configuration object, you can control the destination, frequency, and types of signals that Segment automatically tracks within your application. The following table details the configuration options for Signals-Swift.
305+
Using the Signals Configuration object, you can control the destination, frequency, and types of signals that Segment automatically tracks within your application. The following table details the configuration options for Signals-Swift:
307306

308307

309308
| OPTION | REQUIRED | VALUE | DESCRIPTION |
@@ -312,15 +311,15 @@ Using the Signals Configuration object, you can control the destination, frequen
312311
| **maximumBufferSize** | No | Int | The number of signals to be kept for JavaScript inspection. This buffer is first-in, first-out. Default is **1000**. |
313312
| **relayCount** | No | Int | Relays every X signals to Segment. Default is **20**. |
314313
| **relayInterval** | No | TimeInterval | Relays signals to Segment every X seconds. Default is **60**. |
315-
| **broadcasters** | No | [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 when `sendDebugSignalsToSegment` is true. |
314+
| **broadcasters** | No | 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 when `sendDebugSignalsToSegment` is true. |
316315
| **sendDebugSignalsToSegment** | No | Bool | 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. |
317316
| **obfuscateDebugSignals** | No | Bool | Obfuscates signals being relayed to Segment. Default is **true**. |
318317
| **apiHost** | No | String | API host for signal relay. Default is **"signals.segment.io/v1"**. |
319318
| **useUIKitAutoSignal** | No | Bool | Enables automatic UIKit signal capture via method swizzling. Default is **false**. |
320319
| **useSwiftUIAutoSignal** | No | Bool | Enables automatic SwiftUI signal capture (requires typealiases). Default is **false**. |
321320
| **useNetworkAutoSignal** | No | Bool | Enables automatic network signal capture for URLSession. Default is **false**. |
322-
| **allowedNetworkHosts** | No | [String] | Array of host patterns to track. Use `["*"]` for all hosts. Default is **["*"]**. |
323-
| **blockedNetworkHosts** | No | [String] | Array of host patterns to exclude from tracking. Default is **[]**. |
321+
| **allowedNetworkHosts** | No | String | Array of host patterns to track. Use `["*"]` for all hosts. Default is **["*"]**. |
322+
| **blockedNetworkHosts** | No | String | Array of host patterns to exclude from tracking. Default is **[]**. |
324323

325324
## Next steps
326325

0 commit comments

Comments
 (0)