<commit_before>_    = require '../../utils/lodash'
qs   = require '../../utils/query-string-encoder'

pick = (prefix, obj) -> _.reduce obj, (m, v, k) ->
  m[k.replace(prefix,'')] = k if k.indexOf(prefix) == 0
  m

# Segment QueryString API compatibility layer
class QueryString
  constructor : (traits, tracker, alias, currentUser)->
    @alias = alias
    @currentUser = currentUser
    @traits = traits
    @track = track

    @parse()
    @pardot()

  getCurrentUserId: -> @currentUser.get('id')

  pardot: () =>
    ref = window.location.referrer
    return unless ref.indexOf("https://go.pardot.com")
    q = qs.decode(window.location.referrer.split('httpsRedirect?')[1])
    return unless _.size(q)
    @alias("pardot:#{q.visitor_id}") if q.visitor_id

  parse: () =>
    q = qs.decode()
    return unless _.size(q)

    { hjs_uid, hjs_event, hjs_aid } = q

    @alias(hjs_aid) if hjs_aid

    traits = pick('hjs_trait_', q)
    @traits(hjs_uid, traits) if _.size(traits)

    props = pick('hjs_prop_', q)
    @tracker.track(hjs_event, props) if hjs_event


module.exports = QueryString<commit_msg>remove stuff<commit_after>_    = require '../../utils/lodash'
qs   = require '../../utils/query-string-encoder'

pick = (prefix, obj) -> _.reduce obj, (m, v, k) ->
  m[k.replace(prefix,'')] = k if k.indexOf(prefix) == 0
  m

class QueryString
  constructor : (traits, tracker, alias, currentUser)->
    @alias = alias
    @currentUser = currentUser
    @traits = traits
    @track = track
    @parse()

  getCurrentUserId: -> @currentUser.get('id')

  parse: () =>
    q = qs.decode()
    return unless _.size(q)

    { hjs_uid, hjs_event, hjs_aid } = q

    @alias(hjs_aid) if hjs_aid

    traits = pick('hjs_trait_', q)
    @traits(hjs_uid, traits) if _.size(traits)

    props = pick('hjs_prop_', q)
    @tracker.track(hjs_event, props) if hjs_event


module.exports = QueryString
{'fraction_non_alphanumeric': 0.16110227874933758, 'fraction_numerical': 0.001589825119236884, 'mean_word_length': 3.1312910284463893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 1, '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': '2253059', 'n_tokens_mistral': 698, 'n_tokens_neox': 674, 'n_words': 154}