Skip to content

feat: introduce usage-stats service + init changeset#3

Merged
wrn14897 merged 14 commits into
mainfrom
warren/introduce-usage-stats-service
Sep 16, 2023
Merged

feat: introduce usage-stats service + init changeset#3
wrn14897 merged 14 commits into
mainfrom
warren/introduce-usage-stats-service

Conversation

@wrn14897

@wrn14897 wrn14897 commented Sep 15, 2023

Copy link
Copy Markdown
Member

Add HyperDX anonymous usage statistics reporting service:

  1. The service collects metrics like os, services health, table stats and user counts
  2. Allow users to disable the reporting service by specifying USAGE_STATS_ENABLED=false

@MikeShi42 MikeShi42 left a comment

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.

lgtm

@changeset-bot

changeset-bot Bot commented Sep 16, 2023

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0eac413

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@hyperdx/api Minor
@hyperdx/app Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wrn14897 wrn14897 changed the title feat: introduce usage-stats service feat: introduce usage-stats service + init changeset Sep 16, 2023
@wrn14897
wrn14897 merged commit 0dfef51 into main Sep 16, 2023
@wrn14897
wrn14897 deleted the warren/introduce-usage-stats-service branch September 16, 2023 00:19
mlsalcedo pushed a commit to mlsalcedo/hyperdx that referenced this pull request Feb 27, 2026
alex-fedotyev added a commit that referenced this pull request Mar 17, 2026
- Fix #2: Strengthen test assertion (toBeGreaterThanOrEqual(0) → toBeGreaterThan(0))
  so it actually verifies near-zero outliers land in underflow bucket
