|
1 | | -/* Simple Analytics - Privacy friendly analytics (docs.simpleanalytics.com/script; 2021-12-28; b9e3; v2) */ |
| 1 | +/* Simple Analytics - Privacy friendly analytics (docs.simpleanalytics.com/script; 2021-12-30; 26ba; v8) */ |
2 | 2 | /* eslint-env browser */ |
3 | 3 |
|
4 | 4 | (function (window, overwriteOptions, baseUrl, apiUrlPrefix, version, saGlobal) { |
|
51 | 51 | var pagehide = "pagehide"; |
52 | 52 | var platformText = "platform"; |
53 | 53 | var platformVersionText = "platformVersion"; |
| 54 | + var docsUrl = "https://docs.simpleanalytics.com"; |
54 | 55 | var isBotAgent = |
55 | 56 | /(bot|spider|crawl)/i.test(userAgent) && !/(cubot)/i.test(userAgent); |
56 | 57 | var screen = window.screen; |
|
253 | 254 | attr(scriptElement, "collect-dnt") == trueText; |
254 | 255 |
|
255 | 256 | // Customers can overwrite their hostname, here we check for that |
256 | | - var definedHostname = |
257 | | - overwriteOptions.hostname || |
258 | | - attr(scriptElement, "hostname") || |
259 | | - locationHostname; |
| 257 | + var overwrittenHostname = |
| 258 | + overwriteOptions.hostname || attr(scriptElement, "hostname"); |
| 259 | + var definedHostname = overwrittenHostname || locationHostname; |
260 | 260 |
|
261 | 261 | // Some customers want to collect page views manually |
262 | 262 | var autoCollect = !( |
|
329 | 329 |
|
330 | 330 | // Don't track when Do Not Track is set to true |
331 | 331 | if (!collectDnt && doNotTrack in nav && nav[doNotTrack] == "1") |
332 | | - return warn(notSending + "when " + doNotTrack + " is enabled"); |
| 332 | + return warn( |
| 333 | + notSending + |
| 334 | + "when " + |
| 335 | + doNotTrack + |
| 336 | + " is enabled. See " + |
| 337 | + docsUrl + |
| 338 | + "/dnt" |
| 339 | + ); |
333 | 340 |
|
334 | | - // Don't track when localhost or when it's an IP address |
| 341 | + // Warn when sending from localhost and not having a hostname set |
335 | 342 | if ( |
336 | | - locationHostname.indexOf(".") == -1 || |
337 | | - /^[0-9]+$/.test(locationHostname.replace(/\./g, "")) |
| 343 | + (locationHostname.indexOf(".") == -1 || |
| 344 | + /^[0-9.:]+$/.test(locationHostname)) && |
| 345 | + !overwrittenHostname |
338 | 346 | ) |
339 | | - return warn(notSending + "from " + locationHostname); |
| 347 | + warn( |
| 348 | + "Set a hostname when sending data from " + |
| 349 | + locationHostname + |
| 350 | + ". See " + |
| 351 | + docsUrl + |
| 352 | + "/overwrite-domain-name" |
| 353 | + ); |
340 | 354 |
|
341 | 355 | ///////////////////// |
342 | 356 | // SETUP INITIAL VARIABLES |
|
709 | 723 | {"saGlobal":INSTALL_OPTIONS.sa_global,"mode":INSTALL_OPTIONS.hash_mode ? 'hash' : null,"collectDnt":INSTALL_OPTIONS.collect_dnt}, |
710 | 724 | INSTALL_OPTIONS.custom_domain || "queue.simpleanalyticscdn.com", |
711 | 725 | "", |
712 | | - "cloudflare_2", |
| 726 | + "cloudflare_8", |
713 | 727 | "sa_event" |
714 | 728 | ); |
0 commit comments