Giter Site home page Giter Site logo

4lejandrito / next-plausible Goto Github PK

View Code? Open in Web Editor NEW
553.0 8.0 29.0 1.82 MB

Simple integration for https://nextjs.org and https://plausible.io analytics

Home Page: https://next-plausible.vercel.app

License: MIT License

TypeScript 82.84% JavaScript 17.06% Shell 0.10%
nextjs plausible plausible-analytics

next-plausible's Introduction

Next-Plausible · npm version

Simple integration for https://nextjs.org and https://plausible.io analytics.

See it in action at https://next-plausible.vercel.app, and this commit for a real world example.

Important: If you're using a version of next lower than 11.1.0 please use next-plausible@2 to avoid type checking errors (see #25).

Usage

Include the Analytics Script

To enable Plausible analytics in your Next.js app you'll need to expose the Plausible context, <PlausibleProvider />, at the top level of your application inside _app.js:

// pages/_app.js
import PlausibleProvider from 'next-plausible'

export default function MyApp({ Component, pageProps }) {
  return (
    <PlausibleProvider domain="example.com">
      <Component {...pageProps} />
    </PlausibleProvider>
  )
}

If you want to enable Plausible analytics only on a single page you can wrap the page in a PlausibleProvider component:

// pages/home.js
import PlausibleProvider from 'next-plausible'

export default Home() {
  return (
    <PlausibleProvider domain="example.com">
      <h1>My Site</h1>
      {/* ... */}
    </PlausibleProvider>
  )
}

If are using the app directory include PlausibleProvider inside the root layout:

// app/layout.js
import PlausibleProvider from 'next-plausible'

export default function RootLayout({ children }) {
  return (
    <html>
      <head>
        <PlausibleProvider domain="example.com" />
      </head>
      <body>{children}</body>
    </html>
  )
}

PlausibleProvider Props

Name Description
domain The domain of the site you want to monitor.
customDomain Set this if you use a custom domain to serve the analytics script. Defaults to https://plausible.io. See https://plausible.io/docs/custom-domain for more details.
trackOutboundLinks Set this to true if you want to enable outbound link click tracking.
trackFileDownloads Set this to true if you want to enable file download tracking.
taggedEvents Set this to true if you want to enable custom event tracking in HTML elements.
trackLocalhost Set this to true if you want to enable localhost tracking.
manualPageviews Set this to true if you want to disable automatic pageview events.
pageviewProps Set the custom properties for pageviews. The event- prefix will be added automatically. See an example.
revenue Set this to true if you want to enable ecommerce revenue tracking.
hash Set this to true if you want to use hash-based routing.
exclude Set this if you want to exclude a set of pages from being tracked. See https://plausible.io/docs/excluding-pages for more details.
selfHosted Set this to true if you are self hosting your Plausible instance. Otherwise you will get a 404 when requesting the script.
enabled Use this to explicitly decide whether or not to render script. If not passed the script will be rendered in production environments (checking NODE_ENV and VERCEL_ENV).
integrity Optionally define the subresource integrity attribute for extra security.
scriptProps Optionally override any of the props passed to the script element. See example.

Proxy the Analytics Script

To avoid being blocked by adblockers plausible recommends proxying the script. To do this you need to wrap your next.config.js with the withPlausibleProxy function:

const { withPlausibleProxy } = require('next-plausible')

module.exports = withPlausibleProxy()({
  // ...your next js config, if any
  // Important! it is mandatory to pass a config object, even if empty
})

This will set up the necessary rewrites as described here and configure PlausibleProvider to use the local URLs so you can keep using it like this:

  <PlausibleProvider domain="example.com">
    ...
  </PlausibleProvider>
}

Optionally you can overwrite the proxied script subdirectory and name, as well as the custom domain for the original script:

const { withPlausibleProxy } = require('next-plausible')

module.exports = withPlausibleProxy({
  subdirectory: 'yoursubdirectory',
  scriptName: 'scriptName',
  customDomain: 'http://example.com',
})({
  // ...your next js config, if any
  // Important! it is mandatory to pass a config object, even if empty
})

This will load the script from /yoursubdirectory/js/scriptName.js and fetch it from http://example.com/js/script.js.

