{"id":26084098,"url":"https://github.com/happykit/analytics","last_synced_at":"2025-04-12T00:41:15.785Z","repository":{"id":45542129,"uuid":"284086296","full_name":"happykit/analytics","owner":"happykit","description":"Analytics specifically designed for Next.js","archived":false,"fork":false,"pushed_at":"2021-12-09T11:16:17.000Z","size":417,"stargazers_count":37,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T07:04:09.848Z","etag":null,"topics":["analytics","next","nextjs","pageviews","react","reactjs"],"latest_commit_sha":null,"homepage":"https://happykit.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/happykit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-31T16:54:10.000Z","updated_at":"2024-08-13T11:41:25.000Z","dependencies_parsed_at":"2022-07-19T18:04:15.409Z","dependency_job_id":null,"html_url":"https://github.com/happykit/analytics","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happykit%2Fanalytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happykit%2Fanalytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happykit%2Fanalytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happykit%2Fanalytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/happykit","download_url":"https://codeload.github.com/happykit/analytics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501960,"owners_count":21114681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","next","nextjs","pageviews","react","reactjs"],"created_at":"2025-03-09T04:40:53.332Z","updated_at":"2025-04-12T00:41:15.748Z","avatar_url":"https://github.com/happykit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca id=\"nav\"\u003e\n  \u003cimg src=\"https://i.imgur.com/oeUhHfO.png\" width=\"100%\" /\u003e\n\u003c/a\u003e\n\n\u003cdiv align=\"right\"\u003e\n  \u003ca href=\"https://happykit.dev/\"\u003eWebsite\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;•\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://twitter.com/happykitdev\" target=\"_blank\"\u003eTwitter\u003c/a\u003e\n\u003c/div\u003e\n\n\u0026nbsp;\n\u0026nbsp;\n\nAdd analytics to your Next.js application with a single React Hook. This package integrates your Next.js application with HappyKit Analytics. Create a free [happykit.dev](https://happykit.dev/signup) account to get started.\n\n## Key Features\n\n- Track page views and unique visitors\n- Integrate using a single React Hook\n- Next.js specific dynamic route tracking (e.g. `/[user]`)\n- GDPR compliant by default. No cookie notice necessary.\n- Tiny: [1kB minified + gzipped](https://bundlephobia.com/result?p=@happykit/analytics)\n- No external runtime, so no costly additional request to load a runtime\n- Written in TypeScript\n\n## Installation\n\nAdd the package to your project\n\n```sh\nnpm install @happykit/analytics\n```\n\n## Integration\n\nYou'll need to add a single `useAnalytics` call to your application. The best place to do this is in `pages/_app.js`.\n\nSet up a `pages/_app.js` file with this content:\n\n```js\nimport { useAnalytics } from '@happykit/analytics';\n\nfunction MyApp({ Component, pageProps }) {\n  useAnalytics({ publicKey: '\u003cYour HappyKit Public Key\u003e' }); // \u003c-- add this\n\n  return \u003cComponent {...pageProps} /\u003e;\n}\n\nexport default MyApp;\n```\n\n\u003e Create a free account on [happykit.dev](https://happykit.dev/signup) to get your _HappyKit Public Key_\n\n\u003cdetails\u003e\n\u003csummary\u003eUsing TypeScript?\u003c/summary\u003e\n\n```ts\nimport { useAnalytics } from '@happykit/analytics';\nimport type { AppProps } from 'next/app'\n\nfunction MyApp({ Component, pageProps }: AppProps) {\n  useAnalytics({ publicKey: 'HAPPYKIT KEY' }); // \u003c-- add this\n\n  return \u003cComponent {...pageProps} /\u003e\n}\n\nexport default MyApp\n```\n\n\u003c/details\u003e\n\nYou can read more about using a custom `_app.js` component [here](https://nextjs.org/docs/advanced-features/custom-app).\n\n## Options\n\n`useAnalytics(options)` accepts the following options object:\n\n- `publicKey` **string** (required): The public key for this project from [happykit.dev](https://happykit.dev/).\n- `skip` **function** (optional): This function is called with the created page view record. Return true to avoid tracking it.\n- `skipHostnames` **array of strings** (optional): An array of hostnames which will not be tracked. Defaults to `[\"localhost\"]`. HappyKit tracks page views from preview deployments by default. The data is kept separate from your production data.\n- `delay` **number** (optional): The number of milliseconds to wait before reporting a page view. Defaults to 5000. This is used for batching purposes. This is used only if the browser supports `navigator.sendBeacon`. Otherwise page views are sent immediately.\n\nExample:\n\n```js\nuseAnalytics({\n  publicKey: 'pk_live_5093bcd381',\n  skip: pageView =\u003e pageView.pathname === '/some-ignored-path',\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappykit%2Fanalytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhappykit%2Fanalytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappykit%2Fanalytics/lists"}