forked from adopted-ember-addons/ember-cli-bugsnag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (40 loc) · 1.43 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* jshint node: true */
'use strict';
module.exports = {
name: 'ember-cli-bugsnag',
contentFor: function(type, config) {
var content = '';
var bugsnagConfig;
var envArray;
if (type === 'head' && config.environment !== 'test') {
if (!config.bugsnag) {
console.warn('`config.bugsnag` is not defined, using environment variables instead.');
var envApiKey = process.env['BUGSNAG_API_KEY'];
var envReleases = process.env['BUGSNAG_NOTIFY_RELEASE'];
if (!envApiKey || !envReleases) {
console.error('Environment variables `BUGSNAG_API_KEY` and `BUGSNAG_NOTIFY_RELEASE` are not specified. Bugsnag will not be injected.');
return '';
}
bugsnagConfig = {
apiKey: envApiKey,
notifyReleaseStages: envReleases.split(',')
};
} else {
bugsnagConfig = config.bugsnag;
}
envArray = bugsnagConfig.notifyReleaseStages ? bugsnagConfig.notifyReleaseStages : [];
content = [
'<script ',
'src="https://d2wy8f7a9ursnm.cloudfront.net/bugsnag-2.min.js" ',
'data-appversion="' + config.currentRevision + '" ',
'data-apikey="' + bugsnagConfig.apiKey + '">',
'</script>',
'<script>',
'Bugsnag.releaseStage = "' + config.environment + '";',
'Bugsnag.notifyReleaseStages = ["' + envArray.join('","') + '"];',
'</script>'
];
}
return content;
}
};