npm i react-user-activity-tracker
import Tracker from 'react-user-activity-tracker';
function App() {
const [id, setId] = useState(0);
const changeId = (e) => {
setId(e.target.value);
}
return (
<div className="App">
<button onClick={changeId} value={0}>Button 0</button>
<button onClick={changeId} value={1}>Button 1</button>
<Tracker trackerId={id} onTrackerIdChange={ (id, value) => console.log(`${id} has been active for ${value} seconds. `)} timeout={1500} />
</div>
)
}
number, the identifier for the state being tracked.
function, fired when trackedId changes, get the trackerid and the time is has been active/viewed in seconds.
number, time in seconds when tracking should stop. Default 1800 seconds ( 30 minutes ).
boolean, display a box with values.
number, second passed between each onIntervalSubmit function
function, fired every (x : trackerSubmitInterval ) seconds