<commit_before>/* eslint-disable no-underscore-dangle */

import React from 'react';
import PropTypes from 'prop-types';
import deepEqual from 'deep-equal';

import ActionLoggerComponent from '../../components/ActionLogger/';
import { EVENT_ID } from '../../';

export default class ActionLogger extends React.Component {
  constructor(props, ...args) {
    super(props, ...args);
    this.state = { actions: [] };
    this._actionListener = action => this.addAction(action);
  }

  componentDidMount() {
    this.props.channel.on(EVENT_ID, this._actionListener);
  }

  componentWillUnmount() {
    this.props.channel.removeListener(EVENT_ID, this._actionListener);
  }

  addAction(action) {
    action.data.args = action.data.args.map(arg => JSON.parse(arg)); // eslint-disable-line
    const actions = [...this.state.actions];
    const previous = actions.length && actions[0];
    if (previous && deepEqual(previous.data, action.data, { strict: true })) {
      previous.count++; // eslint-disable-line
    } else {<commit_msg>use retrocycle, no deepEqual if cyclic<commit_after>/* eslint-disable no-underscore-dangle */

import React from 'react';
import PropTypes from 'prop-types';
import deepEqual from 'deep-equal';
import { CYCLIC_KEY, retrocycle } from '../../util';

import ActionLoggerComponent from '../../components/ActionLogger/';
import { EVENT_ID } from '../../';

export default class ActionLogger extends React.Component {
  constructor(props, ...args) {
    super(props, ...args);
    this.state = { actions: [] };
    this._actionListener = action => this.addAction(action);
  }

  componentDidMount() {
    this.props.channel.on(EVENT_ID, this._actionListener);
  }

  componentWillUnmount() {
    this.props.channel.removeListener(EVENT_ID, this._actionListener);
  }

  addAction(action) {
    action.data.args = action.data.args.map(arg => retrocycle(JSON.parse(arg))); // eslint-disable-line
    const isCyclic = !!action.data.args.find(arg => arg[CYCLIC_KEY]);
    const actions = [...this.state.actions];
    const previous = actions.length && actions[0];

    if (previous && !isCyclic && deepEqual(previous.data, action.data, { strict: true })) {
      previous.count++; // eslint-disable-line
    } else {
{'fraction_non_alphanumeric': 0.1577301161751564, 'fraction_numerical': 0.0008936550491510277, 'mean_word_length': 3.674321503131524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '3743582', 'n_tokens_mistral': 670, 'n_tokens_neox': 668, 'n_words': 143}