This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new 90cad09  [OPENMEETINGS-2472] more work on csp, code clean-up
90cad09 is described below

commit 90cad09a90836c525c78dd52fd6f753644906ca5
Author: Maxim Solodovnik <solomax...@gmail.com>
AuthorDate: Sun Oct 4 10:22:13 2020 +0700

    [OPENMEETINGS-2472] more work on csp, code clean-up
---
 .../apache/openmeetings/db/dao/basic/ConfigurationDao.java   |  1 +
 .../java/org/apache/openmeetings/web/pages/BasePage.java     |  2 +-
 .../src/main/java/org/apache/openmeetings/web/pages/om-ga.js | 12 +++++-------
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
index 16c8537..273ce5f 100644
--- 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
+++ 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
@@ -632,6 +632,7 @@ public class ConfigurationDao implements 
IDataProviderDao<Configuration> {
                        if (!Strings.isEmpty(getGaCode())) {
                                // 
https://developers.google.com/tag-manager/web/csp#universal_analytics_google_analytics
                                addCspRule(cspConfig, CSPDirective.IMG_SRC, 
"https://www.google-analytics.com";);
+                               addCspRule(cspConfig, CSPDirective.CONNECT_SRC, 
"https://www.google-analytics.com";);
                                addCspRule(cspConfig, CSPDirective.SCRIPT_SRC, 
"https://www.googletagmanager.com";);
                        }
                        oauthDao.getActive().forEach(oauth -> {
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/BasePage.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/BasePage.java
index 97f6879..dbb1010 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/BasePage.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/BasePage.java
@@ -141,7 +141,7 @@ public abstract class BasePage extends 
AsyncUrlFragmentAwarePage {
                                }
                        })));
                        StringBuilder script = new StringBuilder("initGA('");
-                       
script.append(getGaCode()).append("');").append(isMainPage() ? "initHash()" : 
"init()").append(';');
+                       
script.append(getGaCode()).append("');").append(isMainPage() ? "initHash()" : 
"gtagEvent()").append(';');
                        response.render(OnDomReadyHeaderItem.forScript(script));
                }
                
response.render(CssHeaderItem.forReference(FontAwesome5CssReference.instance()));
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/om-ga.js 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/om-ga.js
index 65b4cb3..b3d6f99 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/om-ga.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/om-ga.js
@@ -3,18 +3,16 @@ window.dataLayer = window.dataLayer || [];
 function gtag() {
        dataLayer.push(arguments);
 }
+function gtagEvent() {
+       gtag('event', 'pageview', {page: location.pathname, hash: 
location.hash});
+}
 function initGA(code) {
        gtag('js', new Date());
 
        gtag('config', code);
 }
-function init() {
-       gtag('event', 'pageview');
-}
 function initHash() {
-       gtag('event', 'pageview', window.location.hash);
+       gtagEvent();
 
-       $(window).bind('hashchange', function() {
-               gtag('event', 'pageview', window.location.hash);
-       });
+       $(window).off('hashchange').on('hashchange', gtagEvent);
 }

Reply via email to