diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2020-10-02 03:20:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-02 03:20:20 +0300 |
commit | 2807e94baaa9b545f27a55a7dd071ba187799491 (patch) | |
tree | 9fa5722fe414e7f1e664d4226b2620d215fd1987 /js | |
parent | 06d43857c48ada2fa7f1ad18a8309e8826c0e413 (diff) |
JS Offline tracking (#15970)
* JS Offline tracking
* minor tweaks
* add some tests
* add some tests
* apply review feedback
Diffstat (limited to 'js')
-rw-r--r-- | js/piwik.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/js/piwik.js b/js/piwik.js index 2014d9dc7f..272dd7324a 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -6855,6 +6855,13 @@ if (typeof window.Matomo !== 'object') { // initialize the Matomo singleton addEventListener(windowAlias, 'beforeunload', beforeUnloadHandler, false); + addEventListener(windowAlias, 'online', function () { + if (isDefined(navigatorAlias.serviceWorker) && isDefined(navigatorAlias.serviceWorker.ready)) { + navigatorAlias.serviceWorker.ready.then(function(swRegistration) { + return swRegistration.sync.register('matomoSync'); + }); + } + }, false); addEventListener(windowAlias,'message', function(e) { if (!e || !e.origin) { |