Skip to content

Commit 8540403

Browse files
Fix masking domain names; fix Docker container
1 parent 994e83a commit 8540403

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM alpine AS stage
55
WORKDIR /app
66
COPY . /app
77

8-
RUN apk add --update npm=12.15.0-r1
8+
RUN apk add --update 'npm<13.0.0'
99
RUN npm install
1010

1111
# Build aclual container
@@ -16,7 +16,7 @@ COPY . /app
1616
COPY --from=stage /app/node_modules /app/node_modules
1717
WORKDIR /app
1818

19-
RUN apk add --update nodejs=12.15.0-r1
19+
RUN apk add --update 'nodejs<13.0.0'
2020

2121
EXPOSE 80
2222

config.js

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export default {
8888
"/google-analytics",
8989
"/www.google-analytics.com",
9090
"/adsbygoogle",
91+
"/gtag/js",
9192
"/googleads",
9293
"/log_event\\?",
9394
"/r/collect",

src/modules/mask.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export const mask = (matchedString) => matchedString.replace(
44
);
55
export const unmask = (string) => string.replace(/\*\(([^\)]+)\)\*/g, (_, masked) =>
66
Buffer.from(decodeURIComponent(masked), "base64").toString()
7-
)
7+
);

src/modules/proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const replaceDomainsForHost = (host) => (match, pos, str) => {
2121
escapedSlashes
2222
? (config.proxyDomain || host).replace(/\//g, "\\/") + "\\"
2323
: (config.proxyDomain || host)
24-
}${ config.strippedPath }/${ match }`;
24+
}${ config.strippedPath }/${ mask(match) }`;
2525
return r;
2626
};
2727

static-test/index.html

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
<meta charset="UTF-8"/>
66

77
<!-- Google Tag Manager Setup (a script which loads other analytics tools) -->
8-
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
9-
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
10-
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= // Don't forget to mask and replace the URL! npm run mask www.googletagmanager.com/gtm.js?id=ABCDEFG
11-
'/www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); // When you're done setting up URL forwarding, prefix /www.googletagmanager.com/... path with your proxy route (/gtm-proxy)
12-
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script> <!-- Replace GTM-XXXXXXX with your tag -->
8+
<!-- Global site tag (gtag.js) - Google Analytics -->
9+
<script async src="/*(d3d3Lmdvb2dsZXRhZ21hbmFnZXIuY29t)*/*(Z3RhZw)*/*(anM)*?id=UA-XXXXXXXX-X"></script>
10+
<script>
11+
window.dataLayer = window.dataLayer || [];
12+
function gtag(){dataLayer.push(arguments);}
13+
gtag('js', new Date());
14+
15+
gtag('config', 'UA-XXXXXXXX-X');
16+
</script>
1317
<!-- End Google Tag Manager Setup -->
1418

1519
<!-- OR: Plain Google Analytics Setup (just Google Analytics) -->

0 commit comments

Comments
 (0)