瀏覽代碼

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

master
damencho 5 年之前
父節點
當前提交
430125a8bd
共有 1 個文件被更改,包括 25 次插入0 次删除
  1. 25
    0
      react/features/analytics/functions.js

+ 25
- 0
react/features/analytics/functions.js 查看文件

@@ -1,5 +1,6 @@
1 1
 // @flow
2 2
 
3
+import { API_ID } from '../../../modules/API';
3 4
 import {
4 5
     checkChromeExtensionsInstalled,
5 6
     isMobileBrowser
@@ -155,6 +156,12 @@ export function initAnalytics({ getState }: { getState: Function }, handlers: Ar
155 156
     //  Report if user is using websocket
156 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 165
     // Optionally, include local deployment information based on the
159 166
     // contents of window.config.deploymentInfo.
160 167
     if (deploymentInfo) {
@@ -184,6 +191,24 @@ export function initAnalytics({ getState }: { getState: Function }, handlers: Ar
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 213
  * Tries to load the scripts for the analytics handlers and creates them.
189 214
  *

Loading…
取消
儲存