@affinidi/affinity-metrics-lib

Client to work with Affinidi Metrics backend

Usage no npm install needed!

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

README

Affinidi Metrics Client (PUBLIC)

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, EventName, EventCategory, EventComponent} from '@affinidi/affinity-metrics-lib'

const event = {
  link:        'any_relevant_unique_id_will_be_hashed',
  name:        EventName.DID_CREATED,
  category:    EventCategory.DID,
  subCategory: 'registry',
  component:   EventComponent.AffinidiRegistry,
}

metrics.send(event, apiKeyHash, metricsUrl)

Parameters

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

EventName, 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.

Setup Integration Tests

Test API key hash should be added to the top level .env file. Reach out to a team member for instructions on how to set up this file, or to obtain a copy.

Events

Metrics Event Description (When Does It Happen) Note
USER_ONBOARDED A developer has signed up for an API key. https://affinity-onboarding-frontend.dev.affinity-project.org/
DID_CREATED A DID has been created.
DID_UPDATED A DID has been updated.
VC_VERIFIED A VC has been verified. VC holder as the link.
VC_VERIFIED_PER_PARTY A VC has been verified. VC verifier as the link.
VC_SAVED A VC has been stored in a wallet. VC ID as the link and issuer ID as the secondary link.
VC_SIGNED A VC has been signed. VC holder as the link.
VC_REVOKED A VC has been revoked. Issuer DID as the link.
VC_ISSUE_INITIATED A VC issue has been initiated. VC ID as the link and issuer ID as the secondary link.
SHARED_MESSAGE_CREATED A VC has been shared as shared message. VC ID as the link and issuer ID as the secondary link.
VP_VERIFIED A VP has been verified. VP holder as the link.
VP_SIGNED A VP has been signed. VP holder as the link and VP ID as the secondary link.
VP_VERIFIED_JWT A VP has been verified in JWT format. VP holder as the link.
VP_SIGNED_JWT A VP has been signed in JWT format. VP holder as the link and VP ID as the secondary link.