Skip to content

Commit cbf9869

Browse files
authored
Merge pull request #3678 from segmentio/revert-3674-revert-3598-DOC-589
Mobile Device Mode Destination Filters Beta (Swift, Kotlin, React Native 2.0) [DOC-589]
2 parents 7d0174b + 5cfbb3f commit cbf9869

File tree

5 files changed

+155
-48
lines changed

5 files changed

+155
-48
lines changed

src/connections/destinations/destination-filters.md

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,38 @@ 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

19-
Keep the following limitations in mind when you use Destination Filters:
23+
Keep the following limitations in mind when you use destination filters:
2024

21-
- 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.
24-
- You can't apply Destination Filters to Warehouses or S3 destinations.
25+
- Segment applies destination filters one at a time in the order that they appear in your workspace.
26+
- 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 device-mode)* Destination filters don't filter some fields that are collected by the destination SDK outside of Segment such as `page.url` and `page.referrer`.
31+
- *(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**.
2632

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

29-
## Create a Destination Filter
35+
## Create a destination filter
3036

31-
To create a Destination Filter:
37+
To create a destination filter:
3238
1. Go to **Connections > Destinations** and select your destination.
3339
2. Click on the **Filters** tab of your destination.
3440
3. Click **+ New Filter**.
@@ -38,11 +44,11 @@ To create a Destination Filter:
3844
7. Name your filter and click the toggle to enable it.
3945
8. Click **Save**.
4046

41-
## Destination Filters API
47+
## Destination filters API
4248

43-
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/).
49+
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/).
4450

45-
The Destination Filters API offers four different filter types:
51+
The destination filters API offers four different filter types:
4652

4753
| Filter | Details |
4854
| ------------------ | ------------------------------------------------------------ |
@@ -55,7 +61,7 @@ To learn more, read Segment's [Destination Filters API docs](https://docs.segmen
5561

5662
## Examples
5763

