@@ -26,30 +26,32 @@ Follow these steps to integrate the Signals SDK into your Swift application:
26
26
27
27
1 . Use Swift Package Manager to add the Signals SDK from the following repository:
28
28
29
- ``` https://github.com/segmentio/Signals-swift.git ```
29
+ ``` zsh
30
+ https://github.com/segmentio/Signals-swift.git
31
+ ```
30
32
31
33
2. Add the initialization code:
32
34
33
- ``` swift
34
- // Configure Analytics with your settings
35
- {... < analytics config> .... }
35
+ ` ` ` swift
36
+ // Configure Analytics with your settings
37
+ {... < analytics config> ....}
36
38
37
- // Set up the Signals SDK configuration
38
- let config = Signals.Configuration (
39
- writeKey : " <WRITE_KEY>" , // Replace <WRITE_KEY> with your actual write key
40
- maximumBufferSize : 100 ,
41
- useSwiftUIAutoSignal : true ,
42
- useNetworkAutoSignal : true
43
- )
39
+ // Set up the Signals SDK configuration
40
+ let config = Signals.Configuration(
41
+ writeKey: " <WRITE_KEY>" , // Replace < WRITE_KEY> with your actual write key
42
+ maximumBufferSize: 100,
43
+ useSwiftUIAutoSignal: true,
44
+ useNetworkAutoSignal: true
45
+ )
44
46
45
- // Locate and set the fallback JavaScript file for edge functions
46
- let fallbackURL = Bundle.main .url (forResource : " MyEdgeFunctions" , withExtension : " js" )
47
+ // Locate and set the fallback JavaScript file for edge functions
48
+ let fallbackURL = Bundle.main.url(forResource: " MyEdgeFunctions" , withExtension: " js" )
47
49
48
- // Apply the configuration and add the Signals plugin
49
- Signals.shared .useConfiguration (config)
50
- Analytics.main .add (plugin : LivePlugins (fallbackFileURL : fallbackURL))
51
- Analytics.main .add (plugin : Signals.shared )
52
- ```
50
+ // Apply the configuration and add the Signals plugin
51
+ Signals.shared.useConfiguration(config)
52
+ Analytics.main.add(plugin: LivePlugins(fallbackFileURL: fallbackURL))
53
+ Analytics.main.add(plugin: Signals.shared)
54
+ ` ` `
53
55
54
56
Verify that you replaced ` < WRITE_KEY> ` with the actual write key you copied in Step 1.
55
57
@@ -59,59 +61,66 @@ Follow these steps to integrate the Signals SDK into your Kotlin application:
59
61
60
62
1. Update your module’s Gradle build file to add the right dependencies:
61
63
62
- ``` kotlin
63
- dependencies {
64
- // Add the Analytics Kotlin library
65
- implementation(" com.segment.analytics.kotlin:android:1.15.0" )
66
- // Add a live plugin for real-time data handling
67
- implementation(" com.segment.analytics.kotlin:analytics-kotlin-live:1.0.0" )
68
- // Add the core Signals library
69
- implementation(" com.segment.analytics.kotlin.signals:core:0.0.1" )
70
- // Compose plugin for Jetpack Compose UI tracking
71
- implementation(" com.segment.analytics.kotlin.signals:compose:0.0.1" )
72
- // OkHttp3 plugin for network activity tracking
73
- implementation(" com.segment.analytics.kotlin.signals:okhttp3:0.0.1" )
74
- }
75
- ```
64
+ ` ` ` kotlin
65
+ dependencies {
66
+ // Add the Analytics Kotlin library
67
+ implementation(" com.segment.analytics.kotlin:android:1.15.0" )
68
+ // Add a live plugin for real-time data handling
69
+ implementation(" com.segment.analytics.kotlin:analytics-kotlin-live:1.0.0" )
70
+ // Add the core Signals library
71
+ implementation(" com.segment.analytics.kotlin.signals:core:0.0.1" )
72
+ // Compose plugin for Jetpack Compose UI tracking
73
+ implementation(" com.segment.analytics.kotlin.signals:compose:0.0.1" )
74
+ // OkHttp3 plugin for network activity tracking
75
+ implementation(" com.segment.analytics.kotlin.signals:okhttp3:0.0.1" )
76
+ }
77
+ ` ` `
76
78
77
79
2. Add the following code to your application to initialize the Signals SDK:
78
80
79
- ``` kotlin
80
- // Configure Analytics with your settings
81
- {.. . < analytics config> .... }
81
+ ` ` ` kotlin
82
+ // Configure Analytics with your settings
83
+ {... < analytics config> ....}
82
84
83
- // Add live plugins for real-time analytics
84
- analytics.add(LivePlugins ())
85
+ // Add live plugins for real-time analytics
86
+ analytics.add(LivePlugins ())
85
87
86
- // Configure and add the Signals plugin
87
- Signals .configuration = Configuration (
88
- maximumBufferSize = 1000 ,
89
- broadcasters = listOf (SegmentBroadcaster (analytics))
90
- )
88
+ // Configure and add the Signals plugin
89
+ Signals.configuration = Configuration(
90
+ maximumBufferSize = 1000,
91
+ broadcasters = listOf(SegmentBroadcaster(analytics))
92
+ )
91
93
92
- // Add the Compose plugin for UI events and screen tracking
93
- analytics.add(SignalsComposeTrackingPlugin ())
94
- ```
94
+ // Add the Compose plugin for UI events and screen tracking
95
+ analytics.add(SignalsComposeTrackingPlugin ())
96
+ ` ` `
95
97
96
98
3. (Optional:) If you want to track network activity, configure your OkHttpClient to use the Signals OkHttp3 plugin:
97
99
98
- ``` kotlin
99
- private val okHttpClient = OkHttpClient .Builder ()
100
- .addInterceptor(SignalsOkHttp3TrackingPlugin ())
101
- .build()
102
- ```
100
+ ` ` ` kotlin
101
+ private val okHttpClient = OkHttpClient.Builder ()
102
+ .addInterceptor(SignalsOkHttp3TrackingPlugin ())
103
+ .build ()
104
+ ` ` `
103
105
104
106
4. Build and run your app.
105
107
106
108
107
109
# # Step 3: Verify and deploy events
108
110
109
- Next, you'll need to verify signal emission and create rules to convert those signals into events.
111
+ Next, you' ll need to verify signal emission and create rules to convert those signals into events:
110
112
111
- ### Verify signal emission
112
-
113
- 1 . Return to ** Connections > Auto-Instrumentation** and click on the new source you created.
113
+ 1. In your Segment workspace, return to **Connections > Auto-Instrumentation** and click on the new source you created.
114
114
2. Verify that signals appear as expected on the dashboard.
115
115
116
- ![ Signals successfully appearing in the Segment UI] ( images/autoinstrumentation_signals.png " Signals successfully appearing in the Segment UI ")
116
+ 
117
+
118
+ 3. Click **Create Rules**.
119
+ 4. In the Rules Editor, add a rule that converts signal data into an event.
120
+ 5. Click **Preview**, then click **Save & Deploy**.
121
+
122
+ Segment displays `Rule updated successfully` to verify that it saved your rule.
123
+
124
+ ## Step 4: Redeploy your application
117
125
126
+ After you' ve finiseh
0 commit comments