{"_id":"@amboras-dev/profitmetrics","name":"@amboras-dev/profitmetrics","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@amboras-dev/profitmetrics","version":"1.0.0","description":"ProfitMetrics server-side hybrid integration (order sync + client bundle) for Amboras storefronts","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./slot-components":{"types":"./dist/slot-components/index.d.ts","import":"./dist/slot-components/index.mjs","require":"./dist/slot-components/index.js"},"./package.json":"./package.json"},"peerDependencies":{"react":">=18"},"devDependencies":{"@types/node":"^20.0.0","@types/react":"^18.0.0","tsup":"^8.0.0","typescript":"^5.0.0"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_id":"@amboras-dev/profitmetrics@1.0.0","_integrity":"sha512-0qd+5yteS2qWlOuLR7Na/T37ifJnSl766KtXpyqE9tLNwEcnum1GWxhf9KzwTPjQjJwJArRBfAQ2oIifCCAJgg==","_resolved":"/tmp/98515fcc928b852916f518c4c3dae9ae/amboras-dev-profitmetrics-1.0.0.tgz","_from":"file:amboras-dev-profitmetrics-1.0.0.tgz","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-0qd+5yteS2qWlOuLR7Na/T37ifJnSl766KtXpyqE9tLNwEcnum1GWxhf9KzwTPjQjJwJArRBfAQ2oIifCCAJgg==","shasum":"5ef3d96106e3e536a21b57810e0eec2479366180","tarball":"https://registry.npmjs.org/@amboras-dev/profitmetrics/-/profitmetrics-1.0.0.tgz","fileCount":15,"unpackedSize":27929,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCm7anL5OMQ5+kSnE+QYfel0wQdcgm+7Ubq3BIuA6XH9QIgVN3E2xzgCdl6O4qKUuvDi4iIisey/L1CH8L00WlXCyQ="}]},"_npmUser":{"name":"syazah","email":"thesyazah@gmail.com"},"directories":{},"maintainers":[{"name":"amboras-vaibhav","email":"vaibhav@amboras.com"},{"name":"azaanatamboras","email":"azaan@amboras.com"},{"name":"syazah","email":"thesyazah@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/profitmetrics_1.0.0_1784196441437_0.3249865010191231"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-16T10:07:21.276Z","1.0.0":"2026-07-16T10:07:21.584Z","modified":"2026-07-16T10:07:21.796Z"},"maintainers":[{"name":"amboras-vaibhav","email":"vaibhav@amboras.com"},{"name":"azaanatamboras","email":"azaan@amboras.com"},{"name":"syazah","email":"thesyazah@gmail.com"}],"description":"ProfitMetrics server-side hybrid integration (order sync + client bundle) for Amboras storefronts","readme":"# @amboras-dev/profitmetrics\n\nProfitMetrics attribution/profit-analytics for Amboras storefronts. Ships the\n\"Serverside Hybrid Universal Integration\" ProfitMetrics documents — exactly two\nparts:\n\n1. **Server-side order sync** (Repo B, `medusa-backend-orchestrator`): on every\n   `order.placed`, a durable outbox + cron drainer POSTs the order to\n   `GET https://my.profitmetrics.io/l.php?v=3uh&pid=<PUBLIC_ID>&o=<order JSON>`.\n2. **Client-side bundle** (this package): `ProfitMetricsProvider` sets\n   `window.profitMetrics = {...}` then injects\n   `https://cdn1.profitmetrics.io/{pid}/bundle.js`, which autonomously captures\n   browser tracking IDs (`etid`/`gclid`/`fbp`/`fbaid`/email) and pairs them with\n   the server-side order within ProfitMetrics' own ~5 minute buffer window.\n\n## Auth model\n\nAuth is a single **non-secret** Website Public ID (`pid`) — structurally\nidentical to Meta's `pixel_id`. There is no OAuth app-review gate, no API\nsecret, and nothing this package needs to keep off the client.\n\n## Install\n\n```bash\npnpm add @amboras-dev/profitmetrics\n```\n\nThen in the storefront's `app/_generated/plugin-registry.ts` (the orchestrator\nregenerates this on every install — manual edits will be overwritten):\n\n```ts\nimport { ProfitMetricsProvider } from '@amboras-dev/profitmetrics/slot-components'\n\nexport const PLUGIN_REGISTRY = {\n  rootProviders: [\n    { id: 'profitmetrics', Component: ProfitMetricsProvider, propsFromConfig: { pid: 'pid' } },\n  ],\n  // ...other slots empty — ProfitMetrics ships no other slot components\n}\n```\n\n## What's tracked\n\nProfitMetrics is a single-event (order) + passive-browser-tracking model —\nunlike GA4/Meta's discrete event catalog, there is no per-event component\ncatalog to wire up. `bundle.js`'s automatic order-confirmation-page email\ncapture is what pairs the browser session with the server-side order POST;\nthis package does not ship a `checkoutComplete` component.\n\n## Consent\n\n`ProfitMetricsProvider` gates script injection on the storefront's\n`amboras_consent` cookie's `analytics` field (defaults to consent-granted when\nno cookie is set). Re-checks on the `amboras-consent-changed` event so it\ninitializes the moment a merchant accepts, without a page reload. The same\nconsent state is also passed into `window.profitMetrics` as\n`cookieStatisticsConsent` / `cookieMarketingConsent`, so `bundle.js` never\ncaptures more than the merchant's banner allows even if a future version of\nthe bundle relaxes its own gating.\n\n## Programmatic API\n\n```ts\nimport { getProfitMetricsConfig } from '@amboras-dev/profitmetrics'\n\nconst config = await getProfitMetricsConfig()\n// { pid: string | null, enabled: boolean } — fails closed to `null` on error\n```\n\n## Out of scope (T1)\n\n- Product feed (XML/CSV cost/margin data) — optional for basic revenue\n  tracking, deferred to a later release.\n- Order/product-level `overrides` (shipping/payment/extra cost, gross profit,\n  title/brand/category overrides) — optional cost/catalog enrichment.\n- Any dedup token invention — `etid` is entirely owned by ProfitMetrics' own\n  `bundle.js`; this package's only job is the consent-gated script injection.\n","readmeFilename":"README.md","_rev":"1-815a531b5396e5dbc3ab20c53f52ed4b"}