Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add missing fields into Replay NetworkRequestData type #8284

Merged
merged 8 commits into from
Jun 7, 2023

Conversation

ryan953
Copy link
Member

@ryan953 ryan953 commented Jun 2, 2023

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

@ryan953 ryan953 requested review from billyvg and Lms24 and removed request for billyvg June 2, 2023 20:05
@ryan953 ryan953 marked this pull request as draft June 3, 2023 00:12
@mydea
Copy link
Member

mydea commented Jun 5, 2023

I think this is not what you think it is :D You are probably looking for ReplayNetworkRequestData? NetworkRequestData is basically the old breadcrumb type we used - I wonder if we can/should streamline this (probably...).

@ryan953 ryan953 requested a review from mydea June 5, 2023 16:40
@ryan953
Copy link
Member Author

ryan953 commented Jun 5, 2023

I think this is not what you think it is :D You are probably looking for ReplayNetworkRequestData? NetworkRequestData is basically the old breadcrumb type we used - I wonder if we can/should streamline this (probably...).

@mydea What i'm trying to do is import types into sentry so i can have well-typed breadcrumbs/attachments/segments/frames (whatever they're called now) within the ui. this the the data that comes back from the /recording-segments/ api endpoint.
The ReplayNetworkRequestData doesn't look like it's exported, and this whole file has been freshly added with the correct frame wrappers and stuff. So I was thinking this is the correct place, but I still need to make sure the type matches what shape real objects have.

@billyvg
Copy link
Member

billyvg commented Jun 5, 2023

@ryan953 I can fix this up, what branch on sentry can I test on?

@ryan953
Copy link
Member Author

ryan953 commented Jun 5, 2023

@billyvg I copy+pasted all the types into ryan953/ref-replay-test-mocks and ryan953/ref-replay-test-mocks uses them even more. So either of those branches would work.

@ryan953
Copy link
Member Author

ryan953 commented Jun 5, 2023

@billyvg I'm also waiting to merge those two linked PRs after the next SDK bump, so I don't need to copy+paste all the types in. So no rush.

@ryan953 ryan953 changed the title chrore: Add missing fields into Replay NetworkRequestData type chore: Add missing fields into Replay NetworkRequestData type Jun 5, 2023
@ryan953 ryan953 closed this Jun 5, 2023
@billyvg
Copy link
Member

billyvg commented Jun 5, 2023

@ryan953 OK I may not actually have too much time to work on this until after the overhead project. I think there's a disconnect here -- FetchBreadcrumbData is wrong here and it is probably ReplayNetworkRequestData that we need there Actually I don't think FetchFrame belongs here at all...

@ryan953 ryan953 reopened this Jun 5, 2023
@billyvg
Copy link
Member

billyvg commented Jun 5, 2023

@ryan953 Ok here are the types for the network request/resp, I think we need to add ReplayNetworkRequestData, but NetworkRequestData still needs to be kept there for backwards compatibility.

FetchFrame/XhrFrame does not exist as a BreadcrumbFrame

@ryan953 ryan953 force-pushed the ryan953/chore-NetworkRequestData-fields branch from 5b7d63d to 732589e Compare June 6, 2023 18:24
@ryan953 ryan953 force-pushed the ryan953/chore-NetworkRequestData-fields branch from 732589e to 13092c3 Compare June 6, 2023 18:27
@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 21.12 KB (+0.46% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 65.86 KB (+0.37% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 19.65 KB (+0.46% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 58.34 KB (+0.44% 🔺)
@sentry/browser - Webpack (gzipped + minified) 21.28 KB (+0.53% 🔺)
@sentry/browser - Webpack (minified) 69.26 KB (+0.33% 🔺)
@sentry/react - Webpack (gzipped + minified) 21.31 KB (+0.54% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 49.23 KB (+0.25% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 28.74 KB (+0.35% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 26.98 KB (+0.37% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 48.63 KB (+2.14% 🔺)
@sentry/replay - Webpack (gzipped + minified) 42.22 KB (+1.82% 🔺)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 67.59 KB (+1.63% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 60.5 KB (+1.89% 🔺)

@ryan953 ryan953 marked this pull request as ready for review June 6, 2023 19:41
@@ -2,3 +2,4 @@ export * from './performance';
export * from './replay';
export * from './replayFrame';
export * from './rrweb';
export type { EventType } from '@sentry-internal/rrweb';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm we have this duplicated here but I forgot why... might be because our fork of rrweb, it wasn't exported? cc @mydea

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took that duplicate definition out, as you saw below.

Now getsentry/sentry-javascript is importing from '@sentry-internal/rrweb' and getsentry/sentry will import from getsentry/sentry-javascript
hopefully i can skip @sentry-internal/rrweb altogether if i've cross referenced everything correctly.

packages/replay/src/types/replayFrame.ts Outdated Show resolved Hide resolved

interface NetworkRequestFrame extends BaseSpanFrame {
data: NetworkRequestData | ReplayNetworkRequestData;
op: 'resource.fetch'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about xhr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think xhr payloads are shaped like ResourceData instead.

packages/replay/src/types/rrweb.ts Show resolved Hide resolved
@@ -2,3 +2,4 @@ export * from './performance';
export * from './replay';
export * from './replayFrame';
export * from './rrweb';
export type { EventType } from '@sentry-internal/rrweb';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took that duplicate definition out, as you saw below.

Now getsentry/sentry-javascript is importing from '@sentry-internal/rrweb' and getsentry/sentry will import from getsentry/sentry-javascript
hopefully i can skip @sentry-internal/rrweb altogether if i've cross referenced everything correctly.

networkRequestHasHeaders: boolean;
networkResponseHasHeaders: boolean;
sessionSampleRate: number;
useCompression: boolean;
useCompressionOption: boolean;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorted these fields, no changes.

this object is duplicated in sentry, so i'm happy for the re-use here.


interface NetworkRequestFrame extends BaseSpanFrame {
data: NetworkRequestData | ReplayNetworkRequestData;
op: 'resource.fetch'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think xhr payloads are shaped like ResourceData instead.

@@ -1,4 +1,5 @@
export * from './performance';
export * from './replay';
export * from './replayFrame';
export * from './request';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new file to prevent circular refs.

@ryan953 ryan953 merged commit b877c10 into develop Jun 7, 2023
62 of 79 checks passed
@ryan953 ryan953 deleted the ryan953/chore-NetworkRequestData-fields branch June 7, 2023 16:36
@mydea
Copy link
Member

mydea commented Jun 9, 2023

Huh, tests did not actually pass here - it seems it cancelled on build step (which we sadly take as "this is fine", apparently). This broke tests 😬 I'll fix it here: https://github.com/getsentry/sentry-javascript/actions/runs/5220067685/jobs/9422724589?pr=8310

mydea added a commit that referenced this pull request Jun 14, 2023
This breaks, as we do not have these packages as dependencies but
devDependencies, but the types are not inlined...

This was introduced here:
#8284

Fixes #8326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants