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.
flush: true and catch the result.
getConfig returns the cache or the default.
Debug output
Analytics Web writes an error to the console only whendebug is true. In production the
SDK is silent.
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
- Do not wait for
trackbefore you show the page. Analytics runs in the background. - Set a value in
defaultConfigurationsfor every configuration key that the page needs. - Log errors. Do not throw them at the user.
- For an event that must not be lost, pass
flush: trueand catch the promise. - Catch errors inside
authProvider.getToken()and return a fresh token from there.