@11-met-dev/event-creator 中文文档教程
11-met-dev-events-sdk
此存储库包含用于创建事件的 11-Met-Dev npm 包的源代码。
Installation and usage
使用 npm 安装:
$ npm install @11-met-dev/event-creator
用途:
const eventCreator = require("@11-met-dev/event-creator");
Example
该包目前只有一个异步函数来创建和注册组织指标的事件。
首先,您需要使用 setUrl 函数设置 api 的基本 url。 (参见上面的完整示例)
为了创建度量的事件,必须提供带有以下参数的 createEvent 函数:
- a valid API key for the organization
- metric's name
- event's value
在您的应用程序代码中,您可以按如下方式使用此函数:
try {
eventCreator.setUrl("http://yoururl.here.com");
await eventCreator.createEvent("01cc781b-bc7b-4d8d-ac0e-bcaf643471fb", "covid_total_cases", 1);
} catch (err) {
console.log(err);
}
11-met-dev-events-sdk
This repository contains the source code for 11-Met-Dev npm package for events creation.
Installation and usage
Installing with npm:
$ npm install @11-met-dev/event-creator
Usage:
const eventCreator = require("@11-met-dev/event-creator");
Example
This package as of now has only one asynchronous function to create and register events of an organization's metric.
First of all you need to set te base url of the api with the setUrl function. (See full example above)
In order to create an event of a metric, one has to provide the createEvent function with the following arguments:
- a valid API key for the organization
- metric's name
- event's value
From within your application code, you can use this function as follows:
try {
eventCreator.setUrl("http://yoururl.here.com");
await eventCreator.createEvent("01cc781b-bc7b-4d8d-ac0e-bcaf643471fb", "covid_total_cases", 1);
} catch (err) {
console.log(err);
}