Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8e2d19f

Browse files
authored
Merge pull request#8104 from segmentio/lalmalani-patch-2
Revise Live Plugins documentation for Public Beta
2 parentse4a1efa +71dde58 commit8e2d19f

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-
Liveplugins are JavaScript code snippets published to your Segment workspace and then downloaded directly to the mobile devices of end users. Live plugins letyouperform real-time modifications to events before theyleave themobiledevice.
6+
LivePlugins let you modify analytics events in real time, directly on user devices, without rebuilding or redeploying your app. They’re JavaScript snippets thatyoupublish from your Segment workspace, where theyrun on your users’mobiledevices to filter or transform data before it’s sent to Segment.
77

8-
On this page, you'll learn howtoset up live plugins and how to createyourown 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/)togive you flexible control overyourevent 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 uselive plugins, you first need to set up your mobile app with a one-time configuration.
23+
To useLive Plugins, you first need to set up your mobile app with a one-time configuration.
2224

23-
To configurelive plugins:
25+
To configureLive Plugins:
2426

25-
1. Includethe[AnalyticsLive for Swift plugin](https://github.com/segment-integrations/analytics-swift-live){:target="_blank"}
26-
and[AnalyticsLive 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-
classPrivacyLivePluginextendsLivePlugin {
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-
deleteevent.context.device.id;
69-
returnevent;
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 attachedyourlive plugin(s) to your mobile source. The nexttime your users launch your app, their Segment SDK will download the latest live plugins, which will run everytime new events are generated.
56+
##Createyourown 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+
<imgalt="Access Live Plugins from the Source overview tab"src="https://github.com/user-attachments/assets/e228bddb-4cb8-4469-9ac6-8a2c322edcbc" />
11264

113-
Follow the stepsin this section to create your ownlive plugin.
65+
Follow the steps in this section to createand deployyour ownLive 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 yourlive plugin to the Analytics instance
92+
###2. Add yourLive Plugin to the Analytics instance
14193

142-
After you define your customlive 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 yourlive plugin.
94+
After you define your customLive 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 yourLive 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 customlive plugin runs during eventprocessing, you can use `LivePluginType` enums, which define different timing options for yourlive plugin. Here are the available types:
106+
To control when your customLive Plugin runs duringtheeventlifecycle, you can use`LivePluginType` enums, which define different timing options for yourLive Plugin. Here are the available types:
155107

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

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

167-
## Liveplugin examples
119+
##LivePlugin 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-
Liveplugins follow an interface thatlet you intercept Segment events and modify their data. This interface includes several functions that you can implement for custom behavior:
256+
LivePlugins expose an interface thatlets 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 forlive 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 forLive 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)

[8]ページ先頭

©2009-2025 Movatter.jp