{"id":49453607,"url":"https://github.com/faouzioudouh/react-tracker","last_synced_at":"2026-06-02T05:00:39.121Z","repository":{"id":57346610,"uuid":"115796343","full_name":"faouzioudouh/react-tracker","owner":"faouzioudouh","description":"React specific tracking library, Track user interaction with minimal API!","archived":false,"fork":false,"pushed_at":"2018-02-04T13:51:54.000Z","size":4569,"stargazers_count":231,"open_issues_count":7,"forks_count":20,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-09-18T05:59:30.484Z","etag":null,"topics":["adobe-analytics","agnostic","analytic","analytics","analytics-tracking","facebook-pixel","google-analytics","padl","react","redux","redux-middleware","tracker","tracking"],"latest_commit_sha":null,"homepage":"https://faouzioudouh.github.io/react-tracker/","language":"JavaScript","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/faouzioudouh.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}},"created_at":"2017-12-30T12:46:09.000Z","updated_at":"2025-06-09T14:28:08.000Z","dependencies_parsed_at":"2022-09-11T16:33:01.178Z","dependency_job_id":null,"html_url":"https://github.com/faouzioudouh/react-tracker","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/faouzioudouh/react-tracker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faouzioudouh%2Freact-tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faouzioudouh%2Freact-tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faouzioudouh%2Freact-tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faouzioudouh%2Freact-tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faouzioudouh","download_url":"https://codeload.github.com/faouzioudouh/react-tracker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faouzioudouh%2Freact-tracker/sbom","scorecard":{"id":392657,"data":{"date":"2025-08-11","repo":{"name":"github.com/faouzioudouh/react-tracker","commit":"f1a592f519f220a77d88ff33fe023482d3d8a3e1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T18:11:57.668Z","repository_id":57346610,"created_at":"2025-08-18T18:11:57.668Z","updated_at":"2025-08-18T18:11:57.668Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33806987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["adobe-analytics","agnostic","analytic","analytics","analytics-tracking","facebook-pixel","google-analytics","padl","react","redux","redux-middleware","tracker","tracking"],"created_at":"2026-04-30T04:01:03.701Z","updated_at":"2026-06-02T05:00:39.115Z","avatar_url":"https://github.com/faouzioudouh.png","language":"JavaScript","funding_links":[],"categories":["📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"# ![React tracker Logo](http://pichoster.net/images/2018/01/07/32e65824cf5bdee238722112b9e95a10.png)\n\n# react-tracker [![build status](https://img.shields.io/travis/reactjs/react-redux/master.svg?style=flat-square)](https://travis-ci.org/faouzioudouh/react-tracker) [![npm version](https://badge.fury.io/js/react-tracker.svg)](https://badge.fury.io/js/react-tracker) [![codecov](https://codecov.io/gh/faouzioudouh/react-tracker/branch/master/graph/badge.svg)](https://codecov.io/gh/faouzioudouh/react-tracker)\n\n_Track user interaction with minimal API_\n\n## What?\n- React specific tracking library, usable as a higher-order component\n- Flexible-scalable solution for tracking\n- Can be pluged with any Analytics platform :\n  - Google Tag Manager\n  - Facebook Pixel\n  - You can mainly do anything in the event listeners callback..\n- Easy to use (Redux-like)\n\n## Installation\n```\n$ npm install --save react-tracker\n```\nThis assumes you are using [npm](https://www.npmjs.com/) as your package manager.\n\n## Demo\nTo see the react-tracker in action please visit the link below.\n\n[Link](https://faouzioudouh.github.io/react-tracker/)\n\n## Documentation\n\n* [Initialize the Tracker](#initialize-the-tracker)\n* [Create event listener](#create-event-istener)\n  * [Listen on one event](#listen-on-one-event)\n  * [Listen on all events](#listen-on-all-events)\n* [Create event creator](#create-event-creator)\n* [Track Events](#track-events)\n* [Usage in React](#usage-with-react)\n  * [Provide Tracker to the root component](#provide-tracker-to-the-root-component)\n  * [Create Add to Cart Event Listener](#create-add-to-cart-event-listener)\n  * [Add to Cart Event creator](#add-to-cart-event-creator)\n  * [Create Product Component](#create-product-component)\n  * [Create Product List Component](#create-products-list-component)\n  * [Create mapTrackingToProps function and pass it to withTracking HOC](#create-mapTrackingToProps-function-and-pass-it-to-withTracking-hoc)\n* [Create Redux middleware to track redux actions](#create-redux-middleware-for-redux-based-apps)\n\n## Initialize the Tracker\nCreate a Tracker holding the tracked events History of your app.\n\nTracker API is `{ on, trackEvent, getHistory }`.\n\n- You can pass your already defined event listeners to the constructor like so:\n\n```js\nconst tracker = new Tracker([trackAddToCart])\n```\n\n- Or you can listen-on-the-go using `on()`:\n\n```js\nconst tracker = new Tracker();\n\n// Listen on `PRODUCT_CLICK`event.\ntracker.on('PRODUCT_CLICK', (event, eventsHistory) =\u003e\n  console.log(event)\n);\n\n// Listen on all events\ntracker.on('*', (event, eventsHistory) =\u003e\n  console.log(event)\n);\n```\n\n## Create Event listener\nEvent listner is a pure function with `(event, eventsHistory) =\u003e tracking goes here`.\n\nIt describes what to do with the just-fired event.\n\nWhy providing the eventsHistory as second parameter ?\n\n=\u003e because in some cases you'll need to apply some restrictions on some events E.g:\n - Track product click only once!\n - Track product click only if pageView is already tracked\n - etc\n\n### Listen on one event\n```js\n/**\n * Listener with eventType specified it will be called when the given eventType is dispatched\n */\nfunction trackAddToCart(event, eventsHistory) {\n    // Call DataLayer or your tracking provider (E.g. Pixel, GTM..)\n    window.dataLayer.push(...event.data);\n\n    // If you want save this event in the events history, just return it\n    // otherwise it will be ignored.\n    return event\n}\n\n// Allow `trackAddToCart` to listen only on `ADD_TO_CART` event\ntrackAddToCart.eventType = 'ADD_TO_CART';\n```\n\n### Listen on all events\n```js\n/**\n * Since no eventType was specified it will be called whenever an event dispatched\n * You can use `switch` statement to handle multiple events in one listener\n */\nfunction trackCartEvents(event, eventsHistory) {\n    switch(event.type) {\n      case 'ADD_TO_CART':\n        // Call DataLayer or your tracking provider (E.g. Pixel, GTM..)\n        window.dataLayer.push(...event);\n        break;\n\n      default:\n        // Silence\n    }\n}\n```\n\n## Track Events\n`trackEvent` is a function that accept an object describes the event as argument.\n\n- Track event `ADD_TO_CART_EVENT` with data.\n```js\ntracker.trackEvent({\n  type: 'ADD_TO_CART_EVENT',\n  data: {\n    productId: '12345',\n    quantity: 5\n  }\n})\n```\n\n- Track event `PRODUCT_CLICK` with no associated data.\n```js\ntracker.trackEvent({ type: 'PRODUCT_CLICK' })\n```\n\n## Usage with React\n### Provide tracker to the root component\n\nAll container components need access to the tracker so they can track events.\n\nWe will use the `\u003cTrackerProvider\u003e` to [magically](https://facebook.github.io/react/docs/context.html) make the tracker available to all container components in the application without passing it explicitly.\n\nYou only need to use it once when you render the root component:\n\n#### `index.js`\n\n```js\nimport React from 'react'\nimport { render } from 'react-dom'\nimport { TrackerProvider, Tracker } from 'react-tracker'\nimport { trackProductClick } from './tracking/listeners/cart'\nimport ProductsList from './components/ProductsList'\n\nconst tracker = new Tracker([trackProductClick])\n\nrender(\n  \u003cTrackerProvider tracker={tracker}\u003e\n    \u003cProductsList products={someProducts} /\u003e\n  \u003c/TrackerProvider\u003e,\n  document.getElementById('root')\n)\n```\n\n### Create Add to Cart Event Listener `.../tracking/listeners/cart.js`\n\n```js\nfunction trackAddToCart(event, eventsHistory) {\n    window.dataLayer.push(...event);\n    return event\n}\n\n// Allow `trackAddToCart` to listen only on `ADD_TO_CART` event\ntrackAddToCart.eventType = 'ADD_TO_CART';\n\nexport default trackAddToCart;\n```\n\n### Add To Cart Event creator `.../tracking/events/cart.js`\nEvent creator should return an object that describe the event (Type and data).\n\n- type: string (Required)\n- data: Any (Optional)\n\n```js\nfunction getAddToCartEvent(id, price) {\n  return {\n      type: 'ADD_TO_CART',\n      data: {\n          id: id,\n          price: price\n      }\n  }\n};\n```\n\n### Create Product Component `components/Product.js`\n\n```js\nimport React from 'react'\n\nconst Product = ({ onClick, title, price, currency }) =\u003e (\n  \u003cli\n    onClick={onClick}\n  \u003e\n    {title}\n    \u003cspan\u003e {price} {currency} \u003c/span\u003e\n  \u003c/li\u003e\n)\n\nexport default Product\n```\n\n### Create Products List Component `components/ProductList.js`\n\n```js\nimport Product from './Product'\n\nconst ProductList = ({ products, trackAddToCart }) =\u003e (\n  \u003cul\u003e\n    {products.map(product =\u003e (\n      \u003cProduct key={product.id} {...product} onClick={() =\u003e trackAddToCart(product.id, product.price)} /\u003e\n    ))}\n  \u003c/ul\u003e\n)\n\nProductList.propTypes = {\n  // ...\n  trackAddToCart: PropTypes.func\n}\n\nexport default ProductList\n```\n\n### Create mapTrackingToProps function and pass it to withTracking HOC `.../compoenets/ProductListContainer.js`\n\n`mapTrackingToProps` should return an object which will be merged with the component Props.\n\n```js\nimport React from 'react';\nimport { withTracking } from 'react-tracker';\nimport { getAddToCartEvent } from '.../tracking/events/cart';\nimport ProductsList from './ProductsList';\n\nconst mapTrackingToProps = trackEvent =\u003e {\n  return {\n    trackAddToCart: (id, price) =\u003e {\n      trackEvent(getAddToCartEvent(id, price))\n    }\n  }\n}\n\n// Finally, we create the `ProductsList` by calling `withTracking()` and passing our `mapTrackingToProps`\nconst ProductsListWithTracking = withTracking(mapTrackingToProps)(ProductsList)\n\nexport default ProductsListWithTracking\n```\n\n## Create redux middleware for redux-based apps\nIf your app is using redux for state managment, you might want to track redux actions directly.\n\nLet's create our [Redux middleware](https://redux.js.org/docs/advanced/Middleware.html) to take the tracker as argument and call trackEvent on every redux action dispatched.\n\n```js\n/**\n * Simple redux middleware to use redux actions as input of tracking!\n * this will call the track function from the provided instance of tracker on every action\n * and use the action type as the event type and the action payload as the event data\n * @param {Object} tracker \n */\nconst trackingMiddleware = tracker =\u003e () =\u003e next =\u003e action =\u003e {\n    tracker.trackEvent(action);\n    next(action);\n};\n\nexport default trackingMiddleware;\n```\n\n```js\nimport { createStore, applyMiddleware } from 'redux';\nimport { Tracker } from 'react-redux';\nimport { trackingMiddleware, Tracker } from '../trackingMiddleware'\n\nconst tracker = new Tracker();\n\nconst store =  createStore(\n  reducers,\n  {}, // initialState\n  applyMiddleware(trackingMiddleware(tracker))\n);\n\n// That's All ;)\n```\n\n## Contribution\n\nThis project is in its early stages, I'd be very happy if you can help :)\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaouzioudouh%2Freact-tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaouzioudouh%2Freact-tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaouzioudouh%2Freact-tracker/lists"}