Skip to content

Commit 17f48a3

Browse files
committed
V10 b
1 parent d593d33 commit 17f48a3

File tree

5 files changed

+34
-57
lines changed

5 files changed

+34
-57
lines changed

compile.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const DEFAULTS = {
7777
nonuniquehostnames: true,
7878
ignoremetrics: true,
7979
dev: false,
80+
skipnonwindow: false,
8081
};
8182

8283
const LIGHT = {
@@ -161,15 +162,27 @@ const templates = [
161162
output: `cloudflare.js`,
162163
variables: {
163164
...DEFAULTS,
165+
skipnonwindow: true,
164166
minify: false,
165167
version: VERSION,
166168
scriptName: `cloudflare_${VERSION}`,
167169
sri: false,
168170
baseUrl: "{{cloudFlareCustomDomain}}",
169171
overwriteOptions: {
170-
saGlobal: "INSTALL_OPTIONS.sa_global",
171-
mode: "INSTALL_OPTIONS.hash_mode ? 'hash' : null",
172-
collectDnt: "INSTALL_OPTIONS.collect_dnt",
172+
hostname: "INSTALL_OPTIONS.hostname",
173+
collectDnt:
174+
"typeof INSTALL_OPTIONS.collect_dnt === 'boolean' ? INSTALL_OPTIONS.collect_dnt : null",
175+
mode: "INSTALL_OPTIONS.hash_mode ? 'hash' : 'normal'",
176+
strictUtm:
177+
"INSTALL_OPTIONS.advanced_settings_toggle && INSTALL_OPTIONS.strict_utm",
178+
allowParams:
179+
"INSTALL_OPTIONS.advanced_settings_toggle && INSTALL_OPTIONS.allow_url_parameters",
180+
nonUniqueHostnames:
181+
"INSTALL_OPTIONS.advanced_settings_toggle && INSTALL_OPTIONS.non_unique_hostnames",
182+
ignorePages:
183+
"INSTALL_OPTIONS.advanced_settings_toggle && INSTALL_OPTIONS.ignore_pages",
184+
namespace:
185+
"INSTALL_OPTIONS.overwrite_namespace && INSTALL_OPTIONS.namespace",
173186
},
174187
},
175188
},

dist/v10/v10.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/v10/v10.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/default.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@
6666
var screen = window.screen;
6767
/** endif **/
6868

69+
/** if skipnonwindow **/
70+
// Skip server side rendered pages on Cloudflare
71+
if (typeof window == "" + undefinedVar) return;
72+
/** endif **/
73+
6974
// Find the script element where options can be set on
7075
var scriptElement =
7176
doc.currentScript || doc.querySelector('script[src*="' + baseUrl + '"]');
@@ -80,12 +85,11 @@
8085
var args = [].slice.call(arguments);
8186

8287
// 2. Prepend log prefix
83-
args.unshift("Simple Analytics: ");
88+
args.unshift("Simple Analytics:");
8489

8590
// 3. Pass along arguments to console.warn
8691
// Function.prototype.bind.call is needed for Internet Explorer
87-
var log = Function.prototype.bind.call(con.warn, con);
88-
log.apply(con, args);
92+
return Function.prototype.apply.call(con.warn, con, args);
8993
};
9094

9195
var warnInFunction = function (name, error) {
@@ -136,8 +140,13 @@
136140
return to;
137141
};
138142

143+
var settings = window.sa_settings;
144+
var logSettings = settings || Object.values(overwriteOptions).length;
145+
139146
// Merge overwriteOptions with sa_settings
140-
overwriteOptions = assign(overwriteOptions, window.sa_settings);
147+
overwriteOptions = assign(overwriteOptions, settings);
148+
149+
if (logSettings) warn("Settings", overwriteOptions);
141150

142151
/** if ignoremetrics **/
143152
// Customers can skip data points

src/embed.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)