Notes:

  • Proxying will only work if you serve your site using next start. Statically generated sites won't be able to rewrite the requests.

  • If you are self hosting plausible, you need to set customDomain to your instance otherwise no data will be sent.

  • Bear in mind that tracking requests will be made to the same domain, so cookies will be forwarded. See #67. If this is an issue for you, from [email protected] you can use middleware to strip the cookies like this:

    import { NextResponse } from 'next/server'
    
    export function middleware(request) {
      const requestHeaders = new Headers(request.headers)
      requestHeaders.set('cookie', '')
      return NextResponse.next({
        request: {
          headers: requestHeaders,
        },
      })
    }
    
    export const config = {
      matcher: '/proxy/api/event',
    }

Send Custom Events

Plausible supports custom events as described at https://plausible.io/docs/custom-event-goals. This package provides the usePlausible hook to safely access the plausible function like this:

import { usePlausible } from 'next-plausible'

export default function PlausibleButton() {
  const plausible = usePlausible()

  return (
    <>
      <button onClick={() => plausible('customEventName')}>Send</button>

      <button
        id="foo"
        onClick={() =>
          plausible('customEventName', {
            props: {
              buttonId: 'foo',
            },
          })
        }
      >
        Send with props
      </button>
    </>
  )
}

If you use Typescript you can type check your custom events like this:

import { usePlausible } from 'next-plausible'

type MyEvents = {
  event1: { prop1: string }
  event2: { prop2: string }
  event3: never
}

const plausible = usePlausible<MyEvents>()

Only those events with the right props will be allowed to be sent using the plausible function.

Developing

  • npm run build will generate the production scripts under the dist folder.

next-plausible's People

Contributors

4lejandrito avatar alexanderbluhm avatar altaywtf avatar boredland avatar christoribeiro avatar cstrnt avatar dominikwilkowski avatar fredrik-lindseth avatar garritfra avatar igassmann avatar jamessingleton avatar lucasra1 avatar macklinhrw avatar michaelwschultz avatar not-matthias avatar paolotiu avatar rrozanka avatar sgithuku avatar steven-tey avatar thepaulmcbride avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

next-plausible's Issues

Multiple tag

IDK why but on each of my websites the tag is appearing multiple time in the Head

_app file

			<PlausibleProvider customDomain="https://stats.dzeio.com" domain="www.tcgdex.net">
                                 ....
			</PlausibleProvider>

Support for `next@canary`

I just wanted to open a bug report for Next.js, and their issue asks if the bug is reproducible in their canary release. Unfortunately, Only Next.js 11 and 12 are listed as a peer dependency of this package, so using canary leads to a "conflicting peer dependency" error.

AFAIK there are ways to "ignore" this error, but maybe it's a good idea allow future releases of next as well. What do you think?

scriptname is index.js instead of plausible.js for selfHosted

When using a self-host version of plausible the remote script name should still be plausible.js instead of index.js.

For example:

{
    source: '/js/plausible.js',
    destination: 'https://plausible.paolotiu.com/js/index.js'
}

I'm not sure if this is intended.

Thank you!

No requests made to self hosted instance

Thank you for this cool Next.js adaptation 👍

I tried to configure it globally on my _app.tsx file:

<PlausibleProvider
      domain="typebot.io"
      selfHosted={true}
      customDomain="https://my-selfhosted-plausible-domain.com"
    >
      <Component {...componentProps} />
    </PlausibleProvider>

And then my next.config.js:

const { withSentryConfig } = require("@sentry/nextjs");
const { withPlausibleProxy } = require("next-plausible");

const withBundleAnalyzer = require("@next/bundle-analyzer")({
  enabled: process.env.ANALYZE === "true",
});

const moduleExports = {};

const SentryWebpackPluginOptions = {};

module.exports = withPlausibleProxy()(
  withBundleAnalyzer(
    withSentryConfig(moduleExports, SentryWebpackPluginOptions)
  )
);

But it doesn't fire anything in prod, no error, no request, nothing. Am I missing something? How can I debug this?

Next.js version: 11.1.0
Package version: 3.0.0

Configurable variable used to check for production

I see the script is only loaded in production and determined by process.env.NODE_ENV. I believe when hosting on Vercel and using their preview deployments, NODE_ENV is production but they provide system variables such as VERCEL_ENV which can be used to determine production vs preview environments.

Maybe a prop can be provided to customise this?

Proxy rewrite for API POST request doesn't work on Netlify

Thanks for this helpful library!

This is not a bug in next-plausible, but just noting for anyone coming across this issue in the future that currently if you're using the withPlausibleProxy function to wrap your Next.js config and proxy the Plausible script and API calls, the latter will fail with a 405: Method Not Allowed error when using Netlify. This is because Netlify intercepts POST requests as part of its form handling feature.

To fix this it's necessary to manually specify the event rewrite rules in your netlify.toml file. For the sake of consistency I have included configuration for the script.js rewrite as well:

[[redirects]]
  from = "/js/script.js"
  to = "https://plausible.io/js/plausible.js"
  status = 200
  force = true

[[redirects]]
  from = "/proxy/api/event"
  to = "https://plausible.io/api/event"
  status = 202
  force = true

Without this I believe the POST request will be intercepted by Netlify before it reaches the configuration in next.config.js (and that which is provided transparently by the withPlausibleProxy wrapper). Therefore I think on Netlify it's preferable to use the above config and skip the withPlausibleProxy config wrapper.

Hope this helps anyone else encountering this same issue.

Types are incompatible with Next@11

Using [email protected], [email protected] and [email protected], the following happens during build:

./node_modules/next-plausible/dist/index.d.ts:2:28
Type error: Cannot find module 'next/dist/next-server/server/config-shared' or its corresponding type declarations.

  1 | import React, { ReactNode } from 'react';
