{"id":15705961,"url":"https://github.com/kyleross/node-datadog-events","last_synced_at":"2025-10-15T08:23:13.342Z","repository":{"id":52689480,"uuid":"135459169","full_name":"KyleRoss/node-datadog-events","owner":"KyleRoss","description":"Send events to DataDog *without* DogStatsD or StatsD","archived":false,"fork":false,"pushed_at":"2021-04-21T01:11:02.000Z","size":34,"stargazers_count":2,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-08T19:38:05.604Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KyleRoss.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-30T15:00:45.000Z","updated_at":"2021-03-08T03:03:42.000Z","dependencies_parsed_at":"2022-08-22T07:20:12.262Z","dependency_job_id":null,"html_url":"https://github.com/KyleRoss/node-datadog-events","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyleRoss%2Fnode-datadog-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyleRoss%2Fnode-datadog-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyleRoss%2Fnode-datadog-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyleRoss%2Fnode-datadog-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KyleRoss","download_url":"https://codeload.github.com/KyleRoss/node-datadog-events/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253764929,"owners_count":21960658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T20:20:50.336Z","updated_at":"2025-10-15T08:23:08.306Z","avatar_url":"https://github.com/KyleRoss.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datadog-events\n\n[![npm](https://img.shields.io/npm/v/datadog-events.svg?style=for-the-badge)](https://www.npmjs.com/package/datadog-events) [![npm](https://img.shields.io/npm/dt/datadog-events.svg?style=for-the-badge)](https://www.npmjs.com/package/datadog-events) [![David](https://img.shields.io/david/KyleRoss/node-datadog-events.svg?style=for-the-badge)](https://david-dm.org/KyleRoss/node-datadog-events) [![Travis](https://img.shields.io/travis/KyleRoss/node-datadog-events/master.svg?style=for-the-badge)](https://travis-ci.org/KyleRoss/node-datadog-events) [![license](https://img.shields.io/github/license/KyleRoss/node-datadog-events.svg?style=for-the-badge)](https://github.com/KyleRoss/node-datadog-events/blob/master/LICENSE) [![Beerpay](https://img.shields.io/beerpay/KyleRoss/node-datadog-events.svg?style=for-the-badge)](https://beerpay.io/KyleRoss/node-datadog-events)\n\n\nSend events to DataDog **without** DogStatsD or StatsD, using the standard DataDog API. Supports Node 6+.\n\n## Getting Started\n### Install\n```sh\nnpm install datadog-events --save\n```\n\n### Use\nBy default, a function is exported that will create a new instance of `DataDogEvents` for you. You may either use the default or create your own instance of the class:\n\n#### Default Exports\n```js\nconst ddEvents = require('datadog-events')({ /* options */ });\n\nasync function doSomething() {\n    // ...\n    \n    if(err) {\n        await ddEvents.error('Some error!', 'These are some details');\n    }\n}\n```\n\n#### Create Instance\n```js\nconst DataDogEvents = require('datadog-events').DataDogEvents;\nconst ddEvents = new DataDogEvents({ /* options */ });\n```\n\n## API Documentation\n### Options\n\n#### Global DataDogEvents Options\nThe following options are available when creating a new instance of `DataDogEvents` or when calling the default export function.\n\n| Option         | Type          | Required? | Description                                                                                                             | Default                       |\n|----------------|---------------|-----------|-------------------------------------------------------------------------------------------------------------------------|-------------------------------|\n| apiKey         | String        | Yes       | Your DataDog API key. This may be populated using environment variable `DATADOG_API_KEY`.                               | `process.env.DATADOG_API_KEY` |\n| domain         | String        | No        | DataDog domain to use for the API. Useful for switching to the EU version (ex. `datadoghq.eu`).                         | `\"datadoghq.com\"`             |\n| titlePrefix    | String        | No        | Optional text to prefix all event titles with.                                                                          | `null`                        |\n| bodyPrefix     | String        | No        | Optional text to prefix all event bodies with.                                                                          | `null`                        |\n| bodyPostfix    | String        | No        | Optional test to postfix all event bodies with.                                                                         | `null`                        |\n| priority       | String        | No        | Priority for all events. Can be either `normal` or `low`.                                                               | `\"normal\"`                    |\n| host           | String        | No        | Optional host name to attach to all events.                                                                             | `null`                        |\n| tags           | Array[String] | No        | Optional tags to attach to all events.                                                                                  | `[]`                          |\n| aggregationKey | String        | No        | Optional key that will allow DataDog to aggregate all events under.                                                     | `null`                        |\n| sourceType     | String        | No        | Optional source type name. See [here](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value/). | `null`                        |\n| markdown       | Boolean       | No        | Format all event bodies as markdown.                                                                                    | `true`                        |\n\n#### Event Options\nThe following options may be provided when sending events with any of the methods documented below. Most of these options will override the global options listed above and are all optional.\n\n| Option         | Type          | Description                                                                                                             |\n| -------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------- |\n| date           | Date          | Date object of the event. By default, it will be the current date/time.                                                 |\n| priority       | String        | Priority for the event. Can be either `normal` or `low`.                                                                |\n| host           | String        | Optional host name to attach to the event.                                                                              |\n| tags           | Array[String] | Tags to append to the event. Tags provided will be appended to the global `options.tags`.                               |\n| aggregationKey | String        | Optional key that will allow DataDog to aggregate all events under.                                                     |\n| sourceType     | String        | Optional source type name. See [here](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value/). |\n| markdown       | Boolean       | Format the body as markdown.                                                                                            |\n\n### DataDogEvents Class\nThe main class for `datadog-events`.\n\n#### constructor([options={}])\nThe constructor for `DataDogEvents`.\n\n| Argument | Type    | Required? | Description                                                     |\n| -------- | ------- | --------- | --------------------------------------------------------------- |\n| options  | ?Object | No        | [Global options](#global-datadogevents-options) for the class.  |\n\n##### Example\n```js\n// Shortcut\nconst ddEvents = require('datadog-events')({ /* options */ });\n\n// Create your own instance\nconst DataDogEvents = require('datadog-events').DataDogEvents;\nconst ddEvents = new DataDogEvents({ /* options */ });\n```\n\n###### Returns - _DataDogEvents_\n\u003e Returns instance of DataDogEvents.\n\n### Methods\n\n#### ddEvents.\u003cerror|warning|info|success\u003e(title, body[, options={}])\nShortcut methods for `ddEvents.sendEvent()`. Will send an event with the given type of the method.\n\n| Argument | Type                | Required? | Description                                                                                                                                                       |\n| -------- | ------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| title    | String              | Yes       | Title for the event.                                                                                                                                              |\n| body     | String|Object|Error | Yes       | The body of the event. If `options.markdown` is `true`, it will be formatted as markdown. If an Object or Error is passed in, it will be formatted into markdown. |\n| options  | ?Object             | No        | Optional [event options](#event-options).                                                                                                                         |\n\n##### Example\n```js\nddEvents.error('There was an error!', error)\n    .then(response =\u003e console.log(response));\n\nawait ddEvents.success('Completed a process!', '**The process was completed!**');\n```\n###### Returns - _Promise[Object]_\n\u003e Promise resolves with object returned from the DataDog API containing `status` and `event` keys. Rejects with error if failed to send.\n\n#### ddEvents.sendEvent(type, title, body[, options={}])\nSends an event to DataDog.\n\n| Argument | Type                | Required? | Description                                                                                                                                                       |\n| -------- | ------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| type     | String              | Yes       | Alert type of the event. Can be `error`, `warning`, `info` or `success`.                                                                                          |\n| title    | String              | Yes       | Title for the event.                                                                                                                                              |\n| body     | String|Object|Error | Yes       | The body of the event. If `options.markdown` is `true`, it will be formatted as markdown. If an Object or Error is passed in, it will be formatted into markdown. |\n| options  | ?Object             | No        | Optional [event options](#event-options).                                                                                                                         |\n\n##### Example\n```js\nddEvents.sendEvent('warning', 'Something happened', '**Warning:** Something crazy happened')\n    .then(resp =\u003e console.log(resp));\n\nawait ddEvents.sendEvent('info', 'Results from my process', resultsObject);\n```\n\n###### Returns - _Promise[Object]_\n\u003e Promise resolves with object returned from the DataDog API containing `status` and `event` keys. Rejects with error if failed to send.\n\n\n### Properties\n#### ddEvents.options - _Object_\nThe [global options](#global-datadogevents-options) for the current instance of DataDogEvents. You may change any of the options at any time.\n\n### Environment Variables\n| Environment Variable | Type   | Option           | Description                                 |\n|----------------------|--------|------------------|---------------------------------------------|\n| DATADOG_API_KEY      | String | `options.apiKey` | Sets the API Key for DataDog automatically. |\n| DATADOG_DOMAIN       | String | `options.domain` | Sets the domain for the DataDog API.        |\n\n## Tests\nTests run automatically in Travis, although you may run them on your own machine. If you do, you must have your own DataDog account and API key. Make sure you add the `DATADOG_API_KEY` environment variable before running the tests.\n\n```sh\nDATADOG_API_KEY=MY_API_KEY npm run test\n```\n\n## License\nMIT License. See [License](https://github.com/KyleRoss/node-datadog-events/blob/master/LICENSE) in the repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyleross%2Fnode-datadog-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyleross%2Fnode-datadog-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyleross%2Fnode-datadog-events/lists"}