import set from 'lib/set'
import query from 'lib/query'
import config, { getId } from './config'
import { getTracker } from './helpers'

export default function createTrackers () {
  const ids = getId()

  ids.forEach(function (id) {
    const name = getTracker(id)
    const options = ids.length > 1 ? { ...config.fields, name } : config.fields

    window.ga('create', id, 'auto', options)
  })

  config.beforeFirstHit()

  if (config.linkers.length > 0) {
    query('require', 'linker')
    query('linker:autoLink', config.linkers)
  }

  if (!config.debug.sendHitTask) {
    set('sendHitTask', null)
  }
}

@@ -197,16 +197,113 @@
 etId()%0A%0A
+  if (config.debug.enabled) %7B%0A    window.ga_debug = %7B%0A      trace: config.debug.trace%0A    %7D%0A  %7D%0A%0A
   ids.fo

add trace check in the create-tracker method