Skip to content

Commit 8e2d19f

Browse files
authored
Merge pull request #8104 from segmentio/lalmalani-patch-2
Revise Live Plugins documentation for Public Beta
2 parents e4a1efa + 71dde58 commit 8e2d19f

File tree

1 file changed

+29
-77
lines changed

1 file changed

+29
-77
lines changed

src/connections/sources/catalog/libraries/mobile/apple/live-plugins.md

Lines changed: 29 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,29 @@ title: Live Plugins
33
strat: swift
44
---
55

6-
Live plugins are JavaScript code snippets published to your Segment workspace and then downloaded directly to the mobile devices of end users. Live plugins let you perform real-time modifications to events before they leave the mobile device.
6+
Live Plugins let you modify analytics events in real time, directly on user devices, without rebuilding or redeploying your app. They’re JavaScript snippets that you publish from your Segment workspace, where they run on your users’ mobile devices to filter or transform data before it’s sent to Segment.
77

8-
On this page, you'll learn how to set up live plugins and how to create your own live plugins. You'll also see example live plugins that address common use cases.
8+
Live Plugins work alongside [Auto-Instrumentation](/docs/connections/auto-instrumentation/) to give you flexible control over your event data.
99

10-
> info "Live Plugins is in pilot"
11-
> Live Plugins is currently in Pilot and available to select Business Tier Customers only. To enable this feature for your workspace, contact your CSM.
10+
On this page, you’ll learn how to set up your mobile app to support Live Plugins, create and deploy custom plugins, and explore examples for common use cases.
1211

13-
## Live plugins overview
12+
> info "Live Plugins is in Public Beta"
13+
> Live Plugins is in public beta for Swift and Kotlin and available to select Business Tier Customers only. To enable this feature for your workspace, contact your CSM.
1414
15-
You can use JavaScript live plugins with Analytics-Swift and Analytics-Kotlin to filter and modify data remotely. As a result, you can filter and modify analytics events without having to deploy updates to the app store for each change, ensuring data quality and consistency for all your mobile users.
15+
## Live Plugins overview
1616

17-
Because live plugins let you modify event data before it leaves a mobile device, you can use the same function to modify data meant for all your cloud-mode and device-mode destinations.
17+
You can use JavaScript Live Plugins with Analytics-Swift and Analytics-Kotlin to modify or filter event data directly on user devices. This lets you make real-time updates to your tracking logic without redeploying your app, helping you maintain data quality and consistency across your mobile users.
18+
19+
Because Live Plugins run before data leaves the device, you can apply the same logic to all destinations or target specific destinations as needed.
1820

1921
## Setup
2022

21-
To use live plugins, you first need to set up your mobile app with a one-time configuration.
23+
To use Live Plugins, you first need to set up your mobile app with a one-time configuration.
2224

23-
To configure live plugins:
25+
To configure Live Plugins:
2426

