@segment/analytics-react-native
Version:
The hassle-free way to add Segment analytics to your React-Native app.
26 lines (25 loc) • 570 B
JavaScript
export const uploadEvents = async ({
writeKey,
url,
events,
retryCount = 0
}) => {
const headers = {
'Content-Type': 'application/json; charset=utf-8'
};
// Only send X-Retry-Count on retries (count > 0), omit on first attempt
if (retryCount > 0) {
headers['X-Retry-Count'] = retryCount.toString();
}
return await fetch(url, {
method: 'POST',
keepalive: true,
body: JSON.stringify({
batch: events,
sentAt: new Date().toISOString(),
writeKey: writeKey
}),
headers
});
};
//# sourceMappingURL=api.js.map