Redo Segment integration#2119
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the legacy Segment setup with a custom Docusaurus plugin that conditionally loads the Segment script client-side and emits a single page view per route change.
- Introduce
src/plugins/segmentplugin to initialize and hook Segment analytics - Drop all old
@site/src/lib/segmentAnalyticscode and remove manualtrack*calls throughout components - Wire up
SEGMENT_ANALYTICS_KEYindocusaurus.config.jsand remove the external plugin dependency
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/plugins/segment/segment.ts | Client-side snippet to lazy-load Segment and track pages |
| src/plugins/segment/index.ts | Docusaurus plugin entry registering the client module |
| src/plugins/segment/package.json | Metadata for the plugin (likely unused in this setup) |
| docusaurus.config.js | Added SEGMENT_ANALYTICS_KEY to customFields and switched plugins |
| src/lib/segmentAnalytics.js & imports | Removed old analytics helper and all its imports from code |
| package.json | Removed the separate docusaurus-plugin-segment dependency |
Comments suppressed due to low confidence (2)
src/plugins/segment/segment.ts:71
- [nitpick] We should document why we pin to version
4.15.3(e.g., matching our CDN or API compatibility) or make it configurable viacustomFields.
analytics.SNIPPET_VERSION = "4.15.3";
src/plugins/segment/package.json:1
- [nitpick] This
package.jsonin the plugin folder isn’t referenced by the build and may cause confusion. Consider removing it or documenting its purpose.
{
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix for Segment duplicate page event issue identified in audit.
This was tested via the preview deployment, and fires a single page view event per page as expected.
Preview
https://metamask-docs-git-sdk-react-fixes-consensys-ddffed67.vercel.app/
To test:
Checklist
Complete this checklist before merging your PR: