forked from stayallive/wp-sentry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-sentry-browser-tracing.wp.js
65 lines (56 loc) · 2.18 KB
/
wp-sentry-browser-tracing.wp.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
;(function () {
if (typeof wp_sentry === 'object') {
var regexUrlList = function (urlList) {
for (var url in urlList) {
if (urlList.hasOwnProperty(url)) {
if (urlList[url].startsWith('regex:')) {
urlList[url] = new RegExp(urlList[url].slice(6), 'i');
}
}
}
};
if (typeof wp_sentry.allowUrls === 'object') {
regexUrlList(wp_sentry.allowUrls);
}
if (typeof wp_sentry.denyUrls === 'object') {
regexUrlList(wp_sentry.denyUrls);
}
if (wp_sentry.tracesSampleRate) {
wp_sentry.tracesSampleRate = parseFloat(wp_sentry.tracesSampleRate);
}
if (typeof wp_sentry_hook === 'function') {
var hookResult = wp_sentry_hook(wp_sentry);
// If the hook returns false we do not continue to initialize Sentry
if (hookResult === false) {
return;
}
}
if (wp_sentry.integrations === undefined) {
wp_sentry.integrations = [
new Sentry.Integrations.BrowserTracing()
];
}
Sentry.init(wp_sentry);
if (typeof wp_sentry.context === 'object') {
Sentry.configureScope(function (scope) {
if (typeof wp_sentry.context.user === 'object') {
scope.setUser(wp_sentry.context.user);
}
if (typeof wp_sentry.context.tags === 'object') {
for (var tag in wp_sentry.context.tags) {
if (wp_sentry.context.tags.hasOwnProperty(tag)) {
scope.setTag(tag, wp_sentry.context.tags[tag]);
}
}
}
if (typeof wp_sentry.context.extra === 'object') {
for (var extra in wp_sentry.context.extra) {
if (wp_sentry.context.extra.hasOwnProperty(extra)) {
scope.setExtra(extra, wp_sentry.context.extra[extra]);
}
}
}
});
}
}
})();