MetricsManagement Module


Version MetricsManagement 1.1.0-next.1

Table of Contents

Usage

To use the MetricsManagement module, you can import it into your project from the Firebolt SDK:

import { MetricsManagement } from "@firebolt-extn-js/ripple-sdk";

Overview

Methods for managing the metrics integrations

Methods

addContext

Add context that can be applied to all metrics reporting

function addContext(context: MetricsContext): Promise<null>;

Parameters:

Param Type Required Description
context MetricsContext true The context to add for metrics

Promise resolution:

Capabilities:

Role Capability
manages xrn:firebolt:capability:metrics:context

Examples

Set the deviceSessionId

JavaScript:

import { MetricsManagement } from "@firebolt-extn-js/ripple-sdk";

let results = await MetricsManagement.addContext({
  deviceSessionId: "ccccc-cccc-cccc-cccc-cccccccc",
});
console.log(results);

Value of results:

null;
JSON-RPC: Request:
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "MetricsManagement.addContext",
  "params": {
    "context": {
      "deviceSessionId": "ccccc-cccc-cccc-cccc-cccccccc"
    }
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}

removeContext

Remove context that was previously added by Metrics.addContext

function removeContext(keys: string[]): Promise<null>;

Parameters:

Param Type Required Description
keys string[] true The list of keys to clear context for
values: 'deviceSessionId'

Promise resolution:

Capabilities:

Role Capability
manages xrn:firebolt:capability:metrics:context

Examples

Remove the override for deviceSessionId

JavaScript:

import { MetricsManagement } from "@firebolt-extn-js/ripple-sdk";

let result = await MetricsManagement.removeContext(["deviceSessionId"]);
console.log(result);

Value of result:

null;
JSON-RPC: Request:
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "MetricsManagement.removeContext",
  "params": {
    "keys": ["deviceSessionId"]
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}

Types

MetricsContext

Context that is used when the platform sends any metrics

type MetricsContext = {
  deviceSessionId?: string; // A unique id that identifies a sessionId correlating to the scope of when the user has interacted with the device. This sessionId should be reset any time the device goes to the active power state
};