Skip to content

Commit 125a2f1

Browse files
authored
Merge pull request #3598 from segmentio/DOC-589
Mobile Device Mode Destination Filters Beta (Swift, Kotlin, React Native 2.0) [DOC-589]
2 parents fa6d3fe + 8ded85f commit 125a2f1

File tree

5 files changed

+135
-29
lines changed

5 files changed

+135
-29
lines changed

src/connections/destinations/destination-filters.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,35 @@ title: Destination Filters
33
rewrite: true
44
---
55

6-
Use Destination Filters to prevent certain data from flowing into a destination. With Destination Filters, you can conditionally filter out event properties, traits, and fields, or even filter out the event itself.
6+
> info ""
7+
> Destination filters are only available to Business Tier customers.
8+
>
9+
> Destination filters for mobile device-mode destinations are in beta and only supports [Swift](/docs/connections/sources/catalog/libraries/mobile/swift-ios#destination-filters), [Kotlin](/docs/connections/sources/catalog/libraries/mobile/kotlin-android/#destination-filters) and [React Native 2.0](/docs/connections/sources/catalog/libraries/mobile/react-native/#destination-filters) libraries.
10+
11+
Use destination filters to prevent certain data from flowing into a destination. You can conditionally filter out event properties, traits, and fields, or even filter out the event itself.
12+
13+
You can configure destination filters on cloud-mode, mobile, and web device-mode and actions-based destinations. With device-mode destinations, you can use the same user interface or API mechanism that you use for your cloud-mode destinations, and have those filters acted upon for device-mode destinations on web and mobile.
714

8-
Common use cases for Destination Filters include:
15+
Common use cases for destination filters include:
916
- Managing PII (personally identifiable information) by blocking fields from reaching certain destinations
1017
- Controlling event volume by sampling or dropping unnecessary events for specific destinations
1118
- Increasing data relevance in your destinations by removing unused or unwanted data
1219
- Preventing test or internally-generated events from reaching your production tools
1320

14-
> info ""
15-
> Destination Filters are only available to Business Tier customers.
16-
1721
### Limitations
1822

1923
Keep the following limitations in mind when you use Destination Filters:
2024

2125
- Segment applies Destination Filters one at a time in the order that they appear in your workspace.
22-
- Destination Filters can only be applied to cloud-mode (server-side) streaming destinations.
23-
- Device-mode destinations aren't supported.
2426
- You can't apply Destination Filters to Warehouses or S3 destinations.
2527
- Each filter can only apply to one source-destination pair.
28+
- *(For device-mode)* Destination filters don't apply to items that are added to the payload server-side such as IP addresses.
29+
- *(For device-mode)* Destination filters don't filter on native events that the destination SDK collects. Instead, you can use the load option to conditionally load relevant bundled JavaScript on the page. See the docs for [load options](/docs/connections/sources/catalog/libraries/website/javascript/#load-options).
30+
- *(For web device-mode)* Destination filters for web device-mode only supports the Analytics.js 2.0 source. You need to enable device mode destination filters for your Analytics.js source. To do this, go to your Javascript source and navigate to **Settings > Analytics.js** and turn the toggle on for **Destination Filters**.
2631

2732
[Contact Segment](https://segment.com/help/contact/){:target="_blank"} if these limitations impact your use case.
2833

29-
## Create a Destination Filter
34+
## Create a destination filter
3035

3136
To create a Destination Filter:
3237
1. Go to **Connections > Destinations** and select your destination.
@@ -38,7 +43,7 @@ To create a Destination Filter:
3843
7. Name your filter and click the toggle to enable it.
3944
8. Click **Save**.
4045

41-
## Destination Filters API
46+
## Destination filters API
4247

4348
The Destination Filters API provides more power than Segment's dashboard Destination Filters settings. With the API, you can create complex filters that are conditionally applied using Segment's [Filter Query Language (FQL)](/docs/api/config-api/fql/).
4449

src/connections/sources/catalog/libraries/mobile/kotlin-android/index.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ analytics.add(yourPlugin)
340340
```
341341

342342
### Example projects using Analytics-Kotlin
343-
See how different platforms and languages use Analytics-Kotlin in different [example projects](https://github.com/segmentio/analytics-kotlin/tree/main/samples).
344-
The example projects contain sample [plugins](https://github.com/segmentio/analytics-kotlin/tree/main/samples/kotlin-android-app/src/main/java/com/segment/analytics/next/plugins) and [destination plugins](https://github.com/segmentio/analytics-kotlin/tree/main/samples/kotlin-android-app-destinations/src/main/java/com/segment/analytics/destinations/plugins) you can utilize.
343+
See how different platforms and languages use Analytics-Kotlin in different [example projects](https://github.com/segmentio/analytics-kotlin/tree/main/samples){:target="_blank"}.
344+
The example projects contain sample [plugins](https://github.com/segmentio/analytics-kotlin/tree/main/samples/kotlin-android-app/src/main/java/com/segment/analytics/next/plugins){:target="_blank"} and [destination plugins](https://github.com/segmentio/analytics-kotlin/tree/main/samples/kotlin-android-app-destinations/src/main/java/com/segment/analytics/destinations/plugins){:target="_blank"} you can use.
345345

346346
## Utility methods
347347
The Analytics-Kotlin utility methods help you work with plugins from the analytics timeline. They include:
@@ -442,6 +442,30 @@ analytics.reset()
442442
{% endcodeexampletab %}
443443
{% endcodeexample %}
444444

445+
## Destination filters
446+
> info ""
447+
> Destination filters are only available to Business Tier customers.
448+
>
449+
> Destination filters on mobile device-mode destinations are in beta and only supports Analytics-Kotlin, [Analytics-Swift](/docs/connections/sources/catalog/libraries/mobile/swift-ios/), and [Analytics-React-Native 2.0](/docs/connections/sources/catalog/libraries/mobile/react-native/).
450+
451+
Use Analytics-Kotlin (Android) to configure [destination filters](docs/connections/destinations/destination-filters/) on your mobile device-mode destinations.
452+
453+
> warning ""
454+
> Keep [these limitations](/docs/connections/destinations/destination-filters/#limitations) in mind when using destination filters.
455+
456+
457+
To get started with destination filters on mobile device-mode destinations using Kotlin:
458+
459+
1. Download and install the dependency.
460+
```java
461+
implementation 'com.segment.analytics.kotlin:destination-filters-kotlin:0.1.0'
462+
```
463+
464+
2. Add the plugin.
465+
```java
466+
analytics.add(DestinationFilters())
467+
```
468+
445469
## Build Your own destination
446470

447471
If Segment doesn't support your Kotlin destination, you can build your own with the template Segment provides.

src/connections/sources/catalog/libraries/mobile/react-native/index.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,45 @@ These are the example plugins you can use and alter to meet your tracking needs:
491491
| Firebase | `@segment/analytics-react-native-plugin-consent-firebase` |
492492
| IDFA | `@segment/analytics-react-native-plugin-idfa` |
493493
494+
## Destination Filters
495+
> info ""
496+
> Destination filters are only available to Business Tier customers.
497+
>
498+
> Destination filters on mobile device-mode destinations are in beta and only supports Analytics-React-Native 2.0, [Analytics-Swift](/docs/connections/sources/catalog/libraries/mobile/swift-ios/) and [Analytics-Kotlin](/docs/connections/sources/catalog/libraries/mobile/kotlin-android/).
499+
500+
Use Analytics-React-Native 2.0 to set up [destination filters](docs/connections/destinations/destination-filters/) on your mobile device-mode destinations.
501+
502+
> warning ""
503+
> You must use Analytics-React-Native version 2.9 or higher to implement destination filters.
504+
>
505+
> Keep [these limitations](/docs/connections/destinations/destination-filters/#limitations) in mind when using destination filters.
506+
507+
To get started with destination filters on mobile device-mode destinations using Analytics-React-Native 2.0:
508+
1. Download and install the `@segment/analytics-react-native-plugin-destination-filters` package as a dependency in your project.
509+
* Using NPM:
510+
```npm
511+
npm install --save @segment/analytics-react-native-plugin-destination-filters
512+
```
513+
* Using Yarn:
514+
```yarn
515+
yarn add @segment/analytics-react-native-plugin-destination-filters
516+
```
517+
2. Follow the instructions for [adding plugins](/docs/connections/sources/catalog/libraries/mobile/react-native/#adding-plugins) on the main Analytics client.
518+
3. Add `DestinationFiltersPlugin` after you create your Segment client.
519+
520+
```kotlin
521+
import { createClient } from '@segment/analytics-react-native';
522+
523+
import { DestinationFiltersPlugin } from '@segment/analytics-react-native-plugin-destination-filters';
524+
525+
const segmentClient = createClient({
526+
writeKey: 'SEGMENT_KEY'
527+
});
528+
529+
segmentClient.add({ plugin: new DestinationFiltersPlugin() });
530+
segment.add({ plugin: new FirebasePlugin() })
531+
```
532+
494533
## Supported Destinations
495534
Segment supports a large number of [Cloud-mode](/docs/connections/destinations/#connection-modes) destinations. Segment also supports the below destinations for Analytics React Native 2.0 in device-mode, with more to follow:
496535
- [Adjust](https://www.npmjs.com/package/@segment/analytics-react-native-plugin-adjust){:target="_blank"}

src/connections/sources/catalog/libraries/mobile/swift-ios/index.md

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ If you're migrating to Analytics-Swift from a different mobile library, you can
1313
> Analytics-Swift currently supports [these destinations](#supported-destinations) in device-mode, with more to follow. Cloud-mode destinations are also supported.
1414
1515

16-
## Getting Started
16+
## Getting started
1717
To get started with the Analytics-Swift mobile library:
1818

1919
1. Create a Source in Segment.
@@ -59,6 +59,10 @@ To get started with the Analytics-Swift mobile library:
5959
`trackApplicationLifecycleEvents`| The default is set to `true`. <br> This automatically tracks lifecycle events. Set to `false` to stop tracking lifecycle events.
6060
`trackDeepLinks` | The default is set to `true`. <br> This automatically track deep links. Set to `false` to stop tracking Deep Links.
6161

62+
63+
> info ""
64+
> Configuration options such as IDFA collection and automatic screen tracking are found in Segment's [Plugin Examples repo](https://github.com/segmentio/analytics-example-plugins/tree/main/plugins/swift){:target="_blank"}.
65+
6266
## Tracking Methods
6367
Once you've installed the Analytics-Swift library, you can start collecting data through Segment's tracking methods:
6468
- [Identify](#identify)
@@ -201,7 +205,7 @@ analytics.alias(newId: "user-123")
201205
{% endcodeexampletab %}
202206
{% endcodeexample %}
203207

204-
## Plugin Architecture
208+
## Plugin architecture
205209
Segment's plugin architecture enables you to modify and augment how the analytics client works. From modifying event payloads to changing analytics functionality, plugins help to speed up the process of getting things done.
206210

207211
Plugins are run through a timeline, which executes in order of insertion based on their entry types. Segment has these 5 entry types:
@@ -330,7 +334,7 @@ analytics.add(plugin: yourIntegration)
330334

331335
Though you can add plugins anywhere in your code, it's best to implement your plugin when you configure the client.
332336

333-
## Utility Methods
337+
## Utility methods
334338
The Analytics Swift utility methods help you work with [plugins](#plugin-architecture) from the analytics timeline. They include:
335339
- [Add](#add)
336340
- [Find](#find)
@@ -406,6 +410,30 @@ analytics.flush()
406410
{% endcodeexampletab %}
407411
{% endcodeexample %}
408412

413+
## Destination filters
414+
> info ""
415+
> Destination filters are only available to Business Tier customers.
416+
>
417+
> Destination filters on mobile device-mode destinations are in beta and only supports Analytics-Swift, [Analytics-Kotlin](/docs/connections/sources/catalog/libraries/mobile/kotlin-android/), and [Analytics-React-Native 2.0](/docs/connections/sources/catalog/libraries/mobile/react-native/).
418+
419+
Use Analytics-Swift to set up [destination filters](docs/connections/destinations/destination-filters/) on your mobile device-mode destinations.
420+
421+
> warning ""
422+
> Keep [these limitations](/docs/connections/destinations/destination-filters/#limitations) in mind when using destination filters.
423+
424+
To get started with destination filters using Swift:
425+
1. Add the Swift package `git@github.com:segmentio/DestinationFilters-Swift.git` as a dependency through either of these 2 options:
426+
1. Your package.swift file
427+
2. Xcode
428+
1. Xcode 12: **File > Swift Packages > Add Package Dependency**
429+
2. Xcode 13: **File > Add Packages...**
430+
431+
After you install the package, import the package with `import DestinationFilters_Swift` to reference the Destination Filters plugin.
432+
2. Add the plugin.
433+
```swift
434+
analytics.add(DestinationFilters())
435+
```
436+
409437
## Ad Tracking and IDFA
410438
[Segment no longer automatically collects IDFA](/docs/connections/sources/catalog/libraries/mobile/ios/ios14-guide/#segment-no-longer-automatically-collects-idfa). If you need to collect the user's IDFA to pass it to specific destinations, or for other uses, [you can manually pass the IDFA to the Segment SDK](/docs/connections/sources/catalog/libraries/mobile/ios/ios14-guide/#you-can-manually-pass-the-idfa-to-the-segment-sdk).
411439

@@ -416,13 +444,13 @@ let idfaPlugin = IDFACollection()
416444
analytics.add(plugin: idfaPlugin)
417445
```
418446

419-
## Supported Destinations
447+
## Supported destinations
420448
Segment supports these destinations for Analytics Swift, with more to come:
421-
* [Amplitude](https://github.com/segment-integrations/analytics-swift-amplitude)
422-
* [Appsflyer](https://github.com/segment-integrations/analytics-swift-appsflyer)
423-
* [Facebook App Events](https://github.com/segment-integrations/analytics-swift-facebook-app-events)
424-
* [Firebase](https://github.com/segment-integrations/analytics-swift-firebase)
425-
* [Mixpanel](https://github.com/segment-integrations/analytics-swift-mixpanel)
449+
* [Amplitude](https://github.com/segment-integrations/analytics-swift-amplitude){:target="_blank"}
450+
* [Appsflyer](https://github.com/segment-integrations/analytics-swift-appsflyer){:target="_blank"}
451+
* [Facebook App Events](https://github.com/segment-integrations/analytics-swift-facebook-app-events){:target="_blank"}
452+
* [Firebase](https://github.com/segment-integrations/analytics-swift-firebase){:target="_blank"}
453+
* [Mixpanel](https://github.com/segment-integrations/analytics-swift-mixpanel){:target="_blank"}
426454

427455
## FAQs
428456
### Can I use the catalog of device-mode destinations from Analytics-iOS?
@@ -431,4 +459,4 @@ No, only the plugins listed above are supported in device-mode for Analytics-Swi
431459
When you successfully package a plugin in device-mode, you will no longer see the integration listed as `false` in the integrations object for a Segment event. This logic is now packaged in the event metadata, and is not surfaced in the Segment debugger.
432460

433461
## Changelog
434-
[View the Analytics-Swift changelog on GitHub](https://github.com/segmentio/analytics-swift/releases).
462+
[View the Analytics-Swift changelog on GitHub](https://github.com/segmentio/analytics-swift/releases){:target="_blank"}.

src/guides/filtering-data.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,30 @@ Note that destination flags are **case sensitive** and match the destination's n
4343

4444
Your data is sent to your warehouse (if you have one) and into the Segment backend systems regardless of what is in the integrations object.
4545

46-
## Destination Filters
46+
## Destination filters
4747

48-
[Destination Filters](https://segment.com/docs/connections/destinations/destination-filters/) allow you to control the data flowing into each specific destination, by examining event payloads, and conditionally preventing data from being sent to destinations. You can filter out entire events, or just specific fields in the properties, in the traits, or in the context of your events. Destination filters are not available for, and do not prevent data from reaching your warehouse(s) or S3 destinations.
48+
[Destination filters](https://segment.com/docs/connections/destinations/destination-filters/) allow you to control the data flowing into each specific destination, by examining event payloads, and conditionally preventing data from being sent to destinations. You can filter out entire events, or just specific fields in the properties, in the traits, or in the context of your events. Destination filters support cloud-based (server-side), actions-based, and mobile and web device-mode destinations. Destination filters aren't available for, and don't prevent data from reaching your warehouse(s) or S3 destinations.
4949

50-
> note ""
51-
> **Note**: Destination Filters are available in workspaces that are on a Business Tier plan only. Destination Filters can only be applied to Cloud-mode ("server-side") streaming destinations. Device-mode destinations are not supported.
50+
> info ""
51+
> Destination filters are only available in workspaces that are on a Business Tier plan.
52+
>
53+
> Destination filters for mobile device-mode destinations are in beta and only supports [Swift](/docs/connections/sources/catalog/libraries/mobile/swift-ios#destination-filters), [Kotlin (Android)](/docs/connections/sources/catalog/libraries/mobile/kotlin-android/#destination-filters), and [React Native 2.0](/docs/connections/sources/catalog/libraries/mobile/react-native/#destination-filters) libraries.
54+
55+
> warning ""
56+
> Keep [these limitations](/docs/connections/destinations/destination-filters/#limitations) in mind when using destination filters.
5257
5358
![](images/destination-filter-create.png)
5459

55-
You can set up Destination Filters from the Segment web app by navigating to the destination from which you want to exclude the data, and clicking the **Destination Filters** tab. From there you can create new filter rules, and edit, enable, and disable existing filters. See the [Destination Filters documentation](https://segment.com/docs/connections/destinations/destination-filters/) for more details.
60+
To set up destination filters from the Segment web app for the destination from which you want to exclude data:
61+
1. *(For web device-mode destinations only)* Enable device mode destination filters for your Analytics.js source. To do this, go to your Javascript source and navigate to **Settings > Analytics.js** and turn the toggle on for **Destination Filters**.
62+
* **NOTE:** Destination filters for web device-mode only supports the Analytics.js 2.0 source.
63+
2. Navigate to **Connections > Destinations** and select the destination you want to set up filters for.
64+
3. Go to the **Filters** tab and click **+ New Filter** to create a destination filter.
65+
See the [Destination Filters documentation](/docs/connections/destinations/destination-filters/) for more details.
5666

57-
You can set up Destination filters using the options presented in the Segment web app, or using Segment's Filter Query Logic (FQL). If you use FQL, your query syntax is limited to 5kb per query.
67+
You can set up destination filters using the options presented in the Segment web app, or using Segment's Filter Query Logic (FQL). If you use FQL, your query syntax is limited to 5kb per query.
5868

59-
## Per-Source Schema Integrations Filters
69+
## Per-Source schema integrations filters
6070

6171
Integration filters allow you to quickly change which destinations receive specific Track, Identify, or Group events. Access this tool in any Source that is receiving data by navigating to the Schema tab. Schema integration filters are available to workspaces that are on a Business Tier plan only.
6272

@@ -68,7 +78,7 @@ The events filtered out of individual destinations using this method still arriv
6878

6979
**Integration filters are all-or-nothing for each event.** If you require more detailed control over which events are sent to specific destinations, you can use Destination Filters to inspect the event payload, and conditionally drop the data or forward it to the destination.
7080

71-
## Schema Event Filters
81+
## Schema event filters
7282

7383
You can use Schema Event Filters to discard and permanently remove Page, Screen and Track events from event-based sources, preventing them from reaching any destinations or warehouses. Use this if you know that you'll never want to access this data again. This functionality is similar to filtering with the Integrations object, however it can be changed from within the Segment app without touching any code.
7484

0 commit comments

Comments
 (0)