Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server side tracking for Remix actions #124

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/remix/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Scripts,
ScrollRestoration,
} from "@remix-run/react";
import { Analytics } from "@vercel/analytics/react";

export default function App() {
return (
Expand All @@ -15,6 +16,7 @@ export default function App() {
<Links />
</head>
<body>
<Analytics />
<Outlet />
<ScrollRestoration />
<Scripts />
Expand Down
10 changes: 5 additions & 5 deletions apps/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
},
"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",
"@remix-run/node": "^2.5.0",
"@remix-run/react": "^2.5.0",
"@remix-run/serve": "^2.5.0",
"@remix-run/server-runtime": "^2.5.0",
"@vercel/analytics": "workspace:*",
"@vercel/remix": "2.0.1",
"@vercel/remix": "2.5.0",
Copy link
Member

Choose a reason for hiding this comment

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

praise: a good opportunity to update these indeed!

"isbot": "^3.6.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
5 changes: 2 additions & 3 deletions packages/web/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
import type { AllowedPropertyValues } from '../types';
import { isProduction, parseProperties } from '../utils';

const ENDPOINT = process.env.VERCEL_URL || process.env.VERCEL_ANALYTICS_URL;
const DISABLE_LOGS = Boolean(process.env.VERCEL_WEB_ANALYTICS_DISABLE_LOGS);

type HeadersObject = Record<string, string | string[] | undefined>;
type AllowedHeaders = Headers | HeadersObject;

Expand Down Expand Up @@ -38,6 +35,8 @@ export async function track(
properties?: Record<string, AllowedPropertyValues>,
context?: Context
): Promise<void> {
const ENDPOINT = process.env.VERCEL_URL || process.env.VERCEL_ANALYTICS_URL;
const DISABLE_LOGS = Boolean(process.env.VERCEL_WEB_ANALYTICS_DISABLE_LOGS);
if (typeof window !== 'undefined') {
if (!isProduction()) {
throw new Error(
Expand Down
Loading