From 6cb7e33b1fca2de851754e9b17e155ce878e75c1 Mon Sep 17 00:00:00 2001 From: Sharon Adewusi Date: Fri, 21 Mar 2025 14:27:08 +0000 Subject: [PATCH 1/2] Update insert functions - include variable scoping.md --- src/connections/functions/insert-functions.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/connections/functions/insert-functions.md b/src/connections/functions/insert-functions.md index e364ba6c94..553d48f471 100644 --- a/src/connections/functions/insert-functions.md +++ b/src/connections/functions/insert-functions.md @@ -111,6 +111,12 @@ To ensure the Destination processes an event payload modified by the function, r > info "" > Functions' runtime includes a `fetch()` polyfill using a `node-fetch` package. Check out the [node-fetch documentation](https://www.npmjs.com/package/node-fetch){:target="_blank"} for usage examples. +### Variable scoping + +When declaring settings variables, make sure to declare them in the function handler rather than globally in your Function. This prevents you leaking the settings values across other function instances. + +The handler for Insert functions is event-specific, for example, `onTrack()`, `onIdentify()`, etc. + ### Errors and error handling Segment considers a function's execution successful if it finishes without error. You can `throw` an error to create a failure on purpose. Use these errors to validate event data before processing it to ensure the function works as expected. From 3310fe6b898d917ab3675853861ecb4d34add454 Mon Sep 17 00:00:00 2001 From: pwseg <86626706+pwseg@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:32:27 -0500 Subject: [PATCH 2/2] style changes --- src/connections/functions/insert-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/connections/functions/insert-functions.md b/src/connections/functions/insert-functions.md index 553d48f471..162af72577 100644 --- a/src/connections/functions/insert-functions.md +++ b/src/connections/functions/insert-functions.md @@ -113,9 +113,9 @@ To ensure the Destination processes an event payload modified by the function, r ### Variable scoping -When declaring settings variables, make sure to declare them in the function handler rather than globally in your Function. This prevents you leaking the settings values across other function instances. +When declaring settings variables, make sure to declare them in the function handler rather than globally in your function. This prevents you leaking the settings values across other function instances. -The handler for Insert functions is event-specific, for example, `onTrack()`, `onIdentify()`, etc. +The handler for insert functions is event-specific, for example, `onTrack()`, `onIdentify()`, and so on. ### Errors and error handling