<commit_before>import React from 'react';

const withCountry = component =>
	class extends React.Component {
		static displayName = `withCountry(${component.displayName
			|| component.name})`;

		constructor(props) {
			super(props);

			this.state = {
				country: 'US',
			};
		}

		async componentDidMount() {
			try {
				const response = await fetch('//freegeoip.net/json/');
				const data = await response.json();

				this.setState({country: data.country_code});
			}
			catch (err) {
				// Failed to fetch can happen if the user has a blocker (ad, tracker...)
				trackJs.track(`Error when getting the country: ${err.message}`);
			}
		}

		render() {
			const {country} = this.state;

			return React.createElement(component, {
				...this.props,
				country,
			});
		}
	};

export default withCountry;<commit_msg>Change endpoint for 2 other free services<commit_after>import React from 'react';

const withCountry = component =>
	class extends React.Component {
		static displayName = `withCountry(${component.displayName
			|| component.name})`;

		constructor(props) {
			super(props);

			this.state = {
				country: 'US',
			};
		}

		async componentDidMount() {
			try {
				const response = await fetch('//ipinfo.io/json');
				const data = await response.json();

				this.setState({country: data.country});
			}
			catch (err) {
				// Failed to fetch can happen if the user has a blocker (ad, tracker...)
				window.trackJs.track(`Error when getting the country: ${err.message}`);

				// trying another server just to be sure
				try {
					const response = await fetch('//get.geojs.io/v1/ip/country.json');
					const data = await response.json();

					this.setState({country: data.country});
				}
				catch (err2) {
					// giving up
					window.trackJs.track(
						`Error when getting the country: ${err2.message}`,
					);
				}
			}
		}

		render() {
			const {country} = this.state;

			return React.createElement(component, {
				...this.props,
				country,
			});
		}
	};

export default withCountry;
{'fraction_non_alphanumeric': 0.14054054054054055, 'fraction_numerical': 0.0019656019656019656, 'mean_word_length': 2.8780952380952383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6610809', 'n_tokens_mistral': 780, 'n_tokens_neox': 612, 'n_words': 162}