mirror of
https://github.com/misenhower/splatoon2.ink.git
synced 2026-07-13 07:01:33 -05:00
Add Google Analytics
This change also disables automatic script/style injection in the HTML Webpack Plugin so we can maintain control over script order.
This commit is contained in:
parent
4c93e3f573
commit
288bdbe7b0
|
|
@ -5,5 +5,8 @@ NINTENDO_SESSION_ID=
|
|||
# Provided by: https://www.reddit.com/user/thejellydude
|
||||
SALMON_RUN_CALENDAR_ICS_URL=https://calendar.google.com/calendar/ical/7e5g474p0ng7vaejkg3mkomhks%40group.calendar.google.com/public/basic.ics
|
||||
|
||||
# (Optional) Google Analytics tracking ID
|
||||
GOOGLE_ANALYTICS_ID=
|
||||
|
||||
# (Optional) Sentry error reporting (https://sentry.io)
|
||||
SENTRY_DSN=
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@
|
|||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<meta name="apple-mobile-web-app-title" content="Splatoon2.ink">
|
||||
<% for (var css in htmlWebpackPlugin.files.css) { %>
|
||||
<link href="<%= htmlWebpackPlugin.files.css[css] %>" rel="stylesheet">
|
||||
<% } %>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="<%= require('../icons/apple-touch-icon.png') %>">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="<%= require('../icons/favicon-32x32.png') %>">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="<%= require('../icons/favicon-16x16.png') %>">
|
||||
|
|
@ -23,5 +26,9 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
|
||||
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
|
||||
<% } %>
|
||||
<script async src='https://www.google-analytics.com/analytics.js'></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
5
src/js/analytics.js
Normal file
5
src/js/analytics.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
if (GOOGLE_ANALYTICS_ID) {
|
||||
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
|
||||
ga('create', GOOGLE_ANALYTICS_ID, 'auto');
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
|
|
@ -5,3 +5,6 @@ import './filters.js';
|
|||
// Start the Vue app with our root component
|
||||
import App from './components/App.vue';
|
||||
new Vue(App).$mount('#app');
|
||||
|
||||
// Start analytics
|
||||
require('./analytics');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
require('dotenv').config();
|
||||
const path = require('path');
|
||||
const glob = require('glob');
|
||||
const webpack = require('webpack');
|
||||
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
|
|
@ -79,6 +81,9 @@ module.exports = function(env) {
|
|||
// 'public/assets/css/*',
|
||||
// 'public/assets/js/*',
|
||||
// ]),
|
||||
new webpack.DefinePlugin({
|
||||
'GOOGLE_ANALYTICS_ID': JSON.stringify(process.env.GOOGLE_ANALYTICS_ID),
|
||||
}),
|
||||
// Extract CSS to a separate file
|
||||
new ExtractTextPlugin({
|
||||
filename: 'assets/css/[name].[contenthash:6].css',
|
||||
|
|
@ -102,6 +107,7 @@ module.exports = function(env) {
|
|||
}),
|
||||
// Build HTML
|
||||
new HtmlWebpackPlugin({
|
||||
inject: false,
|
||||
filename: 'index.html',
|
||||
template: 'src/html/index.html',
|
||||
minify: { collapseWhitespace: true },
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user