Skip to content

Commit

Permalink
Add runtime Generic, make userAgent optional. Fix #221
Browse files Browse the repository at this point in the history
  • Loading branch information
terehov committed Mar 5, 2023
1 parent 8a884f1 commit 2d9d74b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/BaseLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class BaseLogger<LogObj> {
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
this.runtime = isBrowser ? "browser" : isNode ? "nodejs" : "unknown";
const isBrowserBlinkEngine = isBrowser ? ((window?.["chrome"] || (window.Intl && Intl?.["v8BreakIterator"])) && "CSS" in window) != null : false;
const isSafari = isBrowser ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
const isSafari = isBrowser ? /^((?!chrome|android).)*safari/i.test(navigator?.userAgent) : false;
this.stackDepthLevel = isSafari ? 4 : this.stackDepthLevel;

this.settings = {
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { jsonStringifyRecursive } from "./helper.jsonStringifyRecursive.js";
export interface IMetaStatic {
name?: string;
parentNames?: string[];
runtime: string;
runtime: "Nodejs" | "Browser" | "Generic";
browser: string;
}

Expand All @@ -18,8 +18,8 @@ export interface IMeta extends IMetaStatic {
}

const meta: IMetaStatic = {
runtime: "Browser",
browser: globalThis?.["navigator"].userAgent,
runtime: ![typeof window, typeof document].includes("undefined") ? "Browser" : "Generic",
browser: globalThis?.["navigator"]?.userAgent,
};

const pathRegex = /(?:(?:file|https?|global code|[^@]+)@)?(?:file:)?((?:\/[^:/]+){2,})(?::(\d+))?(?::(\d+))?/;
Expand Down

0 comments on commit 2d9d74b

Please sign in to comment.