Skip to content

Commit 7f1847d

Browse files
committed
chore: add analitycs
1 parent 57a3eec commit 7f1847d

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
run: npm ci
3030

3131
- name: Build website
32-
# env:
33-
# GTAG_ID: ${{ vars.GTAG_ID }}
32+
env:
33+
GTAG_ID: ${{ vars.GTAG_ID }}
3434
run: npm run build
3535

3636
- name: Upload artifact

eslint.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ export default [
2525
],
2626
},
2727
},
28+
{
29+
files: ['**/*.html'],
30+
rules: { 'jsdoc/require-jsdoc': 'off' },
31+
},
2832
]

rspack.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,15 @@ export default defineConfig({
5252
],
5353
},
5454
plugins: [
55-
new rspack.HtmlRspackPlugin({ template: './src/index.html' }),
55+
new rspack.DefinePlugin({
56+
GTAG_ID: JSON.stringify(true),
57+
}),
58+
new rspack.HtmlRspackPlugin({
59+
template: './src/index.html',
60+
templateParameters: {
61+
GTAG_ID: process.env.GTAG_ID || '',
62+
},
63+
}),
5664
new rspack.CopyRspackPlugin({
5765
patterns: [{ from: 'public' }],
5866
}),

src/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@
7272
href="https://fonts.googleapis.com/css2?family=Lora:[email protected]&display=swap"
7373
rel="stylesheet"
7474
/>
75+
76+
<!-- Google tag (gtag.js) -->
77+
<script
78+
async
79+
src="https://www.googletagmanager.com/gtag/js?id=<%= GTAG_ID %>"
80+
></script>
81+
<script>
82+
globalThis.dataLayer = globalThis.dataLayer || []
83+
function gtag() {
84+
globalThis.dataLayer.push(arguments)
85+
}
86+
gtag('js', new Date())
87+
88+
gtag('config', '<%= GTAG_ID %>')
89+
</script>
7590
</head>
7691
<body>
7792
<header class="header">

0 commit comments

Comments
 (0)