@blocklet/tracker

1.16.48 • Public • Published

Blocklet Tracker

A library to facilitate blocklet tracking, sending tracking data to a backend, can only be used in browser.

Usage

Import the library in your blocklet's index.jsx file.

import '@blocklet/tracker';

Then you can use the window.tracker object to send tracking data to a backend.

import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

export default function App() {

  const location = useLocation();

  useEffect(() => {
    if (window.tracker && typeof window.tracker.pageView === 'function') {
      window.tracker.pageView(`${location.pathname}${location.search}`);
    }
  }, [location]);
}

Readme

Keywords

Package Sidebar

Install

npm i @blocklet/tracker

Weekly Downloads

782

Version

1.16.48

License

Apache-2.0

Unpacked Size

2.69 kB

Total Files

4

Last publish

Collaborators

  • wangshijun
  • gxw