Skip to main content
Both SDKs queue events and resend a failed request on their own. A failed send does not stop the page. This page lists what the SDK does without code, what a call returns to the caller, and what to do for each error.

What the SDK does on its own

Grain Tag has the same queue. It resends a failed request up to retryAttempts times and sends the queue with the Beacon API on page unload. Read Configuration options for retryAttempts and retryDelay in both SDKs. With the defaults, Analytics Web waits 1 second, then 2 seconds, then 4 seconds between four attempts in total.

What the caller sees

track in Analytics Web queues the event and returns. Do not wait for it before you show the page.
For an event that must not be lost, pass flush: true and catch the result.
Configuration reads never break the page. getConfig returns the cache or the default.
Read Remote configuration for the cache order.

Debug output

Analytics Web writes an error to the console only when debug is true. In production the SDK is silent.
Each logged error has the FormattedError shape from the package types.
Grain Tag writes its activity to the console when debug is true in GrainTagConfig.

Errors

Rules for the caller

  1. Do not wait for track before you show the page. Analytics runs in the background.
  2. Set a value in defaultConfigurations for every configuration key that the page needs.
  3. Log errors. Do not throw them at the user.
  4. For an event that must not be lost, pass flush: true and catch the promise.
  5. Catch errors inside authProvider.getToken() and return a fresh token from there.