Skip to content

Latest commit

 

History

History

README.md

analytics-react-native e2e-cli

E2E test CLI for the @segment/analytics-react-native SDK. Runs the real SDK pipeline on Node.js — events flow through SegmentClient → Timeline → SegmentDestination (batch chunking, upload) → QueueFlushingPlugin (queue management) → uploadEvents HTTP POST.

React Native runtime dependencies (AppState, NativeModules, sovran native bridge, AsyncStorage) are stubbed with minimal Node.js equivalents so the full event processing pipeline executes without a React Native runtime.

Setup

npm install
npm run build

The build uses esbuild to bundle the CLI + SDK source + stubs into a single dist/cli.js.

Usage

node dist/cli.js --input '{"writeKey":"...", ...}'

Input Format

{
  "writeKey": "your-write-key", // required
  "apiHost": "https://...", // optional — SDK default if omitted
  "cdnHost": "https://...", // optional — SDK default if omitted
  "sequences": [
    // required — event sequences to send
    {
      "delayMs": 0,
      "events": [{ "type": "track", "event": "Test", "userId": "user-1" }]
    }
  ],
  "config": {
    // optional
    "flushAt": 20,
    "flushInterval": 30
  }
}

Output Format

{ "success": true, "sentBatches": 0 }

On failure:

{ "success": false, "error": "description", "sentBatches": 0 }

Note: sentBatches is always 0 — the React Native SDK does not expose batch count tracking. The field is present for compatibility with the sdk-e2e-tests CLIOutput interface.