58-
The following examples illustrate common Destinations Filters use cases:
64+
The following examples illustrate common destinations filters use cases:
5965
* [PII management](#pii-management)
6066
* [Control event volume](#control-event-volume)
6167
* [Cleaner data](#cleaner-data)
@@ -67,7 +73,7 @@ The following examples illustrate common Destinations Filters use cases:
6773

6874
Example: Remove email addresses from `context` and `properties`:
6975

70-
Property-level allowlisting is available with Segment's API. Using Destination Filters, you can configure a rule that removes email addresses from `context` and `properties`. As a result, Segment only sends traits without PII to the destination.
76+
Property-level allowlisting is available with Segment's API. Using destination filters, you can configure a rule that removes email addresses from `context` and `properties`. As a result, Segment only sends traits without PII to the destination.
7177

7278

7379
![PII management example](images/destination-filters/pii_example.png)
@@ -96,31 +102,31 @@ In the example below, the rule prevents an event from sending if `Order Complete
96102

97103
### Sample a percentage of events
98104

99-
Using the [Destination Filters API](https://docs.segmentapis.com/tag/Destination-Filters){:target="_blank"}, you can create a rule to randomly sample video heartbeat events.
105+
Using the [destination filters API](https://docs.segmentapis.com/tag/Destination-Filters){:target="_blank"}, you can create a rule to randomly sample video heartbeat events.
100106

101107
### Drop events
102108

103-
[Watch this Destination Filters walkthrough](https://www.youtube.com/watch?v=47dhAF1Hoco){:target="_blank"} to learn how to use event names to filter events sent to destinations.
109+
[Watch this destination filters walkthrough](https://www.youtube.com/watch?v=47dhAF1Hoco){:target="_blank"} to learn how to use event names to filter events sent to destinations.
104110

105111
## Important notes
106112

107113
#### Conflicting settings
108114

109-
Some destinations offer settings that also allow you to filter data. For example, the Facebook App Events destination allows you to map `Screen` events to `Track` events. Because Destination Filters are evaluated and applied _before_ the Destination settings are applied, they can conflict with your settings.
115+
Some destinations offer settings that also allow you to filter data. For example, the Facebook App Events destination allows you to map `Screen` events to `Track` events. Because destination filters are evaluated and applied _before_ the destination settings are applied, they can conflict with your settings.
110116

111-
For example, if you have a Destination Filter that filters Track events _and_ you have the **Use Screen Events as Track Events** setting enabled, `Track` events drop, but `Screen` events still process. The destination settings transform it into a `Track` event - *after* the filters.
117+
For example, if you have a destination filter that filters Track events _and_ you have the **Use Screen Events as Track Events** setting enabled, `Track` events drop, but `Screen` events still process. The destination settings transform it into a `Track` event - *after* the filters.
112118

113119
#### Error handling
114120

115-
Segment makes effort to ensure that Destination Filters can handle unexpected situations. For example, if you use the `contains()` FQL function on the `null` field, Segment returns `false` instead of returning an error. If Segment can't infer your intent, Segment logs an internal error and drops the event. Segment defaults to this behavior to prevent sensitive information, like a PII filter, from getting through.
121+
Segment makes effort to ensure that destination filters can handle unexpected situations. For example, if you use the `contains()` FQL function on the `null` field, Segment returns `false` instead of returning an error. If Segment can't infer your intent, Segment logs an internal error and drops the event. Segment defaults to this behavior to prevent sensitive information, like a PII filter, from getting through.
116122

117123
Errors aren't exposed in your Destination's Event Deliverability tab. For help diagnosing missing destination filter events, [contact Segment](https://segment.com/help/contact/){:target="_blank"}.
118124

119125
## FAQs
120126

121-
#### How do Destination Filters work with array properties?
127+
#### How do destination filters work with array properties?
122128

123-
Destination Filters can filter properties out of objects nested in an array. For example, you can filter out the `price` property of every object in an array at `properties.products`. You can also filter out an entire array from the payload. However, you can't drop nested objects in an array or filter properties out of a single object in an array.
129+
Destination filters can filter properties out of objects nested in an array. For example, you can filter out the `price` property of every object in an array at `properties.products`. You can also filter out an entire array from the payload. However, you can't drop nested objects in an array or filter properties out of a single object in an array.
124130

125131
To block a specific property from all of the objects within a properties array, set the filter using the following the format: `<propertyType>.<arrayName>.<arrayElementLabel>​`.
126132

@@ -136,7 +142,7 @@ Segment supports 10 filters per destination. If you need help consolidating filt
136142

137143
#### Can I set multiple `Only Send` destination filters?
138144

139-
Segment evaluates multiple `Only Send` filters against each other and resolves Destination Filters in order. If multiple `Only Send` filters conflict with each other, Segment won't send information downstream.
145+
Segment evaluates multiple `Only Send` filters against each other and resolves destination filters in order. If multiple `Only Send` filters conflict with each other, Segment won't send information downstream.
140146

141147
#### How many properties can I view in the filter dropdown?
142148

@@ -150,14 +156,14 @@ To filter out events from warehouses, use Selective Sync.
150156

151157
Generally, only Track calls have *name* properties, which correspond to the *event* field in an event.
152158

153-
#### How can I find out when new Destination Filters have been added or removed?
159+
#### How can I find out when new destination filters have been added or removed?
154160

155-
The Activity Feed shows the action, date, and user who performed the action when a Destination Filter is created, modified, enabled, disabled, or deleted. You can also subscribe to notifications for any of these changes in the **Activity Feed** settings page.
161+
The Activity Feed shows the action, date, and user who performed the action when a destination filter is created, modified, enabled, disabled, or deleted. You can also subscribe to notifications for any of these changes in the **Activity Feed** settings page.
156162

157163
#### Why am I getting a permissions denied error when I try to save a filter?
158164

159165
You must have write access to save and edit filters. Read permission access only allows viewing and testing access.
160166

161167
#### How can I test my filter?
162168

163-
Use the Destination Filter tester during setup to verify that you're filtering out the right events. Filtered events show up on the schema page but aren't counted in event deliverability graphs.
169+
Use the destination filter tester during setup to verify that you're filtering out the right events. Filtered events show up on the schema page but aren't counted in event deliverability graphs.

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"}

0 commit comments

Comments
 (0)