{"id":18696464,"url":"https://github.com/hermanya/react-lean-analytics","last_synced_at":"2025-08-01T07:41:48.734Z","repository":{"id":57333891,"uuid":"162863566","full_name":"Hermanya/react-lean-analytics","owner":"Hermanya","description":"📊A/B testing for React apps made super easy","archived":false,"fork":false,"pushed_at":"2024-04-23T01:42:56.000Z","size":682,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T02:46:05.614Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://leananalytics.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hermanya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-12-23T04:59:09.000Z","updated_at":"2023-03-17T14:40:39.000Z","dependencies_parsed_at":"2024-10-31T01:31:51.664Z","dependency_job_id":"f8b608b2-179c-42ba-b89d-465c6a8266d3","html_url":"https://github.com/Hermanya/react-lean-analytics","commit_stats":{"total_commits":16,"total_committers":2,"mean_commits":8.0,"dds":0.25,"last_synced_commit":"3b071a4884183667ed0ee063cffa26f4a74eeb52"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hermanya%2Freact-lean-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hermanya%2Freact-lean-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hermanya%2Freact-lean-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hermanya%2Freact-lean-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hermanya","download_url":"https://codeload.github.com/Hermanya/react-lean-analytics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248533686,"owners_count":21120140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-07T11:19:09.949Z","updated_at":"2025-04-12T07:31:15.661Z","avatar_url":"https://github.com/Hermanya.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-lean-analytics\n\n\u003e React package for lean analytics\n\n[![NPM](https://img.shields.io/npm/v/react-lean-analytics.svg)](https://www.npmjs.com/package/react-lean-analytics) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Install\n\n```bash\nnpm install --save react-lean-analytics\n```\n\nTo see analytics in the dashboard, ensure you have set your `NODE_ENV` environment variable to `production`.\n\n\u003e **The invocations and validations only count in production mode.**\n\n## Usage\n\n```tsx\nimport * as React from 'react'\n\nimport {Experiment, Variant} from 'react-lean-analytics'\n\nclass Example extends React.Component {\n  render () {\n    return (\n       \u003cExperiment\n          trackedAction=\"Purchase\"\n          id=\"....\"\n        \u003e\n          \u003cVariant description={`\"Buy now\" CTA`}\u003e\n            {callback =\u003e (\n              \u003cRetailComponent\n                callback={callback}\n                cta=\"Buy now\"\n              /\u003e\n            )}\n          \u003c/Variant\u003e\n          \u003cVariant description={`\"Buy online\" CTA`}\u003e\n            {callback =\u003e (\n              \u003cRetailComponent\n                callback={callback}\n                cta=\"Buy online\"\n              /\u003e\n            )}\n          \u003c/Variant\u003e\n        \u003c/Experiment\u003e\n\n    )\n  }\n}\n```\n\n### Using weights\n\nWeights are proportional. The default weight for each variant is 1. If you want to make a variant to be chosen more often, give it a \"heavier\" weight.\n\n```tsx\nimport * as React from 'react'\n\nimport {Experiment, Variant} from 'react-lean-analytics'\n\nclass Example extends React.Component {\n  render () {\n    return (\n       \u003cExperiment\n          trackedAction=\"Purchase\"\n          id=\"....\"\n        \u003e\n          \u003cVariant description={`\"Buy now\" CTA`} weight={0.5}\u003e\n            {callback =\u003e (\n              \u003cRetailComponent\n                callback={callback}\n                cta=\"Buy now\"\n              /\u003e\n            )}\n          \u003c/Variant\u003e\n          \u003cVariant description={`\"Buy online\" CTA`} weight={2}\u003e\n            {callback =\u003e (\n              \u003cRetailComponent\n                callback={callback}\n                cta=\"Buy online\"\n              /\u003e\n            )}\n          \u003c/Variant\u003e\n          \u003cVariant description={`\"Buy here\" CTA`}\u003e\n            {callback =\u003e (\n              \u003cRetailComponent\n                callback={callback}\n                cta=\"Buy here\"\n              /\u003e\n            )}\n          \u003c/Variant\u003e\n        \u003c/Experiment\u003e\n\n    )\n  }\n}\n```\n\n## Props\n\n### Experiment\n\n| Name                   | Type     | Default                                 | Description                                                                  |\n| ---------------------- | -------- | --------------------------------------- | ---------------------------------------------------------------------------- |\n| id                     | string   | -                                       | Experiment id.                                                               |\n| forceVariant           | number   | -                                       | Optional variant index to render. Helper for consistent experience.          |\n| onSelectedIndex        | function | -                                       | Optional callback to get variant index at render. (index: number) =\u003e void    |\n| trackedAction          | string   | -                                       | The tracked action of you experiment.                                        |\n| shouldCollectAnalytics | boolean  | `process.env.NODE_ENV === 'production'` | Optional. **The invocations and validations only count in production mode.** |\n\n### Variant\n\n| Name        | Type   | Default | Description                                                         |\n| ----------- | ------ | ------- | ------------------------------------------------------------------- |\n| description | string | -       | What makes this variant different from others.                      |\n| weight      | number | 1       | ex. 0.5, 2, 99. variants invocations can be 'controlled' by weights |\n\n## License\n\nMIT © [Hermanya](https://github.com/Hermanya)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhermanya%2Freact-lean-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhermanya%2Freact-lean-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhermanya%2Freact-lean-analytics/lists"}