-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Override matomo window object #6411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,12 @@ import { localStorageFS } from '../files/filesystems/localStorage' | |
import { fileSystemUtility, migrationTestData } from '../files/filesystems/fileSystemUtility' | ||
import './styles/preload.css' | ||
import isElectron from 'is-electron' | ||
import { Matomo } from '../plugins/matomo' | ||
|
||
const _paq = (window._paq = window._paq || []) | ||
const matomo = new Matomo(_paq) | ||
|
||
window._paq = matomo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redefining window._paq here may be tricky, we don't actually know if loader.js has completed its task async loading the tracker code into _paq, and if the window._paq init object has been properly handled by the matomo initializing script. the point of matomo async loading is prevent any delays that would be caused by sync loading the script. so at this point the _paq may just be an array of the init we set in loader, it may not be the tracker at all @yann300 @ioedeveloper |
||
|
||
// _paq.push(['trackEvent', 'App', 'Preload', 'start']) | ||
|
||
|
@@ -34,13 +39,13 @@ export const Preload = (props: any) => { | |
function loadAppComponent() { | ||
import('../../app') | ||
.then((AppComponent) => { | ||
const appComponent = new AppComponent.default() | ||
const appComponent = new AppComponent.default(matomo) | ||
appComponent.run().then(() => { | ||
props.root.render(<RemixApp app={appComponent} />) | ||
}) | ||
}) | ||
.catch((err) => { | ||
_paq.push(['trackEvent', 'App', 'PreloadError', err && err.message]) | ||
matomo.push(['trackEvent', 'App', 'PreloadError', err && err.message]) | ||
console.error('Error loading Remix:', err) | ||
setError(true) | ||
}) | ||
|
@@ -68,10 +73,10 @@ export const Preload = (props: any) => { | |
]) | ||
if (fsLoaded) { | ||
console.log(fsLoaded.name + ' activated') | ||
_paq.push(['trackEvent', 'Storage', 'activate', fsLoaded.name]) | ||
matomo.push(['trackEvent', 'Storage', 'activate', fsLoaded.name]) | ||
loadAppComponent() | ||
} else { | ||
_paq.push(['trackEvent', 'Storage', 'error', 'no supported storage']) | ||
matomo.push(['trackEvent', 'Storage', 'error', 'no supported storage']) | ||
setSupported(false) | ||
} | ||
} | ||
|
@@ -89,8 +94,8 @@ export const Preload = (props: any) => { | |
return | ||
} | ||
async function loadStorage() { | ||
;(await remixFileSystems.current.addFileSystem(remixIndexedDB.current)) || _paq.push(['trackEvent', 'Storage', 'error', 'indexedDB not supported']) | ||
;(await remixFileSystems.current.addFileSystem(localStorageFileSystem.current)) || _paq.push(['trackEvent', 'Storage', 'error', 'localstorage not supported']) | ||
;(await remixFileSystems.current.addFileSystem(remixIndexedDB.current)) || matomo.push(['trackEvent', 'Storage', 'error', 'indexedDB not supported']) | ||
;(await remixFileSystems.current.addFileSystem(localStorageFileSystem.current)) || matomo.push(['trackEvent', 'Storage', 'error', 'localstorage not supported']) | ||
await testmigration() | ||
remixIndexedDB.current.loaded && (await remixIndexedDB.current.checkWorkspaces()) | ||
localStorageFileSystem.current.loaded && (await localStorageFileSystem.current.checkWorkspaces()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't that slow down the loading? did you notice some latency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it does not slow it down.