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

@exodus/analytics

Package Overview
Dependencies
Maintainers
0
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exodus/analytics

Analytics-provider agnostic analytics reporter

  • 11.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
621
decreased by-37.34%
Maintainers
0
Weekly downloads
 
Created
Source

Exodus analytics

A base class encapsulating analytics integration.

API Reference

Property nameDescription
setPermanentUserIdUse this to set the permanent user id, i.e. the seed derived id fetched from analyticsUserIdAtom
flushUse this to send persisted events to segment. Events that are tracked before setPermanentUserId is set will need to be flushed
getAnonymousIdGets the anonymousId associated with the tracker. This is a UUID until setPermanentUserId is called with the userId
trackUse this method to send events to segment. If setPermanentUserId has not been called, you must use force: true.
identifyUsed primarily to identify a user with the onboarding UUID and to set global "traits". Should be used sparingly -- on seed import or seed create for example.
setDefaultPropertiesPretty much as it sounds. This sets persistent properties to be sent with every call to segment via track
trackInstallsets a persisted event that can be sent with flush postinstall

Usage

import createStorage from '@exodus/storage-memory' // use the relevant platform-specific implementation
import analyticsDefinition from '@exodus/analytics'
import Tracker from '@exodus/segment-metrics'

const analytics = analyticsDefinition.factory({
  storage: storage.namespace('analytics'),
  shareActivityAtom,
  tracker: new Tracker(segmentApiKey),
  // optional
  config: {
    installEventReportingUrl,
  },
  logger,
})

/*
 *  during onboarding, we don't need to set the permanent user id
 *  segment + analytics will automatically generate a UUID to track onboarding
 *  so that we can call .track({ event, properties }) without first being
 *  "connected" or having .setPermanentUserId()
 *
 *  using force: true, you can send the event right away associated w/ the UUID
 *  force: false (default) will simply persist the event until you call .flush()
 */

analytics.track({ ...onboardingEvent, force: true }) // we can use force: true to send the event to segment
analytics.track({ ...anotherEvent }) // without force: true, this event is persisted and can be sent by using .flush()

const userId = await analyticsUserIdAtom.get() // should come from the IOC container

analytics.setPermanentUserId(userId)
analytics.flush() // any persisted event can now be sent
analytics.track({
  event: 'hello world',
})

Constructor Options

Property nameRequiredDescription
trackeryesA Tracker class instance.
storageyesAn object implementing the Storage interface (see below). Needed if you need to persist events (e.g. when a consumer application can be temporarily locked).
shareActivityAtomyesAn atom returning a boolean value indicating if a consumer application is ready to send events.
trackUnvalidatednoA boolean flag indicating if not validated events should be still submitted to Segment API. false by default
confignoStatic configuration options
config.installEventReportingUrlnoUrl to which to post app install events
type SerializedEvent = 'string'

interface Storage {
  set: (key: string, events: SerializedEvent[]) => Promise<undefined>
  get: (key: string) => Promise<SerializedEvent[]>
}

FAQs

Package last updated on 11 Jan 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