Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@guardian/anghammarad

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guardian/anghammarad

Notification service for the Guardian's dev teams

  • 1.8.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-73.91%
Maintainers
0
Weekly downloads
 
Created
Source

Anghammarad Node Client

Anghammarad is a notification service for the Guardian's dev teams.

Usage

To use Anghammarad from your project, include its client library in your package.json.

yarn add @guardian/anghammarad or npm install --save @guardian/anghammarad

The Anghammarad client contains a function that will send a notification.

import { Anghammarad } from '@guardian/anghammarad';

const client = new Anghammarad();
client.notify({ ...parameters });

For example

import { Anghammarad, RequestedChannel } from '@guardian/anghammarad';

const client = new Anghammarad();

client.notify({
  subject: 'Hello',
  message: "Hi there, something has happened which we'd like to tell you about",
  actions: [{ url: 'https://example.com' }],
  target: { Stack: 'my-stack', Stage: 'CODE', App: 'my-app' },
  channel: RequestedChannel.Email,
  sourceSystem: 'my-monitoring-tool',
  topicArn: 'arn:aws:123',
});

Or providing the optional SNS client (more details)

import { Anghammarad, RequestedChannel } from '@guardian/anghammarad';
import { credentialsProvider, snsClient } from './aws';

const client = new Anghammarad();

client.notify({
  subject: 'Hello',
  message: "Hi there, something has happened which we'd like to tell you about",
  actions: [{ url: 'https://example.com' }],
  target: { Stack: 'my-stack', Stage: 'CODE', App: 'my-app' },
  channel: RequestedChannel.Email,
  sourceSystem: 'my-monitoring-tool',
  topicArn: 'arn:aws:123',
  client: snsClient(credentialsProvider()),
});

Parameters

keydescriptionrequiredexample
subjectThe subject line of the messageY"An example alert"
messageThe body of the messageY"This is an example alert. Please ignore"
actionsAn array of objects containing a cta and/or a urlY[{"url": "https://example.com}]
targetA target object containing one or more of Stage, Stack, App and Account numberY{Stage: "CODE"}
channelOne of the accepted channel typesY"prefer hangouts"
sourceSystemThe name of the process sending the alertY"my app"
topicArnThe ARN of the topic to which the message should be sendY"arn:aws:..."
clientAn optional SNS client to send the message with.Nhttps://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html

Channels

Anghammarad can currently notify via either email or Google chat. The channel param can be used to pass the required notification channel. The prefix prefer can be added to specify that where possible a particular channel should be used but if not, use another available channel. The RequestedChannel enum is provided with a list of available values.

SNS Client

By default, an SNS client is created when you create an Anghammarad client. You can also optionally pass in your own SNS client either when creating the Anghammarad client or when sending a message, as shown in the examples below. You may want to do this if you need to provide any custom options to the SNS client either for all of the messages from you application or for specific messages.

// Custom client on notify
import {
  Anghammarad,
  RequestedChannel,
} from "@guardian/anghammarad";
import { credentialsProvider, snsClient } from "./aws";

const client = new Anghammarad();

client.notify({
    subject: "Hello",
    message: "Hi there, something has happened which we'd like to tell you about",
    actions: [{url: "https://example.com"}],
    target: {Stack: "my-stack", Stage: "CODE", App: "my-app"},
    channel: RequestedChannel.Email,
    sourceSystem: "my-monitoring-tool",
    topicArn: "arn:aws:123",
    client: snsClient(credentialsProvider()
})
// Custom client for Anghammarad client
import { Anghammarad, RequestedChannel } from '@guardian/anghammarad';
import { credentialsProvider, snsClient } from './aws';

const client = new Anghammarad(snsClient(credentialsProvider()));

client.notify({
  subject: 'Hello',
  message: "Hi there, something has happened which we'd like to tell you about",
  actions: [{ url: 'https://example.com' }],
  target: { Stack: 'my-stack', Stage: 'CODE', App: 'my-app' },
  channel: RequestedChannel.Email,
  sourceSystem: 'my-monitoring-tool',
  topicArn: 'arn:aws:123',
});

Releasing the client

The client is published to npm as @guardian/anghammarad. You must have an npm account with 2fa enabled and be part of the guardian organisation. You can then run npm version <patch|minor|major> followed by npm publish to publish the library, enterring your OTP when prompted (issues have been encountered running yarn publish in the past so npm is recommended).

FAQs

Package last updated on 20 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc