@guardian/ophan-tracker-js 2.1.1 → 2.1.2-next.0
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/package.json +18 -8
- package/readme.md +98 -11
- package/assets/adblock-detection.js +0 -19
- package/assets/attention.js +0 -160
- package/assets/campaign.js +0 -25
- package/assets/click-path-capture.js +0 -80
- package/assets/components.js +0 -199
- package/assets/contribution.js +0 -25
- package/assets/core.js +0 -282
- package/assets/embed.js +0 -11
- package/assets/fb-instant.js +0 -10
- package/assets/heatmap.js +0 -53
- package/assets/holidays.js +0 -11
- package/assets/http-status.js +0 -13
- package/assets/iframe-tracking.js +0 -88
- package/assets/interactive.js +0 -17
- package/assets/jobs-courses.js +0 -11
- package/assets/jobs.js +0 -11
- package/assets/manage-my-account.js +0 -38
- package/assets/membership.js +0 -25
- package/assets/ng.js +0 -41
- package/assets/perf.js +0 -40
- package/assets/privatebrowsing.js +0 -71
- package/assets/r2.js +0 -24
- package/assets/smart-news.js +0 -19
- package/assets/support.js +0 -34
- package/assets/transmit.js +0 -143
- package/assets/vendor/adBlockDetectionLib.js +0 -366
- package/assets/visibility.js +0 -23
- package/assets/witness.js +0 -11
package/assets/core.js
DELETED
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
let init,
|
|
2
|
-
sendInitialEvent,
|
|
3
|
-
storeDataToSendOnNextEvent,
|
|
4
|
-
hasProp = {}.hasOwnProperty;
|
|
5
|
-
|
|
6
|
-
import transmit from './transmit.js';
|
|
7
|
-
|
|
8
|
-
import visibility from './visibility.js';
|
|
9
|
-
|
|
10
|
-
import adblockDetection from './adblock-detection.js';
|
|
11
|
-
|
|
12
|
-
const VERSION = 17;
|
|
13
|
-
|
|
14
|
-
let doc = window.document;
|
|
15
|
-
|
|
16
|
-
const canStoreEventsInLocalStorage =
|
|
17
|
-
window.localStorage != null && typeof JSON !== 'undefined' && JSON !== null;
|
|
18
|
-
|
|
19
|
-
let platform = null;
|
|
20
|
-
|
|
21
|
-
const MaximumComponentNameLength = 50;
|
|
22
|
-
|
|
23
|
-
init = function (servingPlatform, httpStatus) {
|
|
24
|
-
platform = servingPlatform;
|
|
25
|
-
if (visibility.state() !== 'prerender') {
|
|
26
|
-
return sendInitialEvent(httpStatus);
|
|
27
|
-
} else {
|
|
28
|
-
if (visibility.changeEvent) {
|
|
29
|
-
return doc.addEventListener(
|
|
30
|
-
visibility.changeEvent,
|
|
31
|
-
function () {
|
|
32
|
-
if (visibility.state() === 'visible') {
|
|
33
|
-
return sendInitialEvent(httpStatus);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
false,
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Retrieves the value of a specified query parameter from the current page's URL.
|
|
44
|
-
* Using an old-fashioned way of finding a query param rather than using searchParams
|
|
45
|
-
* as we don't control which environments the CDN distribution is being used in and so don't know if it's supported.
|
|
46
|
-
* @param {string} paramName - The name of the query parameter to retrieve.
|
|
47
|
-
* @returns {string | undefined} The value of the query parameter, or undefined if not found.
|
|
48
|
-
*/
|
|
49
|
-
const getQueryParameterValue = (paramName) => {
|
|
50
|
-
const queryString = window.location.search.substring(1);
|
|
51
|
-
const queryParams = queryString.split('&');
|
|
52
|
-
|
|
53
|
-
for (const param of queryParams) {
|
|
54
|
-
const [key, value] = param.split('=');
|
|
55
|
-
if (key === paramName) {
|
|
56
|
-
return decodeURIComponent(value);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Retrieves the referrer URL from the given referrer or a fallback query parameter.
|
|
63
|
-
* If an authentication flow takes place on page load, the referrer is lost.
|
|
64
|
-
* So, if no referrer, fall back to query param holding the value of the referrer before the auth flow began.
|
|
65
|
-
* See https://github.com/guardian/support-frontend/blob/main/support-frontend/app/controllers/AuthCodeFlowController.scala#L105
|
|
66
|
-
* for an example use. * @param {string} referrer - The document referrer.
|
|
67
|
-
* @param {string} referrer - The document referrer.
|
|
68
|
-
* @returns {string} The referrer URL or the fallback query parameter value.
|
|
69
|
-
*/
|
|
70
|
-
const getReferrer = (referrer) => {
|
|
71
|
-
return referrer || getQueryParameterValue('pre-auth-ref') || '';
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Retrieves the type of navigation that occurred to arrive at the current page, using the Performance API.
|
|
76
|
-
* Returns null if the navigation type is not available.
|
|
77
|
-
* @returns {string | null} The navigation type (e.g., 'navigate', 'reload', 'back_forward'), or null if not available.
|
|
78
|
-
*/
|
|
79
|
-
const getNavigationType = () => {
|
|
80
|
-
if (window.performance?.getEntriesByType) {
|
|
81
|
-
const entries = window.performance.getEntriesByType('navigation');
|
|
82
|
-
if (entries.length > 0) {
|
|
83
|
-
return entries[0].type;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
sendInitialEvent = function (
|
|
90
|
-
httpStatus,
|
|
91
|
-
url = location.href,
|
|
92
|
-
referrer = window.document.referrer,
|
|
93
|
-
) {
|
|
94
|
-
const navigationType = getNavigationType();
|
|
95
|
-
// send initial event
|
|
96
|
-
const event = {
|
|
97
|
-
v: VERSION,
|
|
98
|
-
platform: platform,
|
|
99
|
-
url: url,
|
|
100
|
-
ref: getReferrer(referrer),
|
|
101
|
-
visibilityState: visibility.state(),
|
|
102
|
-
isModernBrowser:
|
|
103
|
-
typeof guardian !== 'undefined' && guardian !== null
|
|
104
|
-
? guardian.isModernBrowser
|
|
105
|
-
: void 0,
|
|
106
|
-
httpStatus: httpStatus,
|
|
107
|
-
tz: new Date().getTimezoneOffset(),
|
|
108
|
-
};
|
|
109
|
-
if (navigationType != null) {
|
|
110
|
-
// Add navigation type as metadata to the event if it's not null
|
|
111
|
-
event.navigationType = navigationType;
|
|
112
|
-
}
|
|
113
|
-
appendContentType(event);
|
|
114
|
-
appendDataFromLocalStorageToEvent(event);
|
|
115
|
-
transmit.sendInitial(event);
|
|
116
|
-
return adblockDetection.run().then(function (adBlockerEnabled) {
|
|
117
|
-
// `adUnitWasHidden` is the query param used
|
|
118
|
-
// by the previous adblock detection, hence reusing it here.
|
|
119
|
-
return transmit.sendMore({
|
|
120
|
-
adUnitWasHidden: adBlockerEnabled,
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const onLoadCaptures = [];
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Registers a data capture function to be called when the document is fully loaded.
|
|
129
|
-
* The result of this function is then sent to the tracker backend service.
|
|
130
|
-
* If the document is already loaded, this is done immediately.
|
|
131
|
-
*
|
|
132
|
-
* @param {() => Record<string, unknown>} dataCapture - A function that returns an object containing performance metrics such as page load time, network latency, etc.
|
|
133
|
-
* Refer to the `perf.js` file where this function is used for more info.
|
|
134
|
-
*/
|
|
135
|
-
const onLoadCapture = (dataCapture) => {
|
|
136
|
-
if (document.readyState === 'complete') {
|
|
137
|
-
const msg = { ...dataCapture() };
|
|
138
|
-
transmit.sendMore(msg);
|
|
139
|
-
} else {
|
|
140
|
-
onLoadCaptures.push(dataCapture);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Processes all registered data capture functions, merges their outputs and sends it to the tracker backend service.
|
|
146
|
-
* If on a 'next-gen' platform, additional component data is appended to the event via the `appendComponentDataToEvent` function.
|
|
147
|
-
*/
|
|
148
|
-
const processCaptures = () => {
|
|
149
|
-
const msg = {};
|
|
150
|
-
|
|
151
|
-
for (const capture of onLoadCaptures) {
|
|
152
|
-
const captureData = capture();
|
|
153
|
-
|
|
154
|
-
for (const key in captureData) {
|
|
155
|
-
if (captureData.hasOwnProperty(key)) {
|
|
156
|
-
msg[key] = captureData[key];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (platform === 'next-gen') {
|
|
162
|
-
appendComponentDataToEvent(msg);
|
|
163
|
-
}
|
|
164
|
-
transmit.sendMore(msg);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
window.addEventListener?.('load', processCaptures, false);
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Appends data from local storage to a given event object.
|
|
171
|
-
* Specifically targets data stored under the 'ophan_follow' key in localStorage.
|
|
172
|
-
* After appending the data to the event, it removes the data from localStorage.
|
|
173
|
-
* @param {Record<string, unknown>} event - The event object to which the local storage data will be appended.
|
|
174
|
-
*/
|
|
175
|
-
const appendDataFromLocalStorageToEvent = (event) => {
|
|
176
|
-
if (canStoreEventsInLocalStorage) {
|
|
177
|
-
const localStorageItems = JSON.parse(
|
|
178
|
-
window.localStorage.getItem('ophan_follow'),
|
|
179
|
-
);
|
|
180
|
-
if (localStorageItems != null) {
|
|
181
|
-
for (const key in localStorageItems) {
|
|
182
|
-
if (localStorageItems.hasOwnProperty(key)) {
|
|
183
|
-
event[key] = localStorageItems[key];
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
window.localStorage.removeItem('ophan_follow');
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Trims component names to a maximum length to ensure they are URL safe.
|
|
193
|
-
* If a component name exceeds the maximum length, it is truncated and appended with an ellipsis.
|
|
194
|
-
* @param {string[]} componentNames - An array of component names.
|
|
195
|
-
* @returns {string[]} An array of trimmed component names.
|
|
196
|
-
*/
|
|
197
|
-
const trimComponentNamesToUrlSafeLength = (componentNames) => {
|
|
198
|
-
return componentNames.map((componentName) =>
|
|
199
|
-
componentName.length > MaximumComponentNameLength
|
|
200
|
-
? componentName.substring(0, MaximumComponentNameLength).concat('…')
|
|
201
|
-
: componentName,
|
|
202
|
-
);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Appends data about rendered components to an event object.
|
|
207
|
-
* Extracts component names from elements with a 'data-component' attribute, trims them for URL safety, ensures uniqueness, and adds them to the event.
|
|
208
|
-
* @param {Object} event - The event object to which component data will be appended.
|
|
209
|
-
*/
|
|
210
|
-
const appendComponentDataToEvent = (event) => {
|
|
211
|
-
const componentElements = document.querySelectorAll('[data-component]');
|
|
212
|
-
const componentNames = Array.prototype.slice.call(componentElements).map((el) =>
|
|
213
|
-
el.getAttribute('data-component')
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
if (componentNames.length > 0) {
|
|
217
|
-
const trimmedComponentNames =
|
|
218
|
-
trimComponentNamesToUrlSafeLength(componentNames);
|
|
219
|
-
// uniquify
|
|
220
|
-
const uniqueComponents = new Set(trimmedComponentNames);
|
|
221
|
-
event.renderedComponents = [...uniqueComponents];
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
storeDataToSendOnNextEvent = function (newData) {
|
|
227
|
-
let existingData, key, value;
|
|
228
|
-
if (canStoreEventsInLocalStorage) {
|
|
229
|
-
existingData =
|
|
230
|
-
JSON.parse(window.localStorage.getItem('ophan_follow')) || {};
|
|
231
|
-
for (key in newData) {
|
|
232
|
-
if (!hasProp.call(newData, key)) continue;
|
|
233
|
-
value = newData[key];
|
|
234
|
-
existingData[key] = value;
|
|
235
|
-
}
|
|
236
|
-
return window.localStorage.setItem(
|
|
237
|
-
'ophan_follow',
|
|
238
|
-
JSON.stringify(existingData),
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Determines the 'content type' based on the platform and guardian object.
|
|
245
|
-
* @param {Record<string, unknown>} event - The event object that will be updated with contentType.
|
|
246
|
-
* @param {string} platform - The current platform ('next-gen', 'embed' or other).
|
|
247
|
-
* @param {Record<string, unknown>} guardian - The guardian object.
|
|
248
|
-
*/
|
|
249
|
-
const appendContentType = (event, platform, guardian) => {
|
|
250
|
-
const contentType =
|
|
251
|
-
platform === 'next-gen' || platform === 'embed'
|
|
252
|
-
? guardian?.config?.page?.contentType
|
|
253
|
-
: guardian?.page?.contentTypes;
|
|
254
|
-
|
|
255
|
-
if (contentType) {
|
|
256
|
-
event.contentType = contentType.toLowerCase();
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
export default {
|
|
261
|
-
init: init,
|
|
262
|
-
storeDataToSendOnNextEvent: storeDataToSendOnNextEvent,
|
|
263
|
-
onLoadCapture: onLoadCapture,
|
|
264
|
-
servingPlatform: function () {
|
|
265
|
-
return platform;
|
|
266
|
-
},
|
|
267
|
-
viewId: transmit.viewId,
|
|
268
|
-
sendInitialEvent: sendInitialEvent,
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Exports for testing purposes.
|
|
273
|
-
*/
|
|
274
|
-
export const _testExports = {
|
|
275
|
-
appendComponentDataToEvent,
|
|
276
|
-
trimComponentNamesToUrlSafeLength,
|
|
277
|
-
getQueryParameterValue,
|
|
278
|
-
onLoadCaptures,
|
|
279
|
-
onLoadCapture,
|
|
280
|
-
processCaptures,
|
|
281
|
-
appendContentType,
|
|
282
|
-
};
|
package/assets/embed.js
DELETED
package/assets/fb-instant.js
DELETED
package/assets/heatmap.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
let heatmapFired = false;
|
|
2
|
-
|
|
3
|
-
const init = () => {
|
|
4
|
-
const addHeatmap = () => {
|
|
5
|
-
let heatmapParam;
|
|
6
|
-
if (
|
|
7
|
-
typeof localStorage !== 'undefined' &&
|
|
8
|
-
localStorage !== null &&
|
|
9
|
-
!heatmapFired
|
|
10
|
-
) {
|
|
11
|
-
heatmapFired = true;
|
|
12
|
-
heatmapParam = window.location.search.replace(
|
|
13
|
-
/^(?:.*[&\?]heatmap(?:\=([^&]*))?)?.*$/,
|
|
14
|
-
'$1',
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
if (heatmapParam === 'experimental') {
|
|
18
|
-
return (document.body.appendChild(
|
|
19
|
-
document.createElement('script'),
|
|
20
|
-
).src = '//dashboard.ophan.co.uk/assets/js/react/heatphan/index.js');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (heatmapParam === 'true' || heatmapParam === 'false') {
|
|
24
|
-
localStorage['ophan_heatmap'] = heatmapParam;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (localStorage['ophan_heatmap'] === 'true' || heatmapParam === 'show') {
|
|
28
|
-
return (document.body.appendChild(
|
|
29
|
-
document.createElement('script'),
|
|
30
|
-
).src = '//dashboard.ophan.co.uk/assets/js/heatmap-bookmarklet.js');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
if (document.readyState === 'complete') {
|
|
37
|
-
return addHeatmap();
|
|
38
|
-
} else {
|
|
39
|
-
return typeof window.addEventListener === 'function'
|
|
40
|
-
? window.addEventListener(
|
|
41
|
-
'load',
|
|
42
|
-
function () {
|
|
43
|
-
return addHeatmap();
|
|
44
|
-
},
|
|
45
|
-
false,
|
|
46
|
-
)
|
|
47
|
-
: void 0;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default {
|
|
52
|
-
init,
|
|
53
|
-
};
|
package/assets/holidays.js
DELETED
package/assets/http-status.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import core from './core.js';
|
|
2
|
-
import './transmit.js';
|
|
3
|
-
import './click-path-capture.js';
|
|
4
|
-
import './perf.js';
|
|
5
|
-
import './campaign.js';
|
|
6
|
-
|
|
7
|
-
const reportStatus = (platform, status) => {
|
|
8
|
-
return core.init(platform, status);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
reportStatus,
|
|
13
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import clickCapture from './click-path-capture.js';
|
|
2
|
-
|
|
3
|
-
const validIframeDomains = [
|
|
4
|
-
'.theguardian.com',
|
|
5
|
-
'.dev-theguardian.com',
|
|
6
|
-
'.thegulocal.com', // NB - leading dot is essential here to avoid matching on non-Guardian-owned domains
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Handles messages received from iframes, recording events as necessary.
|
|
11
|
-
* @param {MessageEvent} messageEvent - The message event received from an iframe.
|
|
12
|
-
*/
|
|
13
|
-
const handleIframeMessage = (messageEvent) => {
|
|
14
|
-
const originDomain = retrieveOriginDomain(messageEvent.origin);
|
|
15
|
-
if (
|
|
16
|
-
originDomain &&
|
|
17
|
-
validIframeDomains.some((domain) => originDomain.endsWith(domain))
|
|
18
|
-
) {
|
|
19
|
-
if (messageEvent.data.type === 'ophan-iframe-click-event') {
|
|
20
|
-
const eventObject = messageEvent.data.value;
|
|
21
|
-
const iFrame = document.getElementById(messageEvent.data.iframeId);
|
|
22
|
-
recordIframeClickEvent(iFrame, eventObject);
|
|
23
|
-
} else if (messageEvent.data.type === 'ophan-iframe-component-event') {
|
|
24
|
-
const eventObject = messageEvent.data.value;
|
|
25
|
-
recordIframeComponentEvent(eventObject);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Retrieves the domain from an event's origin URL.
|
|
32
|
-
* @param {string} eventOrigin - The origin URL of the event.
|
|
33
|
-
* @returns {(string|null)} The domain of the origin URL or null if it cannot be parsed.
|
|
34
|
-
*/
|
|
35
|
-
const retrieveOriginDomain = (eventOrigin) => {
|
|
36
|
-
try {
|
|
37
|
-
const originURL = new URL(eventOrigin);
|
|
38
|
-
return originURL.host;
|
|
39
|
-
} catch (error) {
|
|
40
|
-
if (error instanceof TypeError) {
|
|
41
|
-
// We failed to parse origin as an URL, we should ignore the event
|
|
42
|
-
return null;
|
|
43
|
-
} else {
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Records a click event occurring within an iframe.
|
|
51
|
-
* @param {HTMLElement} iFrame - The iframe element where the click event occurred.
|
|
52
|
-
* @param {Object} clickEvent - The click event object to record.
|
|
53
|
-
*/
|
|
54
|
-
const recordIframeClickEvent = (iFrame, clickEvent) => {
|
|
55
|
-
if (iFrame) {
|
|
56
|
-
clickEvent.clickLinkNames =
|
|
57
|
-
clickCapture.getDataLinkNames(iFrame, clickEvent.clickLinkNames) ||
|
|
58
|
-
clickEvent.clickLinkNames;
|
|
59
|
-
}
|
|
60
|
-
window.guardian.ophan.record(clickEvent);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Validates if an event object is a valid component event.
|
|
65
|
-
* @param {Object} eventObject - The event object to validate.
|
|
66
|
-
* @returns {boolean} True if the event object is valid, false otherwise.
|
|
67
|
-
*/
|
|
68
|
-
const componentEventIsValid = (eventObject) => {
|
|
69
|
-
return (
|
|
70
|
-
eventObject &&
|
|
71
|
-
typeof eventObject === 'object' &&
|
|
72
|
-
eventObject.componentEvent &&
|
|
73
|
-
typeof eventObject.componentEvent === 'object'
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Records a component event from an iframe.
|
|
79
|
-
* @param {Object} eventObject - The component event object to record.
|
|
80
|
-
*/
|
|
81
|
-
const recordIframeComponentEvent = (eventObject) => {
|
|
82
|
-
if (!componentEventIsValid(eventObject)) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
window.guardian.ophan.record(eventObject);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
window.addEventListener('message', handleIframeMessage, false);
|
package/assets/interactive.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import core from './core.js';
|
|
2
|
-
import transmit from './transmit.js';
|
|
3
|
-
import attention from './attention.js';
|
|
4
|
-
import './click-path-capture.js';
|
|
5
|
-
|
|
6
|
-
if (window.guardian?.ophan) {
|
|
7
|
-
guardian.ophan;
|
|
8
|
-
} else {
|
|
9
|
-
core.init('embed');
|
|
10
|
-
window.guardian = guardian || {};
|
|
11
|
-
guardian.ophan = {
|
|
12
|
-
setEventEmitter: attention.setEventEmitter,
|
|
13
|
-
trackComponentAttention: attention.initComponent,
|
|
14
|
-
record: transmit.sendMore,
|
|
15
|
-
viewId: transmit.viewId,
|
|
16
|
-
};
|
|
17
|
-
}
|
package/assets/jobs-courses.js
DELETED
package/assets/jobs.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// Generated by CoffeeScript 2.7.0
|
|
2
|
-
import core from './core.js';
|
|
3
|
-
import transmit from './transmit.js';
|
|
4
|
-
import attention from './attention.js';
|
|
5
|
-
import visibility from './visibility.js';
|
|
6
|
-
|
|
7
|
-
import './click-path-capture.js';
|
|
8
|
-
import './perf.js';
|
|
9
|
-
import './campaign.js';
|
|
10
|
-
|
|
11
|
-
core.init('manage-my-account');
|
|
12
|
-
|
|
13
|
-
if (window.addEventListener) {
|
|
14
|
-
attention.init(visibility);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const sendInitialEvent = (
|
|
18
|
-
url = location.href,
|
|
19
|
-
referrer = document.referrer,
|
|
20
|
-
) => {
|
|
21
|
-
try {
|
|
22
|
-
transmit.bumpViewId();
|
|
23
|
-
core.sendInitialEvent(null, url, referrer);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.log(error);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const exports = {
|
|
30
|
-
sendInitialEvent,
|
|
31
|
-
record: transmit.sendMore,
|
|
32
|
-
viewId: transmit.viewId,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
window.guardian = window.guardian || {};
|
|
36
|
-
window.guardian.ophan = exports;
|
|
37
|
-
|
|
38
|
-
export default exports;
|
package/assets/membership.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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/assets/ng.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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 =
|
|
26
|
-
((ref = window.guardian) != null ? ref.ophan : void 0) != null
|
|
27
|
-
? window.guardian.ophan
|
|
28
|
-
: (core.init('next-gen'),
|
|
29
|
-
privatebrowsing.init(),
|
|
30
|
-
heatmap.init(),
|
|
31
|
-
window.addEventListener != null ? attention.init(visibility) : void 0,
|
|
32
|
-
window.guardian != null ? window.guardian : (window.guardian = {}),
|
|
33
|
-
(window.guardian.ophan = {
|
|
34
|
-
setEventEmitter: attention.setEventEmitter,
|
|
35
|
-
trackComponentAttention: attention.initComponent,
|
|
36
|
-
record: transmit.sendMore,
|
|
37
|
-
viewId: transmit.viewId,
|
|
38
|
-
pageViewId: transmit.viewId,
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
export default ng;
|
package/assets/perf.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Generated by CoffeeScript 2.7.0
|
|
2
|
-
import core from './core.js';
|
|
3
|
-
|
|
4
|
-
const perf =
|
|
5
|
-
window.performance ||
|
|
6
|
-
window.msPerformance ||
|
|
7
|
-
window.webkitPerformance ||
|
|
8
|
-
window.mozPerformance;
|
|
9
|
-
|
|
10
|
-
const sendTimingData = () => {
|
|
11
|
-
const t = perf?.timing;
|
|
12
|
-
if (t) {
|
|
13
|
-
return {
|
|
14
|
-
performance: {
|
|
15
|
-
// Time required for domain lookup.
|
|
16
|
-
dns: t.domainLookupEnd - t.domainLookupStart,
|
|
17
|
-
// Time to establish a connection to server.
|
|
18
|
-
connection: t.connectEnd - t.connectStart,
|
|
19
|
-
// From connection established to first byte of data.
|
|
20
|
-
firstByte: t.responseStart - t.connectEnd,
|
|
21
|
-
// First byte to last byte, or closed, including if from cache.
|
|
22
|
-
lastByte: t.responseEnd - t.responseStart,
|
|
23
|
-
// From last byte of doc to start of domContentLoaded
|
|
24
|
-
domContentLoadedEvent: t.domContentLoadedEventStart - t.responseEnd,
|
|
25
|
-
// domcontentLoaded to start of load event.
|
|
26
|
-
loadEvent: t.loadEventStart - t.domContentLoadedEventStart,
|
|
27
|
-
// click, back/forward, etc...
|
|
28
|
-
navType: perf.navigation.type,
|
|
29
|
-
// No. of redirects on current domain.
|
|
30
|
-
redirectCount: perf.navigation.redirectCount,
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
} else {
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
core.onLoadCapture(sendTimingData);
|
|
39
|
-
|
|
40
|
-
export default perf;
|