2.0.2 • Published 2 years ago

next-use-posthog v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

This is now deprecated

We now offer a PostHog provider and hooks which makes setup easier and more reliable.

We recommend using the approach outlined in our documentation

Old notes

V2.0 breaking changes

In v2.0.0 we moved PostHog to be a peer dependency so you can control which version of PostHog you use without needing changes to this integration.

Install

yarn add next-use-posthog

Usage

In pages/_app.js or pages/_app.tsx

JavaScript

import { usePostHog } from "next-use-posthog";

const App = ({ Component, pageProps }) => {
  usePostHog("API_KEY", {
    api_host: "https://app.posthog.com",
  });

  return <Component {...pageProps} />;
};

export default App;

TypeScript

import { usePostHog } from "next-use-posthog";
import { AppProps } from "next/app";
import { FC } from "react";

const App: FC<AppProps> = ({ Component, pageProps }) => {
  usePostHog("API_KEY", {
    api_host: "https://app.posthog.com",
  });

  return <Component {...pageProps} />;
};

export default App;

Disable in development

import { usePostHog } from "next-use-posthog";
import { AppProps } from "next/app";
import { FC } from "react";

const App: FC<AppProps> = ({ Component, pageProps }) => {
  usePostHog("API_KEY", {
    api_host: "https://app.posthog.com",
    loaded: (posthog) => {
      if (process.env.NODE_ENV === "development") posthog.opt_out_capturing();
    },
  });

  return <Component {...pageProps} />;
};

export default App;

Dependencies

  • React
  • Next.js
  • posthog-js
2.0.2

2 years ago

2.0.1

2 years ago

1.16.3

3 years ago

1.16.2

3 years ago

1.16.1

3 years ago

1.16.4

3 years ago

1.16.0

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.1-security

4 years ago

0.1.0

4 years ago