getsentry / getsentry/sentry-javascript

Stop setting `event.request` in Browser SDKs

未关闭
#15,845 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Task
主要语言
TypeScript
星标
8.7k
派生
1.8k
平均合并
1 天 17 小时
30 天内合并 PR
515

描述

### Description

Today, we set data about the current page on `event.request` in the Browser SDK. This is done by the HttpContext integration:

```ts
// if none of the information we want exists, don't bother
if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {
return;
}

// grab as much info as exists and add it to the event
const url = event.request?.url || getLocationHref();
const { referrer } = WINDOW.document || {};
const { userAgent } = WINDOW.navigator || {};

const headers = {
...event.request?.headers,
...(referrer && { Referer: referrer }),
...(userAgent && { 'User-Agent': userAgent }),
};
const request = {
...event.request,
...(url && { url }),
headers,
};

event.request = request;
```

In product, we show this as "HTTP Request Information" which is pretty confusing. We should stop setting this for browser SDKs, and instead set this information in a different place (e.g. in a `page` context, TBD).

We can then think about instead using this place to store outgoing-request information for failed fetch calls.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。