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.

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