Skip to content

Analytics tracking not working in implement-via button handlers #234

@cursor

Description

@cursor

Issue Description

The implement-via button click handlers (Claude Code, Cursor, GitHub Copilot) were not tracking user actions in Google Analytics 4. This was caused by a dynamic import of the analytics service that was failing silently.

Root Cause

The dynamic import was performed inside a try-catch block with an empty catch statement:

try {
  const analyticsModule = await import(getExtensionUrl('utils/analytics-service.js'));
  // ... tracking logic
} catch (err) {
  /* silent */
}

This two-level closure chain caused the import to fail silently without any error reporting, preventing analytics events from being sent to GA4.

Solution

Replaced the dynamic import with a static import at the module level:

import { trackUserAction } from '../analytics-service.js';

This ensures that:

  1. The analytics service is properly imported and available
  2. Click events on implement-via buttons are tracked correctly
  3. Analytics failures are no longer silently swallowed

Files Modified

  • utils/ide-integration/claude-code-suggestion.js
  • utils/ide-integration/cursor-suggestion.js
  • utils/ide-integration/github-copilot-suggestion.js

Additional Changes

  • Removed duplicated listSection logic by reusing the already-computed itemKind variable
  • Added prompt_truncated to analytics tracking payload for better event instrumentation

Related PR

Fixes: #233

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions