0.0.13 • Published 8 months ago

@strukt-io/analytics v0.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@strukt-io/analytics

A lightweight, privacy-focused analytics package for React web applications.

Features

  • Privacy-focused with configurable data collection
  • Built-in support for page views and custom events
  • TypeScript support
  • Automatic path tracking
  • Customizable endpoint support

Install

npm install @strukt-io/analytics

or

yarn add @strukt-io/analytics

Usage

Import and initialize the analytics hook in your application:

<Analytics pathname="/" options={{
  server: 'https://api.example.com/analytics',
  projectId: 'proj_123abc',
  detailed: false,
  ignoreLocalhost: true,
  ignoreOwnVisits: true,
  recordPath: '/api/event/record',
  actionPath: '/api/event/action',
}} />

or

useAnalytics('/', {
  server: 'https://api.example.com/analytics',
  projectId: 'proj_123abc',
  detailed: false,
  ignoreLocalhost: true,
  ignoreOwnVisits: true,
  recordPath: '/api/event/record',
  actionPath: '/api/event/action',
})

The analytics hook will automatically track page views when the path changes. An undefined or empty path will be skipped.

This hook is safe to use during server-side rendering and will only activate on the client.

API

Parameters

  • pathname {?String} Current path to track
  • config {Object} Configuration object containing:
    • endpoint {String} Analytics API endpoint
    • projectId {String} Your project identifier
    • apiKey {?String} Optional API key for authentication
  • options {?Object} Optional configuration:
    • detailed {Boolean} Enable detailed event tracking
    • ignoreLocalhost {Boolean} Skip tracking on localhost
    • ignoreOwnVisits {Boolean} Skip tracking your own visits
    • customDimensions {Object} Additional data to track

Privacy

This package is designed with privacy in mind:

  • No cookies by default
  • Configurable data collection
  • IP anonymization
  • Respects Do Not Track
  • GDPR compliant
  • No third-party requests

License

MIT © Strukt

0.0.13

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago