Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
sentry: Unify logic for skipping span reporting.
Alex Vandiver9912b4c81574
diff --git a/web/src/channel.js b/web/src/channel.jsindex fc8dd9a3ec7..d294f1c7c34 100644--- a/web/src/channel.js+++ b/web/src/channel.js@@ -5,7 +5,7 @@ import _ from "lodash";import * as blueslip from "./blueslip";import {page_params} from "./page_params";import * as reload_state from "./reload_state";-import {normalize_path} from "./sentry";+import {normalize_path, shouldCreateSpanForRequest} from "./sentry";import * as spectators from "./spectators";let password_change_in_progress = false;@@ -37,7 +37,7 @@ function call(args) {},};let span;- if (args.type === "GET" && args.url === "/json/events") {+ if (!shouldCreateSpanForRequest(args.url)) {// Leave the span unset, so we don't record a transaction} else {if (!existing_span) {diff --git a/web/src/sentry.ts b/web/src/sentry.tsindex bd6d1ba0121..8609de1740f 100644--- a/web/src/sentry.ts+++ b/web/src/sentry.ts@@ -25,6 +25,11 @@ export function normalize_path(path: string, is_portico = false): string {return path;}+export function shouldCreateSpanForRequest(url: string): boolean {+ const parsed = new URL(url, window.location.href);+ return !["/json/events", "/json/users/me/presence"].includes(parsed.pathname);+}+if (page_params.server_sentry_dsn) {const url_matches = [/^\//, new RegExp("^" + _.escapeRegExp(page_params.webpack_public_path))];if (page_params.realm_uri !== undefined) {@@ -76,10 +81,7 @@ if (page_params.server_sentry_dsn) {name: normalize_path(location.pathname, sentry_key === "www"),};},- shouldCreateSpanForRequest(url) {- const parsed = new URL(url, window.location.href);- return !["/json/events", "/json/users/me/presence"].includes(parsed.pathname);- },+ shouldCreateSpanForRequest,}),],allowUrls: url_matches,diff --git a/web/tests/channel.test.js b/web/tests/channel.test.jsindex 362d19e895f..b0ac3712e8e 100644--- a/web/tests/channel.test.js+++ b/web/tests/channel.test.js@@ -22,6 +22,7 @@ mock_esm("../src/spectators", {set_global("window", {location: {replace() {},+ href: "http://example.com",},});@@ -68,7 +69,7 @@ function test(label, f) {test("post", () => {test_with_mock_ajax({run_code() {- channel.post({});+ channel.post({url: "/json/endpoint"});},check_ajax_options(options) {@@ -85,7 +86,7 @@ test("post", () => {test("patch", () => {test_with_mock_ajax({run_code() {- channel.patch({});+ channel.patch({url: "/json/endpoint"});},check_ajax_options(options) {@@ -103,7 +104,7 @@ test("patch", () => {test("put", () => {test_with_mock_ajax({run_code() {- channel.put({});+ channel.put({url: "/json/endpoint"});},check_ajax_options(options) {@@ -120,7 +121,7 @@ test("put", () => {test("delete", () => {test_with_mock_ajax({run_code() {- channel.del({});+ channel.del({url: "/json/endpoint"});},check_ajax_options(options) {@@ -137,7 +138,7 @@ test("delete", () => {test("get", () => {test_with_mock_ajax({run_code() {- channel.get({});+ channel.get({url: "/json/endpoint"});},check_ajax_options(options) {@@ -211,6 +212,7 @@ test("patch_with_form_data", () => {run_code() {channel.patch({data,+ url: "/json/endpoint",processData: false,});assert.ok(appended);@@ -231,7 +233,7 @@ test("authentication_error_401_is_spectator", () => {test_with_mock_ajax({xhr: xhr_401,run_code() {- channel.post({});+ channel.post({url: "/json/endpoint"});},// is_spectator = true@@ -250,7 +252,7 @@ test("authentication_error_401_password_change_in_progress", () => {test_with_mock_ajax({xhr: xhr_401,run_code() {- channel.post({});+ channel.post({url: "/json/endpoint"});},// is_spectator = true@@ -273,7 +275,7 @@ test("authentication_error_401_not_spectator", () => {test_with_mock_ajax({xhr: xhr_401,run_code() {- channel.post({});+ channel.post({url: "/json/endpoint"});},// is_spectator = false@@ -296,7 +298,7 @@ test("reload_on_403_error", () => {},run_code() {- channel.post({});+ channel.post({url: "/json/endpoint"});},check_ajax_options(options) {@@ -319,7 +321,7 @@ test("unexpected_403_response", () => {},run_code() {- channel.post({});+ channel.post({url: "/json/endpoint"});},check_ajax_options(options) {