This repository has been archived by the owner on Aug 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
index.js
50 lines (46 loc) · 1.48 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
/* eslint-env node */
/* eslint no-var: "off", object-shorthand: "off" */
'use strict';
var merge = require('lodash/merge');
var replace = require('broccoli-string-replace');
var mergeTrees = require('broccoli-merge-trees');
var path = require('path');
module.exports = {
name: 'ember-cli-rollbar',
included: function(app) {
var config = this.project.config(this.app.env).rollbar || {};
var defaultEnabled = this.app.env !== 'development' && this.app.env !== 'test';
var enabled = config.enabled == null ? defaultEnabled : config.enabled;
if (process.env.EMBER_CLI_FASTBOOT !== 'true') {
app.import('vendor/rollbar.js', {
prepend: true
});
app.import('vendor/rollbar-module.js');
}
},
treeForVendor: function(vt) {
var vendorTree = this._super.treeForVendor(vt);
if (process.env.EMBER_CLI_FASTBOOT !== 'true') {
var config = this.project.config(this.app.env).rollbar || {};
config = merge({
enabled: this.app.env !== 'development' && this.app.env !== 'test',
captureUncaught: true,
payload: {
environment: this.app.env
}
}, config);
var clientTree = replace(path.join(__dirname, 'client'), {
files: ['rollbar.js'],
pattern: {
match: /ROLLBAR_CONFIG/g,
replacement: JSON.stringify(config)
}
});
return mergeTrees([vendorTree, clientTree], {
overwrite: true
});
} else {
return vendorTree;
}
}
};