# withTracker

Add google analytics reporting to your application.

## Usage

### Installation

```bash
yarn add @arcblock/ux
```

### Configuration & Usage

In your application entry file

```javascript
import React from 'react';
import withTracker from '@arcblock/ux/lib/withTracker';
import { BrowserRouter as Router } from 'react-router-dom';

const App = () => <p>My awesome application</p>;
const TrackedApp = withTracker(App);

export default function WrappedApp() {
  // While the blocklet is deploy to a sub path, this will be work properly.
  const basename = window?.blocklet?.prefix || '/';

  return (
    <Router basename={basename}>
      <TrackedApp />
    </Router>
  );
}
```

Then you can use `window.trackPage(path, title)` and `window.trackEvent(category, action, label, value)` to track page views and events.