> 2 | import { NextConfig } from 'next/dist/next-server/server/config-shared';
    |                            ^
  3 | declare type NextPlausibleProxyOptions = {
  4 |     subdirectory?: string;
  5 |     scriptName?: string;

This is caused by these changes to Next.js: vercel/next.js#26756

With next@11, the above import can simply be replaced with import { NextConfig } from 'next'. AFAIK that would only be compatible with Next@11, so the peer dependency would have to be narrowed to ^11.0.0.

can't see the script event in localhost with a customDomain

Hello,
I'm trying to integrate plausible into a site, however I don't see the file event (script) in localhost. Here is my config:
In _app.js:

      <PlausibleProvider
        domain='vitrine.jokosun.xyz'
        selfHosted={true}
        enabled={true}
        trackLocalhost={true}
        customDomain='https://plausible.xxxxxx.xyz'
      >

In next.config.js:

const { withPlausibleProxy } = require('next-plausible')

module.exports = withPlausibleProxy({
  customDomain: 'https://plausible.xxxxxxxx.xyz',
})({
  experimental: {
    outputStandalone: true,
  },
})

I also tried with enabled true/false and trackLocalhost true/false.

Is tracking localhost real-time?

I have the trackLocalhost prop turned on. I'm testing if I correctly integrated next-plausible, but I'm not 100% sure I did.

Do we know if tracking for localhost is in real-time or not?

Confirming docs and env var usage

Hey there,

Loving Plausible and currently setting this up in our next site.
Our site is hosted on two different providers and both have the process.env.NODE_ENV enabled.
To make sure we track only the live site and not the staging site we introduced another env var called NEXT_PUBLIC_LIVE_SITE.

I did test this but want to make sure I'm not missing anything especially when it comes to SSR.
To include the next-plausible script I added this to our pages/_document.js file.

import Document, { Html, Head, Main, NextScript } from 'next/document';
import PlausibleProvider from 'next-plausible';

export default class MyDocument extends Document {
	render() {
		return (
			<PlausibleProvider domain="domain.tld" enabled={!!process.env.NEXT_PUBLIC_LIVE_SITE}>
				<Html>
					<Head />
					<body>
						<Main />
						<NextScript />
					</body>
				</Html>
			</PlausibleProvider>
		);
	}
}

If this is all correct feel free to close this and maybe add something to the effect of "This is how you add the tracking globally to all your next pages" into the docs?

Can't load Plausible script when using Next `basePath` config

When the Next config option basePath is set we can not load the Plausible script.
Consider the following configuration in next.config.js:

module.exports = (phase, { defaultConfig }) => {
  return withPlausibleProxy()({
      basePath: '/test'
  });
};

The script will be loaded from /js/script.local.js instead of /test/js/script.local.js.

If we set the subdirectory option to test, next-plausible will try to load the script from /test/js/script.local.js but the script will be available at /test/test/js/script.local.js

module.exports = (phase, { defaultConfig }) => {
  return withPlausibleProxy({
      subdirectory: 'test'
  })({
      basePath: '/test'
  });
};

Usage with multiple domains for the same application

Hi, I have an application which is accessible with two domains: domain1.com, domain2.com. (The response is totally identical, just different domains).

How should I set the domain field? Should I use the location.hostname?

Proxy doesn't work with Next `basePath` configuration option

Creating another issue since I can't reopen #62.

The proxy still doesn't work when using the basePath option.
Reproducible using the following config:

module.exports = (phase, { defaultConfig }) => {
  return withPlausibleProxy()({
      basePath: '/test'
  });
};

Using this config, next-plausible will try to call the proxy at /test/proxy/api/event but the rewrites include the basePath by default, so when Next is passed /test/proxy/api/event as the source, it'll make the rewrite source /test/test/proxy/api/event.
This can be fixed by setting basePath to false on the rewrite object for the proxy.

const plausibleRewrites: Rewrite[] = [
  {
    source: getScriptPath(options),
    destination: getRemoteScript(),
  },
  ...getCombinations(allModifiers).map((modifiers) => ({
    source: getScriptPath(options, ...modifiers),
    destination: getRemoteScript(...modifiers),
  })),
  {
    source: getApiEndpoint(nextPlausiblePublicProxyOptions),
    basePath: false,
    destination: `${domain}/api/event`,
  },
]

withPlausibleProxy wrapper not forwarding country

Hi @4lejandrito and thank you for your excellent work !

I tested the 2 methods described in the docs.

1° This config is working properly, I get all the data in my plausible dashboard.

_app.tsx

<PlausibleProvider
      domain="my-next.app"
      customDomain="https://my-plausible-self-hosted.app"
      selfHosted
    >
      {...rest_of_my_app}
</PlausibleProvider>

2° This method is working partially, I'm missing the countries data in my plausible dashboard.

_app.tsx

<PlausibleProvider
      domain="my-next.app"
      customDomain="https://my-plausible-self-hosted.app"
      selfHosted
    >
      {...rest_of_my_app}
</PlausibleProvider>

next.config.js

const { withPlausibleProxy } = require('next-plausible')

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
}

module.exports = withPlausibleProxy({
  customDomain: "https://my-plausible-self-hosted.app"
})(nextConfig)

I think this is caused by the second option not properly passing the header x-forwarded-for.

By the way, is the second config correct ?

Thank you.

The root value has an unexpected property

- The root value has an unexpected property, 0, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOpt

I get this when I build.

Redirects in _middleware.ts not tracked

I basically have some routes set up in my _middleware.ts that will redirect to a different url on my website / sometimes just send people external e.g. my.url/discord will directly redirect you to discord. It looks like these "pageviews" are currently not tracked. Just wanted to check if I configured something wrong / if there is a way to do this? Maybe custom events?

