|
21 | 21 | * |
22 | 22 | */ |
23 | 23 |
|
24 | | -/*global Phoenix*/ |
| 24 | +/*global AppConfig*/ |
25 | 25 | define(function (require, exports, module) { |
26 | 26 | const Metrics = brackets.getModule("utils/Metrics"), |
27 | 27 | PreferencesManager = brackets.getModule("preferences/PreferencesManager"), |
28 | 28 | PerfUtils = brackets.getModule("utils/PerfUtils"), |
29 | 29 | NodeUtils = brackets.getModule("utils/NodeUtils"), |
30 | 30 | themesPref = PreferencesManager.getExtensionPrefs("themes"); |
31 | 31 |
|
| 32 | + const BugsnagPerformance = window.BugsnagPerformance; |
| 33 | + |
32 | 34 | const PLATFORM = Metrics.EVENT_TYPE.PLATFORM, |
33 | 35 | PERFORMANCE = Metrics.EVENT_TYPE.PERFORMANCE, |
34 | 36 | STORAGE = Metrics.EVENT_TYPE.STORAGE; |
@@ -133,17 +135,34 @@ define(function (require, exports, module) { |
133 | 135 | _sendStorageMetrics(); |
134 | 136 | } |
135 | 137 |
|
| 138 | + let bugsnagPerformanceInited = false; |
| 139 | + function _initBugsnagPerformance() { |
| 140 | + bugsnagPerformanceInited = true; |
| 141 | + BugsnagPerformance.start({ |
| 142 | + apiKey: '94ef94f4daf871ca0f2fc912c6d4764d', |
| 143 | + appVersion: AppConfig.version, |
| 144 | + releaseStage: window.__TAURI__ ? |
| 145 | + `tauri-${AppConfig.config.bugsnagEnv}-${Phoenix.platform}` : AppConfig.config.bugsnagEnv, |
| 146 | + autoInstrumentRouteChanges: false, |
| 147 | + autoInstrumentNetworkRequests: false, |
| 148 | + autoInstrumentFullPageLoads: false |
| 149 | + }); |
| 150 | + } |
| 151 | + |
136 | 152 | function _bugsnagPerformance(key, valueMs) { |
137 | | - if(Metrics.isDisabled() || !window.BugsnagPerformance || Phoenix.isTestWindow){ |
| 153 | + if(Metrics.isDisabled() || !BugsnagPerformance || Phoenix.isTestWindow){ |
138 | 154 | return; |
139 | 155 | } |
| 156 | + if(!bugsnagPerformanceInited) { |
| 157 | + _initBugsnagPerformance(); |
| 158 | + } |
140 | 159 | let activityStartTime = new Date(); |
141 | 160 | let activityEndTime = new Date(activityStartTime.getTime() + valueMs); |
142 | | - window.BugsnagPerformance |
| 161 | + BugsnagPerformance |
143 | 162 | .startSpan(key, { startTime: activityStartTime }) |
144 | 163 | .end(activityEndTime); |
145 | 164 | } |
146 | | - |
| 165 | + |
147 | 166 | // Performance |
148 | 167 | function sendStartupPerformanceMetrics() { |
149 | 168 | const healthReport = PerfUtils.getHealthReport(); |
|
0 commit comments