UNPKG

@segment/analytics-react-native

Version:

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

24 lines (22 loc) 444 B
import type { SegmentEvent } from './types'; export const uploadEvents = async ({ writeKey, url, events, }: { writeKey: string; url: string; events: SegmentEvent[]; }) => { return await fetch(url, { method: 'POST', body: JSON.stringify({ batch: events, sentAt: new Date().toISOString(), writeKey: writeKey, }), headers: { 'Content-Type': 'application/json; charset=utf-8', }, }); };