<commit_before>define [
  'settings'
  'promise'
  'easyxdm'
  'biskoto'
  'helpers/url_helper'
], (Settings, Promise, easyXDM, Biskoto, URLHelper)->
  class Session
    constructor: ()->
      @easyXDM = easyXDM
      @promise = new Promise()

      @_cleanUpCookies()

      @analytics_session = @_getCookieAnalyticsSession()
      @yogurt_session = Biskoto.get(Settings.cookies.yogurt.name)

      if @analytics_session isnt null
        ## TODO: SHOULD BE RE-SET expires ATTRIBUTE IF COOKIE ALREADY EXISTS?
        @promise.resolve @analytics_session
      else
        @socket = @_createSocket @_socketUrl(@yogurt_session)
        @_getAnalyticsSession()

    then: (success, fail)-> @promise.then(success, fail)

    _getAnalyticsSession: ->
      Promise.all([
        @_extractIframe()
        @_extractGetParam()
      ]).then (results) =>
        analytics_session = results[0] or results[1]

        if analytics_session
          @_createFirstPartyCookie(analytics_session)<commit_msg>Force bypass of first party cookie only for the create 'analytics_session' phase<commit_after>define [
  'settings'
  'promise'
  'easyxdm'
  'biskoto'
  'helpers/url_helper'
], (Settings, Promise, easyXDM, Biskoto, URLHelper)->
  class Session
    constructor: ()->
      @easyXDM = easyXDM
      @promise = new Promise()

      @_cleanUpCookies()

      @analytics_session = @_getCookieAnalyticsSession()
      @yogurt_session = Biskoto.get(Settings.cookies.yogurt.name)

      # Always create third party cookie on analytics domain
      # if on create phase
      if @analytics_session isnt null and @yogurt_session is null
        ## TODO: SHOULD BE RE-SET expires ATTRIBUTE IF COOKIE ALREADY EXISTS?
        @promise.resolve @analytics_session
      else
        @socket = @_createSocket @_socketUrl(@yogurt_session)
        @_getAnalyticsSession()

    then: (success, fail)-> @promise.then(success, fail)

    _getAnalyticsSession: ->
      Promise.all([
        @_extractIframe()
        @_extractGetParam()
      ]).then (results) =>
        analytics_session = results[0] or results[1]

        if analytics_session
          @_createFirstPartyCookie(analytics_session)
{'fraction_non_alphanumeric': 0.1024345429490124, 'fraction_numerical': 0.0018373909049150207, 'mean_word_length': 3.0786516853932584, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '2052403', 'n_tokens_mistral': 707, 'n_tokens_neox': 678, 'n_words': 152}