Commit 88d0126b by MichaelJier

feature

1. 集成google-gtag
parent e73d7072
...@@ -40,6 +40,7 @@ module.exports = { ...@@ -40,6 +40,7 @@ module.exports = {
DEF_AODIANYUN: '//cdn.aodianyun.com', DEF_AODIANYUN: '//cdn.aodianyun.com',
DEF_S_AODIANYUN: '//cdn.aodianyun.com', DEF_S_AODIANYUN: '//cdn.aodianyun.com',
DEF_SITE: '//web.guangdianyun.tv', DEF_SITE: '//web.guangdianyun.tv',
GTAG_ID: 'G-H08BKPKZPJ',
HTTPS_PORT: '', HTTPS_PORT: '',
HTTP_PORT: '', HTTP_PORT: '',
X_CA_STAGE: '', X_CA_STAGE: '',
......
...@@ -6,6 +6,25 @@ const env = { ...globalEnv, ...modeEnv }; ...@@ -6,6 +6,25 @@ const env = { ...globalEnv, ...modeEnv };
const { DEF_S_AODIANYUN, DEF_OSS, X_CA_STAGE, sentryOptions } = env; const { DEF_S_AODIANYUN, DEF_OSS, X_CA_STAGE, sentryOptions } = env;
const BUILD_DIST = X_CA_STAGE || 'PROD'; const BUILD_DIST = X_CA_STAGE || 'PROD';
const flag = process.env.NODE_ENV === 'production' && !env.private
const gtagConfig = flag
? {
'google-gtag': {
id: env.GTAG_ID,
config: {
anonymize_ip: true, // anonymize IP
send_page_view: false // might be necessary to avoid duplicated page track on page reload
},
// linker:{
// domains:[] // 跨域追踪,追踪两个相关但不同网域的页面
// },
debug: true, // enable to track in dev mode
disableAutoPageTrack: false, // disable if you don't want to track each page route with router.afterEach(...).
additionalAccounts: []
}
}
: {}
export default { export default {
buildDir: 'nuxt-dist', buildDir: 'nuxt-dist',
env: { env: {
...@@ -79,6 +98,7 @@ export default { ...@@ -79,6 +98,7 @@ export default {
modules: [ modules: [
'@nuxtjs/axios', '@nuxtjs/axios',
'@nuxtjs/sentry', '@nuxtjs/sentry',
'@nuxtjs/google-gtag',
[ [
'@nuxtjs/component-cache', '@nuxtjs/component-cache',
{ {
...@@ -87,6 +107,7 @@ export default { ...@@ -87,6 +107,7 @@ export default {
} }
] ]
], ],
...gtagConfig,
sentry: { sentry: {
dsn: sentryOptions.dsn, dsn: sentryOptions.dsn,
config: {} config: {}
......
...@@ -10,25 +10,21 @@ ...@@ -10,25 +10,21 @@
"serve:vvku": "cross-env mode=vvku.private nuxt", "serve:vvku": "cross-env mode=vvku.private nuxt",
"serve:pre": "cross-env mode=pre nuxt", "serve:pre": "cross-env mode=pre nuxt",
"serve:test": "cross-env mode=test nuxt", "serve:test": "cross-env mode=test nuxt",
"build": "nuxt build", "build": "nuxt build",
"build:cm": "cross-env mode=cm.private nuxt build", "build:cm": "cross-env mode=cm.private nuxt build",
"build:vvku": "cross-env mode=vvku.private nuxt build", "build:vvku": "cross-env mode=vvku.private nuxt build",
"build:pre": "cross-env mode=pre nuxt build", "build:pre": "cross-env mode=pre nuxt build",
"build:test": "cross-env mode=test nuxt build", "build:test": "cross-env mode=test nuxt build",
"start": "nuxt start", "start": "nuxt start",
"start:vvku": "cross-env mode=vvku.private nuxt start", "start:vvku": "cross-env mode=vvku.private nuxt start",
"start:cm": "cross-env mode=cm.private nuxt start", "start:cm": "cross-env mode=cm.private nuxt start",
"start:pre": "cross-env mode=pre nuxt start", "start:pre": "cross-env mode=pre nuxt start",
"start:test": "cross-env mode=test nuxt start", "start:test": "cross-env mode=test nuxt start",
"pm2": "pm2 start pm2.json --only live", "pm2": "pm2 start pm2.json --only live",
"pm2:cm": "pm2 start pm2.json --only live-cm", "pm2:cm": "pm2 start pm2.json --only live-cm",
"pm2:vvku": "pm2 start pm2.json --only live-vvku", "pm2:vvku": "pm2 start pm2.json --only live-vvku",
"pm2:pre": "pm2 start pm2.json --only live-pre", "pm2:pre": "pm2 start pm2.json --only live-pre",
"pm2:test": "pm2 start pm2.json --only live-test", "pm2:test": "pm2 start pm2.json --only live-test",
"generate": "nuxt generate", "generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .", "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore ." "lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore ."
...@@ -38,6 +34,7 @@ ...@@ -38,6 +34,7 @@
"@gdyfe/uploader": "^2.0.3", "@gdyfe/uploader": "^2.0.3",
"@nuxtjs/axios": "^5.3.6", "@nuxtjs/axios": "^5.3.6",
"@nuxtjs/component-cache": "^1.1.5", "@nuxtjs/component-cache": "^1.1.5",
"@nuxtjs/google-gtag": "^1.0.4",
"@nuxtjs/router": "^1.5.0", "@nuxtjs/router": "^1.5.0",
"@nuxtjs/sentry": "^4.1.2", "@nuxtjs/sentry": "^4.1.2",
"ali-oss": "^6.10.0", "ali-oss": "^6.10.0",
......
...@@ -2501,6 +2501,11 @@ ...@@ -2501,6 +2501,11 @@
dependencies: dependencies:
lru-cache "^6.0.0" lru-cache "^6.0.0"
"@nuxtjs/google-gtag@^1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@nuxtjs/google-gtag/-/google-gtag-1.0.4.tgz#57562d8ec4c7694573e77edf72097da4a34b0d68"
integrity sha512-0Xgbx1uQ9pKeV2QdU9xoxJVdgH66qyGQJ0l8pzVxz5X476qvJunj6fbcjWk0gT+MEX/VOAhfT/zw0Z1z9q9oNg==
"@nuxtjs/proxy@^2.0.1": "@nuxtjs/proxy@^2.0.1":
version "2.0.1" version "2.0.1"
resolved "https://registry.yarnpkg.com/@nuxtjs/proxy/-/proxy-2.0.1.tgz#2469b6e316311aa8c60d348502a54bfe6d5536aa" resolved "https://registry.yarnpkg.com/@nuxtjs/proxy/-/proxy-2.0.1.tgz#2469b6e316311aa8c60d348502a54bfe6d5536aa"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment