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

analytics-event

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-event

Utility for working with analytics events server-side and in the browser.


Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created

analyticsEvent

A tiny utility for working with analytics events
on the server and in the browser.



Getting Started

Installation

Install with npm:

npm install --save analytics-event

Or with yarn:

yarn add analytics-event
Examples
import AEvent from 'analytics-event'

// Generate event from options 
AEvent({
  name: 'User Signed Up',
  properties: {
    referral_type: 'friend'
  }
})

// Use your favorite analytics library to send events
analytics.track(AEvent({
  name: 'User Signed Up',
  properties: {
    referral_type: 'friend'
  }
}))

Usage

Generating an event
import AEvent from 'analytics-event'

// Generate an event that follows https://schema.org/AnalyticsEvent
AEvent({
  name: 'User Signed Up',
  properties: {
    referral_type: 'friend'
  }
})
Formatting an event
import AEvent from 'analytics-event'

// You can also just import the format function with:
// import { format, loadFormat } from 'analytics-event'
import internalDataFormat from './internal-data-format'

AEvent.loadFormat('internal-data', internalDataFormat)

function receiveIncomingEvents(batch) {
  return batch.map(msg => AEvent.format(msg, {
    preset: 'internal-data'
  }))
}

Contributing

All contributions are super welcome! analytics-event is MIT-licensed.

FAQs

Package last updated on 23 Oct 2018

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