Skip to content

Conversation

conico974
Copy link
Contributor

@conico974 conico974 commented Aug 15, 2025

Middleware now handles forwarding insights events instead of going through the api directly.

Copy link

linear bot commented Aug 15, 2025

Copy link

changeset-bot bot commented Aug 15, 2025

⚠️ No Changeset found

Latest commit: add4a2d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

argos-ci bot commented Aug 15, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2 (Inspect) 👍 Changes approved 4 changed Aug 25, 2025, 9:17 AM
v2-cloudflare (Inspect) 👍 Changes approved 2 changed Aug 25, 2025, 9:12 AM
v2-vercel (Inspect) ✅ No changes detected - Aug 25, 2025, 9:21 AM

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements proxying of analytics events through the middleware instead of sending them directly to the GitBook API. The middleware now handles forwarding insights events to maintain better control over analytics traffic routing.

  • Adds middleware route handler for analytics events at /~gitbook/__evt endpoint
  • Updates InsightsProvider to send events through the middleware proxy instead of directly to the API
  • Replaces API host parameter with base path parameter to support the new routing approach

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/gitbook/src/middleware.ts Adds analytics event forwarding handler and imports GITBOOK_API_URL
packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx Removes unused API URL import and updates InsightsProvider props
packages/gitbook/src/components/Insights/visitorId.ts Updates session endpoint path
packages/gitbook/src/components/Insights/InsightsProvider.tsx Refactors to use basePath instead of apiHost and updates event sending logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@conico974 conico974 merged commit 1211ebe into main Aug 25, 2025
23 of 24 checks passed
@conico974 conico974 deleted the conico/rnd-7887-proxy-analytics branch August 25, 2025 09:34
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