Issue 1:
I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

GTM tags should work the same way on every page, whether the user arrived at this page or browsed to it.

Current Behavior

GTM tags that use the event type stop working properly as soon as a user browse the website. By "browse", I mean using client-side navigation, which doesn't refresh the page but only part of it (kinda the point of SPA)

Steps to Reproduce (for bugs)

You can reproduce on my online staging environment:

Install Chrome plugin: https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna to be able to see the GTM events calls in the browser console

Go to https://staging.hep.loan-advisor.studylink.fr/idrac

Click on the top-left IDRAC logo, you should see logs on the console (event fired)

Go to https://staging.hep.loan-advisor.studylink.fr and select the "Idrac" choice from the select input, then click "Go", you should see logs in the console again (redirection detected, which creates a pageview)

Click on the top-left IDRAC logo, you won't see any log this time

Context

I believe that somehow GTM binds some DOM events upon loading that get cleaned when the DOM changes due to Next.js redirection, which reloads the DOM, partially.

Those GTM tags (type: event) I'm talking about are basically triggers based on HTML class/id in the DOM. When I use the GTM Preview mode (debug), I can see that there is no gtm.linkClick fired when clicking the logo, if I got redirected from another page using a frontend-redirection. But if I refresh the page and click, it works just fine.

The simplest workaround I see is to disable client-side redirection but forcing a page refresh, but that's not a nice workaround and kills the point of building an SPA in the first place.

Maybe there is a way to force refresh the GTM script (need to clean it from the DOM and add it again because it won't trigger if already loaded), or to use a feature within GTM that binds everything again? I don't know.

Your Environment

Tech
Version

next
5.0.1-canary.16

node
6.10.3

browser
Chrome

Issue 2:
Bug report

Deploying Next to a Firebase function, gets the following error:

{ Error: Cannot find module '/srv/next/server/static\vk8cHgwKqiKyVYwLtSV~e\pages\_error.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at _callee$ (/srv/node_modules/next/dist/server/require.js:85:46)
at tryCatch (/srv/node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (/srv/node_modules/regenerator-runtime/runtime.js:288:22)
at Generator.prototype.(anonymous function) [as next] (/srv/node_modules/regenerator-runtime/runtime.js:114:21)
at asyncGeneratorStep (/srv/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)
at _next (/srv/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:27:9) code: 'MODULE_NOT_FOUND' }

Describe the bug

I think this is because there's a mix of slashes and backslashes in the file name so Node can't find it.

The file definitely exists in the correct folder.

System information

OS: Windows

Version of Next.js: 7.0.2

Additional context

Would it make sense to replace all backslashes with slashes in the getPagePath function?