Browse Source

Merge pull request #2479 from bgrozev/ga-tweaks

Ga tweaks
master
virtuacoplenny 7 years ago
parent
commit
423c8d3f53
No account linked to committer's email address
3 changed files with 17 additions and 4 deletions
  1. 11
    3
      analytics-ga.js
  2. 3
    0
      config.js
  3. 3
    1
      react/features/analytics/functions.js

+ 11
- 3
analytics-ga.js View File

4
     /**
4
     /**
5
      *
5
      *
6
      */
6
      */
7
-    function Analytics() {
7
+    function Analytics(options) {
8
         /* eslint-disable */
8
         /* eslint-disable */
9
 
9
 
10
+        if (!options.googleAnalyticsTrackingId) {
11
+            console.log(
12
+                'Failed to initialize Google Analytics handler, no tracking ID');
13
+             return;
14
+        }
15
+
10
         /**
16
         /**
11
          * Google Analytics
17
          * Google Analytics
18
+         * TODO: Keep this local, there's no need to add it to window.
12
          */
19
          */
13
         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
20
         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
14
             (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
21
             (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
15
         })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
22
         })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
16
-        ga('create', 'UA-319188-14', 'jit.si');
23
+        ga('create', options.googleAnalyticsTrackingId, 'jit.si');
17
         ga('send', 'pageview');
24
         ga('send', 'pageview');
18
 
25
 
19
         /* eslint-enable */
26
         /* eslint-enable */
93
         // lengthy and is probably included from elsewhere.
100
         // lengthy and is probably included from elsewhere.
94
         for (const property in event.attributes) {
101
         for (const property in event.attributes) {
95
             if (property !== 'permanent_user_agent'
102
             if (property !== 'permanent_user_agent'
103
+                && property !== 'permanent_callstats_name'
96
                 && event.attributes.hasOwnProperty(property)) {
104
                 && event.attributes.hasOwnProperty(property)) {
97
                 // eslint-disable-next-line prefer-template
105
                 // eslint-disable-next-line prefer-template
98
                 label += property + '=' + event.attributes[property] + '&';
106
                 label += property + '=' + event.attributes[property] + '&';
114
      * lib-jitsi-meet.
122
      * lib-jitsi-meet.
115
      */
123
      */
116
     Analytics.prototype.sendEvent = function(event) {
124
     Analytics.prototype.sendEvent = function(event) {
117
-        if (!event) {
125
+        if (!event || !ga) {
118
             return;
126
             return;
119
         }
127
         }
120
 
128
 

+ 3
- 0
config.js View File

313
     //      "https://example.com/my-custom-analytics.js"
313
     //      "https://example.com/my-custom-analytics.js"
314
     // ],
314
     // ],
315
 
315
 
316
+    // The Google Analytics Tracking ID
317
+    // googleAnalyticsTrackingId = 'your-tracking-id-here-UA-123456-1',
318
+
316
     // Information about the jitsi-meet instance we are connecting to, including
319
     // Information about the jitsi-meet instance we are connecting to, including
317
     // the user region as seen by the server.
320
     // the user region as seen by the server.
318
     deploymentInfo: {
321
     deploymentInfo: {

+ 3
- 1
react/features/analytics/functions.js View File

43
 
43
 
44
     const state = getState();
44
     const state = getState();
45
     const config = state['features/base/config'];
45
     const config = state['features/base/config'];
46
-    const { analyticsScriptUrls, deploymentInfo } = config;
46
+    const { analyticsScriptUrls, deploymentInfo, googleAnalyticsTrackingId }
47
+        = config;
47
     const { group, server, user } = state['features/base/jwt'];
48
     const { group, server, user } = state['features/base/jwt'];
48
     const handlerConstructorOptions = {
49
     const handlerConstructorOptions = {
49
         envType: (deploymentInfo && deploymentInfo.envType) || 'dev',
50
         envType: (deploymentInfo && deploymentInfo.envType) || 'dev',
51
+        googleAnalyticsTrackingId,
50
         group,
52
         group,
51
         product: deploymentInfo && deploymentInfo.product,
53
         product: deploymentInfo && deploymentInfo.product,
52
         subproduct: deploymentInfo && deploymentInfo.environment,
54
         subproduct: deploymentInfo && deploymentInfo.environment,

Loading…
Cancel
Save