Skip to content

feat(nx-dev): add server-side page view tracking for docs#34283

Merged
jaysoo merged 1 commit intomasterfrom
DOC-395
Feb 2, 2026
Merged

feat(nx-dev): add server-side page view tracking for docs#34283
jaysoo merged 1 commit intomasterfrom
DOC-395

Conversation

@jaysoo
Copy link
Copy Markdown
Member

@jaysoo jaysoo commented Feb 2, 2026

Current Behavior

Only markdown and text file requests are tracked server-side via the track-asset-requests edge function. HTML page views are not tracked on the server, missing requests from AI tools and curl.

Expected Behavior

Track all doc page views server-side with a new edge function that:

  • Sends server_page_view events to GA4 with content_type param to differentiate HTML/markdown/text
  • Uses Netlify's excludedPath config for efficient path filtering (zero compute for excluded paths)
  • Skips non-HTML requests via Accept header check

Changes

File Change
track-page-requests.ts NEW - Edge function for HTML page view tracking on /docs/*
track-asset-requests.ts Changed event name to server_page_view, added content_type param
add-link-headers.ts Refactored to use excludedPath config instead of runtime path checks
netlify.toml Added edge function declaration for track-page-requests

GA Event Schema

{
  name: 'server_page_view',
  params: {
    content_type: 'text/html' | 'text/markdown' | 'text/plain',
    file_extension: '.html' | '.md' | '.txt',
    is_ai_tool: 'true' | 'false',
    // ... other params
  }
}

Other Notes

This PR also removes the edge function entries from netlify.toml since it's auto detected from astro-docs/netlify/edge-functions. This makes all the configuration in the actual .ts file, not duplicated in the netlify.toml file.

Related Issue(s)

Closes DOC-395

🤖 Generated with Claude Code

@jaysoo jaysoo requested a review from a team as a code owner February 2, 2026 15:11
@jaysoo jaysoo requested a review from MaxKless February 2, 2026 15:11
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nx-dev Ready Ready Preview Feb 2, 2026 3:50pm

Request Review

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 2, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 1d56bf3
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6980c5ed5a33fc00086ca388
😎 Deploy Preview https://deploy-preview-34283--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Feb 2, 2026

View your CI Pipeline Execution ↗ for commit 1d56bf3

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 7m 44s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2m 38s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 11s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-02 15:54:46 UTC

## Current Behavior
Only markdown and text file requests are tracked server-side via the
track-asset-requests edge function. HTML page views are not tracked
on the server, missing requests from AI tools and curl.

## Expected Behavior
Track all doc page views server-side with a new edge function that:
- Sends `server_page_view` events to GA4 with `content_type` param
- Uses Netlify's `excludedPath` config for efficient path filtering
- Skips non-HTML requests via Accept header check

Changes:
- Add track-page-requests.ts edge function for HTML pages
- Update track-asset-requests.ts to use `server_page_view` event name
- Add `content_type` param to differentiate HTML/markdown/text in GA4
- Refactor add-link-headers.ts to use excludedPath config

## Related Issue(s)
Fixes DOC-395

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment thread astro-docs/netlify/edge-functions/add-link-headers.ts
@jaysoo jaysoo merged commit cdd735d into master Feb 2, 2026
22 checks passed
@jaysoo jaysoo deleted the DOC-395 branch February 2, 2026 16:15
jaysoo added a commit that referenced this pull request Feb 2, 2026
## Current Behavior

Only markdown and text file requests are tracked server-side via the
`track-asset-requests` edge function. HTML page views are not tracked on
the server, missing requests from AI tools and curl.

## Expected Behavior

Track all doc page views server-side with a new edge function that:
- Sends `server_page_view` events to GA4 with `content_type` param to
differentiate HTML/markdown/text
- Uses Netlify's `excludedPath` config for efficient path filtering
(zero compute for excluded paths)
- Skips non-HTML requests via Accept header check

### Changes

| File | Change |
|------|--------|
| `track-page-requests.ts` | **NEW** - Edge function for HTML page view
tracking on `/docs/*` |
| `track-asset-requests.ts` | Changed event name to `server_page_view`,
added `content_type` param |
| `add-link-headers.ts` | Refactored to use `excludedPath` config
instead of runtime path checks |
| `netlify.toml` | Added edge function declaration for
`track-page-requests` |

### GA Event Schema

```javascript
{
  name: 'server_page_view',
  params: {
    content_type: 'text/html' | 'text/markdown' | 'text/plain',
    file_extension: '.html' | '.md' | '.txt',
    is_ai_tool: 'true' | 'false',
    // ... other params
  }
}
```

## Other Notes

This PR also removes the edge function entries from `netlify.toml` since
it's auto detected from `astro-docs/netlify/edge-functions`. This makes
all the configuration in the actual `.ts` file, not duplicated in the
`netlify.toml` file.

## Related Issue(s)

Closes DOC-395

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
FrozenPandaz pushed a commit that referenced this pull request Feb 3, 2026
## Current Behavior

Only markdown and text file requests are tracked server-side via the
`track-asset-requests` edge function. HTML page views are not tracked on
the server, missing requests from AI tools and curl.

## Expected Behavior

Track all doc page views server-side with a new edge function that:
- Sends `server_page_view` events to GA4 with `content_type` param to
differentiate HTML/markdown/text
- Uses Netlify's `excludedPath` config for efficient path filtering
(zero compute for excluded paths)
- Skips non-HTML requests via Accept header check

### Changes

| File | Change |
|------|--------|
| `track-page-requests.ts` | **NEW** - Edge function for HTML page view
tracking on `/docs/*` |
| `track-asset-requests.ts` | Changed event name to `server_page_view`,
added `content_type` param |
| `add-link-headers.ts` | Refactored to use `excludedPath` config
instead of runtime path checks |
| `netlify.toml` | Added edge function declaration for
`track-page-requests` |

### GA Event Schema

```javascript
{
  name: 'server_page_view',
  params: {
    content_type: 'text/html' | 'text/markdown' | 'text/plain',
    file_extension: '.html' | '.md' | '.txt',
    is_ai_tool: 'true' | 'false',
    // ... other params
  }
}
```

## Other Notes

This PR also removes the edge function entries from `netlify.toml` since
it's auto detected from `astro-docs/netlify/edge-functions`. This makes
all the configuration in the actual `.ts` file, not duplicated in the
`netlify.toml` file.

## Related Issue(s)

Closes DOC-395

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
(cherry picked from commit cdd735d)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 8, 2026

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants