react-user-activity-tracker
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

React user activity tracker

installation

npm i react-user-activity-tracker

basic example

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. `)} 
          trackerSubmitInterval={10}
          onIntervalSubmit={ (id, value) => console.log(`${id} has been active for ${value} seconds. `)}
          timeout={1500} 
          />
    </div>
  )
}

props

trackerId

number, the identifier for the state being tracked.

onTrackerIdChange

function, fired when trackedId changes, get the trackerid and the time is has been active/viewed in seconds.

timeout

number, time in seconds when tracking should stop. Default 1800 seconds ( 30 minutes ).

debugOn

boolean, display a box with values.

trackerSubmitInterval

number, second passed between each onIntervalSubmit function

onIntervalSubmit

function, fired every (x : trackerSubmitInterval ) seconds

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.120latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.120
1.1.00
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i react-user-activity-tracker

Weekly Downloads

19

Version

1.1.1

License

MIT

Unpacked Size

14.9 kB

Total Files

8

Last publish

Collaborators

  • andreas_berglund