Skip to content

Commit 6cb7e33

Browse files
authored
Update insert functions - include variable scoping.md
1 parent a8b5a9d commit 6cb7e33

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/connections/functions/insert-functions.md

Lines changed: 6 additions & 0 deletions
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()`, etc.
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)