-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
72 lines (56 loc) · 1.78 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* eslint-env node */
'use strict';
var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var path = require('path');
module.exports = {
name: 'ember-braze',
_getEmberBrazeOptions: function() {
return (this.project.config(process.env.EMBER_ENV) || {}).appboy || {};
},
included: function(app) {
// see: https://github.com/ember-cli/ember-cli/issues/3718
while (typeof app.import !== 'function' && app.app) {
app = app.app;
}
this._super.included.apply(this, arguments);
var vendor = this.treePaths.vendor;
var options = this._getEmberBrazeOptions();
if (options.coreOnly) {
app.import(vendor + '/appboy-web-sdk/appboy.core.min.js');
} else {
app.import(vendor + '/appboy-web-sdk/appboy.min.js');
}
app.import(vendor + '/shims/appboy.js');
if (options.logExitIntent) {
app.import(vendor + '/ouibounce/ouibounce.min.js');
app.import(vendor + '/shims/ouibounce.js');
}
return app;
},
treeForVendor: function(vendorTree) {
var options = this._getEmberBrazeOptions();
var trees = [vendorTree];
var appboyPath = path.dirname(require.resolve('appboy-web-sdk'));
var appboyIncludes;
if (options.coreOnly) {
appboyIncludes = ['appboy.core.min.js'];
} else {
appboyIncludes = ['appboy.min.js'];
}
var appboy = new Funnel(appboyPath, {
destDir: 'appboy-web-sdk',
include: appboyIncludes,
});
trees.push(appboy);
if (options.logExitIntent) {
var ouibouncePath = path.dirname(require.resolve('ouibounce'));
var ouibounce = new Funnel(ouibouncePath, {
destDir: 'ouibounce',
include: ['ouibounce.min.js'],
});
trees.push(ouibounce);
}
return mergeTrees(trees);
}
};