The project contains modular JavaScript libraries designed for managing tasks in a traffic exchange system. It consists of a core npm package and framework-specific wrappers for popular frameworks. The core library is framework-agnostic, written in TypeScript, and compiled to JavaScript.
npm install make-traffic-integration-core
To use the library, initialize the TaskManagerApp
instance with your app's configuration:
import { TaskManagerApp } from "make-traffic-integration-core";
const appConfig = {
apiUrl: 'https://make-traffic-integration.dev.make.services',
appKey: '<!--YourAppKey-->',
};
const taskManager = new TaskManagerApp(appConfig);
taskManager.init(); // Initialize the library
const onTaskClaimed = (task: Task) => {
console.log('Task claimed:', task);
};
taskManager.subscribe(Events.TaskClaimSucceed, onTaskClaimed);
taskManager.getTasks('user123').then(tasks => {
console.log('Tampaigns:', tasks);
});
npm install make-traffic-integration-react-wrapper
Check React Example
import React from "react";
import { TaskManagerProvider } from "make-traffic-integration-react-wrapper";
import {TaskManagerApp} from "make-traffic-integration-core";
const taskManagerApp = TaskManagerApp({
apiUrl: "https://api.example.com",
appKey: "your-app-key",
});
const MyCustomTemplate = (task, actions) => (
<div>
<h3>{task.name}</h3>
<button onClick={actions.go}>Go</button>
<button onClick={actions.claim}>Claim</button>
</div>
);
const App = () => (
<TaskManagerProvider
taskManagerApp={taskManagerApp}
userID="user123"
template={MyCustomTemplate}
/>
);
export default App;
Initializes the task manager. Should be run once before using other methods.
Fetches the list of tasks available for the specified user.
Processes the specified task task.
Claims the specified task for the user.
Subscribes to a specific event related to tasks.
Unsubscribes from a previously subscribed event.
Triggered when a task is successfully claimed.
Triggered when claiming a task fails.
Triggered when a task has been successfully processed.
MIT