Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cmpsr/analytics

Package Overview
Dependencies
Maintainers
0
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cmpsr/analytics

## Philosophy

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44
increased by4.76%
Maintainers
0
Weekly downloads
 
Created
Source

ANALYTICS

Philosophy

To be analytic provider agnostic while mirroring itself into the React ecosystem. Since Segment is also trying to do the same thing, their API makes sense as a good base.

How it works

React app is wrapped in <AnalyticsProvider> which passes context down with functions to track user activities. When these functions are called, it will loop through all valid analytics providers and call their equivalent api.

API

identify: Let the provider know who the logged in user is group: If there are multiple portals, this helps separate them. This is advanced. page: Track a new page, can be added to Next's router track: Track an even such as a button click user: Returns the auto assigned id reset: Clear the identity

More information can be found on Segment

Supported Providers

  • GTag
  • Segment
  • GA (will deprecated july 2023)

Setup

Compile

To compile this library please run yarn run libbuild

Add Provider

Wrap the root of your React app in <AnalyticsProvider><YOUR APP /></AnalyticsProvider>.

Here are the props you can pass in to enable these providers.

export interface IAnalyticsProvider {
  segment?: ISegmentConfig;
  gtag?: IGTagConfig;
  ga?: IGAConfig;
}

Use Function

import useAnalytics from 'useAnalytics';

const { track } = useAnalytics();
track('Hello World');

TODO

Add tests

FAQs

Package last updated on 05 Dec 2024

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