This repository was archived by the owner on Oct 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
104 lines (91 loc) · 2.5 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
'use strict';
/**
* Module dependencies.
*/
var integration = require('@segment/analytics.js-integration');
var is = require('is');
var foldl = require('@ndhoule/foldl');
/**
* Expose `Sentry` integration.
*/
var Sentry = module.exports = integration('Sentry')
.global('Raven')
.global('RavenConfig')
.option('config', '')
.option('serverName', null)
.option('release', null)
.option('ignoreErrors', [])
.option('ignoreUrls', [])
.option('whitelistUrls', [])
.option('includePaths', [])
.option('maxMessageLength', null)
.option('logger', null)
.option('customVersionProperty', null)
.tag('<script src="https://cdn.ravenjs.com/3.24.2/raven.min.js" crossorigin="anonymous">');
/**
* Initialize.
*
* https://docs.sentry.io/clients/javascript/config/
* https://github.com/getsentry/raven-js/blob/3.12.1/src/raven.js#L646-L649
* @api public
*/
Sentry.prototype.initialize = function() {
var dsnPublic = this.options.config;
var customRelease = this.options.customVersionProperty ? window[this.options.customVersionProperty] : null;
var options = {
logger: this.options.logger,
release: customRelease || this.options.release,
serverName: this.options.serverName,
whitelistUrls: this.options.whitelistUrls,
ignoreErrors: this.options.ignoreErrors,
ignoreUrls: this.options.ignoreUrls,
includePaths: this.options.includePaths,
maxMessageLength: this.options.maxMessageLength
};
window.RavenConfig = {
dsn: dsnPublic,
config: reject(options)
};
this.load(this.ready);
};
/**
* Loaded?
*
* @api private
* @return {boolean}
*/
Sentry.prototype.loaded = function() {
return is.object(window.Raven);
};
/**
* Identify.
*
* @api public
* @param {Identify} identify
*/
Sentry.prototype.identify = function(identify) {
window.Raven.setUserContext(identify.traits());
};
/**
* Clean out null values
*/
function reject(obj) {
return foldl(function(result, val, key) {
// strip any null or empty string values
if (val !== null && val !== '' && !is.array(val)) {
result[key] = val;
}
// strip any empty arrays
if (is.array(val)) {
var ret = [];
// strip if there's only an empty string or null in the array since the settings UI lets you save additional rows even though some may be empty strings
for (var x = 0; x < val.length; x++) {
if (val[x] !== null && val[x] !== '') ret.push(val[x]);
}
if (!is.empty(ret)) {
result[key] = ret;
}
}
return result;
}, {}, obj);
}