Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

app-usage-events-react

mhetrics401.1.14TypeScript support: included

A set of types, type checks, and type guards for simpler, safer, and easier to read code.

types, type guards, guards, type checks, checks, type, checking, typescript

readme

app-usage-events-react

utility to easily emit app-usage-events from your app to the mhetrics platform

install

npm install @mhetrics/app-usage-events-react

use

autocaptured events

Add the provider to your react app. This provider is responsible for

  • instantiating the autocapture listeners
  • emitting the app-usage-events
  • configuring the capture-server authorization
import { AppUsageEventsEmitter } from '@mhetrics/app-usage-events-react';

<AppUsageEventsEmitter
  clientKey={config.mhetrics.clientKey}
  captureHost={config.mhetrics.captureHost}
/>

With that, your app will automatically be emitting

  • network events (e.g., rest requests)
  • browser events (e.g., load, unload, focus, blur, navigation)
  • runtime events (e.g., console.log, console.warn, console.error)
  • activity events (e.g., mouse, touch, scroll, keyboard)

observation events

Your app is now also configured to emit observation events. Observation events are produced by your application to track observations useful for analytics. Here is an example of how to emit observation events

import { captureObservationEvent } from '@mhetrics/app-usage-events-react';

await captureObservationEvent({
  /**
   * the type of the observation you are reporting
   */
  type: 'experiment.exposure', // for example, tracking that a user was exposed to an experiment

  /**
   * details about the observation
   */
  details: {
    experiment: 'show-reviews?', // for example, an experiment about whether or not reviews should be shown
    treatment: 'CONTROL', // for example, tracking that they were exposed to the CONTROL treatment of the experiment
  }
})

changelog

Changelog

1.1.14 (2024-04-20)

Bug Fixes

  • emit: re-attempt emission tasks in attempted state (0dcf206)

1.1.13 (2024-04-20)

Bug Fixes

  • dao: json.parse instead of deserialize to support minification (0944e7f)

1.1.12 (2024-03-27)

Bug Fixes

  • autocap: skip autocapture of motion events (42bdecb)

1.1.11 (2023-09-23)

Bug Fixes

  • typedef: resolve tsc issue after returntype update (fd0df51)

1.1.10 (2023-09-23)

Bug Fixes

  • typedef: change returntype of provider (de3dc61)

1.1.9 (2023-09-22)

Bug Fixes

  • deps: resolve event-stream pubsub contract change per update (d349620)

1.1.8 (2023-09-22)

Bug Fixes

  • deps: bump event-stream-pubsub to latest (5a2532e)

1.1.7 (2023-09-07)

Bug Fixes

  • observation: warn without error on observations without sessions (a4cac62)
  • practs: bump to latest best practs (ab32680)

1.1.6 (2023-07-28)

Bug Fixes

  • dao: json.parse instead of deserialize to support minification (57f4731)

1.1.5 (2023-07-25)

Bug Fixes

  • perf: wait for application session instead of queuing to resilient queue (92405eb)

1.1.4 (2023-07-25)

Bug Fixes

  • logs: dont log to console unless asked to (675938f)

1.1.3 (2023-07-25)

Bug Fixes

  • pkg: add back the registry-url parameter to package-publish (28e8ad9)

1.1.2 (2023-07-25)

Bug Fixes

  • publish: ensure build before publish (8162852)

1.1.1 (2023-07-25)

Bug Fixes

  • practs: bump best practs for faster cicd (b9a26fe)

1.1.0 (2023-07-25)

Features

  • observation: add capture observation event method (9b820e6)

Bug Fixes

  • name: rename package to drop emitter suffix (0666dbb)

1.0.1 (2023-07-16)

Bug Fixes

  • pkg: export domain objects (c89b41c)

1.0.0 (2023-07-16)

Features

  • init: initialize based on simple-async-tasks (946e575)