Skip to content

Commit

Permalink
Fix masking domain names; fix Docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Sep 24, 2020
1 parent 994e83a commit 8540403
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM alpine AS stage
WORKDIR /app
COPY . /app

RUN apk add --update npm=12.15.0-r1
RUN apk add --update 'npm<13.0.0'
RUN npm install

# Build aclual container
Expand All @@ -16,7 +16,7 @@ COPY . /app
COPY --from=stage /app/node_modules /app/node_modules
WORKDIR /app

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

EXPOSE 80

Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default {
"/google-analytics",
"/www.google-analytics.com",
"/adsbygoogle",
"/gtag/js",
"/googleads",
"/log_event\\?",
"/r/collect",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const mask = (matchedString) => matchedString.replace(
);
export const unmask = (string) => string.replace(/\*\(([^\)]+)\)\*/g, (_, masked) =>
Buffer.from(decodeURIComponent(masked), "base64").toString()
)
);
2 changes: 1 addition & 1 deletion src/modules/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const replaceDomainsForHost = (host) => (match, pos, str) => {
escapedSlashes
? (config.proxyDomain || host).replace(/\//g, "\\/") + "\\"
: (config.proxyDomain || host)
}${ config.strippedPath }/${ match }`;
}${ config.strippedPath }/${ mask(match) }`;
return r;
};

Expand Down
14 changes: 9 additions & 5 deletions static-test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
<meta charset="UTF-8"/>

<!-- Google Tag Manager Setup (a script which loads other analytics tools) -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
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
'/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)
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script> <!-- Replace GTM-XXXXXXX with your tag -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="/*(d3d3Lmdvb2dsZXRhZ21hbmFnZXIuY29t)*/*(Z3RhZw)*/*(anM)*?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-XXXXXXXX-X');
</script>
<!-- End Google Tag Manager Setup -->

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

0 comments on commit 8540403

Please sign in to comment.