@nuux/sentry 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Nuux::Sentry
|
|
2
2
|
|
|
3
|
-
Automatically configures Sentry for your Rails application
|
|
3
|
+
Automatically configures Sentry for your Rails application.
|
|
4
4
|
|
|
5
5
|
- https://docs.sentry.io/clients/ruby/
|
|
6
6
|
- https://docs.sentry.io/platforms/javascript/
|
|
@@ -35,12 +35,12 @@ Define `SENTRY_DSN` as environment variable.
|
|
|
35
35
|
Nuux::Sentry.configure do |config|
|
|
36
36
|
config.environments = %w[staging production]
|
|
37
37
|
|
|
38
|
-
config.user =
|
|
38
|
+
config.user = proc { try(:current_user) }
|
|
39
39
|
config.user_attributes = %i[id username]
|
|
40
40
|
config.browser_user_attributes = config.user_attributes
|
|
41
41
|
|
|
42
|
-
config.user_context =
|
|
43
|
-
config.extra_context =
|
|
42
|
+
config.user_context = proc { { ip_address: request.remote_ip } }
|
|
43
|
+
config.extra_context = {}
|
|
44
44
|
end
|
|
45
45
|
```
|
|
46
46
|
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
let config = {}
|
|
2
|
-
let user = {}
|
|
3
|
-
let tags = {}
|
|
4
2
|
|
|
5
3
|
const element = document.head.querySelector("meta[name='sentry']")
|
|
6
4
|
|
|
7
5
|
if (element) {
|
|
8
6
|
config = JSON.parse(window.atob(element.getAttribute("content")))
|
|
9
|
-
|
|
10
|
-
if (config.user) {
|
|
11
|
-
user = config.user
|
|
12
|
-
delete config.user
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (config.tags) {
|
|
16
|
-
tags = config.tags
|
|
17
|
-
delete config.tags
|
|
18
|
-
}
|
|
19
7
|
}
|
|
20
8
|
|
|
21
|
-
export { config
|
|
9
|
+
export { config }
|
|
@@ -1,37 +1,18 @@
|
|
|
1
1
|
import * as Sentry from "@sentry/browser"
|
|
2
|
-
import { Integrations as TracingIntegrations } from "@sentry/tracing"
|
|
3
2
|
|
|
4
|
-
import { config
|
|
5
|
-
import { isObject, debug } from "./helper"
|
|
3
|
+
import { config } from "./config"
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!config.tracesSampleRate) config.tracesSampleRate = 1.0
|
|
15
|
-
|
|
16
|
-
// Apply custom configuration
|
|
17
|
-
if (tapFunc instanceof Function) tapFunc(config, user, tags)
|
|
5
|
+
const isObject = (value) => {
|
|
6
|
+
if (value == null) {
|
|
7
|
+
return false
|
|
8
|
+
} else {
|
|
9
|
+
return value instanceof Object && Object.keys(value).length > 0
|
|
10
|
+
}
|
|
11
|
+
}
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
export const init = () => {
|
|
14
|
+
if (isObject(config) && config.dsn) {
|
|
20
15
|
Sentry.init(config)
|
|
21
|
-
|
|
22
|
-
Sentry.configureScope((scope) => {
|
|
23
|
-
if (isObject(user)) {
|
|
24
|
-
debug("@nuux/sentry: setUser", user)
|
|
25
|
-
scope.setUser(user)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (isObject(tags)) {
|
|
29
|
-
debug("@nuux/sentry: setTags", tags)
|
|
30
|
-
for (let [key, value] of Object.entries(tags)) {
|
|
31
|
-
scope.setTag(key, value);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
16
|
}
|
|
36
17
|
}
|
|
37
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuux/sentry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Initialize Sentry from a meta tag",
|
|
5
5
|
"main": "app/assets/javascript/nuux-sentry/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
"author": "nuux",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@sentry/browser": "^
|
|
13
|
-
"@sentry/cli": "^1.67.2",
|
|
14
|
-
"@sentry/tracing": "^6.10.0"
|
|
12
|
+
"@sentry/browser": "^7.50.0"
|
|
15
13
|
},
|
|
16
14
|
"files": [
|
|
17
15
|
"app/assets/javascript/nuux-sentry/*.js"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const isObject = (value) => {
|
|
2
|
-
if (value == null) {
|
|
3
|
-
return false
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
return value instanceof Object && Object.keys(value).length > 0
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const debug = (...attributes) => {
|
|
10
|
-
if (process.env.NODE_ENV == "development") {
|
|
11
|
-
console.debug(...attributes)
|
|
12
|
-
}
|
|
13
|
-
}
|