mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
383e522127
https://linear.app/unleash/issue/2-1232/implement-first-iteration-of-the-new-slack-app-addon This PR implements the first iteration of the new Slack App addon. Unlike the old Slack addon, this one uses a Slack App (bot) that is installed to Slack workspaces in order to post messages. This uses `@slack/web-api`, which internally uses the latest Slack API endpoints like `postMessage`. This is currently behind a flag: `slackAppAddon`. The current flow is that the Unleash Slack App is installed from whatever source: - Unleash addons page; - Direct link; - https://unleash-slack-app.vercel.app/ (temporary URL); - Slack App Directory (in the future); - Etc; After installed, we resolve the authorization to an `access_token` that the user can paste into the Unleash Slack App addon configuration form. https://github.com/Unleash/unleash/assets/14320932/6a6621b9-5b8a-4921-a279-30668be6d46c Co-authored by: @daveleek --------- Co-authored-by: David Leek <david@getunleash.io>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import Webhook from './webhook';
|
|
import SlackAddon from './slack';
|
|
import TeamsAddon from './teams';
|
|
import DatadogAddon from './datadog';
|
|
import Addon from './addon';
|
|
import { LogProvider } from '../logger';
|
|
import SlackAppAddon from './slack-app';
|
|
import { IFlagResolver } from '../types';
|
|
|
|
export interface IAddonProviders {
|
|
[key: string]: Addon;
|
|
}
|
|
|
|
export const getAddons: (args: {
|
|
getLogger: LogProvider;
|
|
unleashUrl: string;
|
|
flagResolver: IFlagResolver;
|
|
}) => IAddonProviders = ({ getLogger, unleashUrl, flagResolver }) => {
|
|
const slackAppAddonEnabled = flagResolver.isEnabled('slackAppAddon');
|
|
|
|
const slackAddon = new SlackAddon({ getLogger, unleashUrl });
|
|
|
|
if (slackAppAddonEnabled) {
|
|
slackAddon.definition.deprecated =
|
|
'This addon is deprecated. Please try the new Slack App addon instead.';
|
|
}
|
|
|
|
const addons: Addon[] = [
|
|
new Webhook({ getLogger }),
|
|
slackAddon,
|
|
new TeamsAddon({ getLogger, unleashUrl }),
|
|
new DatadogAddon({ getLogger, unleashUrl }),
|
|
];
|
|
|
|
if (slackAppAddonEnabled) {
|
|
addons.push(new SlackAppAddon({ getLogger, unleashUrl }));
|
|
}
|
|
|
|
return addons.reduce((map, addon) => {
|
|
// eslint-disable-next-line no-param-reassign
|
|
map[addon.name] = addon;
|
|
return map;
|
|
}, {});
|
|
};
|