|
|
@@ -4,6 +4,7 @@ var RTPStats = require("./RTPStatsCollector.js");
|
|
4
|
4
|
var EventEmitter = require("events");
|
|
5
|
5
|
var StatisticsEvents = require("../../service/statistics/Events");
|
|
6
|
6
|
var CallStats = require("./CallStats");
|
|
|
7
|
+var ScriptUtil = require('../util/ScriptUtil');
|
|
7
|
8
|
|
|
8
|
9
|
// Since callstats.io is a third party, we cannot guarantee the quality of
|
|
9
|
10
|
// their service. More specifically, their server may take noticeably long
|
|
|
@@ -13,15 +14,10 @@ var CallStats = require("./CallStats");
|
|
13
|
14
|
// start downloading their API as soon as possible and (2) do the
|
|
14
|
15
|
// downloading asynchronously.
|
|
15
|
16
|
function loadCallStatsAPI() {
|
|
16
|
|
- (function (d, src) {
|
|
17
|
|
- var elementName = 'script';
|
|
18
|
|
- var newScript = d.createElement(elementName);
|
|
19
|
|
- var referenceNode = d.getElementsByTagName(elementName)[0];
|
|
20
|
|
-
|
|
21
|
|
- newScript.async = true;
|
|
22
|
|
- newScript.src = src;
|
|
23
|
|
- referenceNode.parentNode.insertBefore(newScript, referenceNode);
|
|
24
|
|
- })(document, 'https://api.callstats.io/static/callstats.min.js');
|
|
|
17
|
+ ScriptUtil.loadScript(
|
|
|
18
|
+ 'https://api.callstats.io/static/callstats.min.js',
|
|
|
19
|
+ /* async */ true,
|
|
|
20
|
+ /* prepend */ true);
|
|
25
|
21
|
// FIXME At the time of this writing, we hope that the callstats.io API will
|
|
26
|
22
|
// have loaded by the time we needed it (i.e. CallStats.init is invoked).
|
|
27
|
23
|
}
|