Skip to content

Enable developers to log request/response #486

@kvalenti

Description

@kvalenti

Description

I would like to log all interactions with Slack so that I can see what gets sent across the wire.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Getting the Request information is fairly easy by doing the following:

// Show Received payload
app.use(async ({ next, payload, body, client, context }) => {
    util.prettyJSON(payload, 'RECEIVED (payload): ');
    await next();
});

However, getting the Response information has been more challenging. So far, I am doing the following, which works, but probably isn't the best way:

const logSent = config => {
    util.prettyJSON(config, 'SENT: ')
    return config;
}

// Show sent payload
app.client.axios.interceptors.request.use(logSent, error => Promise.reject(error));
app.use(async ({ next, client }) => {
    if (client.fixed !== true) {
        client.axios.interceptors.request.use(logSent, error => Promise.reject(error));
        client.fixed = true;
    }
    await next();
});

I would prefer to do this at a framework level in one place, rather than in each individual listener. Is there a better way?

Reproducible in:

package version: 2.0.1

node version: v13.12.0

OS version(s): Mac 10.15.3

Steps to reproduce:

  1. Send a request to bot
  2. Send a response via .say()
  3. Send a response via api.client.[]
  4. Send a response via listener's client.[]

Expected result:

  1. Send a request to bot and log the request
  2. Send a response via .say() and log the response
  3. Send a response via api.client.[] and log the response
  4. Send a response via listener's client.[] and log the response

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionM-T: An issue where more input is needed to reach a decisionenhancementM-T: A feature request for new functionality

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions