{"id":15177161,"url":"https://github.com/dogchef-be/nuxt-ab-segment","last_synced_at":"2026-03-03T04:31:16.071Z","repository":{"id":38451999,"uuid":"489360346","full_name":"dogchef-be/nuxt-ab-segment","owner":"dogchef-be","description":"📊 NuxtJS module for A/B testing with Segment Analytics","archived":false,"fork":false,"pushed_at":"2026-01-13T10:51:29.000Z","size":3751,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-13T13:43:27.700Z","etag":null,"topics":["nuxt","nuxt-module","nuxt-typescript","nuxtjs","nuxtjs-ts","segment-analytics","typescript-support"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dogchef-be.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-05-06T13:13:48.000Z","updated_at":"2026-01-13T10:51:33.000Z","dependencies_parsed_at":"2023-12-19T01:01:35.348Z","dependency_job_id":"ddd003cc-de47-4624-a5a2-4a47fb5968e9","html_url":"https://github.com/dogchef-be/nuxt-ab-segment","commit_stats":{"total_commits":19,"total_committers":4,"mean_commits":4.75,"dds":0.4736842105263158,"last_synced_commit":"a192ac0bafcb86a30252ec43f3dbc074206bb250"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dogchef-be/nuxt-ab-segment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogchef-be%2Fnuxt-ab-segment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogchef-be%2Fnuxt-ab-segment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogchef-be%2Fnuxt-ab-segment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogchef-be%2Fnuxt-ab-segment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dogchef-be","download_url":"https://codeload.github.com/dogchef-be/nuxt-ab-segment/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogchef-be%2Fnuxt-ab-segment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30031992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T03:27:35.548Z","status":"ssl_error","status_checked_at":"2026-03-03T03:27:09.213Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nuxt","nuxt-module","nuxt-typescript","nuxtjs","nuxtjs-ts","segment-analytics","typescript-support"],"created_at":"2024-09-27T14:03:29.351Z","updated_at":"2026-03-03T04:31:16.066Z","avatar_url":"https://github.com/dogchef-be.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  nuxt-ab-segment\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  NuxtJS module for A/B testing with Segment Analytics\u003cbr /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/nuxt-ab-segment\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/nuxt-ab-segment?style=flat-square\"\u003e\u003c/a\u003e \u003ca href=\"https://www.npmjs.com/package/nuxt-ab-segment\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/nuxt-ab-segment?style=flat-square\"\u003e\u003c/a\u003e \u003ca href=\"#\"\u003e\u003cimg src=\"https://img.shields.io/github/license/dogchef-be/nuxt-ab-segment?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\n## Table of contents\n\n- [Main features](#main-features)\n- [Dependencies](#dependencies)\n- [Setup](#setup)\n- [Options](#options)\n- [Usage](#usage)\n- [Credits](#credits)\n- [License](#license)\n\n## Main features\n\n- Run multiple experiments simultaneously\n- TypeScript support\n- Cookies to persist variants across users\n- Force a specific variant via url or param. E.g. `url?abs_experiment-x=1` or `this.$abtest('experiment-x', true, true, 1);`\n- Prevent automatic reporting of a/b test analytics. E.g. `this.$abtest('experiment-x', true, false);`\n- Avoid activating the a/b test anywhere. E.g. `this.$abtest('experiment-x', false);`\n- Disable all a/b tests by cookie (`abs_disabled=1`), which is useful for E2E tests in CI/CD pipelines\n\n## Dependencies\n\n- [nuxt-segment](https://github.com/dansmaculotte/nuxt-segment)\n- Or any other alternative to inject [Segment Analytics](https://segment.com)\n\n## Setup\n\n1. Add `nuxt-ab-segment` dependency to your project:\n\n```bash\nnpm install nuxt-ab-segment\n```\n\n2. Add `nuxt-ab-segment` module and configuration to `nuxt.config.js`:\n\n```js\nexport default {\n  // ...other config options\n  modules: [\"nuxt-ab-segment\"];\n  abSegment: {\n    event: \"AB Test\", // optional\n    experiments: '~/experiments.js', // optional\n    debug: process.env.NODE_ENV !== 'production', // optional\n  }\n}\n```\n\n3. Create the `experiments.js` in project's root with an array of your experiments. An example:\n\n```js\n/**\n * {\n *  name: string; A name to identify the experiment on this.$abtest('NAME_HERE')\n *  maxAgeDays: number; Number of days to persist the cookie of user's active variant\n *  variants: number[] | Experiment[]; An array of variant weights or an array of nested experiments.\n * }\n */\nmodule.exports = [\n  {\n    name: \"experiment-x\",\n    maxAgeDays: 15,\n    variants: [50, 50],\n  },\n  {\n    name: \"experiment-y\", // Weights will be automatically calculated [50, 50]\n    maxAgeDays: 15,\n    variants: [\n      {\n        name: \"parent-1\", // Weights will be automatically calculated [34, 33, 33]\n        maxAgeDays: 15,\n        variants: [\n          {\n            name: \"children-1\",\n            maxAgeDays: 15,\n            variants: [50, 50],\n          },\n          {\n            name: \"children-2\",\n            maxAgeDays: 15,\n            variants: [50, 50],\n          },\n          {\n            name: \"children-3\",\n            maxAgeDays: 15,\n            variants: [50, 50],\n          },\n        ],\n      },\n      {\n        name: \"parent-2\",\n        maxAgeDays: 15,\n        variants: [50, 50],\n      }, \n    ],\n  },\n];\n```\n\n4. (Optional) TypeScript support. Add `nuxt-ab-segment` to the `types` section of `tsconfig.json`:\n\n```json\n{\n  \"compilerOptions\": {\n    \"types\": [\"nuxt-ab-segment\"]\n  }\n}\n```\n\n## Options\n\n### `event`\n\n- Type: `String`\n- Default: `AB Test`\n\nEvent name reported to Segment.\n\n### `experiments`\n\n- Type: `String`\n- Default: `~/experiments.js`\n\nFile path for your experiments definition.\n\n### `debug`\n\n- Type: `Boolean`\n- Default:\n  - Development: `true`\n  - Production: `false`\n\nEnables or disables printing Segment reports to the console.\n\n## Usage\n\nIt can be used inside components like:\n\n```js\n{\n  data: () =\u003e ({\n    payBtnLabel: null as string | null,\n  }),\n  mounted() {\n    // Scenario: Determine an experiment variant and display a label accordingly.\n    const expA = this.$abtest('experiment-a');\n    if (expA === 0) {\n      this.payBtnLabel = 'Place order';\n    } else {\n      this.payBtnLabel = 'Pay now!';\n    }\n\n    // Scenario: Force a specific variant programmatically.\n    const expB = this.$abtest('experiment-b', { forceVariant: 1 });\n    console.log('Variant for expB is always 1');\n\n    // Scenario: Assign a variant and report it for analytics.\n    const expC = this.$abtest('experiment-c', { reportVariant: true });\n    console.log(`Variant for expC is ${expC}, and it was reported.`);\n\n    // Scenario: Avoid activating an A/B test at a specific step.\n    // (No variant assignment or reporting is done.)\n    const expD = this.$abtest('experiment-d', { assignVariant: false });\n    console.log('Variant for expD is always 0');\n\n    // Scenario: Report analytics and append specific properties.\n    // (experiment, but additional data is sent.)\n    const expE = this.$abtest('experiment-e', { reportVariant: true, segment: { properties: { device: 'mobile' } } });\n    console.log(`Variant for expE is ${expE}, and will include the properties: { experiment: 'experiment-e', variant: ${expE}, device: 'mobile' }`);\n\n  }\n}\n```\n\nAn example of event properties reported to Segment:\n\n```js\n{\n  experiment: 'experiment-x',\n  variant: 1\n}\n```\n\n## Credits\n\n- [Brandon Mills](https://github.com/btmills) for `weightedRandom()`\n\n## License\n\nSee the LICENSE file for license rights and limitations (MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogchef-be%2Fnuxt-ab-segment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdogchef-be%2Fnuxt-ab-segment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogchef-be%2Fnuxt-ab-segment/lists"}