vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.58k stars 4.76k forks source link

Page views sent to google analytics don’t include config.base in URLs #818

Closed abruere closed 6 years ago

abruere commented 6 years ago

Bug report

Version 0.14.2

Steps to reproduce

  1. Add a config.base path like /docs/

  2. (a) Set config.ga to a valid Google Analytics User Id, (b) set NODE_ENV to production and (c) see URL without base prefix in google analytics panel OR just insert this here (https://github.com/vuejs/vuepress/blob/v0.14.2/lib/app/clientEntry.js#L37) :

router.afterEach(function (to) {
  console.log(to, to.fullPath)
})

What is expected?

Page views sent to google analytics should include config base such as /docs/somepage.html. This is especially expected if vuepress is used to serve only a part of a website in some folder such as /docs.

What is actually happening?

Router to.fullPath is just somepage.html, and is used to log page views.

Other relevant information

abruere commented 6 years ago

I can submit a PR to fix this using app.$withBase helper.

ulivz commented 6 years ago

Release at @0.14.4.