@guardian/ophan-tracker-js 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/adblock-detection.js +24 -0
- package/build/attention.js +149 -0
- package/build/campaign.js +30 -0
- package/build/click-path-capture.js +81 -0
- package/build/components.js +167 -0
- package/build/contribution.js +25 -0
- package/build/core.js +234 -0
- package/build/embed.js +11 -0
- package/build/fb-instant.js +10 -0
- package/build/heatmap.js +32 -0
- package/build/holidays.js +11 -0
- package/build/http-status.js +20 -0
- package/build/iframe-tracking.js +68 -0
- package/build/interactive.js +25 -0
- package/build/jobs-courses.js +11 -0
- package/build/jobs.js +11 -0
- package/build/manage-my-account.js +47 -0
- package/build/membership.js +25 -0
- package/build/ng.js +33 -0
- package/build/perf.js +39 -0
- package/build/privatebrowsing.js +71 -0
- package/build/r2.js +24 -0
- package/build/smart-news.js +19 -0
- package/build/support.js +41 -0
- package/build/transmit.js +107 -0
- package/build/vendor/adBlockDetectionLib.js +367 -0
- package/build/visibility.js +7 -0
- package/build/witness.js +11 -0
- package/package.json +26 -0
- package/readme.md +95 -0
package/build/core.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Using an old-fashioned way of finding a query param rather than using searchParams
|
|
5
|
+
as we don't control which environments the CDN distribution is being used in and so don't know if it's supported.
|
|
6
|
+
*/
|
|
7
|
+
var MaximumComponentNameLength, VERSION, appendComponentDataToEvent, appendContentType, appendDataFromLocalStorageToEvent, canStoreEventsInLocalStorage, doc, getNavigationType, getQueryParameterValue, getReferrer, init, onLoadCapture, onLoadCaptures, platform, sendInitialEvent, storeDataToSendOnNextEvent, trimComponentNamesToUrlSafeLength,
|
|
8
|
+
hasProp = {}.hasOwnProperty;
|
|
9
|
+
|
|
10
|
+
import transmit from './transmit.js';
|
|
11
|
+
|
|
12
|
+
import visibility from './visibility.js';
|
|
13
|
+
|
|
14
|
+
import adblockDetection from './adblock-detection.js';
|
|
15
|
+
|
|
16
|
+
VERSION = 17;
|
|
17
|
+
|
|
18
|
+
doc = window.document;
|
|
19
|
+
|
|
20
|
+
canStoreEventsInLocalStorage = (window.localStorage != null) && (typeof JSON !== "undefined" && JSON !== null);
|
|
21
|
+
|
|
22
|
+
platform = null;
|
|
23
|
+
|
|
24
|
+
MaximumComponentNameLength = 50;
|
|
25
|
+
|
|
26
|
+
init = function(servingPlatform, httpStatus) {
|
|
27
|
+
platform = servingPlatform;
|
|
28
|
+
if (visibility.state() !== 'prerender') {
|
|
29
|
+
return sendInitialEvent(httpStatus);
|
|
30
|
+
} else {
|
|
31
|
+
if (visibility.changeEvent) {
|
|
32
|
+
return doc.addEventListener(visibility.changeEvent, (function() {
|
|
33
|
+
if (visibility.state() === "visible") {
|
|
34
|
+
return sendInitialEvent(httpStatus);
|
|
35
|
+
}
|
|
36
|
+
}), false);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
getQueryParameterValue = function(paramName) {
|
|
42
|
+
var i, keyValue, len, param, queryParams, queryString;
|
|
43
|
+
queryString = window.location.search.substring(1);
|
|
44
|
+
queryParams = queryString.split('&');
|
|
45
|
+
for (i = 0, len = queryParams.length; i < len; i++) {
|
|
46
|
+
param = queryParams[i];
|
|
47
|
+
keyValue = param.split('=');
|
|
48
|
+
if (keyValue[0] === paramName) {
|
|
49
|
+
return decodeURIComponent(keyValue[1]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
getReferrer = function(referrer) {
|
|
55
|
+
var ref;
|
|
56
|
+
if (referrer) {
|
|
57
|
+
return referrer;
|
|
58
|
+
} else {
|
|
59
|
+
/*
|
|
60
|
+
If an authentication flow takes place on page load, the referrer is lost.
|
|
61
|
+
So, if no referrer, fall back to query param holding the value of the referrer before the auth flow began.
|
|
62
|
+
See
|
|
63
|
+
https://github.com/guardian/support-frontend/blob/main/support-frontend/app/controllers/AuthCodeFlowController.scala#L105
|
|
64
|
+
for an example use.
|
|
65
|
+
*/
|
|
66
|
+
return (ref = getQueryParameterValue('pre-auth-ref')) != null ? ref : '';
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
getNavigationType = function() {
|
|
71
|
+
var entries, ref;
|
|
72
|
+
if (((ref = window.performance) != null ? ref.getEntriesByType : void 0) != null) {
|
|
73
|
+
entries = window.performance.getEntriesByType("navigation");
|
|
74
|
+
if (entries.length > 0) {
|
|
75
|
+
return entries[0].type;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
sendInitialEvent = function(httpStatus, url = location.href, referrer = window.document.referrer) {
|
|
82
|
+
var event, navigationType;
|
|
83
|
+
navigationType = getNavigationType();
|
|
84
|
+
// send initial event
|
|
85
|
+
event = {
|
|
86
|
+
v: VERSION,
|
|
87
|
+
platform: platform,
|
|
88
|
+
url: url,
|
|
89
|
+
ref: getReferrer(referrer),
|
|
90
|
+
visibilityState: visibility.state(),
|
|
91
|
+
isModernBrowser: typeof guardian !== "undefined" && guardian !== null ? guardian.isModernBrowser : void 0,
|
|
92
|
+
httpStatus: httpStatus,
|
|
93
|
+
tz: new Date().getTimezoneOffset()
|
|
94
|
+
};
|
|
95
|
+
if (navigationType != null) {
|
|
96
|
+
// Add navigation type as metadata to the event if it's not null
|
|
97
|
+
event.navigationType = navigationType;
|
|
98
|
+
}
|
|
99
|
+
appendContentType(event);
|
|
100
|
+
appendDataFromLocalStorageToEvent(event);
|
|
101
|
+
transmit.sendInitial(event);
|
|
102
|
+
return adblockDetection.run().then(function(adBlockerEnabled) {
|
|
103
|
+
// `adUnitWasHidden` is the query param used
|
|
104
|
+
// by the previous adblock detection, hence reusing it here.
|
|
105
|
+
return transmit.sendMore({
|
|
106
|
+
adUnitWasHidden: adBlockerEnabled
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
onLoadCaptures = [];
|
|
112
|
+
|
|
113
|
+
onLoadCapture = function(dataCapture) {
|
|
114
|
+
var d, key, msg, val;
|
|
115
|
+
if (document.readyState === 'complete') {
|
|
116
|
+
msg = {};
|
|
117
|
+
d = dataCapture();
|
|
118
|
+
for (key in d) {
|
|
119
|
+
val = d[key];
|
|
120
|
+
msg[key] = val;
|
|
121
|
+
}
|
|
122
|
+
return transmit.sendMore(msg);
|
|
123
|
+
} else {
|
|
124
|
+
return onLoadCaptures.push(dataCapture);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
if (typeof window.addEventListener === "function") {
|
|
129
|
+
window.addEventListener('load', function() {
|
|
130
|
+
var capture, d, i, key, len, msg, val;
|
|
131
|
+
msg = {};
|
|
132
|
+
for (i = 0, len = onLoadCaptures.length; i < len; i++) {
|
|
133
|
+
capture = onLoadCaptures[i];
|
|
134
|
+
d = capture();
|
|
135
|
+
for (key in d) {
|
|
136
|
+
val = d[key];
|
|
137
|
+
msg[key] = val;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (platform === "next-gen") {
|
|
141
|
+
appendComponentDataToEvent(msg);
|
|
142
|
+
}
|
|
143
|
+
return transmit.sendMore(msg);
|
|
144
|
+
}, false);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
appendDataFromLocalStorageToEvent = function(event) {
|
|
148
|
+
var key, localStorageItems, value;
|
|
149
|
+
if (canStoreEventsInLocalStorage) {
|
|
150
|
+
localStorageItems = JSON.parse(window.localStorage.getItem("ophan_follow"));
|
|
151
|
+
if (localStorageItems != null) {
|
|
152
|
+
for (key in localStorageItems) {
|
|
153
|
+
if (!hasProp.call(localStorageItems, key)) continue;
|
|
154
|
+
value = localStorageItems[key];
|
|
155
|
+
event[key] = value;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return window.localStorage.removeItem("ophan_follow");
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
trimComponentNamesToUrlSafeLength = function(componentNames) {
|
|
163
|
+
return componentNames.map(function(componentName) {
|
|
164
|
+
if (componentName.length > MaximumComponentNameLength) {
|
|
165
|
+
return componentName.substring(0, MaximumComponentNameLength).concat("…");
|
|
166
|
+
} else {
|
|
167
|
+
return componentName;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
appendComponentDataToEvent = function(event) {
|
|
173
|
+
var componentNames, el, i, key, len, obj, trimmedComponentNames, value;
|
|
174
|
+
componentNames = (function() {
|
|
175
|
+
var i, len, ref, results;
|
|
176
|
+
ref = document.querySelectorAll('[data-component]');
|
|
177
|
+
results = [];
|
|
178
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
|
179
|
+
el = ref[i];
|
|
180
|
+
results.push(el.getAttribute('data-component'));
|
|
181
|
+
}
|
|
182
|
+
return results;
|
|
183
|
+
})();
|
|
184
|
+
if (componentNames.length > 0) {
|
|
185
|
+
trimmedComponentNames = trimComponentNamesToUrlSafeLength(componentNames);
|
|
186
|
+
// uniquify
|
|
187
|
+
obj = {};
|
|
188
|
+
for (i = 0, len = trimmedComponentNames.length; i < len; i++) {
|
|
189
|
+
el = trimmedComponentNames[i];
|
|
190
|
+
(obj[el] = 1);
|
|
191
|
+
}
|
|
192
|
+
return event.renderedComponents = (function() {
|
|
193
|
+
var results;
|
|
194
|
+
results = [];
|
|
195
|
+
for (key in obj) {
|
|
196
|
+
value = obj[key];
|
|
197
|
+
results.push(key);
|
|
198
|
+
}
|
|
199
|
+
return results;
|
|
200
|
+
})();
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
storeDataToSendOnNextEvent = function(newData) {
|
|
205
|
+
var existingData, key, value;
|
|
206
|
+
if (canStoreEventsInLocalStorage) {
|
|
207
|
+
existingData = JSON.parse(window.localStorage.getItem("ophan_follow")) || {};
|
|
208
|
+
for (key in newData) {
|
|
209
|
+
if (!hasProp.call(newData, key)) continue;
|
|
210
|
+
value = newData[key];
|
|
211
|
+
existingData[key] = value;
|
|
212
|
+
}
|
|
213
|
+
return window.localStorage.setItem("ophan_follow", JSON.stringify(existingData));
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
appendContentType = function(event) {
|
|
218
|
+
var contentType, ref, ref1, ref2;
|
|
219
|
+
contentType = platform === "next-gen" || "embed" ? typeof guardian !== "undefined" && guardian !== null ? (ref = guardian.config) != null ? (ref1 = ref.page) != null ? ref1.contentType : void 0 : void 0 : void 0 : typeof guardian !== "undefined" && guardian !== null ? (ref2 = guardian.page) != null ? ref2.contentTypes : void 0 : void 0;
|
|
220
|
+
if ((contentType != null) && contentType !== "") {
|
|
221
|
+
return event.contentType = contentType.toLowerCase();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export default {
|
|
226
|
+
init: init,
|
|
227
|
+
storeDataToSendOnNextEvent: storeDataToSendOnNextEvent,
|
|
228
|
+
onLoadCapture: onLoadCapture,
|
|
229
|
+
servingPlatform: function() {
|
|
230
|
+
return platform;
|
|
231
|
+
},
|
|
232
|
+
viewId: transmit.viewId,
|
|
233
|
+
sendInitialEvent: sendInitialEvent
|
|
234
|
+
};
|
package/build/embed.js
ADDED
package/build/heatmap.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
var heatmapFired, init;
|
|
3
|
+
|
|
4
|
+
heatmapFired = false;
|
|
5
|
+
|
|
6
|
+
init = function() {
|
|
7
|
+
var addHeatmap;
|
|
8
|
+
addHeatmap = function() {
|
|
9
|
+
var heatmapParam;
|
|
10
|
+
if ((typeof localStorage !== "undefined" && localStorage !== null) && !heatmapFired) {
|
|
11
|
+
heatmapFired = true;
|
|
12
|
+
heatmapParam = window.location.search.replace(/^(?:.*[&\?]heatmap(?:\=([^&]*))?)?.*$/, "$1");
|
|
13
|
+
if (heatmapParam === 'true' || heatmapParam === 'false') {
|
|
14
|
+
localStorage['ophan_heatmap'] = heatmapParam;
|
|
15
|
+
}
|
|
16
|
+
if (localStorage['ophan_heatmap'] === 'true' || heatmapParam === 'show') {
|
|
17
|
+
return document.body.appendChild(document.createElement('script')).src = '//dashboard.ophan.co.uk/assets/js/heatmap-bookmarklet.js';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
if (document.readyState === 'complete') {
|
|
22
|
+
return addHeatmap();
|
|
23
|
+
} else {
|
|
24
|
+
return typeof window.addEventListener === "function" ? window.addEventListener('load', function() {
|
|
25
|
+
return addHeatmap();
|
|
26
|
+
}, false) : void 0;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
init: init
|
|
32
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
var reportStatus;
|
|
3
|
+
|
|
4
|
+
import core from "./core.js";
|
|
5
|
+
|
|
6
|
+
import "./transmit.js";
|
|
7
|
+
|
|
8
|
+
import "./click-path-capture.js";
|
|
9
|
+
|
|
10
|
+
import "./perf.js";
|
|
11
|
+
|
|
12
|
+
import "./campaign.js";
|
|
13
|
+
|
|
14
|
+
reportStatus = function(platform, status) {
|
|
15
|
+
return core.init(platform, status);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
reportStatus: reportStatus
|
|
20
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
var componentEventIsValid, handleIframeMessage, recordIframeClickEvent, recordIframeComponentEvent, retrieveOriginDomain, validIframeDomains;
|
|
3
|
+
|
|
4
|
+
import clickCapture from "./click-path-capture.js";
|
|
5
|
+
|
|
6
|
+
validIframeDomains = [
|
|
7
|
+
".theguardian.com",
|
|
8
|
+
".dev-theguardian.com",
|
|
9
|
+
".thegulocal.com" // NB - leading dot is essential here to avoid matching on non-Guardian-owned domains
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
handleIframeMessage = function(messageEvent) {
|
|
13
|
+
var eventObject, iFrame, originDomain;
|
|
14
|
+
originDomain = retrieveOriginDomain(messageEvent.origin);
|
|
15
|
+
if (originDomain && validIframeDomains.some((domain) => {
|
|
16
|
+
return originDomain.endsWith(domain);
|
|
17
|
+
})) {
|
|
18
|
+
if (messageEvent.data.type === 'ophan-iframe-click-event') {
|
|
19
|
+
eventObject = messageEvent.data.value;
|
|
20
|
+
iFrame = document.getElementById(messageEvent.data.iframeId);
|
|
21
|
+
recordIframeClickEvent(iFrame, eventObject);
|
|
22
|
+
} else if (messageEvent.data.type === 'ophan-iframe-component-event') {
|
|
23
|
+
eventObject = messageEvent.data.value;
|
|
24
|
+
recordIframeComponentEvent(eventObject);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
retrieveOriginDomain = function(eventOrigin) {
|
|
30
|
+
var e, originURL;
|
|
31
|
+
try {
|
|
32
|
+
originURL = new URL(eventOrigin);
|
|
33
|
+
return originURL.host;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
e = error;
|
|
36
|
+
if (e instanceof TypeError) { // We failed to parse origin as an URL, we should ignore the event
|
|
37
|
+
return null;
|
|
38
|
+
} else {
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
recordIframeClickEvent = function(iFrame, clickEvent) {
|
|
45
|
+
if (iFrame) {
|
|
46
|
+
clickEvent.clickLinkNames = clickCapture.getDataLinkNames(iFrame, clickEvent.clickLinkNames) || clickEvent.clickLinkNames;
|
|
47
|
+
}
|
|
48
|
+
window.guardian.ophan.record(clickEvent);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
componentEventIsValid = function(eventObject) {
|
|
52
|
+
if (!eventObject || typeof eventObject !== 'object') {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (!eventObject.componentEvent || typeof eventObject.componentEvent !== 'object') {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
recordIframeComponentEvent = function(eventObject) {
|
|
62
|
+
if (!componentEventIsValid(eventObject)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
window.guardian.ophan.record(eventObject);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
window.addEventListener('message', handleIframeMessage, false);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
var ref;
|
|
3
|
+
|
|
4
|
+
import core from "./core.js";
|
|
5
|
+
|
|
6
|
+
import transmit from "./transmit.js";
|
|
7
|
+
|
|
8
|
+
import attention from "./attention.js";
|
|
9
|
+
|
|
10
|
+
import "./click-path-capture.js";
|
|
11
|
+
|
|
12
|
+
if (((ref = window.guardian) != null ? ref.ophan : void 0) != null) {
|
|
13
|
+
window.guardian.ophan;
|
|
14
|
+
} else {
|
|
15
|
+
core.init("embed");
|
|
16
|
+
if (window.guardian == null) {
|
|
17
|
+
window.guardian = {};
|
|
18
|
+
}
|
|
19
|
+
window.guardian.ophan = {
|
|
20
|
+
setEventEmitter: attention.setEventEmitter,
|
|
21
|
+
trackComponentAttention: attention.initComponent,
|
|
22
|
+
record: transmit.sendMore,
|
|
23
|
+
viewId: transmit.viewId
|
|
24
|
+
};
|
|
25
|
+
}
|
package/build/jobs.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
var exports, sendInitialEvent;
|
|
3
|
+
|
|
4
|
+
import core from "./core.js";
|
|
5
|
+
|
|
6
|
+
import transmit from "./transmit.js";
|
|
7
|
+
|
|
8
|
+
import attention from "./attention.js";
|
|
9
|
+
|
|
10
|
+
import visibility from "./visibility.js";
|
|
11
|
+
|
|
12
|
+
import "./click-path-capture.js";
|
|
13
|
+
|
|
14
|
+
import "./perf.js";
|
|
15
|
+
|
|
16
|
+
import "./campaign.js";
|
|
17
|
+
|
|
18
|
+
core.init("manage-my-account");
|
|
19
|
+
|
|
20
|
+
if (window.addEventListener != null) {
|
|
21
|
+
attention.init(visibility);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
sendInitialEvent = function(url = location.href, referrer = window.document.referrer) {
|
|
25
|
+
var e;
|
|
26
|
+
try {
|
|
27
|
+
transmit.bumpViewId();
|
|
28
|
+
return core.sendInitialEvent(null, url, referrer);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
e = error;
|
|
31
|
+
return console.log(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports = {
|
|
36
|
+
sendInitialEvent: sendInitialEvent,
|
|
37
|
+
record: transmit.sendMore,
|
|
38
|
+
viewId: transmit.viewId
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
if (window.guardian == null) {
|
|
42
|
+
window.guardian = {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
window.guardian.ophan = exports;
|
|
46
|
+
|
|
47
|
+
export default exports;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
import core from "./core.js";
|
|
3
|
+
|
|
4
|
+
import transmit from "./transmit.js";
|
|
5
|
+
|
|
6
|
+
import attention from "./attention.js";
|
|
7
|
+
|
|
8
|
+
import visibility from "./visibility.js";
|
|
9
|
+
|
|
10
|
+
import "./click-path-capture.js";
|
|
11
|
+
|
|
12
|
+
import "./perf.js";
|
|
13
|
+
|
|
14
|
+
import "./campaign.js";
|
|
15
|
+
|
|
16
|
+
core.init("membership");
|
|
17
|
+
|
|
18
|
+
if (window.addEventListener != null) {
|
|
19
|
+
attention.init(visibility);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
record: transmit.sendMore,
|
|
24
|
+
viewId: transmit.viewId
|
|
25
|
+
};
|
package/build/ng.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
var ng, ref;
|
|
3
|
+
|
|
4
|
+
import core from "./core.js";
|
|
5
|
+
|
|
6
|
+
import transmit from "./transmit.js";
|
|
7
|
+
|
|
8
|
+
import attention from "./attention.js";
|
|
9
|
+
|
|
10
|
+
import visibility from "./visibility.js";
|
|
11
|
+
|
|
12
|
+
import privatebrowsing from "./privatebrowsing.js";
|
|
13
|
+
|
|
14
|
+
import heatmap from "./heatmap.js";
|
|
15
|
+
|
|
16
|
+
import "./click-path-capture.js";
|
|
17
|
+
|
|
18
|
+
import "./perf.js";
|
|
19
|
+
|
|
20
|
+
import "./iframe-tracking.js";
|
|
21
|
+
|
|
22
|
+
// TODO:
|
|
23
|
+
// pageViewId is used for Google Analytics on frontend, membership and some of the jobs sites.
|
|
24
|
+
// If we can migrate these to use viewId instead then pageViewId can safely be removed
|
|
25
|
+
ng = ((ref = window.guardian) != null ? ref.ophan : void 0) != null ? window.guardian.ophan : (core.init("next-gen"), privatebrowsing.init(), heatmap.init(), window.addEventListener != null ? attention.init(visibility) : void 0, window.guardian != null ? window.guardian : window.guardian = {}, window.guardian.ophan = {
|
|
26
|
+
setEventEmitter: attention.setEventEmitter,
|
|
27
|
+
trackComponentAttention: attention.initComponent,
|
|
28
|
+
record: transmit.sendMore,
|
|
29
|
+
viewId: transmit.viewId,
|
|
30
|
+
pageViewId: transmit.viewId
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export default ng;
|
package/build/perf.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
var perf, sendTimingData;
|
|
3
|
+
|
|
4
|
+
import core from './core.js';
|
|
5
|
+
|
|
6
|
+
perf = window.performance || window.msPerformance || window.webkitPerformance || window.mozPerformance;
|
|
7
|
+
|
|
8
|
+
sendTimingData = function() {
|
|
9
|
+
var t;
|
|
10
|
+
t = perf != null ? perf.timing : void 0;
|
|
11
|
+
if (t != null) {
|
|
12
|
+
return {
|
|
13
|
+
performance: {
|
|
14
|
+
// Time required for domain lookup.
|
|
15
|
+
dns: t.domainLookupEnd - t.domainLookupStart,
|
|
16
|
+
// Time to establish a connection to server.
|
|
17
|
+
connection: t.connectEnd - t.connectStart,
|
|
18
|
+
// From connection established to first byte of data.
|
|
19
|
+
firstByte: t.responseStart - t.connectEnd,
|
|
20
|
+
// First byte to last byte, or closed, including if from cache.
|
|
21
|
+
lastByte: t.responseEnd - t.responseStart,
|
|
22
|
+
// From last byte of doc to start of domContentLoaded
|
|
23
|
+
domContentLoadedEvent: t.domContentLoadedEventStart - t.responseEnd,
|
|
24
|
+
// domcontentLoaded to start of load event.
|
|
25
|
+
loadEvent: t.loadEventStart - t.domContentLoadedEventStart,
|
|
26
|
+
// click, back/forward, etc...
|
|
27
|
+
navType: perf.navigation.type,
|
|
28
|
+
// No. of redirects on current domain.
|
|
29
|
+
redirectCount: perf.navigation.redirectCount
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
} else {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
core.onLoadCapture(sendTimingData);
|
|
38
|
+
|
|
39
|
+
export default perf;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
// Check if a visitor is using private browsing mode (true or false)
|
|
3
|
+
// User agent checking and browser mode checking based on: https://gist.github.com/cou929/7973956#gistcomment-1769682
|
|
4
|
+
var privateBrowsingMode;
|
|
5
|
+
|
|
6
|
+
import transmit from './transmit.js';
|
|
7
|
+
|
|
8
|
+
privateBrowsingMode = function(callback) {
|
|
9
|
+
var reportNormalMode, reportPrivateMode, tryIndexedDB, tryLocalStorage;
|
|
10
|
+
reportNormalMode = function() {
|
|
11
|
+
return callback(false);
|
|
12
|
+
};
|
|
13
|
+
reportPrivateMode = function() {
|
|
14
|
+
return callback(true);
|
|
15
|
+
};
|
|
16
|
+
tryLocalStorage = function() {
|
|
17
|
+
var error;
|
|
18
|
+
try {
|
|
19
|
+
if (localStorage.length) {
|
|
20
|
+
return reportNormalMode();
|
|
21
|
+
} else {
|
|
22
|
+
localStorage.x = 1;
|
|
23
|
+
localStorage.removeItem('x');
|
|
24
|
+
return reportNormalMode();
|
|
25
|
+
}
|
|
26
|
+
} catch (error1) {
|
|
27
|
+
error = error1;
|
|
28
|
+
return reportPrivateMode();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
tryIndexedDB = function() {
|
|
32
|
+
var db, error;
|
|
33
|
+
try {
|
|
34
|
+
db = indexedDB.open('test');
|
|
35
|
+
db.onsuccess = reportNormalMode;
|
|
36
|
+
return db.onerror = reportPrivateMode;
|
|
37
|
+
} catch (error1) {
|
|
38
|
+
error = error1;
|
|
39
|
+
return reportPrivateMode();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Blink
|
|
44
|
+
if (window.webkitRequestFileSystem) {
|
|
45
|
+
return window.webkitRequestFileSystem(window.TEMPORARY, 1, reportNormalMode, reportPrivateMode);
|
|
46
|
+
// Firefox
|
|
47
|
+
} else if ('MozAppearance' in document.documentElement.style) {
|
|
48
|
+
return tryIndexedDB();
|
|
49
|
+
// Safari
|
|
50
|
+
} else if (/constructor/i.test(window.HTMLElement)) {
|
|
51
|
+
return tryLocalStorage();
|
|
52
|
+
} else if (!window.indexedDB && (window.PointerEvent || window.MSPointerEvent)) {
|
|
53
|
+
return reportPrivateMode();
|
|
54
|
+
} else {
|
|
55
|
+
// Rest
|
|
56
|
+
return reportNormalMode();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
init: function() {
|
|
62
|
+
return privateBrowsingMode(function(value) {
|
|
63
|
+
var report;
|
|
64
|
+
report = {
|
|
65
|
+
inPrivateBrowsingMode: value
|
|
66
|
+
};
|
|
67
|
+
return transmit.sendMore(report);
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
privateBrowsingMode: privateBrowsingMode
|
|
71
|
+
};
|
package/build/r2.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.7.0
|
|
2
|
+
import core from './core.js';
|
|
3
|
+
|
|
4
|
+
import transmit from './transmit.js';
|
|
5
|
+
|
|
6
|
+
import attention from './attention.js';
|
|
7
|
+
|
|
8
|
+
import visibility from './visibility.js';
|
|
9
|
+
|
|
10
|
+
import './click-path-capture.js';
|
|
11
|
+
|
|
12
|
+
import './perf.js';
|
|
13
|
+
|
|
14
|
+
import './campaign.js';
|
|
15
|
+
|
|
16
|
+
core.init("r2");
|
|
17
|
+
|
|
18
|
+
if (window.addEventListener != null) {
|
|
19
|
+
attention.init(visibility);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
viewId: transmit.viewId
|
|
24
|
+
};
|