npm package: @jakobinn/analyticsotter
Description: Client-side analytics tracker.
Latest version: 0.1.0

Short answer: **No.** That README describes `@jakobinn/aj-client-sdk` (single package). You’ve split into **core + adapters** and changed names/behavior. Here’s an **accurate, paste-ready README** for the new setup.

---

# AJ Analytics — Monorepo

Lightweight analytics client with batching and graceful flushing. Targets **Web**, **React Native**, and **Node** via thin adapters over a shared **Core**.

## Packages

* `@jakobinn/aj-analytics-core` — shared types, constants, client class
* `@jakobinn/aj-analytics-web` — browser adapter (adds optional campaign/referrer auto-tracking)
* `@jakobinn/aj-analytics-react-native` — RN adapter (safe RN environment detection)
* `@jakobinn/aj-analytics-node` — Node adapter (server-side usage)

> If you’re building for a specific runtime, install that adapter (it re-exports the client). If you only need types/utilities across runtimes, depend on `core`.

## Install

```bash
# pick what you use
npm i @jakobinn/aj-analytics-web
npm i @jakobinn/aj-analytics-react-native
npm i @jakobinn/aj-analytics-node

# shared
npm i @jakobinn/aj-analytics-core
```

## Quick start

### Web (browser)

```ts
import { AnalyticsJJClient } from '@jakobinn/aj-analytics-web';

const analytics = new AnalyticsJJClient({
  apiKey: 'YOUR_PUBLIC_OR_SERVER_KEY',
  // host optional in browser: defaults to current origin => POST /api/v1/track
  refer: true,   // auto-track ?trc11 and external referrers (once per session)
  debug: false,
});

analytics.track('SCREEN_VIEW', 'HOME_SCREEN_OPENED', { userId: 'user_123' });
analytics.feedback('FEATURE_RATING', 'FEATURE_MODAL', { rating: 5, text: 'Great!' });
await analytics.flush();
```

### React Native

```ts
import { AnalyticsJJClient } from '@jakobinn/aj-analytics-react-native';

const analytics = new AnalyticsJJClient({
  apiKey: 'YOUR_SERVER_API_KEY',
  host: 'https://your-analytics.example.com', // REQUIRED in RN
  runtime: 'react_native',
  debug: false,
});
```

### Node

```ts
import { AnalyticsJJClient } from '@jakobinn/aj-analytics-node';

const analytics = new AnalyticsJJClient({
  apiKey: 'YOUR_SERVER_API_KEY',
  host: 'https://your-analytics.example.com', // REQUIRED in Node
  runtime: 'server',
});
```

## Configuration

| key                | type    | default | notes                                                                                  |                 |          |       |                                  |
| ------------------ | ------- | ------- | -------------------------------------------------------------------------------------- | --------------- | -------- | ----- | -------------------------------- |
| `apiKey`           | string  | —       | Sent as `Authorization: Bearer <apiKey>` header.                                       |                 |          |       |                                  |
| `host`             | string  | `''`    | **Browser:** optional (uses current origin). **Node/RN:** **required** (absolute URL). |                 |          |       |                                  |
| `flushInterval`    | number  | `5000`  | ms after last event before auto-flush.                                                 |                 |          |       |                                  |
| `batchSize`        | number  | `20`    | flush immediately when queue ≥ size.                                                   |                 |          |       |                                  |
| `refer`            | boolean | `false` | **Web-only**. Tracks `?trc11` and external `document.referrer` once per session.       |                 |          |       |                                  |
| `runtime`          | string  | —       | e.g. \`'browser'                                                                       | 'react\_native' | 'server' | 'app' | 'client'\`. Added to each event. |
| `setUserTimestamp` | boolean | `false` | Adds ISO `user_timestamp` to each event.                                               |                 |          |       |                                  |
| `debug`            | boolean | `false` | Logs request diagnostics and warnings.                                                 |                 |          |       |                                  |

**Environment auto-detection:** if `properties.environment` isn’t set, the client uses `process.env.ENVIRONMENT` (or `NODE_ENV`) when available: `production | development | test`.

## API

```ts
new AnalyticsJJClient(config: {
  apiKey: string;
  host?: string;
  flushInterval?: number;
  batchSize?: number;
  refer?: boolean;           // web only
  runtime?: 'server' | 'app' | 'client' | 'browser' | 'react_native' | string;
  setUserTimestamp?: boolean;
  debug?: boolean;
});

