mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-22 23:46:44 -06:00
enable sentry browser tracing
This commit is contained in:
parent
d52a6d3b10
commit
1d8c32b7e5
@ -159,7 +159,9 @@ SCRIPTS_ROOT = getattr(configuration, 'SCRIPTS_ROOT', os.path.join(BASE_DIR, 'sc
|
||||
SEARCH_BACKEND = getattr(configuration, 'SEARCH_BACKEND', 'netbox.search.backends.CachedValueSearchBackend')
|
||||
SECURE_SSL_REDIRECT = getattr(configuration, 'SECURE_SSL_REDIRECT', False)
|
||||
SENTRY_DSN = getattr(configuration, 'SENTRY_DSN', DEFAULT_SENTRY_DSN)
|
||||
SENTRY_DSN_JS = getattr(configuration, 'SENTRY_DSN_JS', SENTRY_DSN)
|
||||
SENTRY_ENABLED = getattr(configuration, 'SENTRY_ENABLED', False)
|
||||
SENTRY_ENABLED_JS = getattr(configuration, 'SENTRY_ENABLED_JS', SENTRY_ENABLED)
|
||||
SENTRY_SAMPLE_RATE = getattr(configuration, 'SENTRY_SAMPLE_RATE', 1.0)
|
||||
SENTRY_TRACES_SAMPLE_RATE = getattr(configuration, 'SENTRY_TRACES_SAMPLE_RATE', 0)
|
||||
SENTRY_TAGS = getattr(configuration, 'SENTRY_TAGS', {})
|
||||
|
@ -40,6 +40,7 @@ async function bundleGraphIQL() {
|
||||
async function bundleNetBox() {
|
||||
const entryPoints = {
|
||||
netbox: 'src/index.ts',
|
||||
sentry: 'src/sentry.ts',
|
||||
};
|
||||
try {
|
||||
const result = await esbuild.build({
|
||||
|
BIN
netbox/project-static/dist/sentry.js
vendored
Normal file
BIN
netbox/project-static/dist/sentry.js
vendored
Normal file
Binary file not shown.
BIN
netbox/project-static/dist/sentry.js.map
vendored
Normal file
BIN
netbox/project-static/dist/sentry.js.map
vendored
Normal file
Binary file not shown.
@ -24,6 +24,7 @@
|
||||
"dependencies": {
|
||||
"@mdi/font": "^7.0.96",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"@sentry/browser": "^7.80.1",
|
||||
"bootstrap": "~5.0.2",
|
||||
"clipboard": "^2.0.11",
|
||||
"color2k": "^2.0.0",
|
||||
|
1
netbox/project-static/src/sentry.ts
Normal file
1
netbox/project-static/src/sentry.ts
Normal file
@ -0,0 +1 @@
|
||||
export * as Sentry from '@sentry/browser';
|
@ -107,6 +107,56 @@
|
||||
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.6.tgz#cee20bd55e68a1720bdab363ecf0c821ded4cd45"
|
||||
integrity sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==
|
||||
|
||||
"@sentry-internal/tracing@7.80.1":
|
||||
version "7.80.1"
|
||||
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.80.1.tgz#b0e993265aa75743787d84e6c0655ed17e4bac0f"
|
||||
integrity sha512-5gZ4LPIj2vpQl2/dHBM4uXMi9OI5E0VlOhJQt0foiuN6JJeiOjdpJFcfVqJk69wrc0deVENTtgKKktxqMwVeWQ==
|
||||
dependencies:
|
||||
"@sentry/core" "7.80.1"
|
||||
"@sentry/types" "7.80.1"
|
||||
"@sentry/utils" "7.80.1"
|
||||
|
||||
"@sentry/browser@^7.80.1":
|
||||
version "7.80.1"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.80.1.tgz#3e63a122846a4d5dec04237b97ae064b80546da4"
|
||||
integrity sha512-1dPR6vPJ9vOTzgXff9HGheb178XeEv5hyjBNhCO1f6rjCgnVj99XGNZIgO1Ee1ALJbqlfPWaeV+uSWbbcmgJMA==
|
||||
dependencies:
|
||||
"@sentry-internal/tracing" "7.80.1"
|
||||
"@sentry/core" "7.80.1"
|
||||
"@sentry/replay" "7.80.1"
|
||||
"@sentry/types" "7.80.1"
|
||||
"@sentry/utils" "7.80.1"
|
||||
|
||||
"@sentry/core@7.80.1":
|
||||
version "7.80.1"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.80.1.tgz#ccb85e15495bf0c8b142ca1713408c64e38c9f4c"
|
||||
integrity sha512-3Yh+O9Q86MxwIuJFYtuSSoUCpdx99P1xDAqL0FIPTJ+ekaVMiUJq9NmyaNh9uN2myPSmxvEXW6q3z37zta9ZHg==
|
||||
dependencies:
|
||||
"@sentry/types" "7.80.1"
|
||||
"@sentry/utils" "7.80.1"
|
||||
|
||||
"@sentry/replay@7.80.1":
|
||||
version "7.80.1"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.80.1.tgz#1f47d3e52bfd0ad531f3032ae1eda8528c947c44"
|
||||
integrity sha512-yjpftIyybQeWD2i0Nd7C96tZwjNbSMRW515EL9jwlNxYbQtGtMs0HavP9Y7uQvQrzwSHY0Wp+ooe9PMuvzqbHw==
|
||||
dependencies:
|
||||
"@sentry-internal/tracing" "7.80.1"
|
||||
"@sentry/core" "7.80.1"
|
||||
"@sentry/types" "7.80.1"
|
||||
"@sentry/utils" "7.80.1"
|
||||
|
||||
"@sentry/types@7.80.1":
|
||||
version "7.80.1"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.80.1.tgz#dc720d6f2da0b510d586814451a04a2cdd2f4a9d"
|
||||
integrity sha512-CVu4uPVTOI3U9kYiOdA085R7jX5H1oVODbs9y+A8opJ0dtJTMueCXgZyE8oXQ0NjGVs6HEeaLkOuiV0mj8X3yw==
|
||||
|
||||
"@sentry/utils@7.80.1":
|
||||
version "7.80.1"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.80.1.tgz#1c719f41b4d2c818363551fc40776a274b71efff"
|
||||
integrity sha512-bfFm2e/nEn+b9++QwjNEYCbS7EqmteT8uf0XUs7PljusSimIqqxDtK1pfD9zjynPgC8kW/fVBKv0pe2LufomeA==
|
||||
dependencies:
|
||||
"@sentry/types" "7.80.1"
|
||||
|
||||
"@types/bootstrap@^5.0.17":
|
||||
version "5.2.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/bootstrap/-/bootstrap-5.2.5.tgz#0bb5dea7720611b2bb7ba16bd8a64fafd86fb658"
|
||||
|
@ -23,6 +23,8 @@
|
||||
name="viewport"
|
||||
content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width, viewport-fit=cover"
|
||||
/>
|
||||
<meta name="sentry-trace" content="{% sentry_traceparent %}">
|
||||
<meta name="baggage" content="{% sentry_baggage %}">
|
||||
|
||||
{# Page title #}
|
||||
<title>{% block title %}{% trans "Home" %}{% endblock %} | NetBox</title>
|
||||
@ -65,6 +67,27 @@
|
||||
<link rel="icon" type="image/png" href="{% static 'netbox.ico' %}" />
|
||||
<link rel="apple-touch-icon" type="image/png" href="{% static 'netbox_touch-icon-180.png' %}" />
|
||||
|
||||
{# Sentry loader #}
|
||||
{% if settings.SENTRY_ENABLED_JS %}
|
||||
<script type="text/javascript">
|
||||
window.sentryOnLoad = function () {
|
||||
Sentry.init({
|
||||
release: '{{ settings.VERSION | safe }}',
|
||||
dsn: '{{ settings.SENTRY_DSN_JS | safe }}',
|
||||
integrations: [
|
||||
new Sentry.BrowserTracing()
|
||||
],
|
||||
sampleRate: {{ settings.SENTRY_SAMPLE_RATE }},
|
||||
tracesSampleRate: {{ settings.SENTRY_TRACES_SAMPLE_RATE }}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="{% static 'sentry.js' %}?v={{ settings.VERSION }}">
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{# Javascript #}
|
||||
<script
|
||||
type="text/javascript"
|
||||
|
@ -331,3 +331,19 @@ def applied_filters(context, model, form, query_params):
|
||||
'applied_filters': applied_filters,
|
||||
'save_link': save_link,
|
||||
}
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def sentry_traceparent():
|
||||
"""
|
||||
Return sentry-trace value
|
||||
"""
|
||||
return settings.sentry_sdk.get_traceparent()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def sentry_baggage():
|
||||
"""
|
||||
Return sentry baggage value
|
||||
"""
|
||||
return settings.sentry_sdk.get_baggage()
|
||||
|
Loading…
Reference in New Issue
Block a user