Skip to content

Commit d593d33

Browse files
Merge pull request #31 from simpleanalytics/add-sa-settings
Add sa_settings to overwriteOptions and fix callback with metadata
2 parents c7eb0b3 + 0f0fa6b commit d593d33

39 files changed

+438
-125
lines changed

compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const GREEN = "\x1b[32m%s\x1b[0m";
88
const YELLOW = "\x1b[33m%s\x1b[0m";
99
const RED = "\x1b[31m%s\x1b[0m";
1010

11-
const VERSION = 9;
11+
const VERSION = 10;
1212

1313
Handlebars.registerHelper("or", function (param1, param2) {
1414
return param1 || param2;

dist/latest/auto-events.js

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

dist/latest/cloudflare.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Simple Analytics - Privacy friendly analytics (docs.simpleanalytics.com/script; 2022-07-26; 2f79; v9) */
1+
/* Simple Analytics - Privacy friendly analytics (docs.simpleanalytics.com/script; 2022-09-05; 9974; v10) */
22
/* eslint-env browser */
33

44
(function (
@@ -113,6 +113,29 @@
113113
: [];
114114
};
115115

116+
var isObject = function (object) {
117+
return object && object.constructor === Object;
118+
};
119+
120+
var assign = function () {
121+
var to = {};
122+
var arg = arguments;
123+
for (var index = 0; index < arg.length; index++) {
124+
var nextSource = arg[index];
125+
if (isObject(nextSource)) {
126+
for (var nextKey in nextSource) {
127+
if (hasProp(nextSource, nextKey)) {
128+
to[nextKey] = nextSource[nextKey];
129+
}
130+
}
131+
}
132+
}
133+
return to;
134+
};
135+
136+
// Merge overwriteOptions with sa_settings
137+
overwriteOptions = assign(overwriteOptions, window.sa_settings);
138+
116139
// Customers can skip data points
117140
var ignoreMetrics = convertCommaSeparatedToArray(
118141
overwriteOptions.ignoreMetrics || attr(scriptElement, "ignore-metrics")
@@ -155,26 +178,6 @@
155178
return typeof func == "function";
156179
};
157180

158-
var isObject = function (object) {
159-
return object && object.constructor === Object;
160-
};
161-
162-
var assign = function () {
163-
var to = {};
164-
var arg = arguments;
165-
for (var index = 0; index < arg.length; index++) {
166-
var nextSource = arg[index];
167-
if (isObject(nextSource)) {
168-
for (var nextKey in nextSource) {
169-
if (hasProp(nextSource, nextKey)) {
170-
to[nextKey] = nextSource[nextKey];
171-
}
172-
}
173-
}
174-
}
175-
return to;
176-
};
177-
178181
// Define namespace for the library
179182
var namespaceText = "namespace";
180183
var namespace =
@@ -873,8 +876,8 @@
873876
}
874877
};
875878

876-
var defaultEventFunc = function (event, callback) {
877-
sendEvent(event, callback);
879+
var defaultEventFunc = function (event, metadata, callback) {
880+
sendEvent(event, metadata, callback);
878881
};
879882

880883
// Set default function if user didn't define a function
@@ -905,6 +908,6 @@
905908
{"saGlobal":INSTALL_OPTIONS.sa_global,"mode":INSTALL_OPTIONS.hash_mode ? 'hash' : null,"collectDnt":INSTALL_OPTIONS.collect_dnt},
906909
INSTALL_OPTIONS.custom_domain || "queue.simpleanalyticscdn.com",
907910
"",
908-
"cloudflare_9",
911+
"cloudflare_10",
909912
"sa"
910913
);

dist/latest/custom/app.js

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

dist/latest/custom/app.js.map

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

0 commit comments

Comments
 (0)