mirror of https://github.com/zulip/zulip.git
sentry: Enable reporting on portico and other unauth pages.
This commit is contained in:
parent
b04843e2f9
commit
739d527b16
|
@ -8,7 +8,7 @@ import {page_params} from "./page_params";
|
||||||
type UserInfo = {
|
type UserInfo = {
|
||||||
id?: string;
|
id?: string;
|
||||||
realm: string;
|
realm: string;
|
||||||
role: string;
|
role?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (page_params.server_sentry_dsn) {
|
if (page_params.server_sentry_dsn) {
|
||||||
|
@ -16,10 +16,18 @@ if (page_params.server_sentry_dsn) {
|
||||||
if (page_params.realm_uri !== undefined) {
|
if (page_params.realm_uri !== undefined) {
|
||||||
url_matches.push(new RegExp("^" + _.escapeRegExp(page_params.realm_uri) + "/"));
|
url_matches.push(new RegExp("^" + _.escapeRegExp(page_params.realm_uri) + "/"));
|
||||||
}
|
}
|
||||||
const sentry_key = page_params.realm_sentry_key || "(root)";
|
const sentry_key =
|
||||||
|
// No parameter is the portico pages, empty string is the empty realm
|
||||||
|
page_params.realm_sentry_key === undefined
|
||||||
|
? "www"
|
||||||
|
: page_params.realm_sentry_key === ""
|
||||||
|
? "(root)"
|
||||||
|
: page_params.realm_sentry_key;
|
||||||
const user_info: UserInfo = {
|
const user_info: UserInfo = {
|
||||||
realm: sentry_key,
|
realm: sentry_key,
|
||||||
role: page_params.is_owner
|
};
|
||||||
|
if (sentry_key !== "www") {
|
||||||
|
user_info.role = page_params.is_owner
|
||||||
? "Organization owner"
|
? "Organization owner"
|
||||||
: page_params.is_admin
|
: page_params.is_admin
|
||||||
? "Organization administrator"
|
? "Organization administrator"
|
||||||
|
@ -29,10 +37,12 @@ if (page_params.server_sentry_dsn) {
|
||||||
? "Guest"
|
? "Guest"
|
||||||
: page_params.is_spectator
|
: page_params.is_spectator
|
||||||
? "Spectator"
|
? "Spectator"
|
||||||
: "Member",
|
: page_params.user_id
|
||||||
};
|
? "Member"
|
||||||
if (page_params.user_id) {
|
: "Logged out";
|
||||||
user_info.id = page_params.user_id.toString();
|
if (page_params.user_id) {
|
||||||
|
user_info.id = page_params.user_id.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
|
|
|
@ -28,6 +28,7 @@ from zproject.backends import (
|
||||||
password_auth_enabled,
|
password_auth_enabled,
|
||||||
require_email_format_usernames,
|
require_email_format_usernames,
|
||||||
)
|
)
|
||||||
|
from zproject.config import get_config
|
||||||
|
|
||||||
DEFAULT_PAGE_PARAMS: Mapping[str, Any] = {
|
DEFAULT_PAGE_PARAMS: Mapping[str, Any] = {
|
||||||
"development_environment": settings.DEVELOPMENT,
|
"development_environment": settings.DEVELOPMENT,
|
||||||
|
@ -139,10 +140,19 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
|
||||||
f'<a href="mailto:{escape(support_email)}">{escape(support_email)}</a>'
|
f'<a href="mailto:{escape(support_email)}">{escape(support_email)}</a>'
|
||||||
)
|
)
|
||||||
|
|
||||||
default_page_params = {
|
default_page_params: Dict[str, Any] = {
|
||||||
**DEFAULT_PAGE_PARAMS,
|
**DEFAULT_PAGE_PARAMS,
|
||||||
|
"server_sentry_dsn": settings.SENTRY_FRONTEND_DSN,
|
||||||
"request_language": get_language(),
|
"request_language": get_language(),
|
||||||
}
|
}
|
||||||
|
if settings.SENTRY_FRONTEND_DSN is not None:
|
||||||
|
if realm is not None:
|
||||||
|
default_page_params["realm_sentry_key"] = realm.string_id
|
||||||
|
default_page_params["server_sentry_environment"] = get_config(
|
||||||
|
"machine", "deploy_type", "development"
|
||||||
|
)
|
||||||
|
default_page_params["server_sentry_sample_rate"] = settings.SENTRY_FRONTEND_SAMPLE_RATE
|
||||||
|
default_page_params["server_sentry_trace_rate"] = settings.SENTRY_FRONTEND_TRACE_RATE
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"root_domain_landing_page": settings.ROOT_DOMAIN_LANDING_PAGE,
|
"root_domain_landing_page": settings.ROOT_DOMAIN_LANDING_PAGE,
|
||||||
|
|
Loading…
Reference in New Issue