Skip to content

👷‍♀️ [Devx] Make developer extension queries compatible with exclusion #3434

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cy-moi
Copy link
Collaborator

@cy-moi cy-moi commented Mar 18, 2025

Motivation

Current filter queries do not support exclusion, despite that we support this mode in the filters. It would also be nice to update the query while selecting with facets.

Changes

  1. Added exclusion mode support in query parsing
  2. Added more tests for events filter
  3. Made selections in facets update the search queries (but not vice versa yet)
Screenshot 2025-03-18 at 18 18 34

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@cy-moi cy-moi marked this pull request as ready for review March 19, 2025 12:46
@cy-moi cy-moi requested a review from a team as a code owner March 19, 2025 12:46
Comment on lines +111 to +116
// Handle minus sign prefix for exclude mode
const isExclude = queryPart.startsWith('-')
const part = isExclude ? queryPart.slice(1) : queryPart
const [key, ...valueParts] = part.split(':')
const value = valueParts.join(':') // Rejoin in case there are colons in the value
return [isExclude ? 'exclude' : 'include', key, value]
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: ‏introduce a proper TypeScript type for this, example:

interface QueryPart {
  key: string,
  value: string,
  type: "exclude" | "include"
}

💬 suggestion: ‏unescape the key and values in parseQuery, instead of doing it later.

Comment on lines +195 to +196
const escapedPath = facetPath.replace(/\s+/g, '\\$&')
const escapedValue = value.replace(/\s+/g, '\\$&')
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: ‏expose standalone functions to escape and unescape strings, so you can test them correctly and reuse them.

Comment on lines +31 to +52
const includeParts = queryParts.filter((part) => part[0] === 'include')
const excludeParts = queryParts.filter((part) => part[0] === 'exclude')

// Check if event matches any exclude condition
const isExcluded = excludeParts.some(([_, searchKey, searchTerm]) => {
const restoredSearchTerm = searchTerm ? searchTerm.replaceAll(/\\\s+/gm, ' ') : ''
return matchQueryPart(event, searchKey, restoredSearchTerm)
})

if (isExcluded) {
return false
}

// If no include conditions, event passes
if (includeParts.length === 0) {
return true
}
// Check if event matches any include condition
return includeParts.some(([_, searchKey, searchTerm]) => {
const restoredSearchTerm = searchTerm ? searchTerm.replaceAll(/\\\s+/gm, ' ') : ''
return matchQueryPart(event, searchKey, restoredSearchTerm)
})
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: ‏I think this could be simplified by iterating over the query parts only once:

queryParts.every((queryPart) => {
  const match = matchQueryPart(...)
  const isExcluded = queryPart[0] === "exclude"
  return match !== isExcluded
})

Or matchQueryPart(event, queryPart) could take care of the "excluded" status, and we could just do:

queryParts.every((queryPart) => matchQueryPart(event, queryPart))

At least, extract that logic in a filterQuery function similar to filterFacets and filterOutdatedVersions

Comment on lines +135 to +136
facetValuesFilter: newFacetValuesFilter,
query: generateQueryFromFacetValues(newFacetValuesFilter),
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: query and facetValuesFilter now kind of represent the same thing but in two different formats. It would be nice to keep only one of the two, probably query as it can express more things. This would:

  • simplify the logic, as we don't need to sync the two
  • make the UI more predictable, as the two cannot be out of sync
  • make things faster, as we wouldn't need to filter events based on both the query and facets.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, these two formats coexisting is kind of getting out of hands.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 98.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.19%. Comparing base (5948bd8) to head (1756878).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...xtension/src/panel/hooks/useEvents/eventFilters.ts 97.77% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3434      +/-   ##
==========================================
+ Coverage   92.73%   93.19%   +0.46%     
==========================================
  Files         301      302       +1     
  Lines        7900     7941      +41     
  Branches     1807     1819      +12     
==========================================
+ Hits         7326     7401      +75     
+ Misses        574      540      -34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 144.57 KiB 144.57 KiB 0 B 0.00%
Logs 51.37 KiB 51.37 KiB 0 B 0.00%
Rum Slim 106.00 KiB 106.00 KiB 0 B 0.00%
Worker 23.59 KiB 23.59 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.003 0.003 -0.000
addaction 0.043 0.073 0.030
addtiming 0.001 0.002 0.001
adderror 0.049 0.084 0.035
startstopsessionreplayrecording 0.019 0.040 0.022
startview 0.477 0.650 0.174
logmessage 0.021 0.026 0.005
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 25.68 KiB 25.81 KiB 139 B
addaction 52.64 KiB 54.64 KiB 2.00 KiB
addtiming 25.18 KiB 24.93 KiB -259 B
adderror 57.60 KiB 56.95 KiB -657 B
startstopsessionreplayrecording 24.57 KiB 24.49 KiB -76 B
startview 418.24 KiB 419.30 KiB 1.06 KiB
logmessage 52.59 KiB 53.13 KiB 545 B

🔗 RealWorld

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.

3 participants