Revert "Track event when someone previews basic view"

This reverts commit 77d96032bf.
This commit is contained in:
Chris Hill-Scott
2018-08-08 08:49:16 +01:00
parent 6a06d4d714
commit 7b1d4136bf
6 changed files with 30 additions and 71 deletions

View File

@@ -1,56 +0,0 @@
let stripUUIDs = string => string.replace(
/[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}/g, '…'
);
(function(Modules) {
"use strict";
function sendEvent(category, action, label) {
if (!ga) return;
ga('send', 'event', category, action, label);
}
function sendVirtualPageView(path) {
if (!ga) return;
ga('send', 'pageview', stripUUIDs('/virtual' + path));
}
Modules.TrackError = function() {
this.start = component => sendEvent(
'Error',
$(component).data('error-type'),
$(component).data('error-label')
);
};
Modules.TrackEvent = function() {
this.start = component => sendEvent(
$(component).data('event-category'),
$(component).data('event-action'),
$(component).data('event-label')
);
};
Modules.TrackFormSubmission = function() {
this.start = component => {
$(component).on('submit', function() {
let formData = $('input[name!=csrf_token]', this).serialize();
sendVirtualPageView(window.location.pathname + '?' + formData);
});
};
};
})(window.GOVUK.Modules);

View File

@@ -0,0 +1,22 @@
(function(Modules) {
"use strict";
Modules.TrackError = function() {
this.start = function(component) {
if (!ga) return;
ga(
'send',
'event',
'Error',
$(component).data('error-type'),
$(component).data('error-label')
);
};
};
})(window.GOVUK.Modules);

View File

@@ -128,7 +128,10 @@
ga('set', 'anonymizeIp', true);
ga('set', 'displayFeaturesTask', null);
ga('set', 'transport', 'beacon');
page = window.location.pathname + window.location.search;
ga('send', 'pageview', stripUUIDs(page));
// strip UUIDs
page = (window.location.pathname + window.location.search).replace(
/[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}/g, '…'
)
ga('send', 'pageview', page);
</script>
{% endblock %}

View File

@@ -9,11 +9,7 @@
{% block maincolumn_content %}
<div class="grid-row">
<form
method="post"
class="column-five-sixths"
data-module="track-form-submission"
>
<form method="post" class="column-five-sixths">
<h1 class="heading-large">Basic view</h1>
<p>
Hide the dashboard and other options from team members who only need to send messages.

View File

@@ -10,13 +10,7 @@
<div class="navigation-service-name">
{{ current_service.name }}
{% if current_user.previewing_basic_view %}
<span
class="navigation-service-basic-view-preview"
data-module="track-event"
data-event-category="basic-view"
data-event-action="preview"
data-event-label="{{ current_service.id }}"
>Preview of basic view</span>
<span class="navigation-service-basic-view-preview">Preview of basic view</span>
<a class="navigation-service-basic-view-back-link" href="{{ url_for('main.service_set_basic_view', service_id=current_service.id)}}">Back to settings</a>
{% endif %}
</div>

View File

@@ -70,7 +70,7 @@ gulp.task('javascripts', () => gulp
paths.src + 'javascripts/updateContent.js',
paths.src + 'javascripts/listEntry.js',
paths.src + 'javascripts/liveSearch.js',
paths.src + 'javascripts/analytics.js',
paths.src + 'javascripts/errorTracking.js',
paths.src + 'javascripts/preventDuplicateFormSubmissions.js',
paths.src + 'javascripts/fullscreenTable.js',
paths.src + 'javascripts/conditionalRadios.js',