You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pipeline/enrichments/available-enrichments/custom-javascript-enrichment/writing/index.md
+26-1
Original file line number
Diff line number
Diff line change
@@ -243,7 +243,9 @@ You might be tempted to update derived entities in a similar way by using `event
243
243
244
244
## Discarding the event
245
245
246
-
Sometimes you don’t want the event to appear in your data warehouse or lake, e.g. because you suspect it comes from a bot and not a real user. Starting with Enrich 5.3.0, it is possible to drop an event by calling `event.drop()` in JavaScript enrichment code:
246
+
Sometimes you don’t want the event to appear in your data warehouse or lake, e.g. because you suspect it comes from a bot and not a real user.
247
+
248
+
Starting with Enrich 5.3.0, it is possible to drop an event by calling `event.drop()` in JavaScript enrichment code:
247
249
248
250
```js
249
251
constbotPattern=/.*Googlebot.*/;
@@ -257,12 +259,35 @@ function process(event) {
257
259
}
258
260
```
259
261
262
+
This mechanism can be used to drop not only good events, but also invalid events. The dropped events will not be sent to any stream or destination, thus lowering the infrastructure costs.
263
+
260
264
:::caution
261
265
262
266
There is no way to recover dropped events therefore use it with caution.
263
267
264
268
:::
265
269
270
+
Another way to discard events is throwing an exception in your JavaScript code, which will send the event to [failed events](/docs/fundamentals/failed-events/index.md):
271
+
272
+
```js
273
+
constbotPattern=/.*Googlebot.*/;
274
+
275
+
functionprocess(event) {
276
+
constuseragent=event.getUseragent();
277
+
278
+
if (useragent !==null&&botPattern.test(useragent)) {
279
+
throw"Filtered event produced by Googlebot";
280
+
}
281
+
}
282
+
```
283
+
284
+
:::caution
285
+
286
+
This will create an “enrichment failure” failed event, which may be tricky to distinguish from genuine failures in your enrichment code, e.g. due to a mistake.
287
+
288
+
:::
289
+
290
+
266
291
## Accessing Java methods
267
292
268
293
Because the JavaScript enrichment runs inside the Enrich application, it has access to the Java standard library, as well as _some_ Java libraries (the ones used by Enrich). You can call Java methods via their fully qualified path, for example:
Copy file name to clipboardExpand all lines: docs/pipeline/enrichments/available-enrichments/pii-pseudonymization-enrichment/index.md
+6-2
Original file line number
Diff line number
Diff line change
@@ -42,8 +42,12 @@ It's **important** to keep these things in mind when using this enrichment:
42
42
- Hashing a field can change its format (e.g. email) and its length, thus making a whole valid original event invalid if its schema is not compatible with the hashing.
43
43
- When updating the `salt` after it has already been used, same original values hashed with previous and new salt will have different hashes, thus making a join impossible and/or creating duplicate values.
44
44
45
-
### Anonymous mode
46
-
Enrich 5.3.0 introduced anonymous mode. When [anonymousOnly](https://github.com/snowplow/iglu-central/blob/master/schemas/com.snowplowanalytics.snowplow.enrichments/pii_enrichment_config/jsonschema/2-0-1#L155) is set to true, PII fields are masked only if the `SP-Anonymous` header is present.
45
+
### `anonymousOnly` mode
46
+
Enrich 5.3.0 introduced the `anonymousOnly` mode. When [anonymousOnly](https://github.com/snowplow/iglu-central/blob/master/schemas/com.snowplowanalytics.snowplow.enrichments/pii_enrichment_config/jsonschema/2-0-1#L155) is set to true, PII fields are masked only in events tracked in anonymous mode (i.e. the `SP-Anonymous` header is present).
47
+
48
+
This is useful for compliance with regulation such as GDPR, where you would start with [anonymous tracking](/docs/sources/trackers/javascript-trackers/web-tracker/anonymous-tracking/index.md) by default (all identifiers are masked) and switch to non-anonymous tracking when the user consents to data collection (all identifiers are kept).
49
+
50
+
By default, `anonymousOnly` is `false`, i.e. PII fields are always masked.
0 commit comments