Skip to content

Version Telemetry#1658

Merged
ignaciojimenezr merged 4 commits intomainfrom
version-telemetry
Mar 24, 2026
Merged

Version Telemetry#1658
ignaciojimenezr merged 4 commits intomainfrom
version-telemetry

Conversation

@ignaciojimenezr
Copy link
Collaborator

No description provided.

@railway-app
Copy link

railway-app bot commented Mar 24, 2026

🚅 Environment inspector-pr-1658 in triumphant-alignment has no services deployed.

1 service not affected by this PR
  • mcp-inspector

@chelojimenez
Copy link
Contributor

chelojimenez commented Mar 24, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@ignaciojimenezr ignaciojimenezr marked this pull request as ready for review March 24, 2026 06:10
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Mar 24, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2026

Walkthrough

This pull request enhances PostHog telemetry tracking by introducing version tracking and improving state management during authentication transitions. The changes add a version super property sourced from __APP_VERSION__ to PostHog's static registration, and modify the usePostHogIdentify hook to re-register static telemetry properties (environment, platform, version) after logout. Comprehensive test coverage is introduced for both the hook and PostHog utilities to validate these behaviors across authenticated and unauthenticated states.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
mcpjam-inspector/client/src/hooks/__tests__/usePostHogIdentify.test.ts (1)

5-39: Prefer repository mock presets over ad-hoc client mocks.

This suite hand-rolls its mock state; please align with client/src/test/mocks/ presets for consistency with the rest of client tests.

As per coding guidelines: "mcpjam-inspector/client/**/tests/*.test.{ts,tsx}: Use mock presets from client/src/test/mocks/ including mcpApiPresets and storePresets in client tests".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mcpjam-inspector/client/src/hooks/__tests__/usePostHogIdentify.test.ts`
around lines 5 - 39, Replace the ad-hoc mockState and individual vi.mock calls
in this test with the shared test presets: import and use the repository mock
presets (e.g., mcpApiPresets and storePresets) from client/src/test/mocks and
wire them into the test instead of creating mockState; specifically ensure
usePostHog, useAuth, useConvexAuth and detectPlatform are provided by those
presets (or adapted from them) so identify/register/reset mocks and platform
detection come from the canonical mocks rather than the hand-rolled mockState
and vi.mock declarations.
mcpjam-inspector/client/src/hooks/usePostHogIdentify.ts (1)

39-44: Deduplicate static telemetry registration to avoid config drift.

Lines 39–44 duplicate the same static props defined in PosthogUtils.options.loaded. A shared helper keeps telemetry shape consistent across login/logout paths.

♻️ Suggested refactor
-      posthog.register({
-        environment: import.meta.env.MODE,
-        platform: detectPlatform(),
-        version: __APP_VERSION__,
-      });
+      posthog.register(getStaticTelemetryProps());
// in mcpjam-inspector/client/src/lib/PosthogUtils.ts
+export function getStaticTelemetryProps() {
+  return {
+    environment: import.meta.env.MODE,
+    platform: detectPlatform(),
+    version: __APP_VERSION__,
+  };
+}
-      posthog.register({
-        environment: import.meta.env.MODE, // "development" or "production"
-        platform: detectPlatform(),
-        version: __APP_VERSION__,
-      });
+      posthog.register(getStaticTelemetryProps());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mcpjam-inspector/client/src/hooks/usePostHogIdentify.ts` around lines 39 -
44, The posthog.register call in usePostHogIdentify.ts re-registers the same
static telemetry props already defined in PosthogUtils.options.loaded, causing
duplication and potential config drift; replace the inline object with a single
shared helper or the existing PosthogUtils.options.loaded (e.g., call
posthog.register(PosthogUtils.options.loaded) or extract a
getStaticTelemetryProps() used by both login/logout paths) so
environment/platform/version are defined in one place and reused across
reset/login/logout flows.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@mcpjam-inspector/client/src/hooks/__tests__/usePostHogIdentify.test.ts`:
- Around line 5-39: Replace the ad-hoc mockState and individual vi.mock calls in
this test with the shared test presets: import and use the repository mock
presets (e.g., mcpApiPresets and storePresets) from client/src/test/mocks and
wire them into the test instead of creating mockState; specifically ensure
usePostHog, useAuth, useConvexAuth and detectPlatform are provided by those
presets (or adapted from them) so identify/register/reset mocks and platform
detection come from the canonical mocks rather than the hand-rolled mockState
and vi.mock declarations.

In `@mcpjam-inspector/client/src/hooks/usePostHogIdentify.ts`:
- Around line 39-44: The posthog.register call in usePostHogIdentify.ts
re-registers the same static telemetry props already defined in
PosthogUtils.options.loaded, causing duplication and potential config drift;
replace the inline object with a single shared helper or the existing
PosthogUtils.options.loaded (e.g., call
posthog.register(PosthogUtils.options.loaded) or extract a
getStaticTelemetryProps() used by both login/logout paths) so
environment/platform/version are defined in one place and reused across
reset/login/logout flows.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 662c2ec0-24c0-47ea-b553-92f2872f2c41

📥 Commits

Reviewing files that changed from the base of the PR and between dc6d991 and af3c354.

📒 Files selected for processing (4)
  • mcpjam-inspector/client/src/hooks/__tests__/usePostHogIdentify.test.ts
  • mcpjam-inspector/client/src/hooks/usePostHogIdentify.ts
  • mcpjam-inspector/client/src/lib/PosthogUtils.ts
  • mcpjam-inspector/client/src/lib/__tests__/posthog-utils.test.ts

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 24, 2026
@ignaciojimenezr ignaciojimenezr merged commit 01b977f into main Mar 24, 2026
5 of 6 checks passed
@ignaciojimenezr ignaciojimenezr deleted the version-telemetry branch March 24, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants