<commit_before>import { Button, Layout, Text } from '@ui-kitten/components';
import * as SecureStore from 'expo-secure-store';
import propTypes from 'prop-types';
import React from 'react';
import { StyleSheet } from 'react-native';
import RNRestart from 'react-native-restart';
import { SafeAreaView } from 'react-native-safe-area-context';
import { USER_STORE_KEY, USER_TYPE_KEY } from './auth/context';

export default class GlobalErrorBoundary extends React.Component {
  constructor(props) {
    super(props);
    this.state = { hasError: false, error: null };
  }

  static getDerivedStateFromError(error) {
    return { hasError: true, error };
  }

  componentDidCatch(error, info) {
    // send to back end error log
    fetch('TODO??', {
      method: 'POST',
      headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
      body: JSON.stringify({ error, info }),
    });
  }

  async restartApp() {
    await SecureStore.deleteItemAsync(USER_STORE_KEY);
    await SecureStore.deleteItemAsync(USER_TYPE_KEY);

    RNRestart.restartApp();
  }

  render() {
    if (this.state.hasError) {
      return (
        <SafeAreaView style={styles.safeArea}>
          <Layout>
            <Text>Something went wrong!</Text>
            <Text>{JSON.stringify(this.state.error, null, 2)}</Text>
            <Button onPress={this.restartApp}>Restart</Button>
          </Layout>
        </SafeAreaView>
      );
    }

    return this.props.children;
  }<commit_msg>fix: turn off error log<commit_after>import { Button, Layout, Text } from '@ui-kitten/components';
import * as SecureStore from 'expo-secure-store';
import propTypes from 'prop-types';
import React from 'react';
import { StyleSheet } from 'react-native';
import RNRestart from 'react-native-restart';
import { SafeAreaView } from 'react-native-safe-area-context';
import { USER_STORE_KEY, USER_TYPE_KEY } from './auth/context';

export default class GlobalErrorBoundary extends React.Component {
  constructor(props) {
    super(props);
    this.state = { hasError: false, error: null };
  }

  static getDerivedStateFromError(error) {
    return { hasError: true, error };
  }

  componentDidCatch(error, info) {
    // send to back end error log
    // fetch('TODO??', {
    //   method: 'POST',
    //   headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
    //   body: JSON.stringify({ error, info }),
    // });
  }

  async restartApp() {
    await SecureStore.deleteItemAsync(USER_STORE_KEY);
    await SecureStore.deleteItemAsync(USER_TYPE_KEY);

    RNRestart.restartApp();
  }

  render() {
    if (this.state.hasError) {
      return (
        <SafeAreaView style={styles.safeArea}>
          <Layout>
            <Text>Something went wrong!</Text>
            <Text>{JSON.stringify(this.state.error, null, 2)}</Text>
            <Button onPress={this.restartApp}>Restart</Button>
          </Layout>
        </SafeAreaView>
      );
    }

    return this.props.children;
  }
{'fraction_non_alphanumeric': 0.137620793068977, 'fraction_numerical': 0.0006664445184938354, 'mean_word_length': 3.1464088397790055, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6253305', 'n_tokens_mistral': 940, 'n_tokens_neox': 922, 'n_words': 206}