Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ const fillTemplate = (template, { overwriteOptions = null } = {}) => {
return template
.replace(
/\{\{\s?nginxHost\s?\}\}/gi,
'<!--# echo var="http_host" default="" -->'
'<!--# echo var="http_host" default="" -->',
)
.replace(
/\{\{\s?nginxProxyHost\s?\}\}/gi,
'<!--# echo var="proxy_hostname" default="" --><!--# echo var="proxy_path" default="/simple" -->'
'<!--# echo var="proxy_hostname" default="" --><!--# echo var="proxy_path" default="/simple" -->',
)
.replace(
/\\?"\{\{\s?overwriteOptions\s?\}\}\\?"/gi,
overwriteOptions
? JSON.stringify(overwriteOptions).replace(/:"([^"]+)"/gi, ":$1")
: "{}"
: "{}",
)
.replace(
/"\{\{\s?cloudFlareCustomDomain\s?\}\}"/gi,
'INSTALL_OPTIONS.custom_domain || "queue.simpleanalyticscdn.com"'
'INSTALL_OPTIONS.custom_domain || "queue.simpleanalyticscdn.com"',
);
};

Expand Down Expand Up @@ -284,7 +284,7 @@ const files = templates.reduce((list, template) => {
if (template.variables.sri) {
list.push(
{ ...template, variables: { ...template.variables, sri: true } },
{ ...template, variables: { ...template.variables, sri: false } }
{ ...template, variables: { ...template.variables, sri: false } },
);
} else {
list.push(template);
Expand Down Expand Up @@ -346,7 +346,7 @@ for (const file of files) {
filename: originalFileName,
url: `${finalFileName}.map`,
},
}
},
)
: {
code: prepend + rawCode,
Expand Down Expand Up @@ -374,7 +374,7 @@ for (const file of files) {
RED,
`[${name}][ERROR] ${input
.split("/")
.pop()} ${description} at line ${lineNumber} position ${index}`
.pop()} ${description} at line ${lineNumber} position ${index}`,
);
continue;
}
Expand Down Expand Up @@ -402,15 +402,15 @@ for (const file of files) {

let write = code.replace(
/sourceMappingURL=latest\.js\.map/gi,
`sourceMappingURL=${cdnFileName}.map`
`sourceMappingURL=${cdnFileName}.map`,
);

fs.writeFileSync(versionFile, write);

if (compiledMap) {
let writeCompiled = compiledMap.replace(
/latest\.source\.js/gi,
cdnFileName
cdnFileName,
);

fs.writeFileSync(`${versionFile}.map`, writeCompiled);
Expand Down Expand Up @@ -438,7 +438,7 @@ for (const file of files) {
console.log(
` ${name.toLowerCase()} ${fill1}Compiled ${sourceName} ${fill2} ${bytesZeroFilled} bytes ${
variables.sri ? " (SRI)" : ""
}`
}`,
);
}

Expand Down
15 changes: 8 additions & 7 deletions playground/callback.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -46,15 +46,17 @@
@font-face {
font-family: "Space Grotesk";
font-weight: 500;
src: url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Medium.woff2")
src:
url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Medium.woff2")
format("woff2"),
url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Medium.woff")
format("woff");
}
@font-face {
font-family: "Space Grotesk";
font-weight: 400;
src: url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Regular.woff2")
src:
url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Regular.woff2")
format("woff2"),
url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Regular.woff")
format("woff");
Expand Down Expand Up @@ -179,9 +181,8 @@ <h2>Automated events</h2>
return param;
})
.join(" ");
document.querySelector(
"textarea"
).value += `${type.toUpperCase()}: ${line}\n`;
document.querySelector("textarea").value +=
`${type.toUpperCase()}: ${line}\n`;
}

console.log = function () {
Expand Down Expand Up @@ -253,7 +254,7 @@ <h2>Automated events</h2>
});

const callbackMetadataLink = document.querySelector(
"[data-metadata-callback]"
"[data-metadata-callback]",
);
callbackMetadataLink.addEventListener("click", (event) => {
event.preventDefault();
Expand Down
17 changes: 9 additions & 8 deletions playground/events.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -33,9 +33,9 @@
},
() => {
console.info(
"Simple Analytics auto events: collected before_script_load"
"Simple Analytics auto events: collected before_script_load",
);
}
},
);
</script>

Expand Down Expand Up @@ -67,15 +67,17 @@
@font-face {
font-family: "Space Grotesk";
font-weight: 500;
src: url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Medium.woff2")
src:
url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Medium.woff2")
format("woff2"),
url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Medium.woff")
format("woff");
}
@font-face {
font-family: "Space Grotesk";
font-weight: 400;
src: url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Regular.woff2")
src:
url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Regular.woff2")
format("woff2"),
url("https://assets.simpleanalytics.com/fonts/SpaceGrotesk-Regular.woff")
format("woff");
Expand Down Expand Up @@ -206,9 +208,8 @@ <h2>Automated events</h2>
return param;
})
.join(" ");
document.querySelector(
"textarea"
).value += `${type.toUpperCase()}: ${line}\n`;
document.querySelector("textarea").value +=
`${type.toUpperCase()}: ${line}\n`;
}

console.log = function () {
Expand Down
2 changes: 1 addition & 1 deletion src/auto-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
/^https?:\/\//i.test(link.href) &&
new RegExp(
"\\.(" + (optionsLink.downloadsExtensions || []).join("|") + ")$",
"i"
"i",
).test(link.pathname)
) {
collect = "download";
Expand Down
Loading