25-
1. Include the [Analytics Live for Swift plugin](https://github.com/segment-integrations/analytics-swift-live){:target="_blank"}
26-
and [Analytics Live for Kotlin plugin](https://github.com/segment-integrations/analytics-kotlin-live){:target="_blank"}
27+
1. Include [Analytics-Live for Swift plugin](https://github.com/segment-integrations/analytics-swift-live){:target="_blank"}
28+
and [Analytics-Live for Kotlin](https://github.com/segment-integrations/analytics-kotlin-live){:target="_blank"}
2729
in your project.
2830
2. Add the plugin to your instance of Analytics, using the following code:
2931

@@ -49,68 +51,18 @@ analytics.add(LivePlugins())
4951
{% endcodeexampletab %}
5052
{% endcodeexample %}
5153

52-
After you've completed setup, you can deploy your apps to the Apple App Store and Google Play Store. You can then add new JavaScript plugin code to your mobile apps through the CLI and perform updates as often as needed.
53-
54-
## Live plugin tutorial
55-
56-
This section walks you through a sample live plugin implementation.
57-
58-
### 1. Write a live plugin in JavaScript
59-
60-
Copy and save the following file, which anonymizes events by removing user IDs and device IDs:
61-
62-
```js
63-
class PrivacyLivePlugin extends LivePlugin {
64-
// The execute function is called for every event.
65-
execute(event) {
66-
// Remove the user ID and device ID from the event to anonymize it.
67-
event.userId = null;
68-
delete event.context.device.id;
69-
return event;
70-
}
71-
}
72-
```
73-
74-
Note the name of your saved file. You'll need it in the next step.
75-
76-
### 2. Deploy the plugin with the Live Plugin CLI
77-
78-
With your plugin saved, you'll next deploy the plugin with Segment's Live Plugin CLI. Follow these steps:
79-
80-
#### Install the CLI with Homebrew
81-
82-
Run this command to install the Segment CLI:
83-
84-
```shell
85-
$ brew install segment-integrations/formulae/segmentcli
86-
```
87-
88-
#### Authenticate with Segment
89-
90-
Next, you'll authenticate with Segment to give the CLI access to your workspace:
91-
92-
1. Within your Segment workspace, navigate to **Settings > Workspace Settings > Access Management > Tokens**.
93-
2. Click **Create token** to generate a new token with the `Workspace Owner` role. Copy the token.
94-
3. Return to your command line and use your token to authenticate:
95-
96-
```shell
97-
$ segmentcli auth <ProfileName> <AuthToken>
98-
```
99-
4. Copy your source's ID. You'll find the Source ID under **Settings > API Keys > Source ID** on your source's page.
100-
7. Use your source ID and live plugin file name to upload your live plugin:
101-
102-
```shell
103-
$ segmentcli liveplugins upload <SourceID> <FileName>
104-
```
54+
After you've completed setup, you can deploy your apps to the Apple App Store and Google Play Store. You can then add new JavaScript plugin code to your mobile apps through the Segment website, and perform updates as often as needed.
10555

106-
You've now successfully attached your live plugin(s) to your mobile source. The next time your users launch your app, their Segment SDK will download the latest live plugins, which will run every time new events are generated.
56+
## Create your own Live Plugin
10757

108-
> info ""
109-
> Because the CDN settings object takes a few minutes to rebuild, your live plugins might not be available immediately.
58+
To access Live Plugins for your Swift and Kotlin sources:
11059

111-
## Create your own live plugin
60+
1. In your Segment workspace, go to **Connections > Sources**.
61+
2. Select your Swift or Kotlin source (or create a new one).
62+
3. From the source's overview page, click the Live Plugin tab..
63+
<img alt="Access Live Plugins from the Source overview tab" src="https://github.com/user-attachments/assets/e228bddb-4cb8-4469-9ac6-8a2c322edcbc" />
11264

113-
Follow the steps in this section to create your own live plugin.
65+
Follow the steps in this section to create and deploy your own Live Plugin.
11466

11567
### 1. Subclass the `LivePlugin` class
11668

@@ -137,9 +89,9 @@ analytics.add(new UserIdLivePlugin(LivePluginType.enrichment, null));
13789

13890
In this example, you've created a `UserIdLivePlugin` by subclassing `LivePlugin` and implementing the `execute()` function. This function gets applied to every event.
13991

140-
### 2. Add your live plugin to the Analytics instance
92+
### 2. Add your Live Plugin to the Analytics instance
14193

142-
After you define your custom live plugin, you need to add it to the Analytics instance. The Analytics object is globally accessible, and you can use the `add()` method to include your live plugin.
94+
After you define your custom Live Plugin, you need to add it to the Analytics instance. The Analytics object is globally accessible, and you can use the `add()` method to include your Live Plugin.
14395

14496
When you adding a new instance, you specify the `LivePluginType` and the destination to which it applies, or use null to apply it to all destinations.
14597

@@ -151,7 +103,7 @@ analytics.add(new UserIdLivePlugin(LivePluginType.enrichment, "adobe"));
151103

152104
### 3. Use the `LivePluginType` enums
153105

154-
To control when your custom live plugin runs during event processing, you can use `LivePluginType` enums, which define different timing options for your live plugin. Here are the available types:
106+
To control when your custom Live Plugin runs during the event lifecycle, you can use `LivePluginType` enums, which define different timing options for your Live Plugin. Here are the available types:
155107

156108
```js
157109
const LivePluginType = {
@@ -162,9 +114,9 @@ const LivePluginType = {
162114
}
163115
```
164116

165-
With these enums, you can select the timing that best fits your custom live plugin's target use case. These types align with categories used for Native Plugins.
117+
With these enums, you can select the timing that best fits your custom Live Plugin's target use case. These types align with categories used for Native Plugins.
166118

167-
## Live plugin examples
119+
## Live Plugin examples
168120

169121
The following live plugin examples address common use cases:
170122

@@ -301,7 +253,7 @@ analytics.add(new DownSampleLivePlugin(LivePluginType.enrichment, null));
301253

302254
## Live Plugins API
303255

304-
Live plugins follow an interface that let you intercept Segment events and modify their data. This interface includes several functions that you can implement for custom behavior:
256+
Live Plugins expose an interface that lets you intercept Segment events and modify their data. This interface includes several functions that you can implement for custom behavior:
305257

306258
```js
307259
// Interface for Live Plugins:
@@ -325,7 +277,7 @@ This section covers the primary event callbacks.
325277

326278
#### The `execute` callback
327279

328-
The `execute` callback function serves as the primary entry point for live plugins to intercept and modify events. When you implement the `execute` function in your plugin, you can decide whether to keep the event by returning it or drop it by returning `null`.
280+
The `execute` callback function serves as the primary entry point for Live Plugins to intercept and modify events. When you implement the `execute` function in your plugin, you can decide whether to keep the event by returning it or drop it by returning `null`.
329281

330282
This callback is versatile, as you can use it for various event types when the event type itself is not critical. Additionally, `execute` lets you invoke more specific callbacks based on the event type.
331283

@@ -351,4 +303,4 @@ There's one non-event function:
351303

352304
| Function | Description |
353305
| --------------- | --------------------------------------------------------------------------- |
354-
| `reset(): null` | Called when the Analytics instance is about to be reset. Nothing to return. |
306+
| `reset(): null` | Called when the Analytics instance is about to be reset. Nothing to return. |

0 commit comments

Comments
 (0)