New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nextjs-analytics

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nextjs-analytics

Privacy conscious analytics

  • 0.1.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

next-analytics

A simple solution for self-controlled analytics with Next.js. Inspired by next-auth.

next-analytics is relatively privacy conscious. It records the following:

  • Unique user id (hash of IP, UA, and month to make it temporary)
  • Referrer
  • Path
  • Time
  • Language
  • User agent
  • Platform

Setup

Setting the server

Create a api/analytics folder and add the npm package (nextjs-analytics). From there, create a new file called [...nextanalytics].js (spelling is very important) and add this to it:

import { handleAnalytics } from 'nextjs-analytics/server'

export default handleAnalytics({
  database: 'hits', // The database name to use
  connection: '' // A mongodb connection string (use env variables)
})

Running the client

In your _app.js file, add these lines:

import { useAnalytics } from 'nextjs-analytics/client'

// In your component
useAnalytics()

FAQs

Package last updated on 09 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc