🐛 Désactivation des actions pour les iFrames Safari

Revert de 233e9d3 et 7df6e5d
pull/915/head^2
Maxime Quandalle 2020-03-11 13:43:39 +01:00
parent 9e4d96cb54
commit c5a8f86c8d
No known key found for this signature in database
GPG Key ID: 428641C03D29CA10
2 changed files with 14 additions and 12 deletions

View File

@ -279,6 +279,7 @@
'setDomains',
['*.mon-entreprise.fr', '*.mycompanyinfrance.fr']
])
_paq.push(['trackPageView'])
_paq.push(['enableHeartBeatTimer', 30])
_paq.push(['enableLinkTracking'])
;(function() {

View File

@ -7,12 +7,11 @@ declare global {
}
}
type TrackingAction = 'trackPageView' | 'trackEvent' | 'disableCookies'
type PushArgs = [TrackingAction, ...Array<string | number>]
type PushArgs = ['trackPageView'] | ['trackEvent', ...Array<string | number>]
type PushType = (args: PushArgs) => void
const ua = window.navigator.userAgent
// https://chromium.googlesource.com/chromium/src.git/+/master/docs/ios/user_agent.md
const iOSSafari =
(!!ua.match(/iPad/i) || !!ua.match(/iPhone/i)) &&
!!ua.match(/WebKit/i) &&
@ -24,16 +23,18 @@ export default class Tracker {
previousPath: string | undefined
constructor(
pushFunction: PushType = args => (window?._paq ?? []).push(args)
) {
this.push = debounce(200, pushFunction) as PushType
// There is an issue with the way Safari handle cookies in iframe, cf.
// https://gist.github.com/iansltx/18caf551baaa60b79206.
// TODO : We don't need to disable cookies if a cookie is already set
if (iOSSafari && inIframe) {
pushFunction(['disableCookies'])
pushFunction: PushType = args => {
// There is an issue with the way Safari handle cookies in iframe, cf.
// https://gist.github.com/iansltx/18caf551baaa60b79206. We could probably
// do better but for now we don't track action of iOs Safari user in
// iFrame -- to avoid errors in the number of visitors in our stats.
if (!(iOSSafari && inIframe)) {
window._paq.push(args)
}
}
pushFunction(['trackPageView'])
) {
if (typeof window !== 'undefined') window._paq = window._paq || []
this.push = debounce(200, pushFunction) as PushType
}
connectToHistory(history: History) {