Compare commits

...

2 Commits

Author SHA1 Message Date
Rıdvan Akca
c0f0415f70 feat(better-stack): add resolve incident action 2024-01-16 13:08:16 +03:00
Rıdvan Akca
23c40c89ee feat(better-stack): add create incident action 2024-01-16 12:45:00 +03:00
4 changed files with 170 additions and 1 deletions

View File

@@ -0,0 +1,120 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Create incident',
key: 'createIncident',
description: 'Creates an incident that informs the team.',
arguments: [
{
label: 'Brief Summary',
key: 'briefSummary',
type: 'string',
required: true,
variables: true,
description: 'A short description outlining the issue.',
},
{
label: 'Description',
key: 'description',
type: 'string',
required: false,
variables: true,
description:
'An elaborate description of the situation, offering insights into what is occurring, along with instructions to reproduce the problem.',
},
{
label: 'Requester Email',
key: 'requesterEmail',
type: 'string',
required: true,
variables: true,
description:
'This represents the email address of the individual who initiated the incident request.',
},
{
label: 'Alert Settings - Call',
key: 'alertSettingsCall',
type: 'dropdown',
required: true,
description: 'Should we call the on-call person?',
variables: true,
options: [
{ label: 'Yes', value: 'true' },
{ label: 'No', value: 'false' },
],
},
{
label: 'Alert Settings - Text',
key: 'alertSettingsText',
type: 'dropdown',
required: true,
description: 'Should we text the on-call person?',
variables: true,
options: [
{ label: 'Yes', value: 'true' },
{ label: 'No', value: 'false' },
],
},
{
label: 'Alert Settings - Email',
key: 'alertSettingsEmail',
type: 'dropdown',
required: true,
description: 'Should we email the on-call person?',
variables: true,
options: [
{ label: 'Yes', value: 'true' },
{ label: 'No', value: 'false' },
],
},
{
label: 'Alert Settings - Push Notification',
key: 'alertSettingsPushNotification',
type: 'dropdown',
required: true,
description: 'Should we send a push notification to the on-call person?',
variables: true,
options: [
{ label: 'Yes', value: 'true' },
{ label: 'No', value: 'false' },
],
},
{
label: 'Team Alert Wait Time',
key: 'teamAlertWaitTime',
type: 'string',
required: true,
variables: true,
description:
"What is the time threshold for acknowledgment before escalating to the entire team? (Specify in seconds) - Use a negative value to indicate no team alert if the on-call person doesn't respond, and use 0 for an immediate alert to the entire team.",
},
],
async run($) {
const {
briefSummary,
description,
requesterEmail,
alertSettingsCall,
alertSettingsText,
alertSettingsEmail,
alertSettingsPushNotification,
teamAlertWaitTime,
} = $.step.parameters;
const body = {
summary: briefSummary,
description,
requester_email: requesterEmail,
call: alertSettingsCall,
sms: alertSettingsText,
email: alertSettingsEmail,
push: alertSettingsPushNotification,
team_wait: teamAlertWaitTime,
};
const response = await $.http.post('/v2/incidents', body);
$.setActionItem({ raw: response.data.data });
},
});

View File

@@ -1,3 +1,5 @@
import acknowledgeIncident from './acknowledge-incident/index.js'; import acknowledgeIncident from './acknowledge-incident/index.js';
import createIncident from './create-incident/index.js';
import resolveIncident from './resolve-incident/index.js';
export default [acknowledgeIncident]; export default [acknowledgeIncident, createIncident, resolveIncident];

View File

@@ -0,0 +1,43 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Resolve incident',
key: 'resolveIncident',
description: 'Resolves an incident.',
arguments: [
{
label: 'Incident ID',
key: 'incidentId',
type: 'string',
required: true,
variables: true,
description:
'This represents the identification for an incident that requires resolution.',
},
{
label: 'Resolved by',
key: 'resolvedBy',
type: 'string',
required: false,
variables: true,
description:
"This refers to the individual's name, email, or another form of identification that the person who resolved the incident has provided.",
},
],
async run($) {
const resolvedBy = $.step.parameters.resolvedBy;
const incidentId = $.step.parameters.incidentId;
const body = {
resolved_by: resolvedBy,
};
const response = await $.http.post(
`/v2/incidents/${incidentId}/resolve`,
body
);
$.setActionItem({ raw: response.data.data });
},
});

View File

@@ -3,6 +3,10 @@ favicon: /favicons/better-stack.svg
items: items:
- name: Acknowledge incident - name: Acknowledge incident
desc: Acknowledges an incident. desc: Acknowledges an incident.
- name: Create incident
desc: Creates an incident that informs the team.
- name: Resolve incident
desc: Resolves an incident.
--- ---
<script setup> <script setup>