UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature toggles service. It provides different strategies for handling feature toggles.

38 lines 1.7 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const addon_1 = __importDefault(require("./addon")); const datadog_definition_1 = __importDefault(require("./datadog-definition")); const feature_event_formatter_md_1 = require("./feature-event-formatter-md"); class DatadogAddon extends addon_1.default { constructor(config) { super(datadog_definition_1.default, config); this.msgFormatter = new feature_event_formatter_md_1.FeatureEventFormatterMd(config.unleashUrl, feature_event_formatter_md_1.LinkStyle.MD); } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types async handleEvent(event, parameters) { const { url = 'https://api.datadoghq.com/api/v1/events', apiKey } = parameters; const text = this.msgFormatter.format(event); const { tags: eventTags } = event; const tags = eventTags && eventTags.map((tag) => `${tag.type}:${tag.value}`); const body = { text: `%%% \n ${text} \n %%% `, title: 'Unleash notification update', tags, }; const requestOpts = { method: 'POST', headers: { 'Content-Type': 'application/json', 'DD-API-KEY': apiKey, }, body: JSON.stringify(body), }; const res = await this.fetchRetry(url, requestOpts); this.logger.info(`Handled event ${event.type}. Status codes=${res.status}`); } } exports.default = DatadogAddon; //# sourceMappingURL=datadog.js.map