Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vercel/analytics
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.1.0
Choose a base ref
...
head repository: vercel/analytics
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.1.1
Choose a head ref
  • 2 commits
  • 25 files changed
  • 2 contributors

Commits on Oct 6, 2023

  1. Upgrade @vercel/style-guide (#110)

    * Upgrade @vercel/style-guide
    
    * Run prettier
    tobiaslins authored Oct 6, 2023
    Copy the full SHA
    c57f273 View commit details

Commits on Oct 12, 2023

  1. fix server side events for remix actions (#112)

    * Fix server side events for remix
    
    * Add remix example
    
    * Update packages/web/src/server/index.ts
    
    Co-authored-by: Chris <7249920+chriswdmr@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Chris <7249920+chriswdmr@users.noreply.github.com>
    tobiaslins and chriswdmr authored Oct 12, 2023
    Copy the full SHA
    ab1213b View commit details
2 changes: 1 addition & 1 deletion apps/nextjs/app/api/edge-no-context/route.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ async function handler(request: Request) {
},
{
request,
},
}
);

return new Response('OK');
2 changes: 1 addition & 1 deletion apps/nextjs/components/withAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import React from 'react';

export function withAnalytics<P extends Omit<AnalyticsProps, 'mode'>>(
Component: React.ComponentType,
props?: P,
props?: P
) {
function WithAnalytics(props?: P) {
return (
2 changes: 2 additions & 0 deletions apps/nextjs/e2e/development/pageview.spec.ts
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ test.describe('pageview', () => {
page.on('console', (msg) => {
const message = msg.text();

console.log(message);

if (
message.includes('[Vercel Web Analytics]') ||
message.includes('[Vercel Analytics]')
2 changes: 1 addition & 1 deletion apps/nextjs/middleware.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ export async function middleware(request: NextRequest, event: NextFetchEvent) {
track('Redirect', {
path: request.nextUrl.pathname,
type: 'waitUntil',
}),
})
);
return NextResponse.redirect(new URL('/server-actions', request.url));
}
2 changes: 1 addition & 1 deletion apps/nextjs/pages/api/test.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ async function handler(request: NextRequest, event: NextFetchEvent) {
track('Pages Api Route', {
runtime: 'edge',
router: 'pages',
}),
})
);

return new Response('OK');
6 changes: 6 additions & 0 deletions apps/remix/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules

/build
/public/build
.env

1 change: 1 addition & 0 deletions apps/remix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Remix Vercel Web Analytics Test
25 changes: 25 additions & 0 deletions apps/remix/app/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";

export default function App() {
return (
<html lang="en">
<head>
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
}
24 changes: 24 additions & 0 deletions apps/remix/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { json } from "@vercel/remix";
import { Form, useActionData } from "@remix-run/react";
import { track } from "@vercel/analytics/server";

export const action = async () => {
await track("Server Action", { some: "data" });
return json({ success: true });
};

export default function Home() {
const data = useActionData<typeof action>();
return (
<main>
<h1>Vercel Web Analytics Demo</h1>
{data?.success ? (
<p>Success!</p>
) : (
<Form method="POST" replace>
<button type="submit">Submit action</button>
</Form>
)}
</main>
);
}
11 changes: 11 additions & 0 deletions apps/remix/app/routes/health.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { track } from "@vercel/analytics/server";

export async function loader({ request }: LoaderFunctionArgs) {
const host =
request.headers.get("X-Forwarded-Host") ?? request.headers.get("host");

await track("Health", { host });

return new Response("OK");
}
40 changes: 40 additions & 0 deletions apps/remix/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "remix-vercel-analytics",
"private": true,
"scripts": {
"build": "remix build",
"dev": "remix dev",
"format": "prettier -w .",
"start": "remix-serve build"
},
"prettier": {},
"dependencies": {
"@remix-run/node": "^2.0.1",
"@remix-run/react": "^2.0.1",
"@remix-run/serve": "^2.0.1",
"@remix-run/server-runtime": "^2.0.1",
"@vercel/analytics": "workspace:*",
"@vercel/remix": "2.0.1",
"isbot": "^3.6.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^2.0.1",
"@remix-run/eslint-config": "^2.0.1",
"@types/eslint": "^8.4.10",
"@types/node": "^18.11.9",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"autoprefixer": "^10.4.13",
"cross-env": "^7.0.3",
"postcss": "^8.4.18",
"prettier": "2.7.1",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.0",
"typescript": "^5.2.2"
},
"engines": {
"node": ">=18"
}
}
Loading