From d9cbe838d42679c5c855a692c9233827b4f1d4ab Mon Sep 17 00:00:00 2001 From: "wizard-ci-bot[bot]" <254716194+wizard-ci-bot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:05:01 +0000 Subject: [PATCH] wizard-ci: tanstack-router/tanstack-router-file-based-saas --- .../.posthog-wizard | 0 .../references/identify-users.md | 307 ++++++++++ .../references/tanstack-start.md | 221 +++++++ .../.env.example | 2 + .../package.json | 1 + .../pnpm-lock.yaml | 116 ++++ .../src/routeTree.gen.ts | 543 +++++++----------- .../src/routes/__root.tsx | 38 ++ .../routes/dashboard.invoices.$invoiceId.tsx | 9 +- .../src/routes/dashboard.invoices.index.tsx | 9 +- .../src/routes/login.tsx | 5 +- .../tsconfig.json | 1 + 12 files changed, 911 insertions(+), 341 deletions(-) create mode 100644 apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/.posthog-wizard create mode 100644 apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/references/identify-users.md create mode 100644 apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/references/tanstack-start.md create mode 100644 apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.env.example diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/.posthog-wizard b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/.posthog-wizard new file mode 100644 index 000000000..e69de29bb diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/references/identify-users.md b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/references/identify-users.md new file mode 100644 index 000000000..8647dcb37 --- /dev/null +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/references/identify-users.md @@ -0,0 +1,307 @@ +> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt + +# Identify users - Docs + +Copy page + +# Identify users - Docs + +Linking events to specific users enables you to build a full picture of how they're using your product across different sessions, devices, and platforms. + +This is straightforward to do when [capturing backend events](/docs/product-analytics/capture-events?tab=Node.js.md), as you associate events to a specific user using a `distinct_id`, which is a required argument. + +However, in the frontend of a [web](/docs/libraries/js/usage.md#capturing-events) or [mobile app](/docs/libraries/ios.md#capturing-events), a `distinct_id` is not a required argument — PostHog's SDKs will generate an anonymous `distinct_id` for you automatically and you can capture events anonymously, provided you use the appropriate [configuration](/docs/libraries/js/usage.md#capturing-anonymous-events). + +To link events to specific users, call `identify`: + +PostHog AI + +### Web + +```javascript +posthog.identify( + 'distinct_id', // Replace 'distinct_id' with your user's unique identifier + { email: 'max@hedgehogmail.com', name: 'Max Hedgehog' } // optional: set additional person properties +); +``` + +### Android + +```kotlin +PostHog.identify( + distinctId = distinctID, // Replace 'distinctID' with your user's unique identifier + // optional: set additional person properties + userProperties = mapOf( + "name" to "Max Hedgehog", + "email" to "max@hedgehogmail.com" + ) +) +``` + +### iOS + +```swift +PostHogSDK.shared.identify("distinct_id", // Replace "distinct_id" with your user's unique identifier + userProperties: ["name": "Max Hedgehog", "email": "max@hedgehogmail.com"]) // optional: set additional person properties +``` + +### React Native + +```jsx +posthog.identify('distinct_id', { // Replace "distinct_id" with your user's unique identifier + email: 'max@hedgehogmail.com', // optional: set additional person properties + name: 'Max Hedgehog' +}) +``` + +### Dart + +```dart +await Posthog().identify( + userId: 'distinct_id', // Replace "distinct_id" with your user's unique identifier + userProperties: { + 'email': 'max@hedgehogmail.com', // optional: set additional person properties + 'name': 'Max Hedgehog', + }, +); +``` + +Events captured after calling `identify` are identified events and this creates a person profile if one doesn't exist already. + +Due to the cost of processing them, anonymous events can be up to 4x cheaper than identified events, so it's recommended you only capture identified events when needed. + +## How identify works + +When a user starts browsing your website or app, PostHog automatically assigns them an **anonymous ID**, which is stored locally. + +Provided you've [configured persistence](/docs/libraries/js/persistence.md) to use cookies or `localStorage`, this enables us to track anonymous users – even across different sessions. + +By calling `identify` with a `distinct_id` of your choice (usually the user's ID in your database, or their email), you link the anonymous ID and distinct ID together. + +Thus, all past and future events made with that anonymous ID are now associated with the distinct ID. + +This enables you to do things like associate events with a user from before they log in for the first time, or associate their events across different devices or platforms. + +Using identify in the backend + +Although you can call `identify` using our backend SDKs, it is used most in frontends. This is because there is no concept of anonymous sessions in the backend SDKs, so calling `identify` only updates person profiles. + +## Best practices when using `identify` + +### 1\. Call `identify` as soon as you're able to + +In your frontend, you should call `identify` as soon as you're able to. + +Typically, this is every time your **app loads** for the first time, and directly after your **users log in**. + +This ensures that events sent during your users' sessions are correctly associated with them. + +You only need to call `identify` once per session, and you should avoid calling it multiple times unnecessarily. + +If you call `identify` multiple times with the same data without reloading the page in between, PostHog will ignore the subsequent calls. + +#### Identify users when the web SDK loads + +If your app already knows the signed-in user when you initialize the JavaScript web SDK, the [`loaded` callback](/docs/libraries/js/config.md) is a convenient place to call `identify`. This identifies the user as soon as the SDK has loaded: + +Web + +PostHog AI + +```javascript +posthog.init('', { + api_host: 'https://us.i.posthog.com', + defaults: '2026-05-30', + loaded: (posthog) => { + if (currentUser?.id) { + posthog.identify(currentUser.id, { + email: currentUser.email, + name: currentUser.name, + }) + } + }, +}) +``` + +In this example, `currentUser` represents user data already available from your authentication system. If your app loads the user asynchronously, call `posthog.identify()` as soon as that data becomes available instead. + +### 2\. Use unique strings for distinct IDs + +If two users have the same distinct ID, their data is merged and they are considered one user in PostHog. Two common ways this can happen are: + +- Your logic for generating IDs does not generate sufficiently strong IDs and you can end up with a clash where 2 users have the same ID. +- There's a bug, typo, or mistake in your code leading to most or all users being identified with generic IDs like `null`, `true`, or `distinctId`. + +PostHog also has built-in protections to stop the most common distinct ID mistakes. + +### 3\. Reset after logout + +If a user logs out on your frontend, you should call `reset()` to unlink any future events made on that device with that user. + +This is important if your users are sharing a computer, as otherwise all of those users are grouped together into a single user due to shared cookies between sessions. + +**We strongly recommend you call `reset` on logout even if you don't expect users to share a computer.** + +You can do that like so: + +PostHog AI + +### Web + +```javascript +posthog.reset() +``` + +### iOS + +```swift +PostHogSDK.shared.reset() +``` + +### Android + +```kotlin +PostHog.reset() +``` + +### React Native + +```jsx +posthog.reset() +``` + +### Dart + +```dart +await Posthog().reset(); +``` + +If you *also* want to reset the `device_id` so that the device will be considered a new device in future events, you can pass `true` as an argument: + +Web + +PostHog AI + +```javascript +posthog.reset(true) +``` + +### 4\. Person profiles and properties + +You'll notice that one of the parameters in the `identify` method is a `properties` object. + +This enables you to set [person properties](/docs/product-analytics/person-properties.md). + +Whenever possible, we recommend passing in all person properties you have available each time you call identify, as this ensures their person profile on PostHog is up to date. + +Person properties can also be set being adding a `$set` property to a event `capture` call. + +**\`$set\` and \`$set\_once\` aren't stored on events** + +These properties only tell PostHog how to update person data during ingestion — they aren't kept on the stored event, so you can't filter, break down, or query events by them. To query the values you set, use [person properties](/docs/product-analytics/person-properties.md) instead. + +See our [person properties docs](/docs/product-analytics/person-properties.md) for more details on how to work with them and best practices. + +### 5\. Use deep links between platforms + +We recommend you call `identify` [as soon as you're able](#1-call-identify-as-soon-as-youre-able), typically when a user signs up or logs in. + +This doesn't work if one or both platforms are unauthenticated. Some examples of such cases are: + +- Onboarding and signup flows before authentication. +- Unauthenticated web pages redirecting to authenticated mobile apps. +- Authenticated web apps prompting an app download. + +In these cases, you can use a [deep link](https://developer.android.com/training/app-links/deep-linking) on Android and [universal links](https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app) on iOS to identify users. + +1. Use `posthog.get_distinct_id()` to get the current distinct ID. Even if you cannot call identify because the user is unauthenticated, this will return an anonymous distinct ID generated by PostHog. +2. Add the distinct ID to the deep link as query parameters, along with other properties like UTM parameters. +3. When the user is redirected to the app, parse the deep link and handle the following cases: + +- The mobile app is already authenticated. In this case, call [`posthog.alias()`](/docs/libraries/js/usage.md#alias) with the distinct ID from the web. This associates the two distinct IDs as a single person. +- The mobile app is unauthenticated. In this case, call [`posthog.identify()`](/docs/libraries/js/usage.md#identifying-users) with the distinct ID from the web so pre-login mobile events stay connected to the web session. When the user later logs in on mobile, call `identify()` again with your canonical user ID. + +As long as you associate the distinct IDs with `posthog.identify()` or `posthog.alias()`, you can track events generated across platforms. + +Here's an example implementation for handling deep links from web to mobile: + +PostHog AI + +### iOS + +```swift +import PostHog +class DeepLinkIdentityManager { + static let shared = DeepLinkIdentityManager() + // MARK: - Deep Link Received + func handleDeepLink(_ url: URL, isAuthenticatedOnMobile: Bool) { + guard let webDistinctId = URLComponents(url: url, resolvingAgainstBaseURL: true)? + .queryItems?.first(where: { $0.name == "ph_distinct_id" })?.value else { + return + } + if isAuthenticatedOnMobile { + // The mobile app already knows the current user. + // Alias the incoming web distinct ID to that user. + PostHogSDK.shared.alias(webDistinctId) + } else { + // Reuse the web distinct ID until login on mobile. + PostHogSDK.shared.identify(webDistinctId) + } + } + // MARK: - Login/Signup + func handleLogin(canonicalUserId: String) { + // Switch from the web distinct ID (or a mobile anon ID) + // to your canonical user ID. + PostHogSDK.shared.identify(canonicalUserId) + // Set user properties, track signup event, etc. + } + func handleLogout() { + PostHogSDK.shared.reset() + } +} +``` + +### Android + +```kotlin +import android.net.Uri +import com.posthog.PostHog +object DeepLinkIdentityManager { + // Deep Link Received + fun handleDeepLink(uri: Uri, isAuthenticatedOnMobile: Boolean) { + val webDistinctId = uri.getQueryParameter("ph_distinct_id") ?: return + if (isAuthenticatedOnMobile) { + // The mobile app already knows the current user. + // Alias the incoming web distinct ID to that user. + PostHog.alias(webDistinctId) + } else { + // Reuse the web distinct ID until login on mobile. + PostHog.identify(webDistinctId) + } + } + // Login/Signup + fun handleLogin(canonicalUserId: String) { + // Switch from the web distinct ID (or a mobile anon ID) + // to your canonical user ID. + PostHog.identify(canonicalUserId) + // Set user properties, track signup event, etc. + } + fun handleLogout() { + PostHog.reset() + } +} +``` + +## Further reading + +- [Identifying users docs](/docs/product-analytics/identify.md) +- [How person processing works](/docs/how-posthog-works/ingestion-pipeline.md#2-person-processing) +- [An introductory guide to identifying users in PostHog](/tutorials/identifying-users-guide.md) + +### Still have questions? + +Ask PostHog AI + +### Was this page useful? + +HelpfulCould be better \ No newline at end of file diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/references/tanstack-start.md b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/references/tanstack-start.md new file mode 100644 index 000000000..42329b3bb --- /dev/null +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.claude/skills/integration-react-tanstack-router-code-based/references/tanstack-start.md @@ -0,0 +1,221 @@ +> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt + +# TanStack Start - Docs + +Copy page + +# TanStack Start - Docs + +This tutorial shows how to integrate PostHog with a [TanStack Start](https://tanstack.com/start) app for both client-side and server-side analytics. + +## Installation + +Install the required packages: + +Terminal + +PostHog AI + +```bash +npm install @posthog/react posthog-node +``` + +- `@posthog/react` - React package for our [JS Web SDK](/docs/libraries/js.md) for client-side usage +- `posthog-node` - PostHog [Node.js SDK](/docs/libraries/node.md) for server-side event capture + +## Identifying users + +> **Identifying users is required.** Call `posthog.identify('your-user-id')` after login to link events to a known user. This is what connects frontend event captures, [session replays](/docs/session-replay.md), [LLM traces](/docs/ai-engineering.md), and [error tracking](/docs/error-tracking.md) to the same person — and lets backend events link back too. +> +> Use a stable ID from your auth system when possible, not an email or display name. Send those as person properties instead. If your app has no other stable key, email works as a fallback if they are unique. Never a shared literal like `"anonymous"` or `"user"`, which pools many people onto one person and corrupts their data. When no ID is available at all, skip the identify and retain the anonymous distinct ID that's automatically assigned. +> +> Call `posthog.reset()` on logout, so the next person to use the browser doesn't inherit the last one's identity. +> +> See our guide on [identifying users](/docs/getting-started/identify-users.md) for how to set this up. + +If your app calls your own backend, `tracing_headers` adds `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` to matching `fetch` and `XMLHttpRequest` requests. This lets server-side SDKs link backend events, errors, and LLM traces back to frontend sessions and replays. Use hostnames only, without protocols or paths. + +JavaScript + +PostHog AI + +```javascript +posthog.init('', { + api_host: 'https://us.i.posthog.com', + // Optional: send PostHog session/user context to your backend + tracing_headers: ['api.example.com'], +}) +``` + +This works in local development too, but match on the hostname alone: use `'localhost'`, not `'localhost:3000'`. Ports are never part of a hostname, so a value with one in it never matches anything. `localhost` and `127.0.0.1` are also different hostnames — use whichever your app actually calls. + +Tracing headers help you attribute events across front and backend consistently. When this isn't available, use your server-side stable IDs to deduce the matching `distinctId`, and pass it in when capturing the event. + +## Initialize PostHog on the client + +Wrap your app with `PostHogProvider` in your root route with your project token, host, and other options. + +PostHog AI + +``` +import CspAllowancesCallout from "../_snippets/csp-allowances-callout.mdx" +tsx file=src/routes/__root.tsx +// src/routes/__root.tsx +import { HeadContent, Scripts, createRootRoute } from '@tanstack/react-router' +import { PostHogProvider } from '@posthog/react' +export const Route = createRootRoute({ + head: () => ({ + meta: [ + { charSet: 'utf-8' }, + { name: 'viewport', content: 'width=device-width, initial-scale=1' }, + ], + }), + shellComponent: RootDocument, +}) +function RootDocument({ children }: { children: React.ReactNode }) { + return ( + + + + + + + {children} + + + + + ) +} +``` + +Once the provider is in place, PostHog automatically captures pageviews, sessions, and web vitals. + +## Capture events on the client + +Use the `usePostHog` hook from `@posthog/react` in any component to capture custom events: + +src/routes/checkout.tsx + +PostHog AI + +```jsx +import { usePostHog } from '@posthog/react' +function CheckoutButton({ orderId, total }: { orderId: string; total: number }) { + const posthog = usePostHog() + const handleClick = () => { + posthog.capture('checkout_started', { + order_id: orderId, + total: total, + }) + } + return +} +``` + +### Identify users + +Call `posthog.identify()` when a user logs in to link their events to a user ID: + +TSX + +PostHog AI + +```jsx +import { usePostHog } from '@posthog/react' +function LoginForm() { + const posthog = usePostHog() + const handleLogin = async (userId: string, email: string) => { + // ... your login logic + posthog.identify(userId, { + email: email, + }) + posthog.capture('user_logged_in') + } +} +``` + +Call `posthog.reset()` on logout to clear the identified user. + +## Initialize PostHog on the server + +Create a server-side PostHog client using `posthog-node`. Use a singleton pattern so you reuse the same client across requests: + +src/utils/posthog-server.ts + +PostHog AI + +```typescript +// src/utils/posthog-server.ts +import { PostHog } from 'posthog-node' +let posthogClient: PostHog | null = null +export function getPostHogClient() { + if (!posthogClient) { + posthogClient = new PostHog( + '', + { + host: 'https://us.i.posthog.com', + flushAt: 1, + flushInterval: 0, + }, + ) + } + return posthogClient +} +``` + +## Capture events on the server + +Use the server client in TanStack Start API routes to capture events server-side. Server-side capture is useful for tracking events that shouldn't be spoofable from the client, like purchases or authentication: + +src/routes/api/checkout.ts + +PostHog AI + +```typescript +// src/routes/api/checkout.ts +import { createFileRoute } from '@tanstack/react-router' +import { json } from '@tanstack/react-start' +import { getPostHogClient } from '../../utils/posthog-server' +export const Route = createFileRoute('/api/checkout')({ + server: { + handlers: { + POST: async ({ request }) => { + const body = await request.json() + const posthog = getPostHogClient() + posthog.capture({ + distinctId: body.userId, + event: 'item_purchased', + properties: { + item_id: body.itemId, + price: body.price, + source: 'api', + }, + }) + return json({ success: true }) + }, + }, + }, +}) +``` + +The server-side `capture` call requires a `distinctId` (the user identifier), an `event` name, and optional `properties`. + +## Next steps + +Installing the JS Web SDK and Node SDK means all of their functionality is available in your TanStack Start project. To learn more about this, have a look at our [JS Web SDK docs](/docs/libraries/js/usage.md) and [Node SDK docs](/docs/libraries/node.md). + +### Still have questions? + +Ask PostHog AI + +### Was this page useful? + +HelpfulCould be better \ No newline at end of file diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.env.example b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.env.example new file mode 100644 index 000000000..b2c042ddf --- /dev/null +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/.env.example @@ -0,0 +1,2 @@ +VITE_PUBLIC_POSTHOG_PROJECT_TOKEN= +VITE_PUBLIC_POSTHOG_HOST= diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/package.json b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/package.json index 6c3727079..d6803c762 100644 --- a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/package.json +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/package.json @@ -14,6 +14,7 @@ "@tanstack/react-router-devtools": "^1.158.1", "@tanstack/router-plugin": "^1.158.1", "immer": "^10.1.1", + "posthog-js": "^1.424.0", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/pnpm-lock.yaml b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/pnpm-lock.yaml index 493a95765..c4d3608e1 100644 --- a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/pnpm-lock.yaml +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: immer: specifier: ^10.1.1 version: 10.2.0 + posthog-js: + specifier: ^1.424.0 + version: 1.424.0(@types/react@19.2.13)(react@19.2.4) react: specifier: ^19.0.0 version: 19.2.4 @@ -324,6 +327,15 @@ packages: '@jridgewell/trace-mapping@0.3.31': resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + '@posthog/browser-common@0.7.1': + resolution: {integrity: sha512-JO/5dIVx3NTrbg0W2VciDDmmizsvwaYYHE5cnJE1Gra+UqBnEuVGH9DTE/kBFgVMp+08z5uj/aAprsYD2WG/QQ==} + + '@posthog/core@1.50.1': + resolution: {integrity: sha512-REG9hSmWdQhPvXJfZuH0cwvveq5lS3wAluNSav7mqiaZszALRL4+4qS5FFO2gpgvV5D7OIhkJFB4ZKFbzqbviA==} + + '@posthog/types@1.407.1': + resolution: {integrity: sha512-WhbkXPC2rgylXqmxHqv70ffI3k+KxyR6s7DBIfr5NvIqHkxp6v0pk31D/jbz0DNVbzwkLjyll2pxr4FNbJiYzg==} + '@rolldown/pluginutils@1.0.0-beta.27': resolution: {integrity: sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==} @@ -361,66 +373,79 @@ packages: resolution: {integrity: sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.57.1': resolution: {integrity: sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.57.1': resolution: {integrity: sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.57.1': resolution: {integrity: sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-loong64-gnu@4.57.1': resolution: {integrity: sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==} cpu: [loong64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-loong64-musl@4.57.1': resolution: {integrity: sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==} cpu: [loong64] os: [linux] + libc: [musl] '@rollup/rollup-linux-ppc64-gnu@4.57.1': resolution: {integrity: sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-ppc64-musl@4.57.1': resolution: {integrity: sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==} cpu: [ppc64] os: [linux] + libc: [musl] '@rollup/rollup-linux-riscv64-gnu@4.57.1': resolution: {integrity: sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-musl@4.57.1': resolution: {integrity: sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==} cpu: [riscv64] os: [linux] + libc: [musl] '@rollup/rollup-linux-s390x-gnu@4.57.1': resolution: {integrity: sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.57.1': resolution: {integrity: sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-musl@4.57.1': resolution: {integrity: sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-openbsd-x64@4.57.1': resolution: {integrity: sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==} @@ -490,24 +515,28 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@tailwindcss/oxide-linux-arm64-musl@4.1.18': resolution: {integrity: sha512-1px92582HkPQlaaCkdRcio71p8bc8i/ap5807tPRDK/uw953cauQBT8c5tVGkOwrHMfc2Yh6UuxaH4vtTjGvHg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@tailwindcss/oxide-linux-x64-gnu@4.1.18': resolution: {integrity: sha512-v3gyT0ivkfBLoZGF9LyHmts0Isc8jHZyVcbzio6Wpzifg/+5ZJpDiRiUhDLkcr7f/r38SWNe7ucxmGW3j3Kb/g==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@tailwindcss/oxide-linux-x64-musl@4.1.18': resolution: {integrity: sha512-bhJ2y2OQNlcRwwgOAGMY0xTFStt4/wyU6pvI6LSuZpRgKQwxTec0/3Scu91O8ir7qCR3AuepQKLU/kX99FouqQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@tailwindcss/oxide-wasm32-wasi@4.1.18': resolution: {integrity: sha512-LffYTvPjODiP6PT16oNeUQJzNVyJl1cjIebq/rWWBF+3eDst5JGEFSc5cWxyRCJ0Mxl+KyIkqRxk1XPEs9x8TA==} @@ -644,6 +673,9 @@ packages: '@types/react@19.2.13': resolution: {integrity: sha512-KkiJeU6VbYbUOp5ITMIc7kBfqlYkKA5KhEHVrGMmUUMt7NeaZg65ojdPk+FtNrBAOXNVM5QM72jnADjM+XVRAQ==} + '@types/trusted-types@2.0.7': + resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} + '@vitejs/plugin-react@4.7.0': resolution: {integrity: sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==} engines: {node: ^14.18.0 || >=16.0.0} @@ -704,6 +736,9 @@ packages: cookie-es@2.0.0: resolution: {integrity: sha512-RAj4E421UYRgqokKUmotqAwuplYw15qtdXfY+hGzgCJ/MBjCVZcSoHK/kH9kocfjRjcDME7IiDWR/1WX1TM2Pg==} + core-js@3.50.0: + resolution: {integrity: sha512-BRWgOLKkFeCgRudR6zrs8p9XJZcE14grzKMMssoYrk6krtuEZ7MTKPIY5RzOnqsEKIR9kst7wNzphttraT+Yqw==} + csstype@3.2.3: resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} @@ -724,6 +759,9 @@ packages: resolution: {integrity: sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ==} engines: {node: '>=0.3.1'} + dompurify@3.4.14: + resolution: {integrity: sha512-dVoH9z+MY+C9IilgGCk3YfFqjLi3fChm2OiKJMzh6axrJ5qwxqWaZamgmHrpv22CN/KdbZJuGEGgfQoL00LTdg==} + electron-to-chromium@1.5.286: resolution: {integrity: sha512-9tfDXhJ4RKFNerfjdCcZfufu49vg620741MNs26a9+bhLThdB+plgMeou98CAaHu/WATj2iHOOHTp1hWtABj2A==} @@ -754,6 +792,9 @@ packages: picomatch: optional: true + fflate@0.4.9: + resolution: {integrity: sha512-zdxgIEddhfsyCaWpJ2SdXEP8ZMrKJ6+5jl4OupODcywU0IhRk6gdXuVGcPICyfx2H97hVK7xmJtRLPjkxAX8Vw==} + fill-range@7.1.1: resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} @@ -857,24 +898,28 @@ packages: engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] + libc: [glibc] lightningcss-linux-arm64-musl@1.30.2: resolution: {integrity: sha512-5Vh9dGeblpTxWHpOx8iauV02popZDsCYMPIgiuw97OJ5uaDsL86cnqSFs5LZkG3ghHoX5isLgWzMs+eD1YzrnA==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] + libc: [musl] lightningcss-linux-x64-gnu@1.30.2: resolution: {integrity: sha512-Cfd46gdmj1vQ+lR6VRTTadNHu6ALuw2pKR9lYq4FnhvgBc4zWY1EtZcAc6EffShbb1MFrIPfLDXD6Xprbnni4w==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] + libc: [glibc] lightningcss-linux-x64-musl@1.30.2: resolution: {integrity: sha512-XJaLUUFXb6/QG2lGIW6aIk6jKdtjtcffUT0NKvIqhSBY3hh9Ch+1LCeH80dR9q9LBjG3ewbDjnumefsLsP6aiA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] + libc: [musl] lightningcss-win32-arm64-msvc@1.30.2: resolution: {integrity: sha512-FZn+vaj7zLv//D/192WFFVA0RgHawIcHqLX9xuWiQt7P0PtdFEVaxgF9rjM/IRYHQXNnk61/H/gb2Ei+kUQ4xQ==} @@ -931,11 +976,33 @@ packages: resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==} engines: {node: ^10 || ^12 || >=14} + posthog-js@1.424.0: + resolution: {integrity: sha512-owEiZm26dJe7THtRvgMuKRJ0RS7GhZieL42PVcDN8IWzHdDL2VMEIX6bcIN8+HmK9Jleih7cyhPjw8o3GxRC3w==} + peerDependencies: + '@types/react': '>=16.8.0' + react: '>=16.8.0' + peerDependenciesMeta: + '@types/react': + optional: true + react: + optional: true + + preact@10.29.8: + resolution: {integrity: sha512-ej2aVZ+vZ8WO7tvlQWRM9N63A0KzF9q4mWJfDUHgYaIofWY9hu74QdnQrjoPMmZi2/nZ5gN0bJCQF49xQqx09Q==} + peerDependencies: + preact-render-to-string: '>=5' + peerDependenciesMeta: + preact-render-to-string: + optional: true + prettier@3.8.1: resolution: {integrity: sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==} engines: {node: '>=14'} hasBin: true + query-selector-shadow-dom@1.0.1: + resolution: {integrity: sha512-lT5yCqEBgfoMYpf3F2xQRK7zEr1rhIIZuceDK6+xRkJQ4NMbHTwXqk4NkwDwQMNqXgG9r9fyHnzwNVs6zV5KRw==} + react-dom@19.2.4: resolution: {integrity: sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==} peerDependencies: @@ -1086,6 +1153,9 @@ packages: yaml: optional: true + web-vitals@6.2.1: + resolution: {integrity: sha512-rLcLXA2sx6+9dE88NHFubwTtGxpK4yYBLj6qHPdFoCaLr0cXGb4efOqtKLlm4loGA4OEKHIQKMKzZkKyOh5ctw==} + webpack-virtual-modules@0.6.2: resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==} @@ -1316,6 +1386,17 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 + '@posthog/browser-common@0.7.1': + dependencies: + '@posthog/core': 1.50.1 + '@posthog/types': 1.407.1 + + '@posthog/core@1.50.1': + dependencies: + '@posthog/types': 1.407.1 + + '@posthog/types@1.407.1': {} + '@rolldown/pluginutils@1.0.0-beta.27': {} '@rollup/rollup-android-arm-eabi@4.57.1': @@ -1594,6 +1675,9 @@ snapshots: dependencies: csstype: 3.2.3 + '@types/trusted-types@2.0.7': + optional: true + '@vitejs/plugin-react@4.7.0(vite@7.3.1(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0))': dependencies: '@babel/core': 7.29.0 @@ -1664,6 +1748,8 @@ snapshots: cookie-es@2.0.0: {} + core-js@3.50.0: {} + csstype@3.2.3: {} debug@4.4.3: @@ -1674,6 +1760,10 @@ snapshots: diff@8.0.3: {} + dompurify@3.4.14: + optionalDependencies: + '@types/trusted-types': 2.0.7 + electron-to-chromium@1.5.286: {} enhanced-resolve@5.19.0: @@ -1718,6 +1808,8 @@ snapshots: optionalDependencies: picomatch: 4.0.3 + fflate@0.4.9: {} + fill-range@7.1.1: dependencies: to-regex-range: 5.0.1 @@ -1844,8 +1936,30 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 + posthog-js@1.424.0(@types/react@19.2.13)(react@19.2.4): + dependencies: + '@posthog/browser-common': 0.7.1 + '@posthog/core': 1.50.1 + '@posthog/types': 1.407.1 + core-js: 3.50.0 + dompurify: 3.4.14 + fflate: 0.4.9 + preact: 10.29.8 + query-selector-shadow-dom: 1.0.1 + web-vitals: 6.2.1 + web-vitals-soft-navs: web-vitals@6.2.1 + optionalDependencies: + '@types/react': 19.2.13 + react: 19.2.4 + transitivePeerDependencies: + - preact-render-to-string + + preact@10.29.8: {} + prettier@3.8.1: {} + query-selector-shadow-dom@1.0.1: {} + react-dom@19.2.4(react@19.2.4): dependencies: react: 19.2.4 @@ -1977,6 +2091,8 @@ snapshots: lightningcss: 1.30.2 tsx: 4.21.0 + web-vitals@6.2.1: {} + webpack-virtual-modules@0.6.2: {} yallist@3.1.1: {} diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routeTree.gen.ts b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routeTree.gen.ts index f3accfa48..1e29ba579 100644 --- a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routeTree.gen.ts +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routeTree.gen.ts @@ -8,9 +8,7 @@ // You should NOT make any changes in this file as it will be overwritten. // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. -// Import Routes - -import { Route as rootRoute } from './routes/__root' +import { Route as rootRouteImport } from './routes/__root' import { Route as LoginRouteImport } from './routes/login' import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' import { Route as AuthRouteImport } from './routes/_auth' @@ -29,103 +27,85 @@ import { Route as DashboardInvoicesIndexRouteImport } from './routes/dashboard.i import { Route as DashboardUsersUserRouteImport } from './routes/dashboard.users.user' import { Route as DashboardInvoicesInvoiceIdRouteImport } from './routes/dashboard.invoices.$invoiceId' -// Create/Update Routes - const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', - getParentRoute: () => rootRoute, + getParentRoute: () => rootRouteImport, } as any) - const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ id: '/_pathlessLayout', - getParentRoute: () => rootRoute, + getParentRoute: () => rootRouteImport, } as any) - const AuthRoute = AuthRouteImport.update({ id: '/_auth', - getParentRoute: () => rootRoute, + getParentRoute: () => rootRouteImport, } as any) - const DashboardRouteRoute = DashboardRouteRouteImport.update({ id: '/dashboard', path: '/dashboard', - getParentRoute: () => rootRoute, + getParentRoute: () => rootRouteImport, } as any) - const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', - getParentRoute: () => rootRoute, + getParentRoute: () => rootRouteImport, } as any) - const ExpensiveIndexRoute = ExpensiveIndexRouteImport.update({ id: '/expensive/', path: '/expensive/', - getParentRoute: () => rootRoute, + getParentRoute: () => rootRouteImport, } as any) - const DashboardIndexRoute = DashboardIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardRouteRoute, } as any) - const PathlessLayoutRouteBRoute = PathlessLayoutRouteBRouteImport.update({ id: '/route-b', path: '/route-b', getParentRoute: () => PathlessLayoutRoute, } as any) - const PathlessLayoutRouteARoute = PathlessLayoutRouteARouteImport.update({ id: '/route-a', path: '/route-a', getParentRoute: () => PathlessLayoutRoute, } as any) - const AuthProfileRoute = AuthProfileRouteImport.update({ id: '/profile', path: '/profile', getParentRoute: () => AuthRoute, } as any) - const thisFolderIsNotInTheUrlRouteGroupRoute = thisFolderIsNotInTheUrlRouteGroupRouteImport.update({ id: '/(this-folder-is-not-in-the-url)/route-group', path: '/route-group', - getParentRoute: () => rootRoute, + getParentRoute: () => rootRouteImport, } as any) - const DashboardUsersRouteRoute = DashboardUsersRouteRouteImport.update({ id: '/users', path: '/users', getParentRoute: () => DashboardRouteRoute, } as any) - const DashboardInvoicesRouteRoute = DashboardInvoicesRouteRouteImport.update({ id: '/invoices', path: '/invoices', getParentRoute: () => DashboardRouteRoute, } as any) - const DashboardUsersIndexRoute = DashboardUsersIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardUsersRouteRoute, } as any) - const DashboardInvoicesIndexRoute = DashboardInvoicesIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => DashboardInvoicesRouteRoute, } as any) - const DashboardUsersUserRoute = DashboardUsersUserRouteImport.update({ id: '/user', path: '/user', getParentRoute: () => DashboardUsersRouteRoute, } as any) - const DashboardInvoicesInvoiceIdRoute = DashboardInvoicesInvoiceIdRouteImport.update({ id: '/$invoiceId', @@ -133,207 +113,9 @@ const DashboardInvoicesInvoiceIdRoute = getParentRoute: () => DashboardInvoicesRouteRoute, } as any) -// Populate the FileRoutesByPath interface - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRoute - } - '/dashboard': { - id: '/dashboard' - path: '/dashboard' - fullPath: '/dashboard' - preLoaderRoute: typeof DashboardRouteRouteImport - parentRoute: typeof rootRoute - } - '/_auth': { - id: '/_auth' - path: '' - fullPath: '' - preLoaderRoute: typeof AuthRouteImport - parentRoute: typeof rootRoute - } - '/_pathlessLayout': { - id: '/_pathlessLayout' - path: '' - fullPath: '' - preLoaderRoute: typeof PathlessLayoutRouteImport - parentRoute: typeof rootRoute - } - '/login': { - id: '/login' - path: '/login' - fullPath: '/login' - preLoaderRoute: typeof LoginRouteImport - parentRoute: typeof rootRoute - } - '/dashboard/invoices': { - id: '/dashboard/invoices' - path: '/invoices' - fullPath: '/dashboard/invoices' - preLoaderRoute: typeof DashboardInvoicesRouteRouteImport - parentRoute: typeof DashboardRouteRouteImport - } - '/dashboard/users': { - id: '/dashboard/users' - path: '/users' - fullPath: '/dashboard/users' - preLoaderRoute: typeof DashboardUsersRouteRouteImport - parentRoute: typeof DashboardRouteRouteImport - } - '/(this-folder-is-not-in-the-url)/route-group': { - id: '/(this-folder-is-not-in-the-url)/route-group' - path: '/route-group' - fullPath: '/route-group' - preLoaderRoute: typeof thisFolderIsNotInTheUrlRouteGroupRouteImport - parentRoute: typeof rootRoute - } - '/_auth/profile': { - id: '/_auth/profile' - path: '/profile' - fullPath: '/profile' - preLoaderRoute: typeof AuthProfileRouteImport - parentRoute: typeof AuthRouteImport - } - '/_pathlessLayout/route-a': { - id: '/_pathlessLayout/route-a' - path: '/route-a' - fullPath: '/route-a' - preLoaderRoute: typeof PathlessLayoutRouteARouteImport - parentRoute: typeof PathlessLayoutRouteImport - } - '/_pathlessLayout/route-b': { - id: '/_pathlessLayout/route-b' - path: '/route-b' - fullPath: '/route-b' - preLoaderRoute: typeof PathlessLayoutRouteBRouteImport - parentRoute: typeof PathlessLayoutRouteImport - } - '/dashboard/': { - id: '/dashboard/' - path: '/' - fullPath: '/dashboard/' - preLoaderRoute: typeof DashboardIndexRouteImport - parentRoute: typeof DashboardRouteRouteImport - } - '/expensive/': { - id: '/expensive/' - path: '/expensive' - fullPath: '/expensive' - preLoaderRoute: typeof ExpensiveIndexRouteImport - parentRoute: typeof rootRoute - } - '/dashboard/invoices/$invoiceId': { - id: '/dashboard/invoices/$invoiceId' - path: '/$invoiceId' - fullPath: '/dashboard/invoices/$invoiceId' - preLoaderRoute: typeof DashboardInvoicesInvoiceIdRouteImport - parentRoute: typeof DashboardInvoicesRouteRouteImport - } - '/dashboard/users/user': { - id: '/dashboard/users/user' - path: '/user' - fullPath: '/dashboard/users/user' - preLoaderRoute: typeof DashboardUsersUserRouteImport - parentRoute: typeof DashboardUsersRouteRouteImport - } - '/dashboard/invoices/': { - id: '/dashboard/invoices/' - path: '/' - fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof DashboardInvoicesIndexRouteImport - parentRoute: typeof DashboardInvoicesRouteRouteImport - } - '/dashboard/users/': { - id: '/dashboard/users/' - path: '/' - fullPath: '/dashboard/users/' - preLoaderRoute: typeof DashboardUsersIndexRouteImport - parentRoute: typeof DashboardUsersRouteRouteImport - } - } -} - -// Create and export the route tree - -interface DashboardInvoicesRouteRouteChildren { - DashboardInvoicesInvoiceIdRoute: typeof DashboardInvoicesInvoiceIdRoute - DashboardInvoicesIndexRoute: typeof DashboardInvoicesIndexRoute -} - -const DashboardInvoicesRouteRouteChildren: DashboardInvoicesRouteRouteChildren = - { - DashboardInvoicesInvoiceIdRoute: DashboardInvoicesInvoiceIdRoute, - DashboardInvoicesIndexRoute: DashboardInvoicesIndexRoute, - } - -const DashboardInvoicesRouteRouteWithChildren = - DashboardInvoicesRouteRoute._addFileChildren( - DashboardInvoicesRouteRouteChildren, - ) - -interface DashboardUsersRouteRouteChildren { - DashboardUsersUserRoute: typeof DashboardUsersUserRoute - DashboardUsersIndexRoute: typeof DashboardUsersIndexRoute -} - -const DashboardUsersRouteRouteChildren: DashboardUsersRouteRouteChildren = { - DashboardUsersUserRoute: DashboardUsersUserRoute, - DashboardUsersIndexRoute: DashboardUsersIndexRoute, -} - -const DashboardUsersRouteRouteWithChildren = - DashboardUsersRouteRoute._addFileChildren(DashboardUsersRouteRouteChildren) - -interface DashboardRouteRouteChildren { - DashboardInvoicesRouteRoute: typeof DashboardInvoicesRouteRouteWithChildren - DashboardUsersRouteRoute: typeof DashboardUsersRouteRouteWithChildren - DashboardIndexRoute: typeof DashboardIndexRoute -} - -const DashboardRouteRouteChildren: DashboardRouteRouteChildren = { - DashboardInvoicesRouteRoute: DashboardInvoicesRouteRouteWithChildren, - DashboardUsersRouteRoute: DashboardUsersRouteRouteWithChildren, - DashboardIndexRoute: DashboardIndexRoute, -} - -const DashboardRouteRouteWithChildren = DashboardRouteRoute._addFileChildren( - DashboardRouteRouteChildren, -) - -interface AuthRouteChildren { - AuthProfileRoute: typeof AuthProfileRoute -} - -const AuthRouteChildren: AuthRouteChildren = { - AuthProfileRoute: AuthProfileRoute, -} - -const AuthRouteWithChildren = AuthRoute._addFileChildren(AuthRouteChildren) - -interface PathlessLayoutRouteChildren { - PathlessLayoutRouteARoute: typeof PathlessLayoutRouteARoute - PathlessLayoutRouteBRoute: typeof PathlessLayoutRouteBRoute -} - -const PathlessLayoutRouteChildren: PathlessLayoutRouteChildren = { - PathlessLayoutRouteARoute: PathlessLayoutRouteARoute, - PathlessLayoutRouteBRoute: PathlessLayoutRouteBRoute, -} - -const PathlessLayoutRouteWithChildren = PathlessLayoutRoute._addFileChildren( - PathlessLayoutRouteChildren, -) - export interface FileRoutesByFullPath { '/': typeof IndexRoute '/dashboard': typeof DashboardRouteRouteWithChildren - '': typeof PathlessLayoutRouteWithChildren '/login': typeof LoginRoute '/dashboard/invoices': typeof DashboardInvoicesRouteRouteWithChildren '/dashboard/users': typeof DashboardUsersRouteRouteWithChildren @@ -342,16 +124,14 @@ export interface FileRoutesByFullPath { '/route-a': typeof PathlessLayoutRouteARoute '/route-b': typeof PathlessLayoutRouteBRoute '/dashboard/': typeof DashboardIndexRoute - '/expensive': typeof ExpensiveIndexRoute + '/expensive/': typeof ExpensiveIndexRoute '/dashboard/invoices/$invoiceId': typeof DashboardInvoicesInvoiceIdRoute '/dashboard/users/user': typeof DashboardUsersUserRoute '/dashboard/invoices/': typeof DashboardInvoicesIndexRoute '/dashboard/users/': typeof DashboardUsersIndexRoute } - export interface FileRoutesByTo { '/': typeof IndexRoute - '': typeof PathlessLayoutRouteWithChildren '/login': typeof LoginRoute '/route-group': typeof thisFolderIsNotInTheUrlRouteGroupRoute '/profile': typeof AuthProfileRoute @@ -364,9 +144,8 @@ export interface FileRoutesByTo { '/dashboard/invoices': typeof DashboardInvoicesIndexRoute '/dashboard/users': typeof DashboardUsersIndexRoute } - export interface FileRoutesById { - __root__: typeof rootRoute + __root__: typeof rootRouteImport '/': typeof IndexRoute '/dashboard': typeof DashboardRouteRouteWithChildren '/_auth': typeof AuthRouteWithChildren @@ -385,13 +164,11 @@ export interface FileRoutesById { '/dashboard/invoices/': typeof DashboardInvoicesIndexRoute '/dashboard/users/': typeof DashboardUsersIndexRoute } - export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath fullPaths: | '/' | '/dashboard' - | '' | '/login' | '/dashboard/invoices' | '/dashboard/users' @@ -400,7 +177,7 @@ export interface FileRouteTypes { | '/route-a' | '/route-b' | '/dashboard/' - | '/expensive' + | '/expensive/' | '/dashboard/invoices/$invoiceId' | '/dashboard/users/user' | '/dashboard/invoices/' @@ -408,7 +185,6 @@ export interface FileRouteTypes { fileRoutesByTo: FileRoutesByTo to: | '/' - | '' | '/login' | '/route-group' | '/profile' @@ -441,7 +217,6 @@ export interface FileRouteTypes { | '/dashboard/users/' fileRoutesById: FileRoutesById } - export interface RootRouteChildren { IndexRoute: typeof IndexRoute DashboardRouteRoute: typeof DashboardRouteRouteWithChildren @@ -452,6 +227,199 @@ export interface RootRouteChildren { ExpensiveIndexRoute: typeof ExpensiveIndexRoute } +declare module '@tanstack/react-router' { + interface FileRoutesByPath { + '/login': { + id: '/login' + path: '/login' + fullPath: '/login' + preLoaderRoute: typeof LoginRouteImport + parentRoute: typeof rootRouteImport + } + '/_pathlessLayout': { + id: '/_pathlessLayout' + path: '' + fullPath: '/' + preLoaderRoute: typeof PathlessLayoutRouteImport + parentRoute: typeof rootRouteImport + } + '/_auth': { + id: '/_auth' + path: '' + fullPath: '/' + preLoaderRoute: typeof AuthRouteImport + parentRoute: typeof rootRouteImport + } + '/dashboard': { + id: '/dashboard' + path: '/dashboard' + fullPath: '/dashboard' + preLoaderRoute: typeof DashboardRouteRouteImport + parentRoute: typeof rootRouteImport + } + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRouteImport + } + '/expensive/': { + id: '/expensive/' + path: '/expensive' + fullPath: '/expensive/' + preLoaderRoute: typeof ExpensiveIndexRouteImport + parentRoute: typeof rootRouteImport + } + '/dashboard/': { + id: '/dashboard/' + path: '/' + fullPath: '/dashboard/' + preLoaderRoute: typeof DashboardIndexRouteImport + parentRoute: typeof DashboardRouteRoute + } + '/_pathlessLayout/route-b': { + id: '/_pathlessLayout/route-b' + path: '/route-b' + fullPath: '/route-b' + preLoaderRoute: typeof PathlessLayoutRouteBRouteImport + parentRoute: typeof PathlessLayoutRoute + } + '/_pathlessLayout/route-a': { + id: '/_pathlessLayout/route-a' + path: '/route-a' + fullPath: '/route-a' + preLoaderRoute: typeof PathlessLayoutRouteARouteImport + parentRoute: typeof PathlessLayoutRoute + } + '/_auth/profile': { + id: '/_auth/profile' + path: '/profile' + fullPath: '/profile' + preLoaderRoute: typeof AuthProfileRouteImport + parentRoute: typeof AuthRoute + } + '/(this-folder-is-not-in-the-url)/route-group': { + id: '/(this-folder-is-not-in-the-url)/route-group' + path: '/route-group' + fullPath: '/route-group' + preLoaderRoute: typeof thisFolderIsNotInTheUrlRouteGroupRouteImport + parentRoute: typeof rootRouteImport + } + '/dashboard/users': { + id: '/dashboard/users' + path: '/users' + fullPath: '/dashboard/users' + preLoaderRoute: typeof DashboardUsersRouteRouteImport + parentRoute: typeof DashboardRouteRoute + } + '/dashboard/invoices': { + id: '/dashboard/invoices' + path: '/invoices' + fullPath: '/dashboard/invoices' + preLoaderRoute: typeof DashboardInvoicesRouteRouteImport + parentRoute: typeof DashboardRouteRoute + } + '/dashboard/users/': { + id: '/dashboard/users/' + path: '/' + fullPath: '/dashboard/users/' + preLoaderRoute: typeof DashboardUsersIndexRouteImport + parentRoute: typeof DashboardUsersRouteRoute + } + '/dashboard/invoices/': { + id: '/dashboard/invoices/' + path: '/' + fullPath: '/dashboard/invoices/' + preLoaderRoute: typeof DashboardInvoicesIndexRouteImport + parentRoute: typeof DashboardInvoicesRouteRoute + } + '/dashboard/users/user': { + id: '/dashboard/users/user' + path: '/user' + fullPath: '/dashboard/users/user' + preLoaderRoute: typeof DashboardUsersUserRouteImport + parentRoute: typeof DashboardUsersRouteRoute + } + '/dashboard/invoices/$invoiceId': { + id: '/dashboard/invoices/$invoiceId' + path: '/$invoiceId' + fullPath: '/dashboard/invoices/$invoiceId' + preLoaderRoute: typeof DashboardInvoicesInvoiceIdRouteImport + parentRoute: typeof DashboardInvoicesRouteRoute + } + } +} + +interface DashboardInvoicesRouteRouteChildren { + DashboardInvoicesInvoiceIdRoute: typeof DashboardInvoicesInvoiceIdRoute + DashboardInvoicesIndexRoute: typeof DashboardInvoicesIndexRoute +} + +const DashboardInvoicesRouteRouteChildren: DashboardInvoicesRouteRouteChildren = + { + DashboardInvoicesInvoiceIdRoute: DashboardInvoicesInvoiceIdRoute, + DashboardInvoicesIndexRoute: DashboardInvoicesIndexRoute, + } + +const DashboardInvoicesRouteRouteWithChildren = + DashboardInvoicesRouteRoute._addFileChildren( + DashboardInvoicesRouteRouteChildren, + ) + +interface DashboardUsersRouteRouteChildren { + DashboardUsersUserRoute: typeof DashboardUsersUserRoute + DashboardUsersIndexRoute: typeof DashboardUsersIndexRoute +} + +const DashboardUsersRouteRouteChildren: DashboardUsersRouteRouteChildren = { + DashboardUsersUserRoute: DashboardUsersUserRoute, + DashboardUsersIndexRoute: DashboardUsersIndexRoute, +} + +const DashboardUsersRouteRouteWithChildren = + DashboardUsersRouteRoute._addFileChildren(DashboardUsersRouteRouteChildren) + +interface DashboardRouteRouteChildren { + DashboardInvoicesRouteRoute: typeof DashboardInvoicesRouteRouteWithChildren + DashboardUsersRouteRoute: typeof DashboardUsersRouteRouteWithChildren + DashboardIndexRoute: typeof DashboardIndexRoute +} + +const DashboardRouteRouteChildren: DashboardRouteRouteChildren = { + DashboardInvoicesRouteRoute: DashboardInvoicesRouteRouteWithChildren, + DashboardUsersRouteRoute: DashboardUsersRouteRouteWithChildren, + DashboardIndexRoute: DashboardIndexRoute, +} + +const DashboardRouteRouteWithChildren = DashboardRouteRoute._addFileChildren( + DashboardRouteRouteChildren, +) + +interface AuthRouteChildren { + AuthProfileRoute: typeof AuthProfileRoute +} + +const AuthRouteChildren: AuthRouteChildren = { + AuthProfileRoute: AuthProfileRoute, +} + +const AuthRouteWithChildren = AuthRoute._addFileChildren(AuthRouteChildren) + +interface PathlessLayoutRouteChildren { + PathlessLayoutRouteARoute: typeof PathlessLayoutRouteARoute + PathlessLayoutRouteBRoute: typeof PathlessLayoutRouteBRoute +} + +const PathlessLayoutRouteChildren: PathlessLayoutRouteChildren = { + PathlessLayoutRouteARoute: PathlessLayoutRouteARoute, + PathlessLayoutRouteBRoute: PathlessLayoutRouteBRoute, +} + +const PathlessLayoutRouteWithChildren = PathlessLayoutRoute._addFileChildren( + PathlessLayoutRouteChildren, +) + const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, DashboardRouteRoute: DashboardRouteRouteWithChildren, @@ -462,107 +430,6 @@ const rootRouteChildren: RootRouteChildren = { thisFolderIsNotInTheUrlRouteGroupRoute, ExpensiveIndexRoute: ExpensiveIndexRoute, } - -export const routeTree = rootRoute +export const routeTree = rootRouteImport ._addFileChildren(rootRouteChildren) ._addFileTypes() - -/* ROUTE_MANIFEST_START -{ - "routes": { - "__root__": { - "filePath": "__root.tsx", - "children": [ - "/", - "/dashboard", - "/_auth", - "/_pathlessLayout", - "/login", - "/(this-folder-is-not-in-the-url)/route-group", - "/expensive/" - ] - }, - "/": { - "filePath": "index.tsx" - }, - "/dashboard": { - "filePath": "dashboard.route.tsx", - "children": [ - "/dashboard/invoices", - "/dashboard/users", - "/dashboard/" - ] - }, - "/_auth": { - "filePath": "_auth.tsx", - "children": [ - "/_auth/profile" - ] - }, - "/_pathlessLayout": { - "filePath": "_pathlessLayout.tsx", - "children": [ - "/_pathlessLayout/route-a", - "/_pathlessLayout/route-b" - ] - }, - "/login": { - "filePath": "login.tsx" - }, - "/dashboard/invoices": { - "filePath": "dashboard.invoices.route.tsx", - "parent": "/dashboard", - "children": [ - "/dashboard/invoices/$invoiceId", - "/dashboard/invoices/" - ] - }, - "/dashboard/users": { - "filePath": "dashboard.users.route.tsx", - "parent": "/dashboard", - "children": [ - "/dashboard/users/user", - "/dashboard/users/" - ] - }, - "/(this-folder-is-not-in-the-url)/route-group": { - "filePath": "(this-folder-is-not-in-the-url)/route-group.tsx" - }, - "/_auth/profile": { - "filePath": "_auth.profile.tsx", - "parent": "/_auth" - }, - "/_pathlessLayout/route-a": { - "filePath": "_pathlessLayout.route-a.tsx", - "parent": "/_pathlessLayout" - }, - "/_pathlessLayout/route-b": { - "filePath": "_pathlessLayout.route-b.tsx", - "parent": "/_pathlessLayout" - }, - "/dashboard/": { - "filePath": "dashboard.index.tsx", - "parent": "/dashboard" - }, - "/expensive/": { - "filePath": "expensive/index.tsx" - }, - "/dashboard/invoices/$invoiceId": { - "filePath": "dashboard.invoices.$invoiceId.tsx", - "parent": "/dashboard/invoices" - }, - "/dashboard/users/user": { - "filePath": "dashboard.users.user.tsx", - "parent": "/dashboard/users" - }, - "/dashboard/invoices/": { - "filePath": "dashboard.invoices.index.tsx", - "parent": "/dashboard/invoices" - }, - "/dashboard/users/": { - "filePath": "dashboard.users.index.tsx", - "parent": "/dashboard/users" - } - } -} -ROUTE_MANIFEST_END */ diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/__root.tsx b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/__root.tsx index 1e184d1ec..6bad777ec 100644 --- a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/__root.tsx +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/__root.tsx @@ -6,6 +6,7 @@ import { useRouterState, } from '@tanstack/react-router' import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' +import { PostHogProvider } from 'posthog-js/react' import { Spinner } from '../components/Spinner' import { Breadcrumbs } from '../components/Breadcrumbs' import type { Auth } from '../utils/auth' @@ -22,6 +23,43 @@ export const Route = createRootRouteWithContext<{ }) function RootComponent() { + const apiKey = import.meta.env.VITE_PUBLIC_POSTHOG_PROJECT_TOKEN + const apiHost = import.meta.env.VITE_PUBLIC_POSTHOG_HOST + + if (!apiKey || !apiHost) { + if (import.meta.env.DEV) { + const missingVariable = !apiKey + ? 'VITE_PUBLIC_POSTHOG_PROJECT_TOKEN' + : 'VITE_PUBLIC_POSTHOG_HOST' + + throw new Error( + `${missingVariable} variable required by PostHog is missing or un-configured, this causes events to be silently missed. This error stops appearing once ${missingVariable} is configured`, + ) + } + + return + } + + return ( + + + + ) +} + +function RootLayout() { return ( <>
diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/dashboard.invoices.$invoiceId.tsx b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/dashboard.invoices.$invoiceId.tsx index cdc961db2..2c7f19bb9 100644 --- a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/dashboard.invoices.$invoiceId.tsx +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/dashboard.invoices.$invoiceId.tsx @@ -1,4 +1,5 @@ import { createFileRoute, Link, useNavigate, useRouter } from '@tanstack/react-router' +import { usePostHog } from 'posthog-js/react' import * as React from 'react' import { z } from 'zod' import { InvoiceFields } from '../components/InvoiceFields' @@ -28,9 +29,15 @@ function InvoiceComponent() { const navigate = useNavigate({ from: Route.fullPath }) const invoice = Route.useLoaderData() const router = useRouter() + const posthog = usePostHog() const updateInvoiceMutation = useMutation({ fn: patchInvoice, - onSuccess: () => router.invalidate(), + onSuccess: () => { + posthog.capture('invoice_updated', { + invoice_id: invoice.id, + }) + router.invalidate() + }, }) const [notes, setNotes] = React.useState(search.notes ?? '') diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/dashboard.invoices.index.tsx b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/dashboard.invoices.index.tsx index d2170fbb2..7293a8b7a 100644 --- a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/dashboard.invoices.index.tsx +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/dashboard.invoices.index.tsx @@ -1,4 +1,5 @@ import { createFileRoute, useRouter } from '@tanstack/react-router' +import { usePostHog } from 'posthog-js/react' import { InvoiceFields } from '../components/InvoiceFields' import { Spinner } from '../components/Spinner' import { useMutation } from '../hooks/useMutation' @@ -11,10 +12,16 @@ export const Route = createFileRoute('/dashboard/invoices/')({ function InvoicesIndexComponent() { const router = useRouter() + const posthog = usePostHog() const createInvoiceMutation = useMutation({ fn: postInvoice, - onSuccess: () => router.invalidate(), + onSuccess: ({ data: invoice }) => { + posthog.capture('invoice_created', { + invoice_id: invoice.id, + }) + router.invalidate() + }, }) return ( diff --git a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/login.tsx b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/login.tsx index 456a84c10..bc0b5c186 100644 --- a/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/login.tsx +++ b/apps/basic-integration/tanstack-router/tanstack-router-file-based-saas/src/routes/login.tsx @@ -1,4 +1,5 @@ import { createFileRoute, useRouter } from '@tanstack/react-router' +import { usePostHog } from 'posthog-js/react' import * as React from 'react' import { z } from 'zod' @@ -6,12 +7,12 @@ export const Route = createFileRoute('/login')({ validateSearch: z.object({ redirect: z.string().optional(), }), -}).update({ component: LoginComponent, }) function LoginComponent() { const router = useRouter() + const posthog = usePostHog() const { auth, status } = Route.useRouteContext({ select: ({ auth }) => ({ auth, status: auth.status }), }) @@ -21,6 +22,7 @@ function LoginComponent() { const onSubmit = (e: React.FormEvent) => { e.preventDefault() auth.login(username) + posthog.capture('user_logged_in') router.invalidate() } @@ -56,6 +58,7 @@ function LoginComponent() {

{auth.username}