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vC,EAAOQ,GAChB,GAAIA,EAAM,CACR,IAAI7B,EAAAA,EAAAA,0BAAyB6B,GAAO,OAAO,KAC3C,IAAI3B,EAAAA,EAAAA,6BAA4B2B,GAAO,OAAO,IAChD,CAEA,GAAIR,IACEjB,EAAAA,EAAAA,mCAAkCiB,GAAQ,OAAO,KAGvD,IAAMf,GAAcT,EAAAA,EAAAA,4BAA2BwB,GAC/C,OAAKf,KACDP,EAAAA,EAAAA,wCAAuCO,KACvCH,EAAAA,EAAAA,uCAAsCG,KACtCL,EAAAA,EAAAA,kCAAiCK,IAF2B,KADvCe,CAM3B,IAGF+B,IAAiBS,QAAQ,CAAEC,GAAIC,EAAAA,QAAMC,WAAWC,KAAKC,OACvD,G","sources":["webpack://webstaurantstore/./__alias__/error-tracking/inbound-filters.ts","webpack://webstaurantstore/./common/startErrorLogging.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\n// eslint-disable-next-line no-restricted-imports\nimport { Breadcrumb, Event as SentryEvent, EventHint } from \"@sentry/react\";\n\nexport function getRecentSentryBreadcrumbs(\n error: SentryEvent\n): Breadcrumb[] | null {\n if (!error.breadcrumbs) return null;\n\n const now = Date.now();\n const breadcrumbs: Breadcrumb[] = [];\n\n // We go from the back since the last breadcrumb is most likely the erroneous one\n for (const breadcrumb of error.breadcrumbs) {\n // eslint-disable-next-line no-continue\n if (!breadcrumb) continue;\n\n // We only need to check the last 5s of breadcrumbs as any earlier breadcrumbs are definitely unrelated\n if (breadcrumb.timestamp && now - breadcrumb.timestamp * 1000 > 5000) break;\n\n breadcrumbs.push(breadcrumb);\n }\n\n return breadcrumbs.length ? breadcrumbs : null;\n}\n\nfunction isErrorAndNetworkBreadcrumb(breadcrumb: Breadcrumb): boolean {\n const isError = breadcrumb.level === \"error\";\n const isRequest =\n breadcrumb.category === \"xhr\" || breadcrumb.category === \"fetch\";\n return isError && isRequest;\n}\n\nfunction isChunkLoadError(breadcrumb: Breadcrumb): boolean {\n return (\n !!breadcrumb.message?.includes(\"ChunkLoadError\") ||\n !!breadcrumb.message?.includes(\"Loading CSS chunk\")\n );\n}\n\n/** Blocks raw messages that are google-translate related */\nexport function isGoogleTranslateMessage(event: SentryEvent): boolean {\n const googleTranslateUrlHint = \".translate.goog/\";\n // The CORS errors that come up from google translate are often \"raw\" messages, so we need to look directly at the content\n if (event) {\n if (event.message?.includes(googleTranslateUrlHint)) {\n return true;\n }\n if (event.request?.url?.includes(googleTranslateUrlHint)) {\n return true;\n }\n }\n return false;\n}\n\n/** Blocks Sentry errors that originate from Ad Blockers that block the following urls */\nconst blockedUrls = [\n \"s.pinimg.com\",\n \"ct.pinterest.com\",\n \"analytics.google.com\",\n];\n\nexport function isProbablyBlockedByAdblockNetworkError(\n breadcrumbs: Breadcrumb[]\n): boolean {\n for (const breadcrumb of breadcrumbs) {\n // eslint-disable-next-line no-continue\n if (!isErrorAndNetworkBreadcrumb(breadcrumb)) continue;\n\n const url = breadcrumb.data?.url;\n if (!url) return false;\n\n const isBlocked = blockedUrls.some((blocked) => url.includes(blocked));\n if (isBlocked) return true;\n }\n\n return false;\n}\n\n/**\n * Blocks sentry errors that come from the Google ReCaptcha component being unmounted\n *\n * @see {@link https://github.com/getsentry/sentry-javascript/issues/2514 Sentry Github issue containing recommended snippet}\n * @see {@link https://github.com/google/recaptcha/issues/269#issuecomment-1414409419 Discussion on the ReCaptcha PHP project}\n */\nexport function isGoogleRecaptchaTimeout(hint: EventHint) {\n if (!hint.originalException) return false;\n const timeoutRegex = /^Timeout \\([a-z]\\)$/;\n const error = hint.originalException.toString();\n return error === \"Timeout\" || timeoutRegex.test(error);\n}\n\nexport function isProbablyCausedByHoneyExtension(\n breadcrumbs: Breadcrumb[]\n): boolean {\n for (const breadcrumb of breadcrumbs) {\n const isUiClickEvent = breadcrumb.category === \"ui.click\";\n const isHoneyContainer = breadcrumb.message?.includes(\"#honeyContainer\");\n if (isUiClickEvent && isHoneyContainer) return true;\n }\n return false;\n}\n\n/**\n * Blocks sentry errors that come from unhandled rejections attached to DOM onerror handlers.\n *\n * Initially only blocking events that lack details, we may want to be more aggressive if the\n * events with details continue to be of low quality.\n *\n * @see {@link https://github.com/getsentry/sentry-javascript/issues/2546 Sentry Github issue with discussion}\n * @see {@link https://tfs.clarkinc.biz/DefaultCollection/Webstaurant.StoreFront/_workitems/edit/1195716 Related PBI and internal discussion}\n */\nexport function isNonErrorDomEventRejection(hint: EventHint) {\n const { originalException } = hint;\n\n if (!(originalException instanceof Event)) {\n return false;\n }\n\n if (originalException instanceof CustomEvent) {\n return originalException.detail === null;\n }\n\n return true;\n}\n\n/** Blocks Sentry Errors that come from the page being closed, refreshed, or canceled while a resource is loading */\nlet shouldLogError = false;\n\nwindow.addEventListener(\"load\", function handleWindowLoadEvent() {\n shouldLogError = true;\n});\n\n/**\n * MDN recommends using visibility change over beforeUnload since mobile devices do not always fire the beforeUnload event\n *\n * @see {@link https://www.igvita.com/2015/11/20/dont-lose-user-and-app-state-use-page-visibility/ Article Explaining Why}\n */\ndocument.addEventListener(\n \"visibilitychange\",\n function handleBeforeUnloadEvent() {\n shouldLogError = document.visibilityState === \"visible\";\n }\n);\n\n/** Not all browsers currently support visibilitychange, pagehide is the next best option */\nwindow.addEventListener(\"pagehide\", function handlePageHideEvent() {\n shouldLogError = false;\n});\n\nwindow.addEventListener(\"pageshow\", function handlePageHideEvent() {\n shouldLogError = true;\n});\n\n/** Used in the browser to silence errors caused by reloading the page */\nwindow.addEventListener(\"beforeunload\", function handlePageHideEvent() {\n shouldLogError = false;\n});\n\n/** Used in the browsers that do not support beforeunload */\nwindow.addEventListener(\"unload\", function handlePageHideEvent() {\n shouldLogError = false;\n});\n\n/** Return true to skip logging the error */\nexport function isLoggingNetworkErrorDuringPageUnload(\n breadcrumbs: Breadcrumb[]\n): boolean {\n if (shouldLogError) return false;\n for (const breadcrumb of breadcrumbs) {\n // eslint-disable-next-line no-continue\n if (isErrorAndNetworkBreadcrumb(breadcrumb)) return true;\n if (isChunkLoadError(breadcrumb)) return true;\n }\n\n return false;\n}\n\nexport function isGoogleMissingGmoVariableMessage(event: SentryEvent): boolean {\n if (event) {\n if (event.message?.includes(\"Can't find variable: gmo\")) {\n return true;\n }\n }\n return false;\n}\n","/** @deprecated use `@wss/error-tracking/sentry` instead */\n// eslint-disable-next-line no-restricted-imports\nimport type { BrowserOptions } from \"@sentry/react\";\nimport {\n getRecentSentryBreadcrumbs,\n isLoggingNetworkErrorDuringPageUnload,\n isProbablyBlockedByAdblockNetworkError,\n isGoogleRecaptchaTimeout,\n isNonErrorDomEventRejection,\n isProbablyCausedByHoneyExtension,\n isGoogleMissingGmoVariableMessage,\n} from \"@wss/error-tracking/inbound-filters\";\nimport { env } from \"./Environment\";\nimport Store from \"./Store\";\n\nconst sentryUrls = {\n local: null,\n development:\n \"https://6fae599b54852828599dd44ffdc39435@o4505671666630656.ingest.us.sentry.io/4508518241140736\",\n test:\n \"https://24ae94f2668498360d6f72736047b8d5@o4505671666630656.ingest.us.sentry.io/4508518241140736\",\n production:\n \"https://6c80f7e0154d46a4d132fc1c60b0c81e@o4505671666630656.ingest.us.sentry.io/4508518241140736\",\n};\n\nconst hasConductrics = !!document.querySelector(\n 'script[src$=\"/cdt/js/script.js\"]'\n);\nconst conductricsErrors = [\n \"Minified React error #425\", // Text content error\n \"Minified React error #418\", // Hydration error\n \"Minified React error #423\", // Hydration recover error\n \"Text content does not match server-rendered HTML\",\n \"Hydration failed because the server rendered HTML didn't match the client\",\n \"There was an error while hydrating but React was able to recover by instead client rendering the entire root\",\n];\n/** @see {@link https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-ignore-errors Sentry Docs} */\nconst ignoreErrors: NonNullable = [\n \"Failed to fetch\",\n \"Loading chunk\",\n \"Loading CSS chunk\",\n \"NetworkError when attempting to fetch resource\",\n \"Load failed\",\n \"ResizeObserver\",\n \"Object Not Found Matching Id\",\n \"The operation was aborted.\",\n \"Form values does not contain\", // Needed until 1220972 is completed\n];\nif (hasConductrics) {\n ignoreErrors.push(...conductricsErrors);\n}\n\nimport(/* webpackChunkName: \"vendors~sentry-browser\" */ \"@sentry/react\").then(\n // eslint-disable-next-line consistent-return\n ({ init, getGlobalScope }) => {\n // Change the line below to `const url = sentryUrls.dev` to enable local logging.\n const url = sentryUrls[env.current];\n\n if (!url) {\n // eslint-disable-next-line no-console\n return console.info(\"Skipping Sentry init for local development\");\n }\n\n init({\n dsn: url,\n ignoreErrors,\n environment: env.current,\n allowUrls: [\n \"webpack-internal:///\",\n \"https://localhost:5001\",\n \"https://www.loc.webstaurantstore.com/\",\n \"https://www.dev.webstaurantstore.com/\",\n \"https://argo.dev.webstaurantstore.com/\",\n \"https://www.test.webstaurantstore.com/\",\n \"https://www.webstaurantstore.com/\",\n \"https://argo.webstaurantstore.com/\",\n ],\n beforeSend(event, hint) {\n if (hint) {\n if (isGoogleRecaptchaTimeout(hint)) return null;\n if (isNonErrorDomEventRejection(hint)) return null;\n }\n\n if (event) {\n if (isGoogleMissingGmoVariableMessage(event)) return null;\n }\n\n const breadcrumbs = getRecentSentryBreadcrumbs(event);\n if (!breadcrumbs) return event;\n if (isProbablyBlockedByAdblockNetworkError(breadcrumbs)) return null;\n if (isLoggingNetworkErrorDuringPageUnload(breadcrumbs)) return null;\n if (isProbablyCausedByHoneyExtension(breadcrumbs)) return null;\n\n return event;\n },\n });\n\n getGlobalScope().setUser({ id: Store.getState().user.index });\n }\n);\n"],"names":["getRecentSentryBreadcrumbs","isGoogleTranslateMessage","isProbablyBlockedByAdblockNetworkError","isGoogleRecaptchaTimeout","isProbablyCausedByHoneyExtension","isNonErrorDomEventRejection","isLoggingNetworkErrorDuringPageUnload","isGoogleMissingGmoVariableMessage","error","breadcrumbs","now","Date","breadcrumb","timestamp","push","length","isErrorAndNetworkBreadcrumb","isError","level","isRequest","category","isChunkLoadError","message","includes","event","googleTranslateUrlHint","request","url","blockedUrls","data","some","blocked","hint","originalException","toString","test","isUiClickEvent","isHoneyContainer","Event","CustomEvent","detail","shouldLogError","window","addEventListener","document","visibilityState","ignoreErrors","sentryUrls","local","development","production","hasConductrics","querySelector","then","init","getGlobalScope","env","current","console","info","dsn","environment","allowUrls","beforeSend","setUser","id","Store","getState","user","index"],"sourceRoot":""}