Skip to content

Publish toolkit-core as @sentry/toolkit so getsentry/sentry can share the search-syntax parser? #1533

Open

Description

@sentry-junior

Question

Should we publish packages/toolkit-core (today @sentry/toolkit-core, private: true) to npm as @sentry/toolkit, so that getsentry/sentry's frontend can use the same code as the CLI and MCP server, starting with the search-syntax parser?

@scttcper @gggritso — what do you think? Your take on the frontend side especially: would you add a dependency like this, and is there anything that would block it?

Context

Why toolkit-core and not a separate package

  • No node: imports. It already runs in the CLI (Node/Bun) and the MCP server (Cloudflare Workers).
  • Everything is exported by subpath (./search-syntax, ./events-fields, ./api-request, …), so the frontend would only bundle the parts it imports.
  • @sentry/toolkit is currently unclaimed on npm.
  • One published package is simpler than splitting off a @sentry/search-syntax package and then more packages later.

What it would take

  1. Build step: toolkit-core ships .ts source only (exports point at ./src/*.ts). Publishing means adding a dist/ build (ESM + .d.ts) and pointing the published exports at it, while keeping source resolution for workspace consumers.
  2. Release: add a packages/toolkit-core workspace to .craft.yml with an npm target, a tag prefix, versioning and changelog. The CLI and MCP already release from this monorepo with Craft, so this follows the existing setup.
  3. Rename: change @sentry/toolkit-core to @sentry/toolkit everywhere it's imported in packages/cli and packages/mcp*. It's mechanical but touches a lot of files, so it should be its own PR.
  4. API surface: once it's published, its subpaths are a public API. We need to decide what's public and what stays internal (for example, the auth/OAuth/region-cache modules), and how strict semver is.
  5. Frontend PR: getsentry/sentry swaps its local .pegjs imports for the package, and uses its existing parser.spec.tsx / tokenizer.spec.tsx as parity tests.

Open questions

  • Is @sentry/toolkit the right name? Alternatives include @sentry/toolkit-core made public, or a narrower @sentry/search-syntax.
  • Would the frontend accept grammar changes coming in through toolkit releases instead of being edited in place? Who should own grammar changes?
  • Should we publish everything, or only the parser/fields modules at first?

via byk.

--

View Junior Session [Sentry]

Activity

  1. linear-code commented on Oct 16, 2026

    @linear-code
  2. sentry-junior commented on Oct 17, 2026

    @sentry-junior
    ContributorAuthor

    Known divergence from the frontend parser (from #1534)

    The shared parser no longer matches the frontend on one point. In the frontend's static/app/components/searchSyntax/parser.tsx, predicateFilter checks argument types for AGGREGATE_DURATION, AGGREGATE_DATE and AGGREGATE_PERCENTAGE, but returns true for AGGREGATE_SIZE. So any aggregate whose value looks like a size (avg(span.duration):>1kb) parses as an aggregate size filter, even when none of its arguments is a size field.

    #1534 fixes this in @sentry/toolkit-core/search-syntax: AGGREGATE_SIZE now requires a size-key argument, like the other typed aggregates. Without one, the term falls back to free text, as a duration value on a non-duration aggregate already does.

    Before the frontend switches to the shared package, we should either fix this upstream in getsentry/sentry, or accept the stricter behavior there. With an empty sizeKeys, avg(x):>1kb stops being a typed filter, so frontend callers would need to pass their size fields. For reference, the backend's event_search.py doesn't check the result type for size filters either.

  3. nsdeschenes commented on Oct 21, 2026

    @nsdeschenes

    Heyo @BYK 👋

    We have a couple of concerns with this move:

    • There is a shared integration test suite between the API and FE parsers which acts a contract between the two ensuring constant functionality/support.
    • Pulling this out also significantly increases the burden on developers when it comes to updating things as we'll have to tackle things in two places, rather than one.
  4. BYK commented on Oct 21, 2026

    @BYK
    Member

    Hey @nsdeschenes - thanks a lot, this is exactly why I pinged you folks! Would it be possible to publish the spec/parser from the Sentry side like we do for the scraps package that @natemoo-re created? The core need is having a shared spec/parser for this. I don't really care where it lives :)

  5. BYK commented on Oct 21, 2026

    @BYK
    Member

    And also we should probably incorporate that fix we added here back on the Sentry side

  6. nsdeschenes commented on Oct 22, 2026

    @nsdeschenes

    Hrrm, that is a possibility!

    We'll have to chat with the design-eng folks to see what that would look like exactly, and how it fits in with things. They're fairly coupled right now, so we'd have to put some work in figuring out how to de-couple things, but this approach would be more favourable overall in my opinion!

  7. BYK commented on Oct 22, 2026

    @BYK
    Member

    @nsdeschenes no need for chats or effort, I'll put Junior on it if you agree. If you folks don't like the PR we can iterate on it or simply not merge.

  8. nsdeschenes commented on Oct 22, 2026

    @nsdeschenes

    Yea that should be alright, if you want to initially tag me for review, i can tag the others who should take a peek at it too.

  9. sentry-junior commented on Oct 22, 2026

    @sentry-junior
    ContributorAuthor

    Opened getsentry/sentry#128514 and requested review from @nsdeschenes.

    What it does

    • Adds @sentry/search-syntax under static/packages/search-syntax, set up for publishing the same way as @sentry/icons. The frontend grammar moves into it unchanged, along with the Token / TermOperator / FilterType / BooleanOperator enums. The app now imports both from the package, so there is only one copy of the grammar.
    • Adds a structural TokenConverter and parseSearch to the package. This is the toolkit port, and it passes every case in fixtures/search-syntax. Those are the fixtures the frontend parser and event_search.py already test against, so the API↔FE contract covers the package too.
    • Fixes the AGGREGATE_SIZE gap from fix(core,mcp): Bugbot follow-ups from the shared search parser #1534 in the frontend parser, so typed size aggregates now need a size-key argument. The backend still doesn't check this. That's noted on the PR as a follow-up.

    Not in this PR
    The app keeps its own validating TokenConverter. Having it subclass the package converter, so the structural code lives in one place, is a follow-up.

    Next on the toolkit side
    Once the package is on npm, swap @sentry/toolkit-core/search-syntax and the vendored grammar/search-syntax.pegjs for @sentry/search-syntax/parser and @sentry/search-syntax/tokens. The exported names are the same, but the enums are TS enums rather than as const objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions