|
@@ -18,16 +18,49 @@ var wrtcFuncNames = {
|
18
|
18
|
getUserMedia: "getUserMedia"
|
19
|
19
|
};
|
20
|
20
|
|
21
|
|
-// some errors may happen before CallStats init
|
22
|
|
-// in this case we accumulate them in this array
|
23
|
|
-// and send them to callstats on init
|
|
21
|
+/**
|
|
22
|
+ * Some errors may occur before CallStats.init in which case we will accumulate
|
|
23
|
+ * them and submit them to callstats.io on CallStats.init.
|
|
24
|
+ */
|
24
|
25
|
var pendingErrors = [];
|
25
|
26
|
|
26
|
27
|
function initCallback (err, msg) {
|
27
|
28
|
console.log("CallStats Status: err=" + err + " msg=" + msg);
|
28
|
29
|
}
|
29
|
30
|
|
30
|
|
-var callStatsIntegrationEnabled = config.callStatsID && config.callStatsSecret;
|
|
31
|
+/**
|
|
32
|
+ * The indicator which determines whether the integration of callstats.io is
|
|
33
|
+ * enabled/allowed. Its value does not indicate whether the integration will
|
|
34
|
+ * succeed at runtime but rather whether it is to be attempted at runtime at
|
|
35
|
+ * all.
|
|
36
|
+ */
|
|
37
|
+var _enabled
|
|
38
|
+ = config.callStatsID && config.callStatsSecret
|
|
39
|
+ // Even though AppID and AppSecret may be specified, the integration of
|
|
40
|
+ // callstats.io may be disabled because of globally-disallowed requests
|
|
41
|
+ // to any third parties.
|
|
42
|
+ && (config.disableThirdPartyRequests !== true);
|
|
43
|
+
|
|
44
|
+if (_enabled) {
|
|
45
|
+ // Since callstats.io is a third party, we cannot guarantee the quality of
|
|
46
|
+ // their service. More specifically, their server may take noticeably long
|
|
47
|
+ // time to respond. Consequently, it is in our best interest (in the sense
|
|
48
|
+ // that the intergration of callstats.io is pretty important to us but not
|
|
49
|
+ // enough to allow it to prevent people from joining a conference) to (1)
|
|
50
|
+ // start downloading their API as soon as possible and (2) do the
|
|
51
|
+ // downloading asynchronously.
|
|
52
|
+ (function (d, src) {
|
|
53
|
+ var elementName = 'script';
|
|
54
|
+ var newScript = d.createElement(elementName);
|
|
55
|
+ var referenceNode = d.getElementsByTagName(elementName)[0];
|
|
56
|
+
|
|
57
|
+ newScript.async = true;
|
|
58
|
+ newScript.src = src;
|
|
59
|
+ referenceNode.parentNode.insertBefore(newScript, referenceNode);
|
|
60
|
+ })(document, 'https://api.callstats.io/static/callstats.min.js');
|
|
61
|
+ // FIXME At the time of this writing, we hope that the callstats.io API will
|
|
62
|
+ // have loaded by the time we needed it (i.e. CallStats.init is invoked).
|
|
63
|
+}
|
31
|
64
|
|
32
|
65
|
/**
|
33
|
66
|
* Returns a function which invokes f in a try/catch block, logs any exception
|
|
@@ -101,7 +134,7 @@ var CallStats = {
|
101
|
134
|
* false.
|
102
|
135
|
*/
|
103
|
136
|
isEnabled: function() {
|
104
|
|
- return callStatsIntegrationEnabled;
|
|
137
|
+ return _enabled;
|
105
|
138
|
},
|
106
|
139
|
|
107
|
140
|
pcCallback: _try_catch(function (err, msg) {
|