Skip to content

Commit 4d88617

Browse files
authored
chore: Update Next integration strategy (#50)
* Use history_change instead of a manual pageview function call * Add docs for instrumentation-client and logic to select * Update next wizard for instrumentation-client file * Update readme with local testing guidance * Move testing content * Fix comment * Prettier * const (okay face) * 😑 * Add instrumentation-client test app * Update output message * Remove stray import * Allow absolute paths as --install-dir values * Update readme * Make it copyable * well that didn’t help
1 parent f52e73a commit 4d88617

File tree

21 files changed

+5759
-51
lines changed

21 files changed

+5759
-51
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,34 @@ This also allows us to pick up the bill on behalf of our customers.
7979

8080
When we make improvements to this process, these are available instantly to all users of the wizard, no training delays or other ambiguity.
8181

82+
## Testing locally
83+
84+
Run:
85+
86+
```bash
87+
pnpm try --install-dir=[a path]
88+
```
89+
90+
91+
To build and use the tool locally:
92+
93+
```
94+
pnpm build
95+
```
96+
This compiles the TypeScript code and prepares the `dist` directory. Run this command any time you make changes to the wizard's source code.
97+
98+
```bash
99+
pnpm link --global
100+
```
101+
This command makes your local version of the wizard available system-wide. You generally only need to do this once.
102+
103+
Then:
104+
105+
```bash
106+
wizard [options]
107+
```
108+
The wizard will execute your last build.
109+
82110
## Publishing your tool
83111

84112
To make your version of a tool usable with a one-line `npx` command:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { dirname } from "path";
2+
import { fileURLToPath } from "url";
3+
import { FlatCompat } from "@eslint/eslintrc";
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = dirname(__filename);
7+
8+
const compat = new FlatCompat({
9+
baseDirectory: __dirname,
10+
});
11+
12+
const eslintConfig = [
13+
...compat.extends("next/core-web-vitals", "next/typescript"),
14+
];
15+
16+
export default eslintConfig;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
6+
// Add PostHog rewrites
7+
async rewrites() {
8+
return [
9+
{
10+
source: "/ingest/static/:path*",
11+
destination: "https://us-assets.i.posthog.com/static/:path*",
12+
},
13+
{
14+
source: "/ingest/:path*",
15+
destination: "https://us.i.posthog.com/:path*",
16+
},
17+
{
18+
source: "/ingest/decide",
19+
destination: "https://us.i.posthog.com/decide",
20+
},
21+
];
22+
},
23+
24+
// Required to support PostHog trailing slash API requests
25+
skipTrailingSlashRedirect: true,
26+
};
27+
28+
export default nextConfig;

0 commit comments

Comments
 (0)