- Fix #3: Persist scaleType to URL via useQueryStates so it survives page reload
- Fix #4: Remove conflicting required rule on Count field (Zod schema has it optional)
- Fix #8: Add role="img" and aria-label to ColorLegend for accessibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
alex-fedotyev added a commit that referenced this pull request Mar 17, 2026
…val (#4)

Reverts the scaleType change from useQueryStates back to useState
(fix #3 needs to be done with access to the local dev env to debug
the lint error properly). Keeps the Count field required removal (#4).
alex-fedotyev pushed a commit that referenced this pull request Mar 17, 2026
- Fix ColorLegend Prettier violation (multi-attribute JSX must be multi-line)
- Re-implement scaleType URL persistence (#3) using void operator to
  satisfy no-misused-promises lint rule
- scaleType now survives page reload via useQueryStates
abhiroop93 added a commit to ShareChat/hyperdx that referenced this pull request Apr 28, 2026
…026-04-28

customizations 1-8 implemented and verified:
- #1 live tail feature flag + configurable duration
- #2 autocomplete top-N display (pagination removed)
- hyperdxio#3 per-keystroke clickhouse prefix search + includes() filtering +
     configurable date range (NEXT_PUBLIC_AUTOCOMPLETE_DATE_RANGE_MS)
- hyperdxio#4 privileged-user access gate for team settings
- hyperdxio#5 standard otel sdk exporter for app self-telemetry
- hyperdxio#6 google sso with domain auto-join; sso button above email/password form
- hyperdxio#7 next-runtime-env standalone __ENV.js generation at container startup
- hyperdxio#8 live tail configurable refresh interval (15m/30m/1h)
alex-fedotyev added a commit that referenced this pull request May 6, 2026
The three failing dashboard-container tests in CI shard 1 came down to
two distinct races:

1. Tests #3 (line 112) and #5 (line 194) read getActiveTabsParam()[id]
   synchronously after Add Tab and after tab switches. nuqs flushes URL
   state asynchronously, so the read fires before the param is written.
   Wrap each sync read in expect.poll, mirroring the fix in PR #2209.

2. Test #6 (line 231) paired toggleGroupBordered(idA) with
   addTabToGroup(idB) back-to-back. Both setDashboard calls produce()
   from the same pre-mutation snapshot of the React Query cache, so
   the second PATCH overwrites the first; the toggle is silently
   dropped. The save-and-reload assertion then sees the wrong state
   (or, when goto fires before the PATCH lands, no state at all).

   Narrow the round-trip to a single mutation per step (addTabToGroup
   on group B), wait for networkidle before navigating away, capture
   the dashboard id from the URL while we are still on the page, and
   use expect.poll for the post-reload getGroupOrder assertion. The
   bordered toggle stays covered by the dedicated in-page test at
   line 78. The underlying back-pressure race is tracked separately
   in #2216.
alex-fedotyev added a commit that referenced this pull request May 8, 2026
The three failing dashboard-container tests in CI shard 1 came down to
two distinct races:

1. Tests #3 (line 112) and #5 (line 194) read getActiveTabsParam()[id]
   synchronously after Add Tab and after tab switches. nuqs flushes URL
   state asynchronously, so the read fires before the param is written.
   Wrap each sync read in expect.poll, mirroring the fix in PR #2209.

2. Test #6 (line 231) paired toggleGroupBordered(idA) with
   addTabToGroup(idB) back-to-back. Both setDashboard calls produce()
   from the same pre-mutation snapshot of the React Query cache, so
   the second PATCH overwrites the first; the toggle is silently
   dropped. The save-and-reload assertion then sees the wrong state
   (or, when goto fires before the PATCH lands, no state at all).

   Narrow the round-trip to a single mutation per step (addTabToGroup
   on group B), wait for networkidle before navigating away, capture
   the dashboard id from the URL while we are still on the page, and
   use expect.poll for the post-reload getGroupOrder assertion. The
   bordered toggle stays covered by the dedicated in-page test at
   line 78. The underlying back-pressure race is tracked separately
   in #2216.
kodiakhq Bot pushed a commit that referenced this pull request May 12, 2026
#2200)

## Summary

Heatmap was the only builder-mode display type that did not round-trip through the external dashboards API. The serializer dropped it into the "unsupported" fall-through, so creating, fetching, and updating heatmap tiles via `/api/v2/dashboards` lost the config.

This wires up heatmap end-to-end on the external API: a dedicated select-item schema, an explicit case in both serialization directions, OpenAPI JSDoc, and tests.

Follow-up to #2107 (review feedback from @pulpdrew, who asked whether we had a follow-up ticket to update the external API for the new visualization type).

## What's in the diff

- **Zod schemas** (`packages/api/src/utils/zod.ts`): a heatmap select-item schema that exposes the literal `aggFn: "heatmap"` plus `valueExpression`, optional `countExpression`, `alias`, `heatmapScaleType`; and a heatmap chart-config schema with optional `groupBy` and `numberFormat`. Heatmap is added to the **builder** discriminated union only.
- **Conversion utilities** (`packages/api/src/routers/external-api/v2/utils/dashboards.ts`):
  - Builder serializer: replaces the old `case DisplayType.Heatmap:` fall-through with an explicit case that reads heatmap-specific fields off `config.select[0]` and emits `aggFn: "heatmap"` on the external surface.
  - Builder deserializer: new `case 'heatmap':` mirroring the Pie pattern; maps the external `aggFn: "heatmap"` back to the internal `aggFn: "count"` that the editor form persists, while preserving `countExpression`, `alias`, and `heatmapScaleType` on the select item.
  - The raw-SQL switch is intentionally left untouched: heatmap stays in the unsupported fall-through there because heatmap rendering requires `isBuilderChartConfig`.
- **OpenAPI JSDoc** (`packages/api/src/routers/external-api/v2/dashboards.ts`): `HeatmapSelectItem` and `HeatmapBuilderChartConfig` components, and `heatmap` added to the `TileConfig` `oneOf` and discriminator mapping.
- **Tests** (`packages/api/src/routers/external-api/__tests__/dashboards.test.ts`): heatmap added to the existing "round-trip all supported chart types" tests for both POST and PUT, plus an explicit rejection test confirming raw-SQL heatmap tiles return 400.
- **`packages/api/openapi.json`**: regenerated.

## Notes for review

- No raw-SQL heatmap variant. PR #2107 made heatmap builder-only and `DBDashboardPage.tsx` requires `isBuilderChartConfig` for heatmap rendering, so the raw-SQL fall-through stays.
- `heatmapScaleType` and `countExpression` are persisted on the per-select-item level (via `DerivedColumnSchema` in `packages/common-utils/src/types.ts`), not on the chart config root. The form binds them as `series.0.heatmapScaleType` / `series.0.countExpression`. The schema and conversion utilities follow that.
- The aggFn translation (external `"heatmap"` ↔ internal `"count"`) keeps the saved Mongo document identical to what the editor form produces, so heatmap tiles created via the API render the same way as ones created via the UI.

## Tier

Lands as `review/tier-4` because anything under `packages/api/src/routers/external-api/` is on the critical-path list. Diff is ~250 prod lines (most of it OpenAPI JSDoc and Zod boilerplate); no schema migrations or auth changes.

## Test plan

- [x] `make ci-lint` (yarn lint, tsc --noEmit, OpenAPI lint)
- [x] `make ci-unit` (common-utils + app)
- [ ] CI runs the full integration suite (heatmap round-trip POST + PUT + raw-SQL rejection); local `make dev-int` requires Docker BuildKit which isn't available on this host.

## Deep-review carryover (2026-05-07)

- **Resolved here**: P0/P1 #4 (`convertToInternalTileConfig` comment vs `applyHeatmapDefaults` reality, see commit `946412ad`).
- **Resolved in #2199**: P0/P1 #1 (heatmap arm in `mcpTilesParam`) already shipped; P0/P1 #3 (heatmap entry in `buildQueryGuidePrompt` + `buildCreateDashboardPrompt`) added in commit `e583fc68`.
- **Pending in #2199 post-rebase**: P0/P1 #2 (MCP `createDashboard`/`updateDashboard` calling `getHeatmapTilesWithIncompatibleSources`), since the helper is added in this PR and not yet importable from #2199's branch.
- **Deferred (P2)**: heatmap GET fallthrough silently rewriting to line on malformed docs, and source-kind-change wedge on PUT. Both tracked in #2236.
alex-fedotyev added a commit that referenced this pull request May 12, 2026
…ile round-trip

Adds three integration tests that close coverage holes Brandon flagged:

1. Update changing displayType to heatmap on a non-Trace source: the
   existing reject test covers create-side only. This exercises the
   update path through filterChangedHeatmapTiles' "displayType
   changed to heatmap" branch.
2. Update changing a heatmap tile's source to a non-Trace source:
   exercises filterChangedHeatmapTiles' "sourceId changed on
   existing heatmap" branch. Together with #1, both update-side gate
   conditions in the OSS PR's filterChangedHeatmapTiles are now
   reachable from a test (previously zero coverage).
3. Mixed heatmap + line + number tiles in one dashboard: catches
   regressions where a serializer/deserializer change accidentally
   drops or clobbers sibling tile configs.

Each new test is verified to detect a real regression via local
mutation testing:

- Short-circuiting filterChangedHeatmapTiles to return [] causes
  exactly tests #1 and #2 to fail (2 failed, 6 passed of the 8
  heatmap-name tests). With the function restored, all 8 pass.
- Replacing tiles.map with tiles.slice(0, 1).map in
  convertExternalTilesToInternal causes exactly test #3 to fail
  (1 failed, 7 passed). With map restored, all 8 pass.

Test naming, structure, and config-constant pattern follow the
toMatchObject style Brandon asked for; no wall-of-text comments.
kodiakhq Bot pushed a commit that referenced this pull request May 26, 2026
…drag) (#2205)

## Summary

Follow-up E2E coverage for PR #2015 (the unified `DashboardContainer`
that replaced the legacy section/group concept). Drew explicitly asked
for this in his top-level review on #2015 ("Can you confirm we have
followup issues/tickets covering... 2. New E2E tests covering the new
functionality"). Unit coverage landed in #2015 itself; this PR adds
the missing browser-level coverage.

The container UX has four moving pieces, all exercised here:
collapsible (chevron + URL state), bordered (overflow-menu toggle +
inline border style), tabs (tab bar appearance, tab switching, URL
state), and drag-to-reorder via @dnd-kit. Each test step cites the
source line that defines the behavior so a reviewer can double-check
the assertion matches the implementation.

### Test cases

1. Group renders with default collapsible chevron and bordered style;
   chevron toggles `aria-expanded`.
2. Toggling Hide Border / Show Border via the overflow menu flips the
   inline border style and the menu label.
3. Adding a tab brings the tab bar (1-tab groups don't render it),
   switching tabs updates `?activeTabs` and `aria-selected`.
4. `?collapsed` and `?expanded` URL params survive reload and restore
   per-viewer state.
5. `?activeTabs` URL param survives reload and restores the active
   tab.
6. Save-and-reload round-trip preserves the containers list and the
   second tab on group B.
7. Drag-to-reorder: drag-onto-self is a no-op (the DnD guard at
   `DashboardDndContext.tsx:67-70`); dragging A onto C in `[A, B, C]`
   yields `[B, C, A]` (arrayMove semantics) and the new order
   persists across navigation.

### What changed since the first push

- Tests #3 and #5 wrap `getActiveTabsParam()[id]` reads in
  `expect.poll(...)` because `nuqs` flushes URL state asynchronously
  after `Add Tab` and tab switches. This is the same race pattern
  the heatmap drag-select e2e (PR #2209) hit.
- Test #6 was narrowed to a single mutation per step (`addTabToGroup`
  on group B) and now waits for `networkidle` before navigating away.
  The earlier version paired a `toggleGroupBordered(idA)` with
  `addTabToGroup(idB)` back-to-back; the resulting concurrent
  `setDashboard` calls clobber each other because the second
  `produce` reads the same pre-mutation snapshot. That underlying
  race is tracked in #2216. Bordered round-trip is still covered in
  isolation by test #2.

### Side fixes pulled in

- `DashboardPage.ts` page-object selector was still pointing at the
  stale `add-new-section-menu-item` testid; PR #2015 renamed it to
  `add-new-group-menu-item`. No existing spec exercised `addSection`,
  so this hadn't surfaced. Renamed the locator and the helper from
  `addSection` -> `addGroup`.
- `DashboardContainer.tsx` adds `data-testid="group-add-tab-${id}"`
  on the existing Add Tab menu item so the spec doesn't have to
  match Mantine menu text. One-line non-behavior change.

### Tier

Predicted **Tier 2** by the local classifier: 1 production file,
10 production lines (the testid addition), no API/router/model
touch, single-layer (`packages/app/`). Test files are excluded from
the tier calculation per the classifier rules.

### Out of scope

- Concurrent-mutation back-pressure on `setDashboard` (PATCH clobber).
  Tracked in #2216.
- Multi-user URL state isolation (covered by
  `dashboardSections.test.tsx` unit tests).
- Alert-dot indicators (covered by `DashboardContainer.test.tsx`).
- Legacy `type: "section"` migration (one-time data shape; covered
  by `dashboardSections.test.tsx`).
- Tile drag-reorder (uses `react-grid-layout`, not the new
  `@dnd-kit` container DnD).

## Test plan

- [x] `yarn lint` clean.
- [x] `yarn tsc --noEmit` clean.
- [x] `npx playwright test --list tests/e2e/features/dashboard-container.spec.ts` lists all 7 cases.
- [x] `prose-lint` clean against `origin/main`.
- [x] Local tier prediction: **Tier 2**.
- [ ] CI: full E2E shard run on this branch.

Refs PR #2015. Follow-up race tracked in #2216.
brandon-pereira added a commit that referenced this pull request Jul 22, 2026
- Reduce comments to explain non-obvious "why" only (1-2 lines each), drop
  restated-code and section-header narration.
- Webhook body fallback: only substitute the default template when body is
  null/undefined, so an explicit empty body ("") is honored (Greptile #3).
- deleteWebhook guard: match alerts on channel.webhookId alone (drop the
  channel.type filter) so a legacy/skewed alert still blocks deletion
  (Greptile #2).

Greptile #1 (dangling source references on delete) is intentionally left as-is:
it matches the existing REST DELETE /sources/:id behavior and the tool
description already warns callers to check dependents; full dependency-graph
cleanup is out of scope for this PR.
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.

2 participants