track(eventType: AnalyticsEventType, eventName: string, properties?: TrackProperties): void;

feedback(
  eventName: string,
  source: string,                 // e.g. 'FEATURE_MODAL'
  data?: Partial<FeedbackDataV1>, // { rating, vote, kind, text, ... }
  properties?: TrackProperties
): void;

flush(): Promise<void>;
```

**Event types** (`AnalyticsEventType`):
`CLICKTHROUGH | INTERACTION | SUBMIT | SEARCH | SCREEN_VIEW | SYSTEM | ERROR | SESSION | AUTH | CONVERSION | FEEDBACK | CUSTOM`

**Properties highlights:** `userId`, `email`, `groupId`, `subscriptionStatus`, `isSubscribed`, `data`, `jsonData`, `environment`, `event_name_detailed`, `runtime`, `user_timestamp`, `deviceType`, `windowWidth`, `windowHeight`, `timezone`, `browser`, `os`, `osVersion`.

### Feedback events

```ts
analytics.feedback('FEATURE_RATING', 'FEATURE_MODAL', { rating: 4, text: 'Nice' });
analytics.feedback('POSTER_VOTE', 'POSTER_WIDGET', { vote: 'GOOD' });
analytics.feedback('BUG_REPORTED', 'UPLOAD_SCREEN', {
  kind: 'BUG', severity: 'HIGH', text: 'Crash on large file', contactOk: true, email: 'user@example.com'
});
```

`feedback()` attaches a structured `jsonData` payload with `schema: 'feedback.v1'`.

## Automatic campaign/referrer tracking (Web)

Enabled when `refer: true`:

* If URL contains `?trc11=XYZ` → `CLICKTHROUGH / CAMPAIGN_CLICK` with `event_name_detailed=XYZ` (once per session), then the param is removed from the URL.
* Else if external `document.referrer` is present → `CLICKTHROUGH / REFERRAL_VISIT` with `event_name_detailed=document.referrer` (once per session).

## Auth & transport

* **Auth:** `Authorization: Bearer <apiKey>`
* **Endpoint:** `POST {host or current-origin}/api/v1/track`
* **Body:** `{ "events": [...] }`
* **Browser unload:** uses timers + lifecycle hooks; consider enabling a server endpoint that accepts smaller batches for `keepalive`/`sendBeacon` reliability.

## Breaking from `@jakobinn/aj-client-sdk`

* **Package names:**

  * Web → `@jakobinn/aj-analytics-web`
  * React Native → `@jakobinn/aj-analytics-react-native`
  * Node → `@jakobinn/aj-analytics-node`
  * Shared types/constants → `@jakobinn/aj-analytics-core`
* **Imports:** replace

  ```ts
  // old
  import { AnalyticsJJClient } from '@jakobinn/aj-client-sdk';
  // new (choose your adapter)
  import { AnalyticsJJClient } from '@jakobinn/aj-analytics-web'; // or -react-native / -node
  ```
* **`host` is now required** in **Node** and **React Native** (browser can omit).
* **Event names:** warnings if not `UPPER_SNAKE_CASE` (web & RN console warns in dev).

## Troubleshooting

* **404 Scope not found:** you’re publishing under a scope you don’t own; use `@jakobinn/*` or unscoped names.
* **EUSAGE provenance provider: null:** local publish tried `--provenance`. Run with `--no-provenance` (your publish script already handles this).
* **OTP prompt:** optional unless your org/token enforces 2FA. If needed, pass `--otp 123456`.

---

If you want this split into **per-package READMEs** (web/RN/node/core) I can generate those too, but this covers the project accurately after your changes.