{"size": 526, "ext": "js", "max_stars_repo_path": "client/src/components/withAnalytics.js", "max_stars_repo_name": "coolbox/dj-shop", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/src/components/withAnalytics.js", "max_issues_repo_name": "coolbox/dj-shop", "max_issues_repo_issues_event_min_datetime": "2020-06-25T06:45:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T18:41:23.000Z", "max_forks_repo_path": "client/src/components/withAnalytics.js", "max_forks_repo_name": "peteroome/dj-shop", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 12, "max_forks_count": null, "avg_line_length": 21.9166666667, "max_line_length": 77, "alphanum_fraction": 0.6577946768}
import React, { Component } from 'react';
import ReactGA from "react-ga";

const withAnalytics = (AnalyticsComponent) => {
  return class extends Component {
    constructor(props) {
      super(props);
      ReactGA.initialize(process.env.REACT_APP_GOOGLE_ANALYTICS_TRACKING_ID);
    }

    componentDidMount() {
      ReactGA.pageview(window.location.pathname + window.location.search);
    }

    render() {
      return (
        <AnalyticsComponent {...this.props} />
      );
    }
  }
};

export default withAnalytics;
