🧑💻 (bot) Wrap custom head code scripts with try catch
To avoid having the custom head bugs reported on Sentry
This commit is contained in:
@@ -286,26 +286,6 @@ export const getViewerUrl = (props?: {
|
||||
export const parseNumberWithCommas = (num: number) =>
|
||||
num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||
|
||||
export const injectCustomHeadCode = (customHeadCode: string) => {
|
||||
const headCodes = customHeadCode.split('</noscript>')
|
||||
headCodes.forEach((headCode) => {
|
||||
const [codeToInject, noScriptContentToInject] = headCode.split('<noscript>')
|
||||
const fragment = document
|
||||
.createRange()
|
||||
.createContextualFragment(codeToInject)
|
||||
document.head.append(fragment)
|
||||
|
||||
if (isNotDefined(noScriptContentToInject)) return
|
||||
|
||||
const noScriptElement = document.createElement('noscript')
|
||||
const noScriptContentFragment = document
|
||||
.createRange()
|
||||
.createContextualFragment(noScriptContentToInject)
|
||||
noScriptElement.append(noScriptContentFragment)
|
||||
document.head.append(noScriptElement)
|
||||
})
|
||||
}
|
||||
|
||||
export const getAtPath = <T>(obj: T, path: string): unknown => {
|
||||
if (isNotDefined(obj)) return undefined
|
||||
const pathParts = path.split('.')
|
||||
|
||||
Reference in New Issue
Block a user