Skip to content

Commit c9f7fad

Browse files
committed
deleted section on implicit and explicit batching
1 parent 8877322 commit c9f7fad

File tree

1 file changed

+0
-50
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+0
-50
lines changed

src/connections/sources/catalog/libraries/website/javascript/index.md

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -691,56 +691,6 @@ Your total batched events can’t exceed the maximum payload size of 500 KB, wit
691691
#### Timeout
692692
`timeout` is the number of milliseconds that forces all events queued for batching to be sent, regardless of the batch size, once it’s reached. For example, `timeout: 5000` sends every event in the batch to Segment once 5 seconds passes.
693693

694-
### Implicit and explicit batching
695-
All batching is done implicitly as it doesn’t require you to change your Analytics.js implementation. Implicit batching is a great option is you want an out of the box approach to batching as you only need to add the required parameters to your load method (mentioned above in Setup) and Analytics.js will handle the rest.
696-
697-
You can fire your analytics events as usual and assume they’ll be delivered the same as individual events would. This code block shows implicit batching:
698-
699-
```js
700-
701-
// Implicit Batching
702-
703-
analytics.page('Checkout')
704-
analytics.identify('User ID')
705-
analytics.track('Checkout seen')
706-
707-
// some time later
708-
analytics.track('Product Added')
709-
analytics.track('Checkout clicked')
710-
711-
// These 5 events will potentially be delivered in the same batch, depending on how far apart they're executed (based on batching config)
712-
```
713-
714-
If you want to guarantee which specific events are delivered together in the batch, you can set up explicit batching by using `await Promise` and changing the implicit code example above to this:
715-
716-
```js
717-
const checkout = analytics.page('Checkout')
718-
const identify = analytics.identify('User ID')
719-
const seen = analytics.track('Product Added')
720-
721-
// some time later
722-
const added = analytics.track('Product Added')
723-
const clicked = analytics.track('Checkout clicked')
724-
725-
// Collecting all promises and awaiting on them will create an artificial batch
726-
// This line will block execution until all events in the artificial batch have been delivered
727-
await Promise.all([checkout, identify, seen, added, clicked])
728-
```
729-
In the case where all events are delivered without any user behavior, you can guarantee delivery with explicit batching as shown in this example code:
730-
731-
```js
732-
// Will wait for all events to be delivered before moving on.
733-
await Promise.all([
734-
analytics.page('Checkout'),
735-
analytics.identify('User ID'),
736-
analytics.track('Product Added')
737-
])
738-
739-
// some time later
740-
analytics.track('Product Added')
741-
analytics.track('Checkout clicked')
742-
```
743-
744694
### Batching FAQs
745695
#### Will Analytics.js deliver events that are in the queue when a user closes the browser?
746696
Analytics.js does its best to deliver the queued events before the browser closes, but the delivery isn’t guaranteed.

0 commit comments

Comments
 (0)