forked from adopted-ember-addons/ember-cli-bugsnag
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
56 lines (46 loc) · 1.75 KB
/
index.js
File metadata and controls
56 lines (46 loc) · 1.75 KB
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
51
52
53
54
55
56
/* 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,
libraryUrl: process.env['BUGSNAG_LIBRARY_URL'],
notifyReleaseStages: envReleases.split(','),
releaseStage: process.env['BUGSNAG_RELEASE_STAGE']
};
} else {
bugsnagConfig = config.bugsnag;
}
var libraryUrl = bugsnagConfig.libraryUrl || 'https://d2wy8f7a9ursnm.cloudfront.net/bugsnag-2.min.js';
var releaseStage = bugsnagConfig.releaseStage || config.environment;
envArray = bugsnagConfig.notifyReleaseStages ? bugsnagConfig.notifyReleaseStages : [];
content = [
'<script ',
'src="' + libraryUrl + '" ',
'data-appversion="' + config.currentRevision + '" ',
'data-apikey="' + bugsnagConfig.apiKey + '">',
'</script>',
'<script>',
'if (typeof Bugsnag !== "undefined") {',
'Bugsnag.releaseStage = "' + releaseStage + '";',
'Bugsnag.notifyReleaseStages = ["' + envArray.join('","') + '"];',
'}',
'</script>'
];
}
return content;
}
};