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: src/connections/functions/insert-functions.md
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -267,7 +267,7 @@ To prevent your insert function from processing data, toggle Enable Function off
267
267
268
268
## Batching the destination insert function
269
269
270
-
Batch handlers are an extension of insert functions. When you define an `onBatch` handler alongside the handler functions for single events (for example, `onTrack` or `onIdentity`), you're telling Segment that the insert function can accept and handle batches of events.
270
+
Batch handlers are an extension of insert functions. When you define an `onBatch` handler alongside the handler functions for single events (for example, `onTrack` or `onIdentity`), you're telling Segment that the insert function can accept and handle batches of events.
271
271
272
272
> info ""
273
273
> Batching is available for destination and destination insert functions only.
@@ -289,6 +289,8 @@ Segment collects the events over a short period of time and combines them into a
289
289
290
290
To create a batch handler, define an `onBatch` function within your destination insert function. You can also use the "Default Batch" template found in the Functions editor to get started quickly.
291
291
292
+
You must preserve the original order in the `onBatch` implementation, as Segment's function invoker service relies on positional consistency in the `onBatch` handler between the input and output arrays. When a function returns a transformed batch, Segment pairs each output event with its corresponding input using array index positions, not event IDs or timestamps.
293
+
292
294
```js
293
295
asyncfunctiononBatch(events, settings){
294
296
// handle the batch of events
@@ -306,6 +308,7 @@ The handler function receives an array of events. The events can be of any suppo
0 commit comments