<commit_before>'use strict';

angular.module('ddsApp').service('ImpactStudyService', function($location, $http, $localStorage, $sessionStorage, $log, uuid) {
    var RESEARCH_DOMAIN = 'mes-droits.fr';  // this domain is owned by Poverty Lab researchers mandated by <NAME> and DGCS


    function getSessionId() {
        $sessionStorage.sessionId = $sessionStorage.sessionId || uuid.v4();
        return $sessionStorage.sessionId;
    }

    function resetSessionId() {
        $sessionStorage.sessionId = uuid.v4();
    }

    function getResearchId() {
        $localStorage.researchId = $localStorage.researchId || $location.search().eid;
        return $localStorage.researchId;
    }

    function send(path, payload) {
        if (! getResearchId())
            return;  // this research is based on controlled cohorts; track only users that have a valid research ID opt-in

        /*jshint camelcase: false */
        payload.session_id = getSessionId();
        payload.eid = getResearchId();

        $http.post('https://' + RESEARCH_DOMAIN + '/v1' + path, payload)
             .success(function(res) { $log.info('Data transmitted to researchers', res); })
             .error(function(error) { $log.warn('Data could not be transmitted to researchers', error); });
    }

    return {
        sendResults: function(situation, openfiscaResults) {
            var payload = angular.copy(openfiscaResults);
            payload.postcode = situation.logement.adresse.codePostal;

            send('/sr', payload);
        },

        sendPostCode: function(situation) {
            send('/cp', { postcode: situation.logement.adresse.codePostal });
        },

        sendVisitedPage: function() {
            /*jshint camelcase: false */
            send('/it', { url_visited: $location.absUrl() });
        },

        resetSessionId: resetSessionId
    };<commit_msg>Improve discovery of research domain<commit_after>'use strict';

angular.module('ddsApp').service('ImpactStudyService', function($location, $http, $localStorage, $sessionStorage, $log, uuid) {
    var RESEARCH_DOMAIN = 'mes-droits.fr';  // this domain is owned by Poverty Lab researchers mandated by <NAME> and DGCS


    function getSessionId() {
        $sessionStorage.sessionId = $sessionStorage.sessionId || uuid.v4();
        return $sessionStorage.sessionId;
    }

    function resetSessionId() {
        $sessionStorage.sessionId = uuid.v4();
    }

    function getResearchId() {
        $localStorage.researchId = $localStorage.researchId || $location.search().eid;
        return $localStorage.researchId;
    }

    function send(path, payload) {
        if (! getResearchId())
            return;  // this research is based on controlled cohorts; track only users that have a valid research ID opt-in

        /*jshint camelcase: false */
        payload.session_id = getSessionId();
        payload.eid = getResearchId();

        $http.post('https://' + RESEARCH_DOMAIN + '/v1' + path, payload)
             .success(function(res) { $log.info('Data transmitted to researchers. For more info, see ' + RESEARCH_DOMAIN, res); })
             .error(function(error) { $log.warn('Data could not be transmitted to researchers', error); });
    }

    return {
        sendResults: function(situation, openfiscaResults) {
            var payload = angular.copy(openfiscaResults);
            payload.postcode = situation.logement.adresse.codePostal;

            send('/sr', payload);
        },

        sendPostCode: function(situation) {
            send('/cp', { postcode: situation.logement.adresse.codePostal });
        },

        sendVisitedPage: function() {
            /*jshint camelcase: false */
            send('/it', { url_visited: $location.absUrl() });
        },

        resetSessionId: resetSessionId
    };
{'fraction_non_alphanumeric': 0.12558993183009964, 'fraction_numerical': 0.0015731515469323545, 'mean_word_length': 2.678881388621022, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3730718', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1051, 'n_words': 247}