<commit_before>/**
 * @desc goal() fires strings into auto detected analytics installs
 *
 * @param {str}
 *
 * @return {void}
 *
 * usage:
 *   import goal from 'clearhead/goal';
 *   goal('exp1-foo', 'click', '#bar'); ==>
 *   // optimizely.push(['trackEvent', 'exp1-foo-click-#bar'])
 *   // monetateQ.push(['trackEvent', ['exp1-foo-click-#bar']])
 *   // s.tl() // won't fire b/c !/^(prop|evar)/i.test(args[0])
 *   // dataLayer.push({event:'clearhead.goal', meta:{category, action, label}})
 *   // ga('send', 'event', category, action, label)
 *   // _gaq.push(['_trackEvent', category, action, label]);
 */
import track from './track';
const log = require('./log').bind(null, 'clearhead/goal:');

function goal(category, action, label) {
  'use strict';

  const lowercaseSlug = [category, action, label].join('-').toLowerCase();

  // optimizely goals first
  if (window.optimizely && !!window.optimizely.push) {
    log('optimizely', lowercaseSlug);
    window.optimizely.push(['trackEvent', lowercaseSlug]);
  }

  // monetateQ - lots of arrays but it's correct
  if (window.monetateQ && !!window.monetateQ.push) {
    log('monetateQ', lowercaseSlug);
    window.monetateQ.push(['trackEvent', [lowercaseSlug]]);<commit_msg>update usage of goals.js docs<commit_after>/**
 * @desc goal() fires strings into auto detected analytics installs
 *
 * @param {str}
 *
 * @return {void}
 *
 * usage:
 *   const goal = require('clearhead/goal').bind(null, 'exp1-foo');
 *   goal('click', '#bar'); ==>
 *   // optimizely.push(['trackEvent', 'exp1-foo-click-#bar'])
 *   // monetateQ.push(['trackEvent', ['exp1-foo-click-#bar']])
 *   // s.tl() // won't fire b/c !/^(prop|evar)/i.test(args[0])
 *   // dataLayer.push({event:'clearhead.goal', meta:{category, action, label}})
 *   // ga('send', 'event', 'exp1-foo', 'click', '#bar')
 *   // _gaq.push(['_trackEvent', 'exp1-foo', 'click', '#bar']);
 *
 *   const goal = require('goal').bind(null, 'prop46');
 *   goal('exp1-foo', 'clicked-header'); ==>
 *   // optimizely.push(['trackEvent', 'prop46-exp1-foo-clicked-header'])
 *   // monetateQ.push(['trackEvent', ['prop46-exp1-foo-clicked-header']])
 *   // require('clearhead/track')('prop46', 'exp1-foo-clicked-header');
 *
 */
import track from './track';
const log = require('./log').bind(null, 'clearhead/goal:');

function goal(category, action, label) {
  'use strict';

  const lowercaseSlug = [category, action, label].join('-').toLowerCase();

  // optimizely goals first
  if (window.optimizely && !!window.optimizely.push) {
    log('optimizely', lowercaseSlug);
    window.optimizely.push(['trackEvent', lowercaseSlug]);
  }

  // monetateQ - lots of arrays but it's correct
  if (window.monetateQ && !!window.monetateQ.push) {
    log('monetateQ', lowercaseSlug);
    window.monetateQ.push(['trackEvent', [lowercaseSlug]]);
{'fraction_non_alphanumeric': 0.21763668430335098, 'fraction_numerical': 0.007760141093474427, 'mean_word_length': 4.037300177619893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5340980', 'n_tokens_mistral': 1007, 'n_tokens_neox': 984, 'n_words': 188}