{"id":20020118,"url":"https://github.com/wonism/redux-segment-node","last_synced_at":"2025-05-04T23:32:39.665Z","repository":{"id":57351516,"uuid":"133642759","full_name":"wonism/redux-segment-node","owner":"wonism","description":"Redux middleware for segment on several platforms(`react` and `react-native`)","archived":false,"fork":false,"pushed_at":"2018-11-23T16:12:36.000Z","size":285,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-01T14:18:33.473Z","etag":null,"topics":["redux","redux-middleware","redux-segment-node","segment"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/wonism.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-16T09:33:05.000Z","updated_at":"2019-10-03T01:48:47.000Z","dependencies_parsed_at":"2022-09-19T13:12:14.740Z","dependency_job_id":null,"html_url":"https://github.com/wonism/redux-segment-node","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fredux-segment-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fredux-segment-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fredux-segment-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fredux-segment-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wonism","download_url":"https://codeload.github.com/wonism/redux-segment-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224417740,"owners_count":17307671,"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":["redux","redux-middleware","redux-segment-node","segment"],"created_at":"2024-11-13T08:29:54.743Z","updated_at":"2024-11-13T08:29:55.384Z","avatar_url":"https://github.com/wonism.png","language":"JavaScript","readme":"# Redux Segment Node\n\u003e Redux middleware for [segment](https://segment.com/). This library was\n\u003e created with reference to\n\u003e [analytics-react-native](https://github.com/neiker/analytics-react-native).\n\n[![npm version](https://badge.fury.io/js/redux-segment-node.svg)](https://badge.fury.io/js/redux-segment-node)\n[![Build Status](https://travis-ci.org/wonism/redux-segment-node.svg)](https://travis-ci.org/wonism/redux-segment-node)\n\n## Installation\n```\n$ npm i -S redux-segment-node\n```\n\n## Demo\n```\n# replace the `key` with your `Segment API key` in `config.json`\n$ npm run dev\n# and visit localhost:7777\n```\n\n## Usage\n```js\n// import { applyMiddleware, createStore } from 'redux';\nimport createSegmentTracker from 'redux-segment-node';\n\nconst segmentMiddleware = createSegmentTracker({\n  key: 'API_KEY',\n  flushAfter: 1000,\n});\n\nconst middleware = applyMiddleware(segmentMiddleware);\n\n// const store = createStore(/* ... */);\n\n// identify (recommended: pass `userId` in `eventPayload`)\nstore.dispatch({\n  type: 'SIGN_IN',\n  analytics: {\n    eventType: 'identify',\n    eventPayload: {\n      userId: 'UUID',\n    },\n  },\n});\n\n// track (required: pass `event` in `eventPayload`)\n// If you pass the `signout` or `logout` as an `event` in `track` type,\n// The `userId` will be removed.\nstore.dispatch({\n  type: 'CLICK_CTA_BUTTON',\n  analytics: {\n    eventType: 'track',\n    eventPayload: {\n      event: 'Click CTA Button',\n    },\n  },\n});\n\n// page (recommended: pass `name` in `eventPayload`)\n// screen (similar with `page`)\nstore.dispatch({\n  type: 'VIEW_PAGE',\n  analytics: {\n    eventType: 'page', // or 'screen'\n    eventPayload: {\n      name: 'LANDING_PAGE',\n    },\n  },\n});\n\n// group (required: pass `groupId` in `eventPayload`)\nstore.dispatch({\n  type: 'GROUP',\n  analytics: {\n    eventType: 'group',\n    eventPayload: {\n      groupId: 'UUID',\n    },\n  },\n});\n\n// alias (required: pass `userId` in `eventPayload`)\nstore.dispatch({\n  type: 'ALIAS_USER',\n  analytics: {\n    eventType: 'alias',\n    eventPayload: {\n      userId: 'NEW_UUID',\n    },\n  },\n});\n```\n\n## Configuration\n\u003e createSegmentTracker arguments\n\n| property   | type             | remark |\n|:-----------|:-----------------|:-------|\n| key        | string(required) |        |\n| platform   | string(optional) | one of [`android`, `ios`] or `undefined` |\n| host       | string(optional) | Host where reports will be sent. Useful for debug. |\n| flushAt    | number(optional) | The number of messages to enqueue before flushing. |\n| flushAfter | number(optional) | The number of milliseconds to wait before flushing the queue automatically. |\n\n## Event Types (Segment API Specification)\n- [`identify`](https://segment.com/docs/spec/identify/): Can tie an user to their action and record traits about them.\n- [`track`](https://segment.com/docs/spec/track/): Can track any actions that users perform.\n- [`page`](https://segment.com/docs/spec/page/): Can record the page that users are stay in.\n- [`screen`](https://segment.com/docs/spec/screen/): Can record the screen that users are stay in. (for the mobile application)\n- [`group`](https://segment.com/docs/spec/group/): Can associate the individual users with a group.\n- [`alias`](https://segment.com/docs/spec/alias/): Can merge two user identities.\n\n## Documentation for Segment\nhttps://segment.com/libraries/node\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwonism%2Fredux-segment-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwonism%2Fredux-segment-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwonism%2Fredux-segment-node/lists"}