<commit_before>var portal = require('/lib/xp/portal');
var thymeleaf = require('/lib/xp/thymeleaf');

function handleGet(req) {
    var content = portal.getContent();
    var serviceUrl = req.baseUrl + content._path + "/_/rest/google-analytics/authenticate";
    var view = resolve('ga-report.html');

    var params = {
        serviceUrl: serviceUrl
    };

    return {
        contentType: 'text/html',
        body: thymeleaf.render(view, params),
        pageContributions: {
            bodyEnd: [
                '<script src="' + portal.assetUrl({path: 'js/embed-api.js'}) + '" type="text/javascript"></script>',
                '<script src="' + portal.assetUrl({path: 'js/google-analytics.js'}) + '" type="text/javascript" serviceurl="' + serviceUrl + '"></script>'
            ]
        }<commit_msg>XP-1073 GA - Call authentication service to get access token * Proper way to resolve REST service url<commit_after>var portal = require('/lib/xp/portal');
var thymeleaf = require('/lib/xp/thymeleaf');

function handleGet(req) {
    var serviceUrl = portal.restServiceUrl({
        path: 'google-analytics/authenticate'
    });
    var view = resolve('ga-report.html');

    return {
        contentType: 'text/html',
        body: thymeleaf.render(view, {}),
        pageContributions: {
            bodyEnd: [
                '<script src="' + portal.assetUrl({path: 'js/embed-api.js'}) + '" type="text/javascript"></script>',
                '<script src="' + portal.assetUrl({path: 'js/google-analytics.js'}) + '" type="text/javascript" serviceurl="' + serviceUrl + '"></script>'
            ]
        }
{'fraction_non_alphanumeric': 0.1681087762669963, 'fraction_numerical': 0.002472187886279357, 'mean_word_length': 2.730414746543779, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6435877', 'n_tokens_mistral': 495, 'n_tokens_neox': 476, 'n_words': 95}