<commit_before>/*
 * Copyright 2017 Expedia, Inc.
 *
 *       Licensed under the Apache License, Version 2.0 (the "License");
 *       you may not use this file except in compliance with the License.
 *       You may obtain a copy of the License at
 *
 *           http://www.apache.org/licenses/LICENSE-2.0
 *
 *       Unless required by applicable law or agreed to in writing, software
 *       distributed under the License is distributed on an "AS IS" BASIS,
 *       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *       See the License for the specific language governing permissions and
 *       limitations under the License.
 *
 */

import React, {Component} from 'react';
import ReactGA from 'react-ga';
import PropTypes from 'prop-types';

const gaTrackingID = (window.haystackUiConfig && window.haystackUiConfig.gaTrackingID) || null;
ReactGA.initialize(gaTrackingID);

const trackPage = (page) => {
    ReactGA.set({ page });
    ReactGA.pageview(page);
};

const withTracker = (WrappedComponent) => {
    class Wrapper extends Component {

        propTypes = {
        location: PropTypes.objectOf(PropTypes.string)
        };

        componentDidMount() {
            const page = this.props.location.pathname;
            trackPage(page);
        }

        componentWillReceiveProps(nextProps) {
            const currentPage = this.props.location.pathname;
            const nextPage = nextProps.location.pathname;

            if (currentPage !== nextPage) {
                trackPage(nextPage);
            }
        }

        render() {<commit_msg>wrapper withTracker non-static propTypes fix<commit_after>/*
 * Copyright 2017 Expedia, Inc.
 *
 *       Licensed under the Apache License, Version 2.0 (the "License");
 *       you may not use this file except in compliance with the License.
 *       You may obtain a copy of the License at
 *
 *           http://www.apache.org/licenses/LICENSE-2.0
 *
 *       Unless required by applicable law or agreed to in writing, software
 *       distributed under the License is distributed on an "AS IS" BASIS,
 *       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *       See the License for the specific language governing permissions and
 *       limitations under the License.
 *
 */

import React, {Component} from 'react';
import ReactGA from 'react-ga';
import PropTypes from 'prop-types';

const gaTrackingID = (window.haystackUiConfig && window.haystackUiConfig.gaTrackingID) || null;
ReactGA.initialize(gaTrackingID);

const trackPage = (page) => {
    ReactGA.set({ page });
    ReactGA.pageview(page);
};

const withTracker = (WrappedComponent) => {
    class Wrapper extends Component {
        static propTypes = {
            location: PropTypes.objectOf(PropTypes.string).isRequired
        };

        componentDidMount() {
            const page = this.props.location.pathname;
            trackPage(page);
        }

        componentWillReceiveProps(nextProps) {
            const currentPage = this.props.location.pathname;
            const nextPage = nextProps.location.pathname;

            if (currentPage !== nextPage) {
                trackPage(nextPage);
            }
        }

        render() {
{'fraction_non_alphanumeric': 0.09163591635916359, 'fraction_numerical': 0.004920049200492005, 'mean_word_length': 2.5397170837867247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2872761', 'n_tokens_mistral': 863, 'n_tokens_neox': 849, 'n_words': 275}