{"_id":"11metrics-pixel-react-native","_rev":"2-b464db48c90deb732c93404c3000591c","name":"11metrics-pixel-react-native","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"11metrics-pixel-react-native","version":"0.1.0","keywords":["11metrics","analytics","tracking","pixel","react-native","mobile","expo"],"author":{"name":"11metrics Ltd."},"license":"MIT","_id":"11metrics-pixel-react-native@0.1.0","maintainers":[{"name":"11metrics","email":"marco.stranieri@11metrics.ai"}],"homepage":"https://app.11metrics.ai/extensions","dist":{"shasum":"e65bd7340432dff7a44ab992f02919d2b796a87f","tarball":"https://registry.npmjs.org/11metrics-pixel-react-native/-/11metrics-pixel-react-native-0.1.0.tgz","fileCount":15,"integrity":"sha512-2Pu9SfJDpxxi0SzxoTAKHBKVu2e94NpVpc8YgbbaC2VIhH67zvhtrN24lpyCGwdBwhxSWzabjRHh+tIGNo1CDw==","signatures":[{"sig":"MEQCIEamAA30xvorFP43uah0bipk2GhccoIlYcsXUrA5KErUAiBUC+pX14zTS5x0QNozuxpHFe2U2Q0uBmfIXIxsEMOMJw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33593},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"07e2aa3f94bc6f673be14bfa0b5e7047d42a0496","private":false,"scripts":{"test":"npm run build && node smoke-test.mjs","build":"tsc -p tsconfig.json","clean":"rm -rf dist"},"_npmUser":{"name":"11metrics","email":"marco.stranieri@11metrics.ai"},"_npmVersion":"11.6.2","description":"Official 11metrics tracking SDK for React Native apps. Zero native dependencies — pure-JS SHA-256 hashing, a pluggable storage adapter for persistent anonymous IDs, and an optional React Navigation integration for automatic screen-view tracking.","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.0","@types/node":"^22.0.0"},"peerDependencies":{"react":">=17.0.0","react-native":">=0.65.0"},"_npmOperationalInternal":{"tmp":"tmp/11metrics-pixel-react-native_0.1.0_1783059959652_0.49534400467696327","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"11metrics-pixel-react-native","version":"0.2.0","description":"Official 11metrics tracking SDK for React Native apps. Zero native dependencies — pure-JS SHA-256 hashing, a pluggable storage adapter for persistent anonymous IDs, and an optional React Navigation integration for automatic screen-view tracking.","license":"MIT","author":{"name":"11metrics Ltd."},"homepage":"https://app.11metrics.ai/extensions","keywords":["11metrics","analytics","tracking","pixel","react-native","mobile","expo"],"private":false,"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"sideEffects":false,"scripts":{"build":"tsc -p tsconfig.json","clean":"rm -rf dist","test":"npm run build && node smoke-test.mjs"},"peerDependencies":{"react":">=17.0.0","react-native":">=0.65.0"},"devDependencies":{"typescript":"^5.6.0","@types/node":"^22.0.0"},"gitHead":"8ac06cb490a694fb035b4fb45693c4934be1430c","_id":"11metrics-pixel-react-native@0.2.0","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-RuMA3EwJBlnrdmqKbcMGmOw9x0gkqoN/BWqIZPnk6FXINQsXpunIPH2K6gUC4iDEoMlbIQaUTU8DapR7cx8QvA==","shasum":"92a8066f9ee95093fbd8b1238ea15de6a5c2d6f8","tarball":"https://registry.npmjs.org/11metrics-pixel-react-native/-/11metrics-pixel-react-native-0.2.0.tgz","fileCount":15,"unpackedSize":48140,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIC70Vks9vTCPbPv/KKQT3iDTPe217AfbMnpzbzIyDsh/AiEAmcEPjgscRnNHr0LYIZ53Q7arfcg3qzMb7xpJoaDA0as="}]},"_npmUser":{"name":"11metrics","email":"marco.stranieri@11metrics.ai"},"directories":{},"maintainers":[{"name":"11metrics","email":"marco.stranieri@11metrics.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/11metrics-pixel-react-native_0.2.0_1785577330398_0.7193333593937445"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-03T06:25:59.557Z","modified":"2026-08-01T09:42:10.670Z","0.1.0":"2026-07-03T06:25:59.793Z","0.2.0":"2026-08-01T09:42:10.548Z"},"author":{"name":"11metrics Ltd."},"license":"MIT","homepage":"https://app.11metrics.ai/extensions","keywords":["11metrics","analytics","tracking","pixel","react-native","mobile","expo"],"description":"Official 11metrics tracking SDK for React Native apps. Zero native dependencies — pure-JS SHA-256 hashing, a pluggable storage adapter for persistent anonymous IDs, and an optional React Navigation integration for automatic screen-view tracking.","maintainers":[{"name":"11metrics","email":"marco.stranieri@11metrics.ai"}],"readme":"# 11metrics-pixel-react-native\n\nOfficial 11metrics tracking SDK for React Native apps. Talks to the same\n`POST /api/pixel` endpoint the web `pixel.js` SDK uses — no backend changes\nrequired to start receiving mobile events.\n\nZero native dependencies: hashing is pure-JS SHA-256 (no `crypto.subtle`,\nno native crypto module to link), and identity persistence is a pluggable\nstorage adapter rather than a hard dependency on any specific storage\nlibrary. Works in Expo Go and bare React Native alike.\n\n## Install\n\n```\nnpm install 11metrics-pixel-react-native\n```\n\n## Usage\n\n```ts\n// App.tsx\nimport AsyncStorage from '@react-native-async-storage/async-storage'; // recommended, not required\nimport { init, screenView, track, identify } from '11metrics-pixel-react-native';\n\ninit({\n  pixelId: 'YOUR_PIXEL_ID', // Settings → Pixel Setup in the 11metrics app\n  pixelUrl: 'https://app.11metrics.ai', // optional, this is the default\n  storage: AsyncStorage, // optional — omit to fall back to in-memory (resets each app restart)\n});\n\n// Manual screen tracking.\nscreenView('ProductDetail', { product_id: 'abc123' });\n\n// Custom event.\ntrack('button_press', { button: 'checkout' });\n\n// After login. email/phone are hashed on-device before anything is sent.\nidentify({ email: 'user@example.com', first_name: 'Marco' });\n```\n\n### Automatic screen tracking with React Navigation\n\n```tsx\nimport { NavigationContainer } from '@react-navigation/native';\nimport { trackNavigationStateChange } from '11metrics-pixel-react-native';\n\nexport default function App() {\n  return (\n    <NavigationContainer onStateChange={trackNavigationStateChange}>\n      {/* ... */}\n    </NavigationContainer>\n  );\n}\n```\n\nNot using React Navigation? Call `screenView(name)` yourself wherever your\nnavigation library exposes a focus/route-change event.\n\n## Why no native dependencies\n\n- **Hashing**: `crypto.subtle` isn't reliably available across React\n  Native's JS engines (Hermes/JSC) and versions. Rather than require a\n  native crypto module (native linking, `pod install`, Expo config plugins —\n  friction most SDKs don't need to impose), this package ships its own\n  pure-JS SHA-256 implementation, verified against known FIPS test vectors\n  (see `smoke-test.mjs`).\n- **Storage**: there's no browser-`localStorage` equivalent built into\n  React Native's JS runtime — every persistence option (AsyncStorage, MMKV,\n  SecureStore) is a native module. Rather than pick one and force it on\n  every consumer, `init({ storage })` accepts anything with a\n  `getItem`/`setItem` shape. `@react-native-async-storage/async-storage`\n  is the recommended default (it's already in most React Native apps), but\n  MMKV or your own adapter both work identically.\n- **React Navigation**: `trackNavigationStateChange` accepts `state:\n  unknown` rather than importing `@react-navigation/native`'s types, so\n  this package has zero dependency on it — apps using a different\n  navigation library (or none) simply don't call that function.\n\n## API\n\n- `init(config: { pixelId, pixelUrl?, storage?, gpc?, priorBlocking?, consent? })`\n- `screenView(screenName, meta?)` — sent as `event: \"pageview\"`, same event\n  type web uses, so mobile screen views land in the same reports as web\n  pageviews with no extra setup.\n- `track(name, meta?)` — custom event.\n- `identify(data)` — `{ email?, phone?, first_name?, last_name? }`.\n- `setConsent(granted: boolean)` — record the visitor's consent decision from\n  your app's consent screen (flushes buffered events + starts persisting the\n  device id when granted; stops sending + drops the buffer when withdrawn).\n- `getAnonymousId()` — the persisted per-device anonymous id.\n- `trackNavigationStateChange(state)` — wire into React Navigation's\n  `onStateChange` for automatic screen tracking.\n\n## Privacy: GPC & prior-blocking (parity with the web pixel)\n\nRN has no cookies or `navigator.globalPrivacyControl`, so the equivalents are\nconfig + storage:\n\n- **GPC** — `init({ gpc: true })` when your app should honour a universal\n  opt-out (e.g. an OS/app \"opt out of tracking\" toggle). Analytics are\n  suppressed, the device id is never persisted, and one `gpc_optout` beacon is\n  sent so the server records the withdrawal in the consent ledger.\n- **Prior-blocking** — `init({ priorBlocking: 'geo' | 'strict' })`. Events are\n  **buffered** until a consent decision resolves, then replayed exactly once\n  (the web `q()` defer/replay). `geo` asks `/api/pixel/consent-context` and\n  holds only for visitors who require prior consent; `strict` always holds\n  until `setConsent(true)`. The persistent device id is written to storage\n  **only** once analytics is allowed.\n- **Default** (`priorBlocking: 'off'`, no `gpc`) — unchanged: events send\n  immediately. Drive consent yourself with `setConsent()` /\n  `init({ consent: boolean })`.\n\n## Local development\n\n```\nnpm install\nnpm run build\nnpm test    # runs the build, then sha256 + payload smoke tests\n```\n\n## Publishing\n\n```\nnpm run build\nnpm test\nnpm login          # once, with your npm account\nnpm publish         # from this directory\n```\n\nBump `version` in `package.json` first if this isn't the first release.\n","readmeFilename":"README.md"}