bend-shared-utilities v1.0.0
bend-shared-utilities
This is a shared utilities package for handling various service integrations.
Description
A shared utilities package that provides various service integrations. Here is a list of our current integrations:
- PagerDuty
PagerDuty Integration
We use the PagerDuty API to manage incidents. The package uses the @pagerduty/pdjs
library for this integration.
Exposed Methods
PagerDutyService Class
This class provides the following methods for interacting with the PagerDuty API:
constructor(apiToken, fromEmail)
: This method initializes the PagerDutyService with the provided API token and email. If no values are provided, it defaults to the values in the environment variablesPAGERDUTY_API_TOKEN
andPAGERDUTY_FROM_EMAIL
.createIncident(title, serviceId, urgency, incident_details)
: This method creates a new incident in PagerDuty. It takes the following parameters:title
: The title of the incident.serviceId
: The ID of the service the incident is associated with.urgency
: The urgency of the incident. Defaults to "high".incident_details
: Additional details about the incident.
createIncidentFromErrorLog(errorLog, serviceId, urgency)
: This method creates a new incident in PagerDuty based on an error log. It takes the following parameters:errorLog
: The error log from Mongo DB.serviceId
: The ID of the service the incident is associated with.urgency
: The urgency of the incident. Defaults to "high".environment
: Node Environment.
acknowledgeIncident(incidentId)
: This method acknowledges a given incident in PagerDuty. It takes theincidentId
as a parameter.resolveIncident(incidentId)
: This method resolves a given incident in PagerDuty. It takes theincidentId
as a parameter.
Dependencies
- Node.js version 20.10.0
@pagerduty/pdjs
version 2.2.4axios
version 1.7.7dotenv
version 16.4.5
License
MIT
10 months ago