@affinityproject/affinity-metrics-lib

Client to work with Affinity Metrics backend

Usage no npm install needed!

<script type="module">
  import affinityprojectAffinityMetricsLib from 'https://cdn.skypack.dev/@affinityproject/affinity-metrics-lib';
</script>

README

Affinity metrics client

For security reasons we hash a link before sending it over the network. In a most cases link should be any relevant id that could help with a tracking. :caution: Strongly avoid passing any ppi or sensitive data in a subcategory fields.

Usage:

import { metrics, EventCategory, EventComponent} from '@affinityproject/affinity-metrics-lib'

const event = {
  link:        'any_relevant_unique_id_will_be_hashed',
  name:        'Did Created',
  category:    EventCategory.DID,
  subCategory: 'registry',
  component:   EventComponent.AffinityWalletExpoSDK
}

metrics.send(event, 'a1870180fca44ea69633797fd1643f1287452043fcac23a5fb7d944abf8d1f0e', metricsUrl)

Parameters

  • event - tacking event
  • apiKeyhash - hash from your application key used for service 2 service communication.
  • metricsUrl - optional url of metric service https://affinity-metrics.[env].affinity-project.org

EventComponent and EventCategory are predefined library level enums, in case you need to add a new component or category do it via PR. Try to keep the category as generic as possible.