mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-14 01:16:17 +02:00
chore: better debug logs in slack app (#7467)
Should improve the readability of our Slack App integration logs.
This commit is contained in:
parent
4c1d8dd423
commit
47b0c61670
@ -38,7 +38,9 @@ describe('SlackAppAddon', () => {
|
|||||||
const getLogger = jest.fn(() => loggerMock);
|
const getLogger = jest.fn(() => loggerMock);
|
||||||
const mockError = {
|
const mockError = {
|
||||||
code: ErrorCode.PlatformError,
|
code: ErrorCode.PlatformError,
|
||||||
data: 'Platform error message',
|
data: {
|
||||||
|
error: 'Platform error message',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const event: IEvent = {
|
const event: IEvent = {
|
||||||
@ -150,7 +152,7 @@ describe('SlackAppAddon', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(loggerMock.warn).toHaveBeenCalledWith(
|
expect(loggerMock.warn).toHaveBeenCalledWith(
|
||||||
`Error handling event ${event.type}. A platform error occurred: Platform error message`,
|
`Error handling event ${event.type}. A platform error occurred: ${JSON.stringify(mockError.data)}`,
|
||||||
expect.any(Object),
|
expect.any(Object),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -178,7 +180,7 @@ describe('SlackAppAddon', () => {
|
|||||||
|
|
||||||
expect(postMessage).toHaveBeenCalledTimes(3);
|
expect(postMessage).toHaveBeenCalledTimes(3);
|
||||||
expect(loggerMock.warn).toHaveBeenCalledWith(
|
expect(loggerMock.warn).toHaveBeenCalledWith(
|
||||||
`Error handling event ${FEATURE_ENVIRONMENT_ENABLED}. A platform error occurred: Platform error message`,
|
`Error handling event ${FEATURE_ENVIRONMENT_ENABLED}. A platform error occurred: ${JSON.stringify(mockError.data)}`,
|
||||||
expect.any(Object),
|
expect.any(Object),
|
||||||
);
|
);
|
||||||
expect(loggerMock.info).toHaveBeenCalledWith(
|
expect(loggerMock.info).toHaveBeenCalledWith(
|
||||||
|
@ -67,7 +67,9 @@ export default class SlackAppAddon extends Addon {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.logger.debug(`Found candidate channels: ${eventChannels}.`);
|
this.logger.debug(
|
||||||
|
`Found candidate channels: ${JSON.stringify(eventChannels)}.`,
|
||||||
|
);
|
||||||
|
|
||||||
if (!this.slackClient || this.accessToken !== accessToken) {
|
if (!this.slackClient || this.accessToken !== accessToken) {
|
||||||
const client = new WebClient(accessToken);
|
const client = new WebClient(accessToken);
|
||||||
@ -162,13 +164,13 @@ export default class SlackAppAddon extends Addon {
|
|||||||
if (error.code === ErrorCode.PlatformError) {
|
if (error.code === ErrorCode.PlatformError) {
|
||||||
const { data } = error as WebAPIPlatformError;
|
const { data } = error as WebAPIPlatformError;
|
||||||
this.logger.warn(
|
this.logger.warn(
|
||||||
`Error handling event ${event.type}. A platform error occurred: ${data}`,
|
`Error handling event ${event.type}. A platform error occurred: ${JSON.stringify(data)}`,
|
||||||
error,
|
error,
|
||||||
);
|
);
|
||||||
} else if (error.code === ErrorCode.RequestError) {
|
} else if (error.code === ErrorCode.RequestError) {
|
||||||
const { original } = error as WebAPIRequestError;
|
const { original } = error as WebAPIRequestError;
|
||||||
this.logger.warn(
|
this.logger.warn(
|
||||||
`Error handling event ${event.type}. A request error occurred: ${original}`,
|
`Error handling event ${event.type}. A request error occurred: ${JSON.stringify(original)}`,
|
||||||
error,
|
error,
|
||||||
);
|
);
|
||||||
} else if (error.code === ErrorCode.RateLimitedError) {
|
} else if (error.code === ErrorCode.RateLimitedError) {
|
||||||
|
Loading…
Reference in New Issue
Block a user