<commit_before>{{--<script type="text/javascript">--}}

var bannerId = 'b-{{ $banner->uuid }}';
var scripts = [];
if (typeof window.remplib.banner === 'undefined') {
    scripts.push('{{ asset(mix('/js/banner.js', '/assets/lib')) }}');
}

var styles = [];

var waiting = scripts.length + styles.length;
var run = function() {
    if (waiting) {
        return;
    }
    var alignments = JSON.parse('{!! json_encode($alignments) !!}');
    var dimensions = JSON.parse('{!! json_encode($dimensions) !!}');
    var positions = JSON.parse('{!! json_encode($positions) !!}');
    var banner = remplib.banner.fromModel({!! $banner->toJson() !!});

    banner.show = false;
    banner.alignmentOptions = alignments;
    banner.dimensionOptions = dimensions;
    banner.positionOptions = positions;

    banner.uuid = "{{ $banner->uuid }}";
    banner.campaignUuid = "{{ $campaign->uuid }}";
    remplib.campaign.storeCampaignDetails('{{ $campaign->uuid }}', '{{ $banner->uuid }}');

    var d = document.createElement('div');
    d.id = bannerId;
    var bp = document.createElement('banner-preview');
    d.appendChild(bp);

    var target = null;
    if (banner.displayType == 'inline') {
        target = document.querySelector(banner.targetSelector);
        if (target === null) {
            console.warn("REMP: unable to display banner, selector not matched: " + banner.targetSelector);
            return;
        }
    } else {
        target = document.getElementsByTagName('body')[0];
    }
    target.appendChild(d);

    remplib.banner.bindPreview('#' + bannerId, banner);

    setTimeout(function() {
        remplib.tracker.trackEvent("banner", "show", {
            "utm_source": "remp_campaign",
            "utm_medium": banner.displayType,
            "utm_campaign": banner.campaignUuid,
            "utm_content": banner.uuid
        })
        banner.show = true;
        if (banner.closeTimeout) {
            setTimeout(function() {
                banner.show = false;
            }, banner.closeTimeout);
        }
    }, banner.displayDelay);
};

for (var i=0; i<scripts.length; i++) {
    remplib.loadScript(scripts[i], function() {
        waiting -= 1;
        run();<commit_msg>Moving campaign banner tracking to state where user actually sees the banner<commit_after>{{--<script type="text/javascript">--}}

var bannerId = 'b-{{ $banner->uuid }}';
var scripts = [];
if (typeof window.remplib.banner === 'undefined') {
    scripts.push('{{ asset(mix('/js/banner.js', '/assets/lib')) }}');
}

var styles = [];

var waiting = scripts.length + styles.length;
var run = function() {
    if (waiting) {
        return;
    }
    var alignments = JSON.parse('{!! json_encode($alignments) !!}');
    var dimensions = JSON.parse('{!! json_encode($dimensions) !!}');
    var positions = JSON.parse('{!! json_encode($positions) !!}');
    var banner = remplib.banner.fromModel({!! $banner->toJson() !!});

    banner.show = false;
    banner.alignmentOptions = alignments;
    banner.dimensionOptions = dimensions;
    banner.positionOptions = positions;

    banner.uuid = "{{ $banner->uuid }}";
    banner.campaignUuid = "{{ $campaign->uuid }}";

    var d = document.createElement('div');
    d.id = bannerId;
    var bp = document.createElement('banner-preview');
    d.appendChild(bp);

    var target = null;
    if (banner.displayType == 'inline') {
        target = document.querySelector(banner.targetSelector);
        if (target === null) {
            console.warn("REMP: unable to display banner, selector not matched: " + banner.targetSelector);
            return;
        }
    } else {
        target = document.getElementsByTagName('body')[0];
    }
    target.appendChild(d);

    remplib.banner.bindPreview('#' + bannerId, banner);

    setTimeout(function() {
        remplib.tracker.trackEvent("banner", "show", {
            "utm_source": "remp_campaign",
            "utm_medium": banner.displayType,
            "utm_campaign": banner.campaignUuid,
            "utm_content": banner.uuid
        })
        banner.show = true;
        if (banner.closeTimeout) {
            setTimeout(function() {
                banner.show = false;
            }, banner.closeTimeout);
        }
        remplib.campaign.storeCampaignDetails('{{ $campaign->uuid }}', '{{ $banner->uuid }}');
    }, banner.displayDelay);
};

for (var i=0; i<scripts.length; i++) {
    remplib.loadScript(scripts[i], function() {
        waiting -= 1;
        run();
{'fraction_non_alphanumeric': 0.170355466130114, 'fraction_numerical': 0.0013413816230717639, 'mean_word_length': 2.804421768707483, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 17, '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': '819896', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1351, 'n_words': 260}