<commit_before>//
// Analytics for the main layout. This includes buttons in the header, footer
// or any other actions that occur on each page.
//

import { data as sd } from 'sharify'

// Track pageview
analytics.page(
  { path: location.pathname },
  { integrations: { Marketo: false } }
)

// Track pageload speed
if (
  window.performance &&
  window.performance.timing &&
  sd.TRACK_PAGELOAD_PATHS
) {
  window.addEventListener('load', function() {
    _.each(sd.TRACK_PAGELOAD_PATHS.split('|'), path => {
      if (window.location.pathname.split('/')[1] === path) {
        window.setTimeout(function() {
          const {
            requestStart,
            loadEventEnd,
            domComplete,
          } = window.performance.timing

          analytics.track('Page load time', {
            requestStart,
            loadEventEnd,
            domComplete,
            nonInteraction: 1,
          })
        }, 0)
      }
    })
  })
}

// Track 15 second bounce rate
setTimeout(function() {
  analytics.track('time on page more than 15 seconds', {
    category: '15 Seconds',
    message: sd.CURRENT_PATH,
  })
}, 15000)

// Track 3 Minute bounce rate
setTimeout(function() {
  analytics.track('time on page more than 3 minutes', {
    category: '3 Minutes',
    message: sd.CURRENT_PATH,
  })
}, 180000)

// debug tracking calls in development
if (sd.NODE_ENV !== 'production') {
  analytics.on('track', function() {
    console.info('TRACKED: ', arguments[0], JSON.stringify(arguments[1]))
  })
}

if (sd.NODE_ENV === 'development') {
  analyticsHooks.on('all', function(name, data) {
    console.info('ANALYTICS HOOK: ', name, data)
  })
}
<commit_msg>adding 30sec and 1 min stay on the page events to analytics<commit_after>//
// Analytics for the main layout. This includes buttons in the header, footer
// or any other actions that occur on each page.
//

import { data as sd } from 'sharify'

// Track pageview
analytics.page(
  { path: location.pathname },
  { integrations: { Marketo: false } }
)

// Track pageload speed
if (
  window.performance &&
  window.performance.timing &&
  sd.TRACK_PAGELOAD_PATHS
) {
  window.addEventListener('load', function() {
    _.each(sd.TRACK_PAGELOAD_PATHS.split('|'), path => {
      if (window.location.pathname.split('/')[1] === path) {
        window.setTimeout(function() {
          const {
            requestStart,
            loadEventEnd,
            domComplete,
          } = window.performance.timing

          analytics.track('Page load time', {
            requestStart,
            loadEventEnd,
            domComplete,
            nonInteraction: 1,
          })
        }, 0)
      }
    })
  })
}

// Track 15 second bounce rate
setTimeout(function() {
  analytics.track('time on page more than 15 seconds', {
    category: '15 Seconds',
    message: sd.CURRENT_PATH,
  })
}, 15000)

// Track 30 second bounce rate
setTimeout(function() {
  analytics.track('time on page more than 30 seconds', {
    category: '30 Seconds',
    message: sd.CURRENT_PATH,
  })
}, 30000)

// Track 1 min bounce rate
setTimeout(function() {
  analytics.track('time on page more than 1 minute', {
    category: '1 Minute',
    message: sd.CURRENT_PATH,
  })
}, 60000)

// Track 3 Minute bounce rate
setTimeout(function() {
  analytics.track('time on page more than 3 minutes', {
    category: '3 Minutes',
    message: sd.CURRENT_PATH,
  })
}, 180000)

// debug tracking calls in development
if (sd.NODE_ENV !== 'production') {
  analytics.on('track', function() {
    console.info('TRACKED: ', arguments[0], JSON.stringify(arguments[1]))
  })
}

if (sd.NODE_ENV === 'development') {
  analyticsHooks.on('all', function(name, data) {
    console.info('ANALYTICS HOOK: ', name, data)
  })
}

{'fraction_non_alphanumeric': 0.13699360341151387, 'fraction_numerical': 0.019189765458422176, 'mean_word_length': 2.7380478087649402, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1769859', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1168, 'n_words': 301}