@wltech/hooks
Advanced tools
Comparing version 0.0.27-alpha.32 to 0.0.27-alpha.33
{ | ||
"name": "@wltech/hooks", | ||
"version": "0.0.27-alpha.32", | ||
"version": "0.0.27-alpha.33", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "", |
@@ -8,3 +8,3 @@ /** | ||
const hash = location.hash; | ||
const title = document.title?.split('-') || []; | ||
const title = document.title?.split("-") || []; | ||
let page_path = hash?.substring(1); | ||
@@ -15,6 +15,31 @@ const arr = page_path?.split("?"); | ||
page_query: arr?.[1], | ||
page_title: title.length > 1 ? title.slice(1).join('-') : document.title, | ||
page_title: title.length > 1 ? title.slice(1).join("-") : document.title, | ||
}; | ||
}; | ||
const formatHistory = (splitTitle = false) => { | ||
const path = window.location.pathname; | ||
const search = window.location.search; | ||
let page_path = path; | ||
const arr = search?.substring(1).split("&"); | ||
let page_query: any = {}; | ||
if (arr) { | ||
arr.forEach((query) => { | ||
let parts = query.split("="); | ||
page_query[parts[0]] = parts[1]; | ||
}); | ||
} | ||
let split = ""; | ||
if (splitTitle) { | ||
const title = document.title?.split("-") || []; | ||
split = title.length > 1 ? title.slice(1).join("-") : document.title; | ||
} | ||
return { | ||
page_path: page_path, | ||
page_query: page_query, | ||
page_title: splitTitle ? split : document.title, | ||
}; | ||
}; | ||
/** | ||
@@ -37,6 +62,20 @@ * 获取URL参数 | ||
/** | ||
* sentry 设置全局tab | ||
* sentry 设置全局tab hath模式 | ||
*/ | ||
export const sentryConfigureScopeTag = () => { | ||
Sentry.configureScope((scope) => { | ||
const { page_path, page_query, page_title } = formatHistory(); | ||
scope.setTag("url", location.href); | ||
scope.setTag("corp_id", page_query?.["corp_id"]); | ||
scope.setTag("page_search", location.search); | ||
scope.setTag("page_path", page_path); | ||
scope.setTag("page_name", page_title); | ||
}); | ||
}; | ||
/** | ||
* sentry 设置全局tab history模式 | ||
*/ | ||
export const sentryHistoryConfigureScopeTag = () => { | ||
Sentry.configureScope((scope) => { | ||
const { page_path, page_query, page_title } = formatHash(); | ||
@@ -94,7 +133,4 @@ scope.setTag("url", location.href); | ||
*/ | ||
export const sentryCaptureEvent = ( | ||
message: string, | ||
param?: {} | ||
) => { | ||
Sentry.captureEvent({ message, level: "info", ...param }); | ||
export const sentryCaptureEvent = (message: string, param?: {}) => { | ||
Sentry.captureEvent({ message, level: "info", ...param }); | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170275
5778