{"_id":"@avsbhq/snippet-types","_rev":"5-25a0af0668c817d4f0d0e89cd29dc36a","name":"@avsbhq/snippet-types","dist-tags":{"latest":"1.4.0"},"versions":{"1.0.0":{"name":"@avsbhq/snippet-types","version":"1.0.0","keywords":["avsb","ab-testing","experiments","types","typescript","snippet"],"license":"MIT","_id":"@avsbhq/snippet-types@1.0.0","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"homepage":"https://github.com/avsbhq/a-vs-b/tree/main/packages/avsb-snippet-types#readme","bugs":{"url":"https://github.com/avsbhq/a-vs-b/issues"},"dist":{"shasum":"effc80f3944727755d84196c347372f45c1dbe86","tarball":"https://registry.npmjs.org/@avsbhq/snippet-types/-/snippet-types-1.0.0.tgz","fileCount":5,"integrity":"sha512-FDR4QMQGRvY9NizbUEc2mtsd5As6e4ceiWUOfYSgON8gZnR3HdfBqXoXVXjz41sNt1BEIrQFCUg7G8VX3ApPOg==","signatures":[{"sig":"MEYCIQDIAZC7TBMJfur4smiDLIHrx7ligtbGTpDeEaAmdJNCcAIhAKBXOG+/U4fDVTu7cDXcL/lnmMM4yV3xu6PfU7y/FbzR","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27593},"types":"./avsb.d.ts","exports":{".":{"types":"./avsb.d.ts"},"./package.json":"./package.json","./variation-code":{"types":"./variation-code.d.ts"}},"gitHead":"5eed46d5944b522ba0aa34e82850c98bb91667fe","scripts":{"sync:types":"node ../../snippet/scripts/syncSnippetTypes.mjs","check:types":"node ../../snippet/scripts/syncSnippetTypes.mjs --check"},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"repository":{"url":"git+https://github.com/avsbhq/a-vs-b.git","type":"git","directory":"packages/avsb-snippet-types"},"_npmVersion":"10.9.8","description":"TypeScript declarations for window.avsb, the A vs B web-snippet API","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/snippet-types_1.0.0_1785971354709_0.9411039054953911","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@avsbhq/snippet-types","version":"1.1.0","keywords":["avsb","ab-testing","experiments","types","typescript","snippet"],"license":"MIT","_id":"@avsbhq/snippet-types@1.1.0","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"homepage":"https://github.com/avsbhq/a-vs-b/tree/main/packages/avsb-snippet-types#readme","bugs":{"url":"https://github.com/avsbhq/a-vs-b/issues"},"dist":{"shasum":"3df6d2a7ba09cc0da2e95cc580b42447588bdaed","tarball":"https://registry.npmjs.org/@avsbhq/snippet-types/-/snippet-types-1.1.0.tgz","fileCount":5,"integrity":"sha512-qOHdT2VqXsFFUMW5Hx4LnAXDlo3CzOSe1x1zMhJVCtlDsW4YHfQsmSTCL9a6V7o+hmIYK5pfCN9pKTl9Q3KBOg==","signatures":[{"sig":"MEUCICVOFoOB+6iiDbt0ZQFygPpFrI6ArFhQ4ah9P1F7EQCmAiEA/8KOa0aweWCdsbFSwkWFzfrp/ED3yCfmHX59RbNiVp4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27284},"types":"./avsb.d.ts","exports":{".":{"types":"./avsb.d.ts"},"./package.json":"./package.json","./variation-code":{"types":"./variation-code.d.ts"}},"gitHead":"d31d88fbf202f40041b4cb47f77882f454fa5ef8","scripts":{"sync:types":"node ../../snippet/scripts/syncSnippetTypes.mjs","check:types":"node ../../snippet/scripts/syncSnippetTypes.mjs --check"},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"repository":{"url":"git+https://github.com/avsbhq/a-vs-b.git","type":"git","directory":"packages/avsb-snippet-types"},"_npmVersion":"10.9.8","description":"TypeScript declarations for window.avsb, the A vs B web-snippet API","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/snippet-types_1.1.0_1786795913504_0.8455159440973643","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@avsbhq/snippet-types","version":"1.2.0","keywords":["avsb","ab-testing","experiments","types","typescript","snippet"],"license":"MIT","_id":"@avsbhq/snippet-types@1.2.0","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"homepage":"https://github.com/avsbhq/a-vs-b/tree/main/packages/avsb-snippet-types#readme","bugs":{"url":"https://github.com/avsbhq/a-vs-b/issues"},"dist":{"shasum":"b98c7d4c334faa7c16500899857509db83a1c992","tarball":"https://registry.npmjs.org/@avsbhq/snippet-types/-/snippet-types-1.2.0.tgz","fileCount":5,"integrity":"sha512-lWP9CnR4whCH/81UdZGgsjTxAnZAXEjhYh5pzSsJwsU5z60FPoo+qfW1sdi6OfzNW0F5IXBtbQCiQ2BKIp7K7g==","signatures":[{"sig":"MEYCIQDZ1rYaJuA3ZzICZkCo/Vd6m/4whS6sz0VsrF+jU73NsgIhAOfvTkFRHuyAqPLEP0779r1OrrrHDndcS6XyloGplrNN","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27778},"types":"./avsb.d.ts","exports":{".":{"types":"./avsb.d.ts"},"./package.json":"./package.json","./variation-code":{"types":"./variation-code.d.ts"}},"gitHead":"e3fd50de900ede1909b531dbaeeb8bd5b8255e63","scripts":{"sync:types":"node ../../snippet/scripts/syncSnippetTypes.mjs","check:types":"node ../../snippet/scripts/syncSnippetTypes.mjs --check"},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"repository":{"url":"git+https://github.com/avsbhq/a-vs-b.git","type":"git","directory":"packages/avsb-snippet-types"},"_npmVersion":"10.9.8","description":"TypeScript declarations for window.avsb, the A vs B web-snippet API","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/snippet-types_1.2.0_1787203619150_0.8187654079411062","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@avsbhq/snippet-types","version":"1.3.0","keywords":["avsb","ab-testing","experiments","types","typescript","snippet"],"license":"MIT","_id":"@avsbhq/snippet-types@1.3.0","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"homepage":"https://github.com/avsbhq/a-vs-b/tree/main/packages/avsb-snippet-types#readme","bugs":{"url":"https://github.com/avsbhq/a-vs-b/issues"},"dist":{"shasum":"d8bc82679163528ec794150ce65e1186cac7dee4","tarball":"https://registry.npmjs.org/@avsbhq/snippet-types/-/snippet-types-1.3.0.tgz","fileCount":5,"integrity":"sha512-t7FrGTCdf3umOMi/C7v4tFA36Jg5NFWJV65WrD9TMzCIzRBQmMx2IlYxQa7vvJeFv8dHzLWhelLFwumrIqMIIg==","signatures":[{"sig":"MEYCIQCnx+Ik+ruqroUxUr62LqinyhlVSQmEu/6L3hZ1a0/b1gIhAL14qUdKUlr9leoGgMTrkQhVZCgEhuFC/yRZOZjBD1mm","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27981},"types":"./avsb.d.ts","exports":{".":{"types":"./avsb.d.ts"},"./package.json":"./package.json","./variation-code":{"types":"./variation-code.d.ts"}},"gitHead":"93624d7c029a71ec8fff651cb6ce87a15c23126c","scripts":{"sync:types":"node ../../snippet/scripts/syncSnippetTypes.mjs","check:types":"node ../../snippet/scripts/syncSnippetTypes.mjs --check"},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"repository":{"url":"git+https://github.com/avsbhq/a-vs-b.git","type":"git","directory":"packages/avsb-snippet-types"},"_npmVersion":"10.9.8","description":"TypeScript declarations for window.avsb, the A vs B web-snippet API","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/snippet-types_1.3.0_1787296210178_0.5299857715998026","host":"s3://npm-registry-packages-npm-production"}},"1.4.0":{"name":"@avsbhq/snippet-types","version":"1.4.0","description":"TypeScript declarations for window.avsb, the A vs B web-snippet API","keywords":["avsb","ab-testing","experiments","types","typescript","snippet"],"license":"MIT","sideEffects":false,"types":"./avsb.d.ts","exports":{".":{"types":"./avsb.d.ts"},"./variation-code":{"types":"./variation-code.d.ts"},"./package.json":"./package.json"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/avsbhq/a-vs-b.git","directory":"packages/avsb-snippet-types"},"homepage":"https://github.com/avsbhq/a-vs-b/tree/main/packages/avsb-snippet-types#readme","bugs":{"url":"https://github.com/avsbhq/a-vs-b/issues"},"scripts":{"sync:types":"node ../../snippet/scripts/syncSnippetTypes.mjs","check:types":"node ../../snippet/scripts/syncSnippetTypes.mjs --check"},"_id":"@avsbhq/snippet-types@1.4.0","gitHead":"3d5d909772b046eb23d01b107ffcc610cd06e137","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-SkXQCeoauyMXktzm4+tUtX0FcJoJxVrqnTwqu8wJiXWhfvDxscw6K90qApAfTWyzpahBsvz2lRifA8z2BBtaKw==","shasum":"5dacafd2b7cbfd1dfd15223f9b252b3045c65d99","tarball":"https://registry.npmjs.org/@avsbhq/snippet-types/-/snippet-types-1.4.0.tgz","fileCount":5,"unpackedSize":28661,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGMaCkmin6Ybhclj59phDAK53JNhfQe1LYRcBwspOdWvAiBfBLcCYMf3CKjbLd7HwpDUOe+6xefqEVxk26yOU9Wuyw=="}]},"_npmUser":{"name":"main1479","email":"m.main2402@gmail.com"},"directories":{},"maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/snippet-types_1.4.0_1788535203210_0.6505728912847928"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-05T23:09:14.477Z","modified":"2026-09-04T15:20:03.498Z","1.0.0":"2026-08-05T23:09:14.861Z","1.1.0":"2026-08-15T12:11:53.655Z","1.2.0":"2026-08-20T05:26:59.297Z","1.3.0":"2026-08-21T07:10:10.291Z","1.4.0":"2026-09-04T15:20:03.342Z"},"bugs":{"url":"https://github.com/avsbhq/a-vs-b/issues"},"license":"MIT","homepage":"https://github.com/avsbhq/a-vs-b/tree/main/packages/avsb-snippet-types#readme","keywords":["avsb","ab-testing","experiments","types","typescript","snippet"],"repository":{"type":"git","url":"git+https://github.com/avsbhq/a-vs-b.git","directory":"packages/avsb-snippet-types"},"description":"TypeScript declarations for window.avsb, the A vs B web-snippet API","maintainers":[{"name":"main1479","email":"m.main2402@gmail.com"}],"readme":"# @avsbhq/snippet-types\n\nTypeScript types for `window.avsb`, the A vs B web-snippet API.\n\nTypes only. Nothing is bundled, nothing runs, and your production build is\nunchanged: the snippet itself arrives from the A vs B CDN through the install tag\nyou paste into your site.\n\n## Install\n\n```bash\nnpm install --save-dev @avsbhq/snippet-types\n```\n\n## Use it\n\nThese are global declarations, so add the package to `types` in your\n`tsconfig.json` rather than importing it:\n\n```json\n{\n  \"compilerOptions\": {\n    \"types\": [\"@avsbhq/snippet-types\"]\n  }\n}\n```\n\nIf you would rather not touch `types` (which replaces the default \"include every\ninstalled type package\" behaviour), reference it from any `.d.ts` in your project\ninstead:\n\n```ts\n// docs-example: not typechecked here, because the A vs B repository does not install @avsbhq/snippet-types as a dependency, so the type reference has nothing to resolve against\n\n/// <reference types=\"@avsbhq/snippet-types\" />\n```\n\nEither way, `avsb` and `window.avsb` are typed everywhere, and every shape has a\nname you can use:\n\n```ts\navsb.ready?.(() => {\n  avsb.track.event('signup_completed', { revenue: 49.99 });\n\n  const variation: string | null = avsb.getVariation('exp_id_from_the_dashboard');\n  if (variation) console.log('running', variation, 'on snippet', avsb.version);\n});\n\nfunction reportOrder(order: AvsbPurchaseOrder): void {\n  avsb.track.purchase(order);\n}\n\nconst unsubscribe = avsb.on?.('event', (record: AvsbIntegrationRecord) => {\n  if (record.event_type === 'exposure') myAnalytics.track('AB exposure', { ...record });\n});\nunsubscribe?.();\n```\n\n`ready`, `on` and `consent` are optional on `AvsbApi` because the preview bypass\nruntime does not define them, so reach them with `?.` as above.\n\n`getVisitorId()` is typed `string | null`, because there is no visitor id before\n`avsb.init()` in consent mode, and none at all for a visitor who denied\nanalytics:\n\n```ts\nconst visitorId: string | null = avsb.getVisitorId();\nif (visitorId) sendToYourBackend(visitorId);\n```\n\n## The names\n\n`AvsbApi` is the type of `window.avsb`. The shapes it uses are all named too:\n`AvsbTrackFunction`, `AvsbTrackEventProperties`, `AvsbPurchaseOrder`,\n`AvsbPurchaseItem`, `AvsbIntegrationRecord`, `AvsbIntegrationEventType`,\n`AvsbConsentApi`, `AvsbConsentState`, `AvsbDatasetHandle`,\n`AvsbDatasetGetResult`, `AvsbRecsClient`, `AvsbRecsRequest`, `AvsbRecsResult`,\n`AvsbRecProduct`, `AvsbCommerceApi`, `AvsbContractProduct`, `AvsbContractCart`,\n`AvsbContractCartLine`, `AvsbUtils`, `AvsbWaitUntilFn`, `AvsbWaitTarget`,\n`AvsbWaitOptions`, `AvsbGuardedThenable`, `AvsbCookieApi`, `AvsbKVStore`,\n`AvsbElementProps`.\n\nEvery one of them is global, so no import is needed, and every one is stable:\nnames here are only added, never renamed or removed.\n\n## Writing variation, trigger, or project code\n\nCode written inside the A vs B editor gets an `options` toolkit and the\n`initVariation` / `initTrigger` / `initProject` entry points. Those are authoring\nglobals, so they live behind a subpath and stay out of your site's global scope:\n\n```json\n{\n  \"compilerOptions\": {\n    \"types\": [\"@avsbhq/snippet-types\", \"@avsbhq/snippet-types/variation-code\"]\n  }\n}\n```\n\n```ts\nfunction initVariation(options: AvsbVariationOptions): void {\n  options.waitUntil<HTMLElement>('.hero h1').then((el) => {\n    options.utils.setText(el, 'A clearer headline');\n    options.track.event('hero_seen');\n  });\n}\n```\n\nThe A vs B CLI (`avsb clone`) already writes this configuration for you when it\nscaffolds a local experiment project.\n\n## Calling the API before the snippet has loaded\n\nThe loader tag is `async`, so the API can arrive after your own code runs. The\ninstall tag defines `avsb.ready`, `avsb.on`, `avsb.consent.set` and the four\n`avsb.track.*` methods from the first byte of the page, so those calls are queued\nand replayed. Everything else belongs inside `avsb.ready(...)`.\n\n## Versioning\n\nPublished in lockstep with the rest of the `@avsbhq/*` family. The declarations\nmirror the snippet runtime's own types, and a test in the A vs B repository fails\nif the two drift apart.\n\n## Links\n\n- [Snippet SDK API reference](https://avsb.cloud/docs/developer-reference/snippet-sdk-api)\n- [Tracking events](https://avsb.cloud/docs/developer-reference/tracking-events)\n- [Debug mode](https://avsb.cloud/docs/troubleshooting/debug-mode)\n","readmeFilename":"README.md"}