Skip to content

feat(browser): support dom.maxStringLength configuration (#6175) #6311

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

Merged
merged 5 commits into from
Dec 6, 2022

Conversation

ZachGawlik
Copy link
Contributor

@ZachGawlik ZachGawlik commented Nov 27, 2022

Implements the configuration feature described in #6175 . This lets sentry users opt in to having longer, potentially more helpful, UI breadcrumbs.

Closes #6175

@ZachGawlik
Copy link
Contributor Author

The CI build failed on suites/tracing/browsertracing/long-tasks-enabled/test.ts, but it passes locally for me. It seems like this test might just be flaky, given this recent master build also failed this test. If someone who has access could rerun the build, it might resolve the issue. But let me know if I'm missing something!

I'd appreciate any guidance on how to proceed from here.

@mydea
Copy link
Member

mydea commented Dec 1, 2022

Thanks for the work! I re-ran the failing tests, all good now. I'll merge this in, so it should go out with the next release 🚀

/**
* Given a child DOM element, returns a query-selector statement describing that
* and its ancestors
* e.g. [HTMLElement] => body > div > input#foo.btn[name=baz]
* @returns generated DOM path
*/
export function htmlTreeAsString(elem: unknown, keyAttrs?: string[]): string {
export function htmlTreeAsString(
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, actually, this is technically a breaking change (as this method is exported...), so we can't change the signature in that way 😬

Can you make this:

export function htmlTreeAsString(
  elem: unknown, 
  keyAttrs?: string[],
  options?: { maxStringLength?: number }
) {}

It's not as nice, but will have to do for now!

Or, alternatively, make it a union type:

export function htmlTreeAsString(
  elem: unknown, 
  options?: { keyAttrs?: string[], maxStringLength?: number } | string[]
) {}

And handle this in the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agh thanks! I didn't think through how this function isn't merely exposed to other packages within this repo, but that it's also exposed anywhere that imports @sentry/utils. I've updated to that latter format, and I've restored the test for the original format.

@ZachGawlik ZachGawlik force-pushed the zg/feat/dom-max-string-length branch from 3c99a73 to 052be4b Compare December 2, 2022 14:36
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! This will go out with the next release 🎉

@mydea mydea merged commit 6e09ffe into getsentry:master Dec 6, 2022
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.

Allow more characters in UI Breadcrumbs
2 participants