Browse Source

feat: Adds user props to analytics for iframe and external api.

master
damencho 5 years ago
parent
commit
430125a8bd
1 changed files with 25 additions and 0 deletions
  1. 25
    0
      react/features/analytics/functions.js

+ 25
- 0
react/features/analytics/functions.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
+import { API_ID } from '../../../modules/API';
3
 import {
4
 import {
4
     checkChromeExtensionsInstalled,
5
     checkChromeExtensionsInstalled,
5
     isMobileBrowser
6
     isMobileBrowser
155
     //  Report if user is using websocket
156
     //  Report if user is using websocket
156
     permanentProperties.websocket = navigator.product !== 'ReactNative' && typeof config.websocket === 'string';
157
     permanentProperties.websocket = navigator.product !== 'ReactNative' && typeof config.websocket === 'string';
157
 
158
 
159
+    // permanentProperties is external api
160
+    permanentProperties.externalApi = typeof API_ID === 'number';
161
+
162
+    // Report if we are loaded in iframe
163
+    permanentProperties.inIframe = _inIframe();
164
+
158
     // Optionally, include local deployment information based on the
165
     // Optionally, include local deployment information based on the
159
     // contents of window.config.deploymentInfo.
166
     // contents of window.config.deploymentInfo.
160
     if (deploymentInfo) {
167
     if (deploymentInfo) {
184
     }
191
     }
185
 }
192
 }
186
 
193
 
194
+/**
195
+ * Checks whether we are loaded in iframe.
196
+ *
197
+ * @returns {boolean} Returns {@code true} if loaded in iframe.
198
+ * @private
199
+ */
200
+function _inIframe() {
201
+    if (navigator.product === 'ReactNative') {
202
+        return false;
203
+    }
204
+
205
+    try {
206
+        return window.self !== window.top;
207
+    } catch (e) {
208
+        return true;
209
+    }
210
+}
211
+
187
 /**
212
 /**
188
  * Tries to load the scripts for the analytics handlers and creates them.
213
  * Tries to load the scripts for the analytics handlers and creates them.
189
  *
214
  *

Loading…
Cancel
Save