blueslip: Untangle from page_params.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-06-22 18:30:03 -07:00 committed by Tim Abbott
parent f7eecb0e03
commit 0b3cf78333
4 changed files with 6 additions and 4 deletions

View File

@ -247,6 +247,7 @@ module.exports = {
node: false, node: false,
}, },
globals: { globals: {
DEVELOPMENT: false,
ZULIP_VERSION: false, ZULIP_VERSION: false,
}, },
rules: { rules: {

View File

@ -9,7 +9,6 @@
import * as Sentry from "@sentry/browser"; import * as Sentry from "@sentry/browser";
import $ from "jquery"; import $ from "jquery";
import {page_params} from "./base_page_params";
import {BlueslipError, display_stacktrace} from "./blueslip_stacktrace"; import {BlueslipError, display_stacktrace} from "./blueslip_stacktrace";
if (Error.stackTraceLimit !== undefined) { if (Error.stackTraceLimit !== undefined) {
@ -81,7 +80,7 @@ export function info(msg: string, more_info?: unknown): void {
export function warn(msg: string, more_info?: unknown): void { export function warn(msg: string, more_info?: unknown): void {
const args = build_arg_list(msg, more_info); const args = build_arg_list(msg, more_info);
logger.warn(...args); logger.warn(...args);
if (page_params.development_environment) { if (DEVELOPMENT) {
console.trace(); console.trace();
} }
} }
@ -100,7 +99,7 @@ export function error(msg: string, more_info?: object | undefined, original_erro
logger.error(...args); logger.error(...args);
// Throw an error in development; this will show a dialog (see below). // Throw an error in development; this will show a dialog (see below).
if (page_params.development_environment) { if (DEVELOPMENT) {
throw new BlueslipError(msg, more_info, original_error); throw new BlueslipError(msg, more_info, original_error);
} }
// This function returns to its caller in production! To raise a // This function returns to its caller in production! To raise a
@ -109,7 +108,7 @@ export function error(msg: string, more_info?: object | undefined, original_erro
// Install a window-wide onerror handler in development to display the stacktraces, to make them // Install a window-wide onerror handler in development to display the stacktraces, to make them
// hard to miss // hard to miss
if (page_params.development_environment) { if (DEVELOPMENT) {
$(window).on("error", (event: JQuery.TriggeredEvent) => { $(window).on("error", (event: JQuery.TriggeredEvent) => {
const {originalEvent} = event; const {originalEvent} = event;
if (originalEvent instanceof ErrorEvent && originalEvent.error instanceof Error) { if (originalEvent instanceof ErrorEvent && originalEvent.error instanceof Error) {

View File

@ -51,5 +51,6 @@ declare global {
}; };
} }
const DEVELOPMENT: boolean;
const ZULIP_VERSION: string; const ZULIP_VERSION: string;
} }

View File

@ -199,6 +199,7 @@ const config = (
}, },
plugins: [ plugins: [
new DefinePlugin({ new DefinePlugin({
DEVELOPMENT: JSON.stringify(!production),
ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION ?? "development"), ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION ?? "development"),
}), }),
new DebugRequirePlugin(), new DebugRequirePlugin(),