diff --git a/src/connections/sources/catalog/libraries/mobile/apple/live-plugins.md b/src/connections/sources/catalog/libraries/mobile/apple/live-plugins.md index 69f1d6d0d8..2ed355627e 100644 --- a/src/connections/sources/catalog/libraries/mobile/apple/live-plugins.md +++ b/src/connections/sources/catalog/libraries/mobile/apple/live-plugins.md @@ -3,27 +3,29 @@ title: Live Plugins strat: swift --- -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. +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. -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. +Live Plugins work alongside [Auto-Instrumentation](/docs/connections/auto-instrumentation/) to give you flexible control over your event data. -> info "Live Plugins is in pilot" -> Live Plugins is currently in Pilot and available to select Business Tier Customers only. To enable this feature for your workspace, contact your CSM. +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. -## Live plugins overview +> info "Live Plugins is in Public Beta" +> 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. -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. +## Live Plugins overview -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. +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. + +Because Live Plugins run before data leaves the device, you can apply the same logic to all destinations or target specific destinations as needed. ## Setup -To use live plugins, you first need to set up your mobile app with a one-time configuration. +To use Live Plugins, you first need to set up your mobile app with a one-time configuration. -To configure live plugins: +To configure Live Plugins: -1. Include the [Analytics Live for Swift plugin](https://github.com/segment-integrations/analytics-swift-live){:target="_blank"} - and [Analytics Live for Kotlin plugin](https://github.com/segment-integrations/analytics-kotlin-live){:target="_blank"} +1. Include [Analytics-Live for Swift plugin](https://github.com/segment-integrations/analytics-swift-live){:target="_blank"} + and [Analytics-Live for Kotlin](https://github.com/segment-integrations/analytics-kotlin-live){:target="_blank"} in your project. 2. Add the plugin to your instance of Analytics, using the following code: @@ -49,68 +51,18 @@ analytics.add(LivePlugins()) {% endcodeexampletab %} {% endcodeexample %} -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. - -## Live plugin tutorial - -This section walks you through a sample live plugin implementation. - -### 1. Write a live plugin in JavaScript - -Copy and save the following file, which anonymizes events by removing user IDs and device IDs: - -```js -class PrivacyLivePlugin extends LivePlugin { - // The execute function is called for every event. - execute(event) { - // Remove the user ID and device ID from the event to anonymize it. - event.userId = null; - delete event.context.device.id; - return event; - } -} -``` - -Note the name of your saved file. You'll need it in the next step. - -### 2. Deploy the plugin with the Live Plugin CLI - -With your plugin saved, you'll next deploy the plugin with Segment's Live Plugin CLI. Follow these steps: - -#### Install the CLI with Homebrew - -Run this command to install the Segment CLI: - -```shell -$ brew install segment-integrations/formulae/segmentcli -``` - -#### Authenticate with Segment - -Next, you'll authenticate with Segment to give the CLI access to your workspace: - -1. Within your Segment workspace, navigate to **Settings > Workspace Settings > Access Management > Tokens**. -2. Click **Create token** to generate a new token with the `Workspace Owner` role. Copy the token. -3. Return to your command line and use your token to authenticate: - - ```shell - $ segmentcli auth - ``` -4. Copy your source's ID. You'll find the Source ID under **Settings > API Keys > Source ID** on your source's page. -7. Use your source ID and live plugin file name to upload your live plugin: - - ```shell - $ segmentcli liveplugins upload - ``` +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. -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. +## Create your own Live Plugin -> info "" -> Because the CDN settings object takes a few minutes to rebuild, your live plugins might not be available immediately. +To access Live Plugins for your Swift and Kotlin sources: -## Create your own live plugin +1. In your Segment workspace, go to **Connections > Sources**. +2. Select your Swift or Kotlin source (or create a new one). +3. From the source's overview page, click the Live Plugin tab.. +Access Live Plugins from the Source overview tab -Follow the steps in this section to create your own live plugin. +Follow the steps in this section to create and deploy your own Live Plugin. ### 1. Subclass the `LivePlugin` class @@ -137,9 +89,9 @@ analytics.add(new UserIdLivePlugin(LivePluginType.enrichment, null)); In this example, you've created a `UserIdLivePlugin` by subclassing `LivePlugin` and implementing the `execute()` function. This function gets applied to every event. -### 2. Add your live plugin to the Analytics instance +### 2. Add your Live Plugin to the Analytics instance -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. +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. 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. @@ -151,7 +103,7 @@ analytics.add(new UserIdLivePlugin(LivePluginType.enrichment, "adobe")); ### 3. Use the `LivePluginType` enums -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: +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: ```js const LivePluginType = { @@ -162,9 +114,9 @@ const LivePluginType = { } ``` -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. +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. -## Live plugin examples +## Live Plugin examples The following live plugin examples address common use cases: @@ -301,7 +253,7 @@ analytics.add(new DownSampleLivePlugin(LivePluginType.enrichment, null)); ## Live Plugins API -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: +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: ```js // Interface for Live Plugins: @@ -325,7 +277,7 @@ This section covers the primary event callbacks. #### The `execute` callback -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`. +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`. 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. @@ -351,4 +303,4 @@ There's one non-event function: | Function | Description | | --------------- | --------------------------------------------------------------------------- | -| `reset(): null` | Called when the Analytics instance is about to be reset. Nothing to return. | \ No newline at end of file +| `reset(): null` | Called when the Analytics instance is about to be reset. Nothing to return. |