basically using:
return NextResponse.redirect('new route / url")
in _middleware.ts

thanks!

Double Pageviews

I've just set this up on a website and I'm seeing double pageviews. I've set it up in _app.js as recommended (exactly the same code, except for the domain).

Even in local, when I run with npm start I see 2 "event ignored" logs in the console. Is this the expected behaviour or is there something wrong with my setup?

Ability to track localhost traffic

Being able to track localhost traffic for testing is super helpful but I'm not seeing it as an option here.

Plausible has a way to do it using an extension plausible.local.js. Anyway this could be added as a provider prop?

withPlausibleProxy with next.js 13 app directory

I can't get withPlausibleProxy working with the new app directory of next.js 13.

Is this not supported yet or am I doing something wrong?

My current workaround is setting the customDomain prop in the PlausibleProvider and defining rewrites in next.config.js.

Wrap usePlausible in useCallback

usePlausible returns a new function every time, which makes it unsuitable to use in the dependency array of other react hooks.

For now, I'm working around it with a custom wrapper, but it's not ideal:

import { usePlausible as useNextPlausible } from 'next-plausible'
import { useCallback } from 'react'

export function usePlausible() {
  const plausible = useNextPlausible()

  // disabling deps rule because the upstream implementation never changes
  // but it isn't set up with useCallback, so every time it's a new function

  // eslint-disable-next-line react-hooks/exhaustive-deps
  return useCallback(plausible, [])
}

Support file downloads tracking

Discussed in #55

Originally posted by TobiasMelen August 30, 2022
Hi,

We're trying to use withPlausibleProxy but using script.file-downloads.js instead of scripts.js to track file-downloads as described here. I've tried changing scriptName options as well as setting a custom script src in the components script props, but neither of those solutions worked.

Should this be possible within the "automatic" config or will it require manual setup?

Self-hosting script with plausible-tracker?

Hey @4lejandrito, first of all thanks for maintaining!

I have a question how to self host the script, because of SRI. I came across this here:

In another post I saw that the script is now posted to npm:
plausible/analytics#1834

Is there a way that I can combine these two and just link to the script from the npm package with the scriptProps like

    <PlausibleProvider
      domain="example.com"
      scriptProps={{
        src: '/custom/js/script.js',
      }}
    />

Thanks in advance.

Proxying causes the "event" request to redirect when trailingSlash: true

I'm setting up Plausible on my NextJS site (using Vercel).

Using the default settings in next.config.js to set up the proxy:

const { withPlausibleProxy } = require('next-plausible')

module.exports = withPlausibleProxy()({
  // ...your next js config, if any
})

When visiting a page on my site, the page request to /api/event gets 308 redirected from /api/event to /api/event/ because I have "trailingSlash: true" in my next.config.js.

See screenshot:

Screenshot_49

utm support missing

Utm tracking does not work for us currently. Is it not supported yet, or did we something wrong?

withPlausibleProxy causes next/image requests to CDNs like Sanity.io 400

I was using withPlausibleProxy when all of a sudden in production my images disappeared.

Steps to Reproduce

  1. Add withPlausibleProxy to your next.config.js file
  2. Have next/image components where the source is not internal aka /public
  3. Run yarn build && yarn start
  4. Go to localhost:3000 and observe images not loading
  5. Open network tab in your browser console and notice requests are 400'ing for images that are not in /public

Vercel script/js 404

Hi, I have troubles to get next-plausible to work with Vercel. When I deploy to Vercel and go to my site there will be no visitors showing up in Plausible. If I look in the console I got an net::ERR_ABORTED 404 error on /js/script.js. When I test it locally with trackLocalhost it works fine. Does anybody know what I'm doing wrong?

_app.js

import '../styles/globals.css'
import PlausibleProvider from 'next-plausible'

function MyApp({ Component, pageProps }) {
  return (
    <PlausibleProvider domain='test.com' selfHosted={true} enabled={true}>
      <Component {...pageProps} />
    </PlausibleProvider>
  )
}

export default MyApp

next.config.js

/** @type {import('next').NextConfig} */

const { withPlausibleProxy } = require('next-plausible')

module.exports = withPlausibleProxy({
  customDomain: 'https://www.test-custom-domain.com/',
})({
  reactStrictMode: true,
  swcMinify: true,
})

Disable console logs

I am getting a bunch of WARNING Ignoring Event: localhost that end up showing up in my build due to my setup. Coud PlausibleProvider have some kind of prop to disable logging?

Events Tracked Immediately with `useEffect` Fail to Send

I'm was to track 404 page URLs using Plausible's suggested approach. I modified this for Next.js as follows:

function Custom404() {
  const analytics = useAnalytics();
  useEffect(() => {
    analytics('Page Not Found', {
      props: { page: document.location.pathname },
    });
  }, [analytics]);
 // ...

However, this fails to send the event when the page is loaded directly (if the user arrives at the 404 page via client side routing, it works fine). My theory is that Plausible isn't ready yet, so the event is ignored.

Possible Solution

In the 404 page tracking docs referenced above, it shows a version of the Plausible script tag that includes a .q parameter for holding a queue of events that may have fired before the script loads:

<script defer data-domain="<yourdomain.com>" src="https://plausible.io/js/plausible.js"></script>
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>

I wonder if next-plausible could adopt such an approach to ensure the events are processed. The Plausible analytics script itself consumes this queue, so just defining it on the window may be enough. Note that I may be wrong about the root cause of this issue and the above approach may not resolve it.

Temporary Solution

I did confirm that delaying my 404 tracking code resulted in a successful tracking of the event, even when the 404 page is directly loaded from SSR.

function Custom404() {
  const analytics = useAnalytics();
  useEffect(() => {
    setTimeout(() => {
      analytics('Page Not Found', {
        props: { page: document.location.pathname },
      });
    }, 300);
  }, [analytics]);
 // ...

Documentation is incorrect for withPlausibleProxy subdirectory option

The documentation specifies that the below snippet would result in the script being loaded from /js/yoursubdirectory/scriptName.js

const { withPlausibleProxy } = require('next-plausible')

module.exports = withPlausibleProxy({
  subdirectory: 'yoursubdirectory',
  scriptName: 'scriptName',
  customDomain: 'http://example.com',
})({
  // ...your next js config, if any
})

In reality it loads the script from /yoursubdirectory/js/scriptName.js

Proxy /api/event routes using withPlausibleProxy for custom domains

Using withPlausibleProxy the URL rewrite rules are applied. Additionally a custom domain can be set. However, I think it would also make sense to rewrite the POST /api/event requests. As the script can be loaded but all plausible events are still being blocked.

<PlausibleProvider domain="http://plausible.example.com">
    ...
</PlausibleProvider>
const { withPlausibleProxy } = require('next-plausible')

module.exports = withPlausibleProxy({
  customDomain: 'http://plausible.example.com',
})({
  // ...your next js config, if any
})

This will proxy the GET request of fetching the script.js but e.g. the event POST requests are going to http://plausible.example.comand are still being blocked.

When self-hosting plausible it is currently only possible to host it on root path as no base path can be set, see discussion.

So I think it would be great if we could also proxy the event requests.

Add `usePlausibleEvent`

Hi there,

would be great to have a small additional hook that fires an event on the component mount. I tried implementing it, but I got stuck creating the right templates; they don't work properly. Maybe you have a clue.

#72

Johannes

Support custom domains for proxy

Hey! First of all, I want to thank you for writing this library 😄 .

Right now, it seems that withPlausibleProxy hard codes the destination url. I'm trying to use this with a custom domain since I self-hosted. It would be nice to be able to specify a custom domain. I could give it a shot if you want!

Thank you!

Plausible script not included on website

Hi,

the script.js file is not loaded for me with the following setup.

next.config.js

/** @type {import('next').NextConfig} */

const withTM = require('next-transpile-modules')(['echarts', 'zrender']);

const nextConfig = {
    reactStrictMode: true,
    eslint: {
        dirs: ['src'],
    },
};

module.exports = withTM(nextConfig);

_app.ts

import type { AppProps } from 'next/app';
import PlausibleProvider from 'next-plausible';

function MyApp({ Component, pageProps }: AppProps) {
    return (
        <PlausibleProvider domain="xxx" trackLocalhost={true}>
            <Component {...pageProps} />
        </PlausibleProvider>
    );
}

export default MyApp;

When I include the script tag manually in the header plausible works fine.

Any ideas what might cause this?

Request Header Fields Too Large when using combined with auth0/next-auth

We are getting 431 (Request Header Fields Too Large) when using next-plausible and auth0/nextjs-auth. The auth library sets a couple of http only cookies for an encrypted session which are quite large (size 4000 and 3300 respectively).

Is there a setting or a workaround for this problem that you are aware of?

Thanks!

Not catching any requests

Hey

I've added the proxy and followed the instructions for vercel. I checked my frontend for plausible events, there were indeed triggered.

The plausible.io dashboard did not seem to show any visits. Do you know what could be the reason? How to debug it further?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.