Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
web-et-numerique
LLLE_Project
Ecolyo
Commits
4c911e62
Commit
4c911e62
authored
Jan 07, 2022
by
Yoan VALLET
Browse files
feat: handle remote url for matomo
parent
958098c7
Changes
2
Show whitespace changes
Inline
Side-by-side
src/targets/browser/index.tsx
View file @
4c911e62
...
...
@@ -61,6 +61,7 @@ const setupApp = memoize(() => {
Piwik
.
getTracker
()
const
tracker
=
new
MatomoTracker
({
cozyUrl
:
cozyUrl
,
url
:
__PIWIK_TRACKER_URL__
,
siteId
:
__PIWIK_SITEID__
,
history
:
history
,
...
...
src/utils/matomoTracker.ts
View file @
4c911e62
...
...
@@ -2,6 +2,7 @@ import { History, Location, UnregisterCallback } from 'history'
import
{
readCozyDataFromDOM
}
from
'
cozy-ui/transpiled/react/helpers/appDataset
'
interface
InitSettings
{
cozyUrl
:
string
url
:
string
siteId
:
number
history
:
History
...
...
@@ -15,6 +16,7 @@ declare global {
}
export
default
class
MatomoTracker
{
cozyUrl
:
string
url
:
string
siteId
:
number
phpFilename
:
string
...
...
@@ -23,6 +25,7 @@ export default class MatomoTracker {
unlistenFromHistory
:
UnregisterCallback
constructor
({
cozyUrl
,
url
,
siteId
,
history
,
...
...
@@ -33,6 +36,7 @@ export default class MatomoTracker {
'
MatomoTracker cannot be initialized! SiteId and url are mandatory.
'
)
}
this
.
cozyUrl
=
cozyUrl
this
.
url
=
url
this
.
siteId
=
siteId
this
.
phpFilename
=
phpFilename
...
...
@@ -48,6 +52,9 @@ export default class MatomoTracker {
if
(
url
.
indexOf
(
'
http://
'
)
!==
-
1
||
url
.
indexOf
(
'
https://
'
)
!==
-
1
)
{
url
=
`
${
url
}
/`
}
else
if
(
url
.
indexOf
(
'
/remote
'
)
!==
-
1
)
{
//use of remote doctype
url
=
`
${
this
.
cozyUrl
}${
url
}
/`
}
else
{
url
=
document
.
location
.
protocol
===
'
https:
'
...
...
@@ -58,7 +65,11 @@ export default class MatomoTracker {
window
.
_paq
=
window
.
_paq
||
[]
MatomoTracker
.
push
([
'
enableHeartBeatTimer
'
,
30
])
MatomoTracker
.
push
([
'
setSiteId
'
,
this
.
siteId
])
MatomoTracker
.
push
([
'
setTrackerUrl
'
,
`
${
url
+
this
.
phpFilename
}
`
])
// MatomoTracker.push(['setTrackerUrl', `${url + this.phpFilename}`])
MatomoTracker
.
push
([
'
setTrackerUrl
'
,
`http://cozy.tools:8080/remote/org.ecolyo.matomo.rec`
,
])
MatomoTracker
.
push
([
'
enableLinkTracking
'
])
}
return
{
...
...
Bastien DUMONT
@bdumont
mentioned in commit
54d29134
·
Apr 28, 2022
mentioned in commit
54d29134
mentioned in commit 54d29134d5ad6384bdbacb6a87f7e7051b5994f0
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment