Skip to content

Commit

Permalink
Add vue-gtag and env variable to netlify toml
Browse files Browse the repository at this point in the history
  • Loading branch information
JackWilb committed Sep 28, 2023
1 parent 892bafb commit e185c2c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
publish = "dist/"
command = "yarn build"

[build.environment]
VITE_GA_TAG = "G-RL3875SQTJ"

[context.production.environment]
VITE_MULTINET_HOST = "https://api.multinet.app"
VITE_OAUTH_API_ROOT = "https://api.multinet.app/oauth/"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"vega-lite": "^5.8.0",
"vite": "^4.0.5",
"vue": "^2.7.0",
"vue-gtag": "1.16.1",
"vuetify": "^2.6.10",
"yorkie": "^2.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export const host: string = import.meta.env.VITE_MULTINET_HOST || 'http://localh
export const oauthApiRoot: string = import.meta.env.VITE_OAUTH_API_ROOT || `${host}/oauth`;
export const oauthClientId: string = import.meta.env.VITE_OAUTH_CLIENT_ID || '';
export const prodBuild: boolean = import.meta.env.PROD;
export const gaTag: string = import.meta.env.VITE_GA_TAG || '';
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import oauthClient from '@/oauth';
import { oauthClientId, prodBuild } from '@/environment';
import { createPinia, PiniaVuePlugin } from 'pinia';
import { invalidateSharedLoginCookie, readSharedLoginCookie, writeSharedLoginCookie } from 'multinet';
import './vuegtag';

Vue.config.productionTip = false;
Vue.use(PiniaVuePlugin);
Expand Down
12 changes: 12 additions & 0 deletions src/vuegtag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Vue from 'vue';
import VueGtag from 'vue-gtag';

import { gaTag } from '@/environment';

if (gaTag) {
Vue.use(VueGtag, {
config: {
id: gaTag,
},
});
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4696,6 +4696,11 @@ vue-eslint-parser@^9.0.1:
lodash "^4.17.21"
semver "^7.3.6"

[email protected]:
version "1.16.1"
resolved "https://registry.yarnpkg.com/vue-gtag/-/vue-gtag-1.16.1.tgz#edb2f20ab4f6c4d4d372dfecf8c1fcc8ab890181"
integrity sha512-5vs0pSGxdqrfXqN1Qwt0ZFXG0iTYjRMu/saddc7QIC5yp+DKgjWQRpGYVa7Pq+KbThxwzzMfo0sGi7ISa6NowA==

[email protected]:
version "2.7.10"
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.7.10.tgz#9e20f35b2fdccacacf732dd7dedb49bf65f4556b"
Expand Down

0 comments on commit e185c2c

Please sign in to comment.