-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
37 lines (27 loc) · 813 Bytes
/
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
'use strict';
const fs = require('fs');
function readSnippet(fileName) {
return fs.readFileSync(`${__dirname}/vendor/${fileName}`, 'utf8');
}
module.exports = {
name: require('./package').name,
contentFor(type, config) {
const addonConfig = config['ember-user-performance-monitoring'] || {};
const { enabled, observePaint, observeLoad, observeTTI } = addonConfig;
if (type === 'head' && enabled) {
let script = '<script>';
script += readSnippet('observer.js');
if (observePaint) {
script += readSnippet('observe-paint.js');
}
if (observeLoad) {
script += readSnippet('observe-load.js');
}
if (observeTTI) {
script += readSnippet('observe-tti.js');
}
script += '</script>';
return script;
}
}
};