Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

sentry: Add tracing extensions when Sentry is not enabled.

Alex Vandiver3ab22233f073
diff --git a/web/src/sentry.ts b/web/src/sentry.ts
index 51222f949a8..a6f546d2341 100644
--- a/web/src/sentry.ts
+++ b/web/src/sentry.ts
@@ -91,4 +91,9 @@ if (page_params.server_sentry_dsn) {
user: user_info,
},
});
+} else {
+ // Always add the tracing extensions, so Sentry doesn't throw runtime errors if one calls
+ // startTransaction without having created the Sentry.BrowserTracing object.
+ Sentry.addTracingExtensions();
+ Sentry.init({});
}
diff --git a/web/tests/lib/index.js b/web/tests/lib/index.js
index 3455ac896dd..04e5ff8fe62 100644
--- a/web/tests/lib/index.js
+++ b/web/tests/lib/index.js
@@ -5,6 +5,7 @@ const path = require("path");
require("css.escape");
require("handlebars/runtime");
+const Sentry = require("@sentry/browser");
const {JSDOM} = require("jsdom");
const _ = require("lodash");
@@ -38,6 +39,9 @@ require("@babel/register")({
root: path.resolve(__dirname, "../.."),
});
+// Ensure that startTransaction and friends are available at runtime
+Sentry.addTracingExtensions();
+
// Create a helper function to avoid sneaky delays in tests.
function immediate(f) {
return () => f();