summaryrefslogtreecommitdiff
path: root/shared/logger/node_modules/@sentry/browser/esm/integrations/httpcontext.js
diff options
context:
space:
mode:
authorrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
committerrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
commitbce557cc2dc767628bed6aac87301a1be7c5431b (patch)
treeb51a051228d01fe3306cd7626d4a96768aadb944 /shared/logger/node_modules/@sentry/browser/esm/integrations/httpcontext.js
init commit
Diffstat (limited to 'shared/logger/node_modules/@sentry/browser/esm/integrations/httpcontext.js')
-rw-r--r--shared/logger/node_modules/@sentry/browser/esm/integrations/httpcontext.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/shared/logger/node_modules/@sentry/browser/esm/integrations/httpcontext.js b/shared/logger/node_modules/@sentry/browser/esm/integrations/httpcontext.js
new file mode 100644
index 0000000..014a182
--- /dev/null
+++ b/shared/logger/node_modules/@sentry/browser/esm/integrations/httpcontext.js
@@ -0,0 +1,47 @@
+import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
+import { WINDOW } from '../helpers.js';
+
+/** HttpContext integration collects information about HTTP request headers */
+class HttpContext {constructor() { HttpContext.prototype.__init.call(this); }
+ /**
+ * @inheritDoc
+ */
+ static __initStatic() {this.id = 'HttpContext';}
+
+ /**
+ * @inheritDoc
+ */
+ __init() {this.name = HttpContext.id;}
+
+ /**
+ * @inheritDoc
+ */
+ setupOnce() {
+ addGlobalEventProcessor((event) => {
+ if (getCurrentHub().getIntegration(HttpContext)) {
+ // if none of the information we want exists, don't bother
+ if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {
+ return event;
+ }
+
+ // grab as much info as exists and add it to the event
+ const url = (event.request && event.request.url) || (WINDOW.location && WINDOW.location.href);
+ const { referrer } = WINDOW.document || {};
+ const { userAgent } = WINDOW.navigator || {};
+
+ const headers = {
+ ...(event.request && event.request.headers),
+ ...(referrer && { Referer: referrer }),
+ ...(userAgent && { 'User-Agent': userAgent }),
+ };
+ const request = { ...event.request, ...(url && { url }), headers };
+
+ return { ...event, request };
+ }
+ return event;
+ });
+ }
+} HttpContext.__initStatic();
+
+export { HttpContext };
+//# sourceMappingURL=httpcontext.js.map