Skip to content

Commit 4204e8e

Browse files
authored
Merge pull request #7514 from sade-wusi/patch-9
Update insert functions - include variable scoping [DOC-1065]
2 parents 2ce6b74 + 3310fe6 commit 4204e8e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/connections/functions/insert-functions.md

+6
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ To ensure the Destination processes an event payload modified by the function, r
111111
> info ""
112112
> 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.
113113
114+
### Variable scoping
115+
116+
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.
117+
118+
The handler for insert functions is event-specific, for example, `onTrack()`, `onIdentify()`, and so on.
119+
114120
### Errors and error handling
115121

116122
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.

0 commit comments

Comments
 (0)