femonitor-web
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -62,3 +62,4 @@ import { VueConstructor } from "vue"; | ||
} | ||
export declare type IData = Record<string, unknown>; | ||
export declare type PlainObject = Record<string | number | symbol, unknown>; | ||
export declare type IData = Record<string | number | symbol, unknown>; | ||
export declare const defaultTrackerOptions: { | ||
@@ -125,2 +126,3 @@ env: Env; | ||
getNetworkType(): void; | ||
getLocaleLanguage(): void; | ||
getUserAgent(): void; | ||
@@ -143,4 +145,4 @@ /** | ||
*/ | ||
configData(key: string, value: Record<string, unknown> | string | number | Array<any>, deepmerge?: boolean): Monitor; | ||
configData(options: Record<string, unknown>, deepmerge?: boolean): Monitor; | ||
configData(key: string, value: unknown, deepmerge?: boolean): Monitor; | ||
configData(options: PlainObject, deepmerge?: boolean): Monitor; | ||
changeOptions(key: keyof ITrackerOptions, value: ITrackerOptions[keyof ITrackerOptions]): void; | ||
@@ -147,0 +149,0 @@ private handleErrorReport; |
@@ -10,1 +10,2 @@ export declare function isObject(input: any): boolean; | ||
}; | ||
export declare function getLocaleLanguage(): string; |
{ | ||
"name": "femonitor-web", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A web SDK for frontend error and performance monnitor", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -20,6 +20,6 @@ import merge from "deepmerge"; | ||
} from "./behaviorObserver"; | ||
import { getDeviceInfo, IDeviceInfo } from "./device"; | ||
import { getDeviceInfo } from "./device"; | ||
import { Reporter } from "./report"; | ||
import { TrackerEvents, IHttpReqErrorRes } from "../types"; | ||
import { isObject, getNetworkType } from "./util"; | ||
import { isObject, getNetworkType, getLocaleLanguage } from "./util"; | ||
import packageJson from "../../package.json"; | ||
@@ -29,3 +29,2 @@ import { SpaHandler } from "./spaHandler"; | ||
import { eventWithTime } from "rrweb/typings/types"; | ||
import stringify from "json-stringify-safe"; | ||
@@ -97,4 +96,6 @@ export type ErrorCombine = | ||
export type IData = Record<string, unknown>; | ||
export type PlainObject = Record<string | number | symbol, unknown>; | ||
export type IData = Record<string | number | symbol, unknown>; | ||
export const defaultTrackerOptions = { | ||
@@ -173,2 +174,3 @@ env: Env.Dev, | ||
this.getNetworkType(); | ||
this.getLocaleLanguage(); | ||
this.getUserAgent(); | ||
@@ -199,6 +201,4 @@ | ||
Object.keys(deviceInfo).forEach((key) => { | ||
this.configData({ | ||
[`_${key}`]: deviceInfo[key as keyof IDeviceInfo] | ||
}); | ||
this.configData({ | ||
_deviceInfo: deviceInfo | ||
}); | ||
@@ -214,2 +214,9 @@ } | ||
getLocaleLanguage(): void { | ||
const localeLanguage = getLocaleLanguage(); | ||
this.configData({ | ||
_locale: localeLanguage | ||
}); | ||
} | ||
getUserAgent(): void { | ||
@@ -315,4 +322,4 @@ this.configData({ | ||
TrackerEvents.performanceInfoReady, | ||
(performanceInfo: IPerformanceInfo<number>) => { | ||
this.configData("_performance", stringify(performanceInfo), false); | ||
(performanceInfo: IPerformanceInfo) => { | ||
this.configData("_performance", performanceInfo, false); | ||
} | ||
@@ -333,16 +340,7 @@ ); | ||
*/ | ||
configData(key: string, value: unknown, deepmerge?: boolean): Monitor; | ||
configData(options: PlainObject, deepmerge?: boolean): Monitor; | ||
configData( | ||
key: string, | ||
value: Record<string, unknown> | string | number | Array<any>, | ||
deepmerge?: boolean | ||
): Monitor; | ||
configData(options: Record<string, unknown>, deepmerge?: boolean): Monitor; | ||
configData( | ||
key: Record<string, unknown> | string, | ||
value: | ||
| Record<string, unknown> | ||
| string | ||
| number | ||
| boolean | ||
| Array<any> = true, | ||
key: PlainObject | string, | ||
value: unknown, | ||
deepmerge = true | ||
@@ -352,3 +350,3 @@ ): Monitor { | ||
if (isObject(value) && deepmerge) { | ||
this.$data = merge(this.$data, value as Record<string, unknown>); | ||
this.$data = merge(this.$data, value as PlainObject); | ||
} else { | ||
@@ -358,14 +356,13 @@ this.$data[key as string] = value; | ||
} else if (isObject(key)) { | ||
if (typeof value !== "boolean") { | ||
throw new Error("deepmerge should be boolean"); | ||
if (typeof value === "boolean") { | ||
deepmerge = value; | ||
} | ||
value = key; | ||
deepmerge = value; | ||
value = key; | ||
if (deepmerge) { | ||
this.$data = merge(this.$data, value); | ||
this.$data = merge(this.$data, value as PlainObject); | ||
} else { | ||
this.$data = { | ||
...this.$data, | ||
...value | ||
...(value as PlainObject) | ||
}; | ||
@@ -372,0 +369,0 @@ } |
@@ -65,1 +65,6 @@ export function isObject(input: any): boolean { | ||
} | ||
export function getLocaleLanguage() { | ||
if (navigator.languages != undefined) return navigator.languages[0]; | ||
return navigator.language; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1453461
11928
39