{"id":26679938,"url":"https://github.com/make-software/make-traffic-integration-lib","last_synced_at":"2025-06-25T03:07:54.548Z","repository":{"id":284144324,"uuid":"940775346","full_name":"make-software/make-traffic-integration-lib","owner":"make-software","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-24T11:07:05.000Z","size":201,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T12:25:54.438Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/make-software.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":"2025-02-28T19:12:07.000Z","updated_at":"2025-03-24T11:07:09.000Z","dependencies_parsed_at":"2025-03-24T12:26:01.337Z","dependency_job_id":"d729f479-ebce-4728-b68f-ed4df76fe967","html_url":"https://github.com/make-software/make-traffic-integration-lib","commit_stats":null,"previous_names":["make-software/make-traffic-integration-lib"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fmake-traffic-integration-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fmake-traffic-integration-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fmake-traffic-integration-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fmake-traffic-integration-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/make-software","download_url":"https://codeload.github.com/make-software/make-traffic-integration-lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245598218,"owners_count":20641884,"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":"2025-03-26T06:19:00.416Z","updated_at":"2025-06-25T03:07:54.529Z","avatar_url":"https://github.com/make-software.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Make Traffic Integration JS Library\n\nThe project contains modular JavaScript libraries designed for managing tasks in a traffic exchange system. \nIt consists of a [core npm package](https://www.npmjs.com/package/make-traffic-integration-core) and framework-specific \nwrappers for popular frameworks. \nThe core library is framework-agnostic, written in TypeScript, and compiled to JavaScript.\n\n---\n\n## **Installation**\n\n```bash\nnpm install make-traffic-integration-core\n```\n\n---\n\n### **Initialization**\nTo use the library, initialize the `TaskManagerApp` instance with your app's configuration:\n\n```javascript\nimport { TaskManagerApp } from \"make-traffic-integration-core\";\n\nconst appConfig = {\n    apiUrl: 'https://make-traffic-integration.dev.make.services',\n    appKey: '\u003c!--YourAppKey--\u003e',\n};\n\nconst taskManager = new TaskManagerApp(appConfig);\ntaskManager.init(); // Initialize the library\n```\n\n---\n\n### Example\n```typescript\nconst onCampaignClaimed = (task: Campaign) =\u003e {\n    console.log('Campaign claimed:', task);\n};\n\ntaskManager.subscribe(Events.CampaignClaimSucceed, onCampaignClaimed);\n\ntaskManager.getCampaigns('user123').then(campaigns =\u003e {\n    console.log('Campaigns:', campaigns);\n});\n```\n\n\n### **React Example with wrapper library **\n```bash\n  npm install make-traffic-integration-react-wrapper\n```\n\nCheck [React Example](./examples/react-app/README.md)\n\n#### Code Example\n\n```tsx\nimport React from \"react\";\nimport { TaskManagerProvider } from \"make-traffic-integration-react-wrapper\";\nimport {TaskManagerApp} from \"make-traffic-integration-core\";\n\nconst taskManagerApp = TaskManagerApp({\n    apiUrl: \"https://api.example.com\",\n    appKey: \"your-app-key\",\n});\n\nconst MyCustomTemplate = (campaign, actions) =\u003e (\n    \u003cdiv\u003e\n        \u003ch3\u003e{campaign.name}\u003c/h3\u003e\n        \u003cbutton onClick={actions.go}\u003eGo\u003c/button\u003e\n        \u003cbutton onClick={actions.claim}\u003eClaim\u003c/button\u003e\n    \u003c/div\u003e\n);\n\nconst App = () =\u003e (\n    \u003cTaskManagerProvider\n        taskManagerApp={taskManagerApp}\n        userID=\"user123\"\n        template={MyCustomTemplate}\n    /\u003e\n);\n\nexport default App;\n```\n\n## Core Methods\n\n### `async init(): Promise\u003cvoid\u003e`\nInitializes the task manager. Should be run once before using other methods.\n\n### `async getCampaigns(userID: string): Promise\u003cCampaignList\u003e`\nFetches the list of campaigns available for the specified user.\n\n### `async goProcess(userID: string, task: Campaign): Promise\u003cvoid\u003e`\nProcesses the specified campaign task.\n\n### `async claimProcess(userID: string, task: Campaign): Promise\u003cvoid\u003e`\nClaims the specified campaign task for the user.\n\n### `subscribe(event: Events, callback: (task: Campaign) =\u003e void): void`\nSubscribes to a specific event related to campaign tasks.\n\n### `unsubscribe(event: Events, callback: (task: Campaign) =\u003e void): void`\nUnsubscribes from a previously subscribed event.\n\n## Events\n\n### `Events.CampaignClaimSucceed`\nTriggered when a campaign is successfully claimed.\n\n### `Events.CampaignClaimFailed`\nTriggered when claiming a campaign fails.\n\n### `Events.CampaignProcessed`\nTriggered when a campaign has been successfully processed.\n\n## License\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmake-software%2Fmake-traffic-integration-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmake-software%2Fmake-traffic-integration-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmake-software%2Fmake-traffic-integration-lib/lists"}