<commit_before>import {Component, PropTypes} from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';

import {metrics} from '@ciscospark/react-component-utils';

import {
  connectToMercury,
  updateStatusConnecting,
  updateStatusConnected
} from './actions';

const metricName = {
  MERCURY_CONNECT_START: `mercuryConnection:start`,
  MERCURY_CONNECT_END: `mercuryConnection:end`,
  MERCURY_CONNECT_DURATION: `mercuryConnection:duration`
};

class MercuryComponent extends Component {

  componentDidMount() {
    const props = this.props;
    const {spark} = props;

    spark.listenToAndRun(spark.mercury, `change:connecting`, () => {
      props.updateStatusConnecting(spark.mercury.connecting);
    });

    spark.listenToAndRun(spark.mercury, `change:connected`, () => {
      props.updateStatusConnected(spark.mercury.connected);
    });

    this.setupMercury(this.props);
  }<commit_msg>feat(redux-module-mercury): listen to device registration changes<commit_after>import {Component, PropTypes} from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';

import {metrics} from '@ciscospark/react-component-utils';

import {
  connectToMercury,
  updateStatusConnecting,
  updateStatusConnected
} from './actions';

const metricName = {
  MERCURY_CONNECT_START: `mercuryConnection:start`,
  MERCURY_CONNECT_END: `mercuryConnection:end`,
  MERCURY_CONNECT_DURATION: `mercuryConnection:duration`
};

class MercuryComponent extends Component {

  componentDidMount() {
    const props = this.props;
    const {spark} = props;

    spark.listenToAndRun(spark.mercury, `change:connecting`, () => {
      props.updateStatusConnecting(spark.mercury.connecting);
    });

    spark.listenToAndRun(spark.mercury, `change:connected`, () => {
      props.updateStatusConnected(spark.mercury.connected);
    });

    spark.listenToAndRun(spark.device, `change:registered`, () => {
      this.setupMercury(this.props);
    });
  }
{'fraction_non_alphanumeric': 0.12762762762762764, 'fraction_numerical': 0.0, 'mean_word_length': 5.169753086419753, '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': '5108491', 'n_tokens_mistral': 639, 'n_tokens_neox': 636, 'n_words': 105}