From 5b203d75ec32e6132be551b133d690164b824cc3 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Mon, 11 Nov 2024 15:49:20 +0000 Subject: [PATCH 01/13] add before send docs --- contents/docs/libraries/js/index.mdx | 147 +++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index d37258b173bc..0f79a41d5018 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -456,6 +456,153 @@ const handleCookieConsent = (consent) => { - If you don't want PostHog to store anything on the user's browser (e.g. if you want to rely on your own identification mechanism only or want completely anonymous users), you can set `disable_persistence: true` in PostHog's config. If you do this, remember to call [`posthog.identify`](#identifying-users) **every time** your app loads. If you don't, every page refresh is treated as a new and different user. +## Amending events before they are captured + +When initializing the SDK you can provide a `beforeSend` function. +This can be used to amend or reject events before they are sent to PostHog. + +> **Note:** amending and rejecting events should be done with care. It can cause unexpected results in parts of PostHog. + +### Not all events are processed by `beforeSend`. + +Events whic are to do with billing or where sampling/editing would break the PostHog feature are never processed by `beforeSend` + +* $web_experiment_applied +* $$client_ingestion_warning +* $feature_enrollment_update +* $feature_flag_called +* survey dismissed +* survey sent +* survey shown +* $snapshot +* $identify +* $groupidentify +* $create_alias + +### Redacting information in events + +`beforeSend` gives you one place to edit or redact information before it is sent to PostHog. + +#### Redact URLs in event properties + +``` +posthog.init('my_token', { + beforeSend: (event): event | null => { + const redactedProperties = {} + for (const [key, value] of Object.entries(event.properties || {})) { + if (key.includes(url)) { + redactedProperties[key] = value.replace(/customer_id/\d+/, 'customer_id/1234567') + } else { + redactedProperties[key] = value + } + } + event.properties = redactedProperties + + return event + } +}) +``` + +#### Redact person properties in $set or $set_once + +``` +posthog.init('my_token', { + beforeSend: (event): event | null => { + event.$set = { + ...event.$set, + homeAddress: '******' + } + event.$set_once = { + ...event.$set, + // TODO should these two account for initial / current prefixes? + homeAddress: '******' + } + + return event + } +}) +``` + +#### Redact URLs in heatmap data + +``` +posthog.init('my_token', { + beforeSend: (event): event | null => { + if (event.event !== '$heatmap') { + const redactedHeatmapData = {} + + for(const [url, data] of Object.entries(event.properties.$heatmap_data)) { + redactedHeatmapData[url.replace(/private_id\/\d+/, 'private_id/1234567')] = data + } + event.properties.$heatmap_data = redactedHeatmapData + } + + return event + } +}) +``` + +### Sampling events + +Sampling lets you choose to send only a percentage of events to PostHog. It is a good way to control your costs without having to completely turn off features of the SDK. + +Some functions of PostHog - for example much of web analytics - relies on receiving all events. Sampling $pageview or $pageleave events in particular can cause unexpected results. + +#### Sampling events using our provided customization + +If you're using NPM we offer a pre-built function to sample by event name. +You can import this or copy it from our repo. + +``` +posthog.init('my_token', { + // capture only half of dead click and web vitals events + beforeCapture: sampleByEvent(['$dead_click', '$web_vitals'], 50) +}) +``` + +#### Sampling events using a custom function + +``` +posthog.init('my_token', { + beforeSend: (event) => { + let sampleRate = 1.1 // default to always returning the event + if (event.event === '$heatmap) { + sampleRate = 0.1 + } + if (event.event === '$dead_click') { + sampleRate = 0.01 + } + return Math.random() <= sampleRate ? event : null + } +}) +``` + +#### Sampling to receive only 40% of events by person distinct id + +If you're using NPM we offer a pre-built function to sample by distinct id. +You can import this or copy it from our repo. + +A particular distinct id will always either send all events or no events. + +``` +posthog.init('my_token', { + beforeCapture: sampleByDistinctId(40) +}) +``` + +#### Sampling to receive only 25% of events by session id + +If you're using NPM we offer a pre-built function to sample by distinct id. +You can import this or copy it from our repo. + +A particular session id will always either send all events or no events. + +``` +posthog.init('my_token', { + beforeCapture: sampleBySessionId(25) +}) +``` + ## Config When calling `posthog.init`, there are various configuration options you can set in addition to `loaded` and `api_host`. From 7ecbaa6333006839f9b495ac854207c686b60ac0 Mon Sep 17 00:00:00 2001 From: PostHog Date: Mon, 11 Nov 2024 15:51:18 +0000 Subject: [PATCH 02/13] Fix typos --- contents/docs/libraries/js/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index 0f79a41d5018..aae55698a976 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -465,7 +465,7 @@ This can be used to amend or reject events before they are sent to PostHog. ### Not all events are processed by `beforeSend`. -Events whic are to do with billing or where sampling/editing would break the PostHog feature are never processed by `beforeSend` +Events which are to do with billing or where sampling/editing would break the PostHog feature are never processed by `beforeSend` * $web_experiment_applied * $$client_ingestion_warning From d0662299e4046c4b345dd7de5a110ec8f1b06a6b Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Mon, 11 Nov 2024 17:36:29 +0000 Subject: [PATCH 03/13] Update contents/docs/libraries/js/index.mdx Co-authored-by: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> --- contents/docs/libraries/js/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index aae55698a976..7c8ec459d23d 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -565,7 +565,7 @@ posthog.init('my_token', { ``` posthog.init('my_token', { beforeSend: (event) => { - let sampleRate = 1.1 // default to always returning the event + let sampleRate = 1.0 // default to always returning the event if (event.event === '$heatmap) { sampleRate = 0.1 } From bc21434ef4d168daa39cf2f1aafcf6fb0ae46ab7 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Mon, 11 Nov 2024 17:37:14 +0000 Subject: [PATCH 04/13] Fix --- contents/docs/libraries/js/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index 7c8ec459d23d..c0d7247c6990 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -572,7 +572,7 @@ posthog.init('my_token', { if (event.event === '$dead_click') { sampleRate = 0.01 } - return Math.random() <= sampleRate ? event : null + return Math.random() < sampleRate ? event : null } }) ``` From 0e4c4d88a1a7b7feca429e8ea0ea0725b82e898b Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Mon, 11 Nov 2024 21:53:29 +0000 Subject: [PATCH 05/13] config renaming --- contents/docs/libraries/js/index.mdx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index c0d7247c6990..9528ff9c312b 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -458,14 +458,14 @@ const handleCookieConsent = (consent) => { ## Amending events before they are captured -When initializing the SDK you can provide a `beforeSend` function. +When initializing the SDK you can provide a `before_send` function. This can be used to amend or reject events before they are sent to PostHog. > **Note:** amending and rejecting events should be done with care. It can cause unexpected results in parts of PostHog. -### Not all events are processed by `beforeSend`. +### Not all events are processed by `before_send`. -Events which are to do with billing or where sampling/editing would break the PostHog feature are never processed by `beforeSend` +Events which are to do with billing or where sampling/editing would break the PostHog feature are never processed by `before_send` * $web_experiment_applied * $$client_ingestion_warning @@ -481,13 +481,13 @@ Events which are to do with billing or where sampling/editing would break the Po ### Redacting information in events -`beforeSend` gives you one place to edit or redact information before it is sent to PostHog. +`before_send` gives you one place to edit or redact information before it is sent to PostHog. #### Redact URLs in event properties ``` posthog.init('my_token', { - beforeSend: (event): event | null => { + before_send: (event): event | null => { const redactedProperties = {} for (const [key, value] of Object.entries(event.properties || {})) { if (key.includes(url)) { @@ -507,7 +507,7 @@ posthog.init('my_token', { ``` posthog.init('my_token', { - beforeSend: (event): event | null => { + before_send: (event): event | null => { event.$set = { ...event.$set, homeAddress: '******' @@ -527,7 +527,7 @@ posthog.init('my_token', { ``` posthog.init('my_token', { - beforeSend: (event): event | null => { + before_send: (event): event | null => { if (event.event !== '$heatmap') { const redactedHeatmapData = {} @@ -556,7 +556,7 @@ You can import this or copy it from our repo. ``` posthog.init('my_token', { // capture only half of dead click and web vitals events - beforeCapture: sampleByEvent(['$dead_click', '$web_vitals'], 50) + before_send: sampleByEvent(['$dead_click', '$web_vitals'], 50) }) ``` @@ -564,7 +564,7 @@ posthog.init('my_token', { ``` posthog.init('my_token', { - beforeSend: (event) => { + before_send: (event) => { let sampleRate = 1.0 // default to always returning the event if (event.event === '$heatmap) { sampleRate = 0.1 @@ -586,7 +586,7 @@ A particular distinct id will always either send all events or no events. ``` posthog.init('my_token', { - beforeCapture: sampleByDistinctId(40) + before_send: sampleByDistinctId(40) }) ``` @@ -599,7 +599,7 @@ A particular session id will always either send all events or no events. ``` posthog.init('my_token', { - beforeCapture: sampleBySessionId(25) + before_send: sampleBySessionId(25) }) ``` From f4a66cd18a450777fa48ca07df99ad56ec2a44c7 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Wed, 13 Nov 2024 11:16:23 +0000 Subject: [PATCH 06/13] Update contents/docs/libraries/js/index.mdx Co-authored-by: Ian Vanagas <34755028+ivanagas@users.noreply.github.com> --- contents/docs/libraries/js/index.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index 9528ff9c312b..401ba940c5ce 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -458,8 +458,7 @@ const handleCookieConsent = (consent) => { ## Amending events before they are captured -When initializing the SDK you can provide a `before_send` function. -This can be used to amend or reject events before they are sent to PostHog. +When initializing the SDK, you can provide a `before_send` function. This can be used to amend or reject events before they are sent to PostHog. > **Note:** amending and rejecting events should be done with care. It can cause unexpected results in parts of PostHog. From e7564346d3eb933ad8a6c934985933074a243712 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Wed, 13 Nov 2024 11:18:03 +0000 Subject: [PATCH 07/13] Apply suggestions from code review Co-authored-by: Ian Vanagas <34755028+ivanagas@users.noreply.github.com> --- contents/docs/libraries/js/index.mdx | 45 +++++++++++++--------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index 401ba940c5ce..c54b45a7a167 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -460,23 +460,23 @@ const handleCookieConsent = (consent) => { When initializing the SDK, you can provide a `before_send` function. This can be used to amend or reject events before they are sent to PostHog. -> **Note:** amending and rejecting events should be done with care. It can cause unexpected results in parts of PostHog. +> **Note:** Amending and rejecting events should be done with care. It can cause unexpected results in parts of PostHog. ### Not all events are processed by `before_send`. -Events which are to do with billing or where sampling/editing would break the PostHog feature are never processed by `before_send` +Events which relate to billing or where sampling/editing would break the PostHog feature are never processed by `before_send`. Our SDK ignores attempts to try to amend these events. These include: -* $web_experiment_applied -* $$client_ingestion_warning -* $feature_enrollment_update -* $feature_flag_called -* survey dismissed -* survey sent -* survey shown -* $snapshot -* $identify -* $groupidentify -* $create_alias +* `$web_experiment_applied` +* `$$client_ingestion_warning` +* `$feature_enrollment_update` +* `$feature_flag_called` +* `survey dismissed` +* `survey sent` +* `survey shown` +* `$snapshot` +* `$identify` +* `$groupidentify` +* `$create_alias` ### Redacting information in events @@ -545,12 +545,11 @@ posthog.init('my_token', { Sampling lets you choose to send only a percentage of events to PostHog. It is a good way to control your costs without having to completely turn off features of the SDK. -Some functions of PostHog - for example much of web analytics - relies on receiving all events. Sampling $pageview or $pageleave events in particular can cause unexpected results. +Some functions of PostHog - for example much of web analytics - relies on receiving all events. Sampling `$pageview `or `$pageleave` events in particular can cause unexpected results. #### Sampling events using our provided customization -If you're using NPM we offer a pre-built function to sample by event name. -You can import this or copy it from our repo. +If you're using NPM we offer a pre-built function to sample by event name. You can import this or copy it from our repo. ``` posthog.init('my_token', { @@ -576,12 +575,11 @@ posthog.init('my_token', { }) ``` -#### Sampling to receive only 40% of events by person distinct id +#### Sampling to receive only 40% of events by person distinct ID -If you're using NPM we offer a pre-built function to sample by distinct id. -You can import this or copy it from our repo. +If you're using NPM we offer a pre-built function to sample by distinct ID. You can import this or copy it from our repo. -A particular distinct id will always either send all events or no events. +A particular distinct ID will always either send all events or no events. ``` posthog.init('my_token', { @@ -589,12 +587,11 @@ posthog.init('my_token', { }) ``` -#### Sampling to receive only 25% of events by session id +#### Sampling to receive only 25% of events by session ID -If you're using NPM we offer a pre-built function to sample by distinct id. -You can import this or copy it from our repo. +If you're using NPM we offer a pre-built function to sample by session ID. You can import this or copy it from our repo. -A particular session id will always either send all events or no events. +A particular session ID will always either send all events or no events. ``` posthog.init('my_token', { From 92ef63da7226f684fe2db87dc38e836fa15e5ee3 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Wed, 13 Nov 2024 12:39:43 +0000 Subject: [PATCH 08/13] update examples --- contents/docs/libraries/js/index.mdx | 85 +++++++++++----------------- 1 file changed, 33 insertions(+), 52 deletions(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index c54b45a7a167..935fe70cb8cc 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -458,25 +458,9 @@ const handleCookieConsent = (consent) => { ## Amending events before they are captured -When initializing the SDK, you can provide a `before_send` function. This can be used to amend or reject events before they are sent to PostHog. +When initializing the SDK, you can provide a `before_send` function. This can be used to amend or reject events before they are sent to PostHog. -> **Note:** Amending and rejecting events should be done with care. It can cause unexpected results in parts of PostHog. - -### Not all events are processed by `before_send`. - -Events which relate to billing or where sampling/editing would break the PostHog feature are never processed by `before_send`. Our SDK ignores attempts to try to amend these events. These include: - -* `$web_experiment_applied` -* `$$client_ingestion_warning` -* `$feature_enrollment_update` -* `$feature_flag_called` -* `survey dismissed` -* `survey sent` -* `survey shown` -* `$snapshot` -* `$identify` -* `$groupidentify` -* `$create_alias` +> **Note:** Amending and rejecting events is advanced functionality and should be done with care. It can cause unexpected results in parts of PostHog. ### Redacting information in events @@ -486,17 +470,34 @@ Events which relate to billing or where sampling/editing would break the PostHog ``` posthog.init('my_token', { - before_send: (event): event | null => { - const redactedProperties = {} - for (const [key, value] of Object.entries(event.properties || {})) { - if (key.includes(url)) { - redactedProperties[key] = value.replace(/customer_id/\d+/, 'customer_id/1234567') - } else { - redactedProperties[key] = value - } + before_send: (event: CaptureResult): CaptureResult | null => { + // redacting URLs will be specific to your site structure + function redactUrl(value: string): string { + return value.replace(/project\/\d+/, 'project/1234567'); } + + function redactObject(objectToRedact: Record): Record { + return Object.entries(objectToRedact).reduce((acc, [key, value]) => { + const redactedValue = key.includes("url") && typeof value === "string" ? redactUrl(value) : value; + acc[redactUrl(key)] = redactedValue; + return acc; + }, {}); + } + + const redactedProperties = redactObject(event.properties || {}); event.properties = redactedProperties - + + if (event.event === '$$heatmap') { + // $heatmap data is keyed by url + event.properties.$heatmap_data = redactObject(event.properties.$heatmap_data || {}); + } + + const redactedSet = redactObject(event.$set || {}); + event.$set = redactedSet + + const redactedSetOnce = redactObject(event.$set_once || {}); + event.$set_once = redactedSetOnce + return event } }) @@ -506,15 +507,14 @@ posthog.init('my_token', { ``` posthog.init('my_token', { - before_send: (event): event | null => { + before_send: (event: CaptureResult): CaptureResult | null => { event.$set = { ...event.$set, - homeAddress: '******' + name: 'secret name' } event.$set_once = { - ...event.$set, - // TODO should these two account for initial / current prefixes? - homeAddress: '******' + ...event.$set_once, + initial_name: 'secret name' } return event @@ -522,25 +522,6 @@ posthog.init('my_token', { }) ``` -#### Redact URLs in heatmap data - -``` -posthog.init('my_token', { - before_send: (event): event | null => { - if (event.event !== '$heatmap') { - const redactedHeatmapData = {} - - for(const [url, data] of Object.entries(event.properties.$heatmap_data)) { - redactedHeatmapData[url.replace(/private_id\/\d+/, 'private_id/1234567')] = data - } - event.properties.$heatmap_data = redactedHeatmapData - } - - return event - } -}) -``` - ### Sampling events Sampling lets you choose to send only a percentage of events to PostHog. It is a good way to control your costs without having to completely turn off features of the SDK. @@ -562,7 +543,7 @@ posthog.init('my_token', { ``` posthog.init('my_token', { - before_send: (event) => { + before_send: (event CaptureResult): CaptureResult | null => { let sampleRate = 1.0 // default to always returning the event if (event.event === '$heatmap) { sampleRate = 0.1 From 054b4315e6c5a8ba1c3dc7eed1f2a7dd928d6668 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Wed, 13 Nov 2024 12:46:42 +0000 Subject: [PATCH 09/13] add dev mode --- contents/docs/libraries/js/index.mdx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index 935fe70cb8cc..2db6ca40aa91 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -580,6 +580,19 @@ posthog.init('my_token', { }) ``` +### Or send no events while developing + +When working locally it can be useful to see what posthog would do, without actually sending the data to PostHog + +``` +posthog.init('my_token', { + before_send: (event: CaptureResult): CaptureResult | null { + console.log('posthog event: ' + event.event, event) + return null + } +}) +``` + ## Config When calling `posthog.init`, there are various configuration options you can set in addition to `loaded` and `api_host`. From 63d4cfe6c44e7af3bcbd56666fedf50206935a98 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Fri, 15 Nov 2024 10:57:40 +0000 Subject: [PATCH 10/13] Update contents/docs/libraries/js/index.mdx Co-authored-by: Ioannis J --- contents/docs/libraries/js/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index 2db6ca40aa91..ab8a7a805a24 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -543,7 +543,7 @@ posthog.init('my_token', { ``` posthog.init('my_token', { - before_send: (event CaptureResult): CaptureResult | null => { + before_send: (event: CaptureResult): CaptureResult | null => { let sampleRate = 1.0 // default to always returning the event if (event.event === '$heatmap) { sampleRate = 0.1 From 6b619cbac757bfd9c86344f7b032f8ae901c00c4 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Fri, 15 Nov 2024 11:16:49 +0000 Subject: [PATCH 11/13] Apply suggestions from code review --- contents/docs/libraries/js/index.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index ab8a7a805a24..d3d49eb03c95 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -535,7 +535,7 @@ If you're using NPM we offer a pre-built function to sample by event name. You c ``` posthog.init('my_token', { // capture only half of dead click and web vitals events - before_send: sampleByEvent(['$dead_click', '$web_vitals'], 50) + before_send: sampleByEvent(['$dead_click', '$web_vitals'], 0.5) }) ``` @@ -564,7 +564,7 @@ A particular distinct ID will always either send all events or no events. ``` posthog.init('my_token', { - before_send: sampleByDistinctId(40) + before_send: sampleByDistinctId(0.4) }) ``` @@ -576,7 +576,7 @@ A particular session ID will always either send all events or no events. ``` posthog.init('my_token', { - before_send: sampleBySessionId(25) + before_send: sampleBySessionId(0.25) }) ``` From 84491b8017f5d33d6ac7e5c110ba7f5d1aae12b3 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Fri, 15 Nov 2024 12:10:02 +0000 Subject: [PATCH 12/13] and array example --- contents/docs/libraries/js/index.mdx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index d3d49eb03c95..09d8f3485813 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -580,6 +580,21 @@ posthog.init('my_token', { }) ``` +### Providing more than one before_send function + +You can provide an array of functions to be called one after the other + + +``` +posthog.init('my_token', { + before_send: [ + sampleByDistinctId(0.5), // only half of people + sampleByEvent(['$web_vitals], 0.1), // and they capture all events except 10% of web vitals + sampleByEvent(['$$heatmap], 0.5), // and 50% of heatmaps + ] +} +``` + ### Or send no events while developing When working locally it can be useful to see what posthog would do, without actually sending the data to PostHog From 6f4a6c6b2ea75ef14d00aee2d74ebe0787850700 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Tue, 19 Nov 2024 12:09:31 +0000 Subject: [PATCH 13/13] Update contents/docs/libraries/js/index.mdx --- contents/docs/libraries/js/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/docs/libraries/js/index.mdx b/contents/docs/libraries/js/index.mdx index 09d8f3485813..bbc5cbf10bfe 100644 --- a/contents/docs/libraries/js/index.mdx +++ b/contents/docs/libraries/js/index.mdx @@ -458,7 +458,7 @@ const handleCookieConsent = (consent) => { ## Amending events before they are captured -When initializing the SDK, you can provide a `before_send` function. This can be used to amend or reject events before they are sent to PostHog. +Since version 1.187.0, when initializing the SDK, you can provide a `before_send` function. This can be used to amend or reject events before they are sent to PostHog. > **Note:** Amending and rejecting events is advanced functionality and should be done with care. It can cause unexpected results in parts of PostHog.