Skip to content

feat(browser-starfish): add relative image support in ui - #63680

Merged
DominikB2014 merged 5 commits into
masterfrom
DominikB2014/relaitve-image-ui-support
Jan 26, 2024
Merged

DominikB2014 merged 5 commits into
masterfrom
DominikB2014/relaitve-image-ui-support

Conversation

@DominikB2014

@DominikB2014 DominikB2014 commented Jan 23, 2024 •

Copy link
Copy Markdown
Contributor

Once this getsentry/relay#2975 is merged and we update our JS SDK, we can grab the raw_domain field from spansIndexed in order to support the sample image view for relative urls.

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 23, 2024
@DominikB2014
DominikB2014 marked this pull request as ready for review January 26, 2024 16:18
@DominikB2014
DominikB2014 requested a review from a team January 26, 2024 16:18
@DominikB2014 DominikB2014 changed the title (wip) add relative image support in ui feat(browser-starfish): add relative image support in ui Jan 26, 2024

@gggritso gggritso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍🏻 if it's possible to concat the URL more safely it'd be a good idea!

return (
<ImageContainer
src={resource[SPAN_DESCRIPTION]}
src={new URL(src).toString()}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can throw, we should account for error cases here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍 good point, I also looked into the api, I think we should pass in the base url param into the URL constructor too i.e newURL(domain, span[description]) instead of constructing the string.

in case there are any issues with slashes and stuff for example.
i.e
image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@AbhiPrasad I've made the changes!

src = url.href;
} catch {
Sentry.captureException(new Error('Invalid URL'), {
data: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's no data field able to be provided here, you probably want to set tags or contexts instead here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So strange, typescript said its available so I assumed that it would work, will update that in a PR soon!

let src = resource[SPAN_DESCRIPTION];
if (isRelativeUrl && hasRawDomain) {
try {
const url = new URL(resource[SPAN_DESCRIPTION], resource[RAW_DOMAIN]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

l: Can we extract this out to be a utility function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, what parts specifically, the whole try catch block? The try catch block + the isRelativeUrl && hasRawDomain logic?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The try catch block + the isRelativeUrl && hasRawDomain logic.

Ideally with a func signature that looks like the following:

function getUrlFromSpanDescription(description: string | undefined, domain: string | undefined): string | undefined;

but it's also l we dont have to come back and add this too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, I can definitely see this being used elsewhere in the future.

@DominikB2014
DominikB2014 merged commit 4d501d1 into master Jan 26, 2024
@DominikB2014
DominikB2014 deleted the DominikB2014/relaitve-image-ui-support branch January 26, 2024 20:40
DominikB2014 added a commit that referenced this pull request Jan 31, 2024
…eption (#63978)

@AbhiPrasad made a good point here, that we should be using the `tags`
property instead of data when capturing exceptions
#63680 (comment)

This PR makes the appropriate changes
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 11, 2024

This branch was successfully deployed

1 active deployment
Preview — 0b7beaf4 Deployed Jan 26, 2024 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants