UNPKG

@segment/analytics-react-native

Version:

The hassle-free way to add Segment analytics to your React-Native app.

33 lines (31 loc) 711 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uploadEvents = void 0; 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 }); }; exports.uploadEvents = uploadEvents; //# sourceMappingURL=api.js.map