Skip to content

refactor: split tracking domain logic from segment client#174

Merged
angeloashmore merged 3 commits intomainfrom
aa/refactor-tracking
May 5, 2026
Merged

refactor: split tracking domain logic from segment client#174
angeloashmore merged 3 commits intomainfrom
aa/refactor-tracking

Conversation

@angeloashmore
Copy link
Copy Markdown
Member

@angeloashmore angeloashmore commented May 5, 2026

Resolves:

Description

Moves Prismic-specific tracking logic out of src/lib/segment.ts into a new src/tracking.ts module, keeping lib/segment.ts domain-agnostic. The Segment write key is now derived from the Prismic host rather than PRISMIC_ENV.

Checklist

  • A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA 1


Note

Medium Risk
Changes how CLI telemetry is initialized and how the Segment write key is selected (now based on host and .prismicrc), which could impact event delivery/opt-out behavior. Runtime risk is mostly limited to analytics but touches the CLI entrypoint and exit-flush flow.

Overview
Telemetry refactor: Moves Prismic-specific tracking concerns (telemetry opt-out via .prismicrc, repository grouping, command start/end properties, and user identity) into a new src/tracking.ts, leaving src/lib/segment.ts as a domain-agnostic event queue + sender.

Initialization changes: CLI startup (src/index.ts) and sync now call initTracking/trackCommandStart/trackCommandEnd/trackUser instead of lib/segment helpers, and the Segment write key is determined from the resolved Prismic host (prod vs non-prod) and passed through the subprocess payload to sendSegmentEvents.

Reviewed by Cursor Bugbot for commit 23fc651. Bugbot is set up for automated code reviews on this repo. Configure here.

Footnotes

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5d82a30. Configure here.

Comment thread src/tracking.ts
Comment thread src/tracking.ts
Comment thread src/lib/segment.ts
angeloashmore and others added 2 commits May 5, 2026 01:33
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Stamp userId on track events when missing, attach repository groupId on
command-start, and treat missing .prismicrc files as telemetry-enabled
instead of crashing the telemetry check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@angeloashmore angeloashmore merged commit 12303fe into main May 5, 2026
13 checks passed
@angeloashmore angeloashmore deleted the aa/refactor-tracking branch May 5, 2026 02:09
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.

1 participant