您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AnalyticsAdapter.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* global config, JitsiMeetJS */
  2. // Load the integration of a third-party analytics API such as Google Analytics.
  3. // Since we cannot guarantee the quality of the third-party service (e.g. their
  4. // server may take noticeably long time to respond), it is in our best interest
  5. // (in the sense that the intergration of the analytics API is important to us
  6. // but not enough to allow it to prevent people from joining a conference) to
  7. // download the API asynchronously. Additionally, Google Analytics will download
  8. // its implementation asynchronously anyway so it makes sense to append the
  9. // loading on our side rather than prepend it.
  10. if (config.disableThirdPartyRequests !== true) {
  11. JitsiMeetJS.util.ScriptUtil.loadScript(
  12. 'analytics.js?v=1',
  13. /* async */ true,
  14. /* prepend */ false);
  15. }
  16. class NoopAnalytics {
  17. sendEvent () {}
  18. }
  19. // XXX Since we asynchronously load the integration of the analytics API and the
  20. // analytics API may asynchronously load its implementation (e.g. Google
  21. // Analytics), we cannot make the decision with respect to which analytics
  22. // implementation we will use here and we have to postpone it i.e. we will make
  23. // a lazy decision.
  24. class AnalyticsAdapter {
  25. constructor () {
  26. }
  27. sendEvent (...args) {
  28. var a = this.analytics;
  29. if (a === null || typeof a === 'undefined') {
  30. var AnalyticsImpl = window.Analytics || NoopAnalytics;
  31. this.analytics = a = new AnalyticsImpl();
  32. }
  33. try {
  34. a.sendEvent(...args);
  35. } catch (ignored) {}
  36. }
  37. }
  38. export default new AnalyticsAdapter();