Skip to content

Commit e7c26c3

Browse files
spencerattickmarkzegarelli
andauthored
batch example (#4424)
* batch example We currently don't have an example in our docs around what a batch request should look like if someone is using the Functions tester to see how their code behaves. This update adds such an example for clarity. * Update src/connections/functions/destination-functions.md --------- Co-authored-by: markzegarelli <[email protected]>
1 parent db8002d commit e7c26c3

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/connections/functions/destination-functions.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,39 @@ async function onBatch(events, settings){
214214
> info ""
215215
> The `onBatch` handler is an optional extension. Destination functions must still contain single event handlers as a fallback, in cases where Segment does not receive enough events to execute the batch.
216216
217-
The handler function receives an array of events. The events can be of any supported type, and a single batch may contain more than one event type. Handler functions also receive function settings.
217+
The handler function receives an array of events. The events can be of any supported type and a single batch may contain more than one event type. Handler functions can also receive function settings. Here is an example of what a batch can look like:
218+
219+
```json
220+
[
221+
{
222+
"type": "identify",
223+
"userId": "019mr8mf4r",
224+
"traits": {
225+
"email": "[email protected]",
226+
"name": "Jake Peterson",
227+
"age": 26
228+
}
229+
},
230+
{
231+
"type": "track",
232+
"userId": "019mr8mf4r",
233+
"event": "Song Played",
234+
"properties": {
235+
"name": "Fallin for You",
236+
"artist": "Dierks Bentley"
237+
}
238+
},
239+
{
240+
"type": "track",
241+
"userId": "971mj8mk7p",
242+
"event": "Song Played",
243+
"properties": {
244+
"name": "Get Right",
245+
"artist": "Jennifer Lopez"
246+
}
247+
}
248+
]
249+
```
218250

219251
For example, you could send the array of events to an external services batch endpoint:
220252

0 commit comments

Comments
 (0)