Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
49 changes: 29 additions & 20 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,37 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
typescript:
name: typescript
biome:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest
- name: Run Biome
run: biome ci

tests:
name: unit tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: checkout
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Install
uses: ./.github/composite-actions/install
- name: lint
run: pnpm -r lint
- name: type-check
run: pnpm -r type-check
- name: prettier
run: pnpm prettier -c .
- name: build
run: pnpm -r build
- name: test
- name: Run tests
run: pnpm -r test

playwright:
name: playwright
name: e2e tests
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
Expand All @@ -41,14 +50,14 @@ jobs:
- 'test:e2e:production'
- 'test:e2e:development'
steps:
- name: checkout
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v5
- name: Install
uses: ./.github/composite-actions/install
- name: get playwright version
- name: Get Playwright version
id: pw
run: echo "version=$(cat apps/nextjs/package.json | jq -r '.devDependencies."@playwright/test"')" >> $GITHUB_OUTPUT
- name: install playwright
- name: Install Playwright
run: pnpx playwright@${{ steps.pw.outputs.version }} install
- name: test
- name: Run tests
run: pnpm -r ${{ matrix.test }}
4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

10 changes: 0 additions & 10 deletions .prettierignore

This file was deleted.

5 changes: 3 additions & 2 deletions apps/astro/src/pages/blog/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import Layout from '../../layouts/Base.astro';

export async function getStaticPaths() {
const blogEntries = await getCollection('blog');
return blogEntries.map(entry => ({
params: { slug: entry.slug }, props: { entry },
return blogEntries.map((entry) => ({
params: { slug: entry.slug },
props: { entry },
}));
}

Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-15/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Analytics } from '@vercel/analytics/next';
import type { Metadata } from 'next';
import localFont from 'next/font/local';
import { Analytics } from '@vercel/analytics/next';
import './globals.css';

const geistSans = localFont({
Expand Down
5 changes: 4 additions & 1 deletion apps/nextjs-15/src/app/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
padding: 0 20px;
border: none;
border: 1px solid transparent;
transition: background 0.2s, color 0.2s, border-color 0.2s;
transition:
background 0.2s,
color 0.2s,
border-color 0.2s;
cursor: pointer;
display: flex;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/app/api/edge-no-context/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('app API edge-no-context route', () => {
expect(response.status).toBe(200);
expect(log).toHaveBeenCalledTimes(1);
expect(log).toHaveBeenCalledWith(
'[Vercel Web Analytics] Track "Edge Event" with data {"data":"edge","router":"app","manual":true}'
'[Vercel Web Analytics] Track "Edge Event" with data {"data":"edge","router":"app","manual":true}',
);
});
});
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
Expand Up @@ -12,7 +12,7 @@ async function handler(request: Request) {
},
{
request,
}
},
);

return new Response('OK');
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/app/api/edge/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('app API edge route', () => {
expect(response.status).toBe(200);
expect(log).toHaveBeenCalledTimes(1);
expect(log).toHaveBeenCalledWith(
'[Vercel Web Analytics] Track "Edge Event" with data {"data":"edge","router":"app"}'
'[Vercel Web Analytics] Track "Edge Event" with data {"data":"edge","router":"app"}',
);
});
});
2 changes: 1 addition & 1 deletion apps/nextjs/app/api/serverless/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('app API serverless route', () => {
expect(response.status).toBe(200);
expect(log).toHaveBeenCalledTimes(1);
expect(log).toHaveBeenCalledWith(
'[Vercel Web Analytics] Track "Serverless Event" with data {"data":"serverless","router":"app"}'
'[Vercel Web Analytics] Track "Serverless Event" with data {"data":"serverless","router":"app"}',
);
});
});
2 changes: 1 addition & 1 deletion apps/nextjs/app/rsc/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cookies } from 'next/headers';
import { track } from '@vercel/analytics/server';
import { cookies } from 'next/headers';

export default async function RSC() {
cookies();
Expand Down
12 changes: 6 additions & 6 deletions apps/nextjs/e2e/development/beforeSend.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { useMockForProductionScript } from '../utils';

test.describe('beforeSend', () => {
Expand Down Expand Up @@ -35,15 +35,15 @@ test.describe('beforeSend', () => {

expect(
messages.find((m) =>
m.includes('[pageview] http://localhost:3000/before-send/first')
)
m.includes('[pageview] http://localhost:3000/before-send/first'),
),
).toBeDefined();
expect(
messages.find((m) =>
m.includes(
'[pageview] http://localhost:3000/before-send/second?secret=REDACTED'
)
)
'[pageview] http://localhost:3000/before-send/second?secret=REDACTED',
),
),
).toBeDefined();

expect(messages.find((m) => m.includes('secret=vercel'))).toBeUndefined();
Expand Down
10 changes: 5 additions & 5 deletions apps/nextjs/e2e/development/pageview.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { useMockForProductionScript } from '../utils';

test.describe('pageview', () => {
Expand Down Expand Up @@ -35,13 +35,13 @@ test.describe('pageview', () => {

expect(
messages.find((m) =>
m.includes('[pageview] http://localhost:3000/navigation/first')
)
m.includes('[pageview] http://localhost:3000/navigation/first'),
),
).toBeDefined();
expect(
messages.find((m) =>
m.includes('[pageview] http://localhost:3000/navigation/second')
)
m.includes('[pageview] http://localhost:3000/navigation/second'),
),
).toBeDefined();
});
});
4 changes: 2 additions & 2 deletions apps/nextjs/e2e/production/beforeSend.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { test, expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { useMockForProductionScript } from '../utils';

test.describe('beforeSend', () => {
test('should replace the value of the secret query parameter', async ({
page,
}) => {
const payloads: { page: string; payload: Object }[] = [];
const payloads: { page: string; payload: unknown }[] = [];

await useMockForProductionScript({
page,
Expand Down
8 changes: 4 additions & 4 deletions apps/nextjs/e2e/production/pageview.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { test, expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { useMockForProductionScript } from '../utils';

test.describe('pageview', () => {
test('should track page views when navigating between pages', async ({
page,
}) => {
const payloads: { page: string; payload: Object }[] = [];
const payloads: { page: string; payload: unknown }[] = [];

await useMockForProductionScript({
page,
Expand Down Expand Up @@ -52,7 +52,7 @@ test.describe('pageview', () => {
});

test('should properly send dynamic route', async ({ page }) => {
const payloads: { page: string; payload: Object }[] = [];
const payloads: { page: string; payload: unknown }[] = [];

await useMockForProductionScript({
page,
Expand Down Expand Up @@ -132,7 +132,7 @@ test.describe('pageview', () => {
test('should send pageviews when route doesnt change but path does', async ({
page,
}) => {
const payloads: { page: string; payload: Object }[] = [];
const payloads: { page: string; payload: unknown }[] = [];

await useMockForProductionScript({
page,
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/e2e/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Page } from '@playwright/test';
import type { Page } from '@playwright/test';

export async function useMockForProductionScript(props: {
page: Page;
onPageView: (page: string, payload: Object) => void;
onPageView: (page: string, payload: unknown) => void;
debug?: boolean;
}) {
await props.page.route('**/_vercel/insights/script.js', async (route, _) => {
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { NextResponse } from 'next/server';
import type { NextFetchEvent, NextRequest } from 'next/server';
import { track } from '@vercel/analytics/server';
import type { NextFetchEvent, NextRequest } from 'next/server';
import { NextResponse } from 'next/server';

export async function middleware(request: NextRequest, event: NextFetchEvent) {
event.waitUntil(
track('Redirect', {
path: request.nextUrl.pathname,
type: 'waitUntil',
})
}),
);
return NextResponse.redirect(new URL('/server-actions', request.url));
}
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/pages/api/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('pages API edge route', () => {
expect(response.status).toBe(200);
expect(log).toHaveBeenCalledTimes(1);
expect(log).toHaveBeenCalledWith(
'[Vercel Web Analytics] Track "Pages Api Route" with data {"runtime":"edge","router":"pages"}'
'[Vercel Web Analytics] Track "Pages Api Route" with data {"runtime":"edge","router":"pages"}',
);
});
});
4 changes: 2 additions & 2 deletions apps/nextjs/pages/api/test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { track } from '@vercel/analytics/server';
import { NextFetchEvent, NextRequest } from 'next/server';
import type { NextFetchEvent, NextRequest } from 'next/server';

export const config = {
runtime: 'edge',
};

async function handler(request: NextRequest, event: NextFetchEvent) {
async function handler(_request: NextRequest, _event: NextFetchEvent) {
track('Pages Api Route', {
runtime: 'edge',
router: 'pages',
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlaywrightTestConfig, devices } from '@playwright/test';
import path from 'path';
import path from 'node:path';
import { devices, type PlaywrightTestConfig } from '@playwright/test';

// Use process.env.PORT by default and fallback to port 3000
const PORT = process.env.PORT || 3000;
Expand Down
10 changes: 6 additions & 4 deletions apps/nuxt/app/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition: color 0.5s, background-color 0.5s;
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
font-family:
Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
Expand Down
2 changes: 1 addition & 1 deletion apps/nuxt/app/assets/main.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import './base.css';
@import "./base.css";

#app {
max-width: 1280px;
Expand Down
4 changes: 2 additions & 2 deletions apps/sveltekit/src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { dev } from '$app/environment';
import {
injectAnalytics,
type BeforeSendEvent,
injectAnalytics,
} from '@vercel/analytics/sveltekit';
import { dev } from '$app/environment';

injectAnalytics({
mode: dev ? 'development' : 'production',
Expand Down
4 changes: 2 additions & 2 deletions apps/sveltekit/src/routes/[slug]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { page } from '$app/stores';
import { track } from '@vercel/analytics/sveltekit';
import { track } from '@vercel/analytics/sveltekit';
import { page } from '$app/stores';
</script>

<h1>We don't talk about {$page.params.slug}</h1>
Expand Down
10 changes: 6 additions & 4 deletions apps/vue/src/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition: color 0.5s, background-color 0.5s;
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
font-family:
Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
Expand Down
2 changes: 1 addition & 1 deletion apps/vue/src/assets/main.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import './base.css';
@import "./base.css";

#app {
max-width: 1280px;
Expand Down
3 changes: 1 addition & 2 deletions apps/vue/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fileURLToPath, URL } from 'node:url';

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { defineConfig } from 'vite';

// https://vite.dev/config/
export default defineConfig({
Expand Down
Loading
Loading