forked from opentiny/tiny-engine
fix(errorMonitor): add config for errormonitor (#381)
This commit is contained in:
parent
a010bfa4d6
commit
68838ed5f9
|
@ -24,8 +24,7 @@ const http = useHttp()
|
|||
* @param { json } params {"event_type": design_error,"url": "elit in reprehenderit enim incididunt" }
|
||||
* @returns { Promise }
|
||||
*/
|
||||
export const requestEvent = (params) =>
|
||||
http.post('/platform-center/api/platform/monitoring/event', params).catch(() => {})
|
||||
export const requestEvent = (url, params) => http.post(url, params).catch(() => {})
|
||||
|
||||
/**
|
||||
* 页面更新
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2023 - present TinyEngine Authors.
|
||||
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license.
|
||||
*
|
||||
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
|
||||
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
||||
*
|
||||
*/
|
||||
* Copyright (c) 2023 - present TinyEngine Authors.
|
||||
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license.
|
||||
*
|
||||
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
|
||||
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
||||
*
|
||||
*/
|
||||
|
||||
import { requestEvent } from './http.js'
|
||||
|
||||
let monitorUrl = ''
|
||||
|
||||
/**
|
||||
* 全局js异常埋点上报
|
||||
* @param errorMessage 异常信息
|
||||
|
@ -35,7 +37,7 @@ const getUrlUnit = () => {
|
|||
|
||||
const globalMonitoring = () => {
|
||||
window.onerror = function (errorMessage, scriptURI, lineNo, columnNo, error) {
|
||||
requestEvent({
|
||||
requestEvent(monitorUrl, {
|
||||
event_type: 'design_JSError',
|
||||
url: window.location.href,
|
||||
unit: getUrlUnit(),
|
||||
|
@ -67,7 +69,7 @@ const promiseMonitoring = () => {
|
|||
}
|
||||
}
|
||||
|
||||
requestEvent({
|
||||
requestEvent(monitorUrl, {
|
||||
event_type: 'design_promiseError',
|
||||
url: window.location.href,
|
||||
unit: getUrlUnit(),
|
||||
|
@ -92,7 +94,7 @@ const promiseMonitoring = () => {
|
|||
|
||||
export const iframeMonitoring = () => {
|
||||
window.frames[0].onerror = function (errorMessage, scriptURI, lineNo, columnNo, error) {
|
||||
requestEvent({
|
||||
requestEvent(monitorUrl, {
|
||||
event_type: 'design_iframeError',
|
||||
url: window.location.href,
|
||||
unit: getUrlUnit(),
|
||||
|
@ -106,7 +108,8 @@ export const iframeMonitoring = () => {
|
|||
}
|
||||
}
|
||||
|
||||
export const initMonitor = () => {
|
||||
export const initMonitor = (url) => {
|
||||
monitorUrl = url
|
||||
globalMonitoring()
|
||||
promiseMonitoring()
|
||||
}
|
||||
|
|
|
@ -3,3 +3,8 @@
|
|||
NODE_ENV=production
|
||||
VITE_CDN_DOMAIN=https://npm.onmicrosoft.cn
|
||||
# VITE_ORIGIN=
|
||||
|
||||
# 错误监控上报 url
|
||||
VITE_ERROR_MONITOR_URL=/platform-center/api/platform/monitoring/event
|
||||
# 是否开启错误监控
|
||||
VITE_ERROR_MONITOR=false
|
||||
|
|
|
@ -17,7 +17,6 @@ import i18n from '@opentiny/tiny-engine-controller/js/i18n'
|
|||
import App from './App.vue'
|
||||
import globalConfig from '../config/lowcode.config'
|
||||
import { initMonitor } from '@opentiny/tiny-engine-controller/js/monitor'
|
||||
import { isDevelopEnv } from '@opentiny/tiny-engine-controller/js/environments'
|
||||
import { injectGlobalComponents } from '@opentiny/tiny-engine-common'
|
||||
import { initHttp } from '@opentiny/tiny-engine-http'
|
||||
import 'virtual:svg-icons-register'
|
||||
|
@ -30,8 +29,8 @@ initHttp({ env: import.meta.env })
|
|||
// eslint-disable-next-line no-new
|
||||
new TinyThemeTool(tinySmbTheme, 'smbtheme') // 初始化主题
|
||||
|
||||
if (!isDevelopEnv) {
|
||||
initMonitor()
|
||||
if (import.meta.env.VITE_ERROR_MONITOR === 'true' && import.meta.env.VITE_ERROR_MONITOR_URL) {
|
||||
initMonitor(import.meta.env.VITE_ERROR_MONITOR_URL)
|
||||
}
|
||||
|
||||
window.TinyGlobalConfig = globalConfig
|
||||
|
|
Loading…
Reference in New Issue