<commit_before>/* global window: false */
import promisescript from 'promisescript';
export default class ReactInstrumentationPiano {

  constructor(config) {
    this.config = {
      endpoint: 'https://sandbox.tinypass.com/api/v3',
      aid: 'M3UZnikdix',
      debug: true,
      externalScript: '//sandbox.tinypass.com/api/tinypass.min.js',
      ...config,
    };
  }

  get name() {
    return 'react-i13n-piano';
  }

  get eventHandlers() {
    return {
      pageview: this.pageview.bind(this),
    };
  }

  ensureScriptHasLoaded() {
    if (!this.script) {
      const pPiano = typeof this.config.loadExternalScript === 'function' ?
        this.config.loadExternalScript() :
        promisescript({
          url: this.config.externalScript,
          type: 'script',
          exposed: 'tp',
        });
      this.script = pPiano.then(() => {
        if (typeof window !== 'undefined' && typeof window.tp !== 'undefined') {
          if (this.config.endpoint) {
            window.tp.push([ 'setEndpoint', this.config.endpoint ]);
          }
          if (this.config.aid) {
            window.tp.push([ 'setAid', this.config.aid ]);
          }
          if (this.config.debug) {
            window.tp.push([ 'setDebug', this.config.debug ]);
          }
          if (this.config.sandbox) {
            window.tp.push([ 'setSandbox', this.config.sandbox ]);
          }
          if (this.config.useTinypassAccounts) {
            window.tp.push([ 'setUseTinypassAccounts', this.config.useTinypassAccounts ]);
          }

          return new Promise((resolve, reject) => {
            window.tp.push([<commit_msg>fix: force to https, remove useless config<commit_after>/* global window: false */
import promisescript from 'promisescript';
export default class ReactInstrumentationPiano {

  constructor(config) {
    this.config = {
      debug: true,
      externalScript: '//sandbox.tinypass.com/api/tinypass.min.js',
      ...config,
    };
  }

  get name() {
    return 'react-i13n-piano';
  }

  get eventHandlers() {
    return {
      pageview: this.pageview.bind(this),
    };
  }

  ensureScriptHasLoaded() {
    if (!this.script) {
      const pPiano = typeof this.config.loadExternalScript === 'function' ?
        this.config.loadExternalScript() :
        promisescript({
          url: `https://${ this.config.externalScript }`,
          type: 'script',
          exposed: 'tp',
        });
      this.script = pPiano.then(() => {
        if (typeof window !== 'undefined' && typeof window.tp !== 'undefined') {
          if (this.config.endpoint) {
            window.tp.push([ 'setEndpoint', this.config.endpoint ]);
          }
          if (this.config.aid) {
            window.tp.push([ 'setAid', this.config.aid ]);
          }
          if (this.config.debug) {
            window.tp.push([ 'setDebug', this.config.debug ]);
          }
          if (this.config.sandbox) {
            window.tp.push([ 'setSandbox', this.config.sandbox ]);
          }
          if (this.config.useTinypassAccounts) {
            window.tp.push([ 'setUseTinypassAccounts', this.config.useTinypassAccounts ]);
          }

          return new Promise((resolve, reject) => {
            window.tp.push([
{'fraction_non_alphanumeric': 0.1476780185758514, 'fraction_numerical': 0.0018575851393188853, 'mean_word_length': 2.0742150333016176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '2167527', 'n_tokens_mistral': 1010, 'n_tokens_neox': 985, 'n_words': 176}