Sending PII Handling Telemetry
Having defined each of your software systems with their own API key with appropriate permissions, defined data retention policies with your Data Protection Officer(s), you are now ready to start sending data use observations to Metronome.
import { ServerConfiguration, TelemetryApi, TelemetryRequest, createConfiguration } from "@privatedataservices/metronome-client";import { explainError } from "./errors";
const clientConfig = createConfiguration( { baseServer: new ServerConfiguration("https://the-flower-boutique.dev.eu-west-1.privatedataservices.com", {}), authMethods: { ApiKeyAuth: process.env.METRONOME_API_KEY }});const telemetryApiClient = new TelemetryApi(clientConfig);
try { const telemetryData: TelemetryRequest = {"observationTime": new Date(), "policies": ["user-account-access"], "observations": [ {"itemId": "mysql/CodeExamples/customer-123", "subItemIds": ["email", "address"]}, {"itemId": "mysql/CodeExamples/customer-456", "subItemIds": ["email", "phone", "cc_num"]}]}; await telemetryApiClient.postTelemetry(telemetryData); console.log("Telementry data posted successfully.");} catch (err) { explainError(err);}require 'metronome'require_relative 'errors'
# Configure client with API keyclient_config = Metronome::Configuration.newclient_config.scheme = 'https'client_config.host = 'code-examples.dev.eu-west-1.metronome.privatedataservices.com'client_config.api_key['X-API-Key'] = ENV['METRONOME_API_KEY']
telemetry_api_client = Metronome::TelemetryApi.new(Metronome::ApiClient.new(client_config))
begin telemetry_data = Metronome::TelemetryRequest.new( observation_time: Time.now, policies: ["user-account-access"], observations: [ Metronome::TelemetryObservation.new( item_id: "mysql/CodeExamples/customer-123", sub_item_ids: ["email", "address"] ), Metronome::TelemetryObservation.new( item_id: "mysql/CodeExamples/customer-456", sub_item_ids: ["email", "phone", "cc_num"] ) ] ) api_client.post_telemetry(telemetry_request: telemetry_data) puts "Telemetry data posted successfully."rescue => err explain_error(err)end
# If you wish to send a telemetry request to a message queue before submitting to Metronome, you# can serialise it to JSON with `json_string = telemetry_data.to_hash.to_json` then reconstruct# it with build_from_hash.Each TelemetryRequest has an observation time, a list of 1 or more policies
that were used to handle the data, as well as a list of observations. Each
observation must contain an item-id and a list of 1 or more sub-item-ids.
The item-id values are strings that are meaningful to your organisation and
which will help you locate the data item in question. In the example above,
the organisation has data in several different PII stores, and has chosen to
identify the data store type, database or schema name, table name and then the
ID value in that table. These are observations in a mysql
server, in the CodeExamples database,
customer table with ID values
123 and 456.
If you have a central PII store and only wish to record the table name and ID,
a simple value of customer-123 might be
sufficient for you to identify the data item. We make no prescriptions about
how you identify your data items. You decide what a meaningful identifier is
for your organisation.