Skip to content

Commit

Permalink
Import using named reference.
Browse files Browse the repository at this point in the history
Looks like newrelic looks for a "this.agent" property.
  • Loading branch information
adunkman committed Sep 2, 2021
1 parent a4b7323 commit 27ab39c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions bot/actions/closeMessage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { incrementMetric } from "newrelic";
import newRelic from "newrelic";
import { AllMiddlewareArgs, BlockAction, ButtonAction, SlackActionMiddlewareArgs } from "@slack/bolt";

export const CLOSE_MESSAGE_ACTION_ID = "close_ephemeral_message";
Expand All @@ -7,7 +7,7 @@ export async function handleMessageClose(event: SlackActionMiddlewareArgs<BlockA
// We must acknowledge this event, or it will show as a UI error.
event.ack();

incrementMetric("Actions/messageClose");
newRelic.incrementMetric("Actions/messageClose");

await event.respond({
delete_original: true
Expand Down
4 changes: 2 additions & 2 deletions bot/actions/menuClick.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { incrementMetric } from "newrelic";
import newRelic from "newrelic";
import { AllMiddlewareArgs, BlockAction, OverflowAction, SlackActionMiddlewareArgs } from "@slack/bolt";

export const OVERFLOW_MENU_CLICK_ACTION_ID = "overflow_menu_click";
Expand All @@ -7,5 +7,5 @@ export async function handleMenuClick(event: SlackActionMiddlewareArgs<BlockActi
// We must acknowledge this event, or it will show as a UI error.
await event.ack();

incrementMetric("Actions/menuClick");
newRelic.incrementMetric("Actions/menuClick");
}
6 changes: 3 additions & 3 deletions bot/actions/message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { incrementMetric } from "newrelic";
import newRelic from "newrelic";
import { AllMiddlewareArgs, GenericMessageEvent, SlackEventMiddlewareArgs } from "@slack/bolt";
import { WebAPICallResult } from "@slack/web-api";
import { capitalize } from "../helpers/capitalize";
Expand All @@ -21,7 +21,7 @@ export async function handleMessage(event: SlackEventMiddlewareArgs<'message'> &

if (matches.length === 0) {
// This message contains only ignored items.
incrementMetric("Actions/message/ignoredTerm");
newRelic.incrementMetric("Actions/message/ignoredTerm");
return;
}

Expand All @@ -36,7 +36,7 @@ export async function handleMessage(event: SlackEventMiddlewareArgs<'message'> &
const random = Math.floor(Math.random() * trigger.alternatives.length);
const alternative = trigger.alternatives[random];
const why = (trigger.why || '').replace(/:TERM:/gi, capitalize(text));
incrementMetric(`Actions/message/term/${text.toLowerCase()}`);
newRelic.incrementMetric(`Actions/message/term/${text.toLowerCase()}`);
return `Instead of saying “${text.toLowerCase()},” how about *${alternative}*? You may be able to edit your message. ${why}`;
});

Expand Down
4 changes: 2 additions & 2 deletions bot/actions/messageEdited.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { incrementMetric } from "newrelic";
import newRelic from "newrelic";
import { AllMiddlewareArgs, GenericMessageEvent, MessageChangedEvent, SlackEventMiddlewareArgs } from "@slack/bolt";
import { config } from "../triggers/triggers";

Expand Down Expand Up @@ -43,7 +43,7 @@ export async function handleMessageEdited(event: SlackEventMiddlewareArgs<'messa
if (!message.text.match(config.allTriggersRegExp)) {
// The user has adjusted their language and it no longer matches our
// triggers.
incrementMetric("Actions/messageEdited/termRemoved");
newRelic.incrementMetric("Actions/messageEdited/termRemoved");
await event.client.reactions.remove({
name: config.emoji,
channel: messageChanged.channel,
Expand Down
8 changes: 4 additions & 4 deletions bot/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { incrementMetric } from "newrelic";
import newRelic from "newrelic";
import { App, ExpressReceiver, Installation as InstallationType, LogLevel, subtype } from "@slack/bolt";
import { Sequelize } from "sequelize";
import { InstallationFactory } from "./models/installation";
Expand Down Expand Up @@ -38,7 +38,7 @@ const receiver = new ExpressReceiver({
logLevel: LogLevel.INFO,
installationStore: {
storeInstallation: async (installation) => {
incrementMetric("InstallationStore/storeInstallation");
newRelic.incrementMetric("InstallationStore/storeInstallation");

await Installation.create({
id: installation.isEnterpriseInstall
Expand All @@ -49,7 +49,7 @@ const receiver = new ExpressReceiver({
});
},
fetchInstallation: async (query) => {
incrementMetric("InstallationStore/fetchInstallation");
newRelic.incrementMetric("InstallationStore/fetchInstallation");

const installation = await Installation.findByPk(
query.isEnterpriseInstall ? query.enterpriseId : query.teamId
Expand All @@ -58,7 +58,7 @@ const receiver = new ExpressReceiver({
return installation.installationObject as InstallationType;
},
deleteInstallation: async (query) => {
incrementMetric("InstallationStore/deleteInstallation");
newRelic.incrementMetric("InstallationStore/deleteInstallation");

const installation = await Installation.findByPk(
query.isEnterpriseInstall ? query.enterpriseId : query.teamId
Expand Down

0 comments on commit 27ab39c

Please sign in to comment.