npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

make-traffic-integration-react-wrapper

v0.3.2

Published

React hook and provider for the Make Traffic task manager.

Readme

make-traffic-integration-react-wrapper

React hook and provider for the Make Traffic task manager.

npm

Installation

npm install make-traffic-integration-core make-traffic-integration-react-wrapper

make-traffic-integration-core is a peer dependency — install it alongside this package.


Quick Start

import { useTaskManager } from "make-traffic-integration-react-wrapper";

const { tasks, isLoading, error, goProcess, claimProcess } = useTaskManager({
    taskManagerApp: app,
    userID: "user-123",
    authProvider: "telegram",
});

API

useTaskManager(options)UseTaskManagerResult

React hook. Initialises the manager once, fetches tasks, and exposes go/claim actions.

const {
    tasks,        // Task[]
    isLoading,    // boolean
    error,        // Error | null
    refresh,      // () => void — re-fetch task list
    goProcess,    // (task: Task) => Promise<void>
    claimProcess, // (task: Task) => Promise<void>
} = useTaskManager({
    taskManagerApp,           // TaskManagerApp instance
    userID: "user-123",
    authProvider: "telegram", // forwarded to all API calls
    filters: {                // forwarded to getTasks
        isActive: true,
        categories: ["default"],
    },
});

Call refresh() explicitly after goProcess and claimProcess to keep the list in sync.

→ examples/react-app/src/examples/full/App.tsx


TaskManagerProvider

Declarative alternative to useTaskManager. Pass a template render function — the provider handles init, fetching, and actions.

import { TaskManagerProvider } from "make-traffic-integration-react-wrapper";

<TaskManagerProvider
    taskManagerApp={app}
    userID="user-123"
    authProvider="telegram"
    template={(task, { go, claim }) => (
        <div key={task.id}>
            <span>{task.name}</span>
            <button onClick={go}>Go</button>
            <button onClick={claim}>Claim</button>
        </div>
    )}
/>

→ examples/react-app/src/examples/simple/App.tsx


TaskClaimModalHost

Required for plugin-rendered UI (e.g. quiz or survey tasks). Place once near the app root. Subscribes to ClaimModalOpen, renders a modal shell, and passes a DOM container to the plugin via provideHost. Emits ClaimModalClosed on dismiss.

import { TaskClaimModalHost } from "make-traffic-integration-react-wrapper";

// Minimal — uses built-in styles
<TaskClaimModalHost taskManagerApp={window.globalTaskManager} />

// Custom styles via props
<TaskClaimModalHost
    taskManagerApp={window.globalTaskManager}
    style={{ maxWidth: "480px" }}
    overlayStyle={{ backdropFilter: "blur(4px)" }}
    contentStyle={{ padding: 24 }}
/>

Props

| Prop | Type | Description | |------|------|-------------| | taskManagerApp | TaskManagerApp | Required. The manager instance. | | overlayClassName | string | Class added to the backdrop. | | overlayStyle | CSSProperties | Inline style merged into the backdrop. | | className | string | Class added to the modal panel. | | style | CSSProperties | Inline style merged into the modal panel (e.g. maxWidth, background). | | contentClassName | string | Class added to the inner content div. | | contentStyle | CSSProperties | Inline style merged into the inner content div. |

→ examples/react-app/src/examples/full/App.tsx


getRewardValue(rewards, type)number

Extracts a reward amount by type from a task's reward list.

import { getRewardValue } from "make-traffic-integration-react-wrapper";

const coins = getRewardValue(task.rewards, "coin");
const energy = getRewardValue(task.rewards, "energy");

getTaskIconUrl(task, assetsPath?)string

Resolves the icon URL for a task. Uses customMetadata.icon when present; falls back to www.svg. Absolute URLs are passed through unchanged.

import { getTaskIconUrl } from "make-traffic-integration-react-wrapper";

const iconUrl = getTaskIconUrl(task, "/icons"); // "/icons/redirect.svg" or "/icons/www.svg"
const iconUrl = getTaskIconUrl(task);           // "redirect.svg" or "www.svg"

→ examples/react-app/src/components/TaskRow.tsx


pluginRegistry

Typed helpers to extract plugin-specific metadata from task.customMetadata.

import { pluginRegistry } from "make-traffic-integration-react-wrapper";

const meta = pluginRegistry.redirect.getMetadata(task);
// { url: string, secondsToClaim: number }

Error Handling

claimProcess rejects with HttpError (from make-traffic-integration-core) when the server returns an error. The message is parsed from the JSON response body.

import { HttpError } from "make-traffic-integration-core";

try {
    await claimProcess(task);
    refresh();
} catch (err) {
    if (err instanceof HttpError) {
        showError(err.message); // e.g. "task has not been completed"
    }
}

→ examples/react-app/src/examples/full/App.tsx


Event Subscriptions

Subscribe inside useEffect and always return the unsubscribe function.

import { Events } from "make-traffic-integration-core";

React.useEffect(() => {
    const manager = window.globalTaskManager;
    if (!manager) return;
    const handler = (task) => showSuccess(`Claimed: ${task.name}`);
    manager.subscribe(Events.TaskClaimSucceed, handler);
    return () => manager.unsubscribe(Events.TaskClaimSucceed, handler);
}, []);

Examples

| Example | What it shows | |---------|--------------| | full | Production setup: singleton, refresh, events, modal host, toasts | | hook | useTaskManager minimal usage | | simple | TaskManagerProvider declarative approach |


License

MIT