sitespeed.io icon indicating copy to clipboard operation
sitespeed.io copied to clipboard

Can the slack summary be sent to a generic webhook URL endpoint?

Open kmaqsudi opened this issue 4 years ago • 22 comments

is it possible to send the slack summary to a generic webhook such as the public URL provided by microsoft teams?

kmaqsudi avatar Apr 14 '21 16:04 kmaqsudi

Hi @kmaqsudi we need to create a new plugin for that, but it should not be too hard. Checkout the Matrix plugin that I guess have most functionality that is needed: https://github.com/sitespeedio/sitespeed.io/tree/main/lib/plugins/matrix

Do you have time @kmaqsudi to give It a try? I can help guide you.

soulgalore avatar Apr 14 '21 19:04 soulgalore

Yes I'll give it a try tonight and let you know how it goes. Thanks

On Wed, Apr 14, 2021, 3:41 PM Peter Hedenskog @.***> wrote:

Hi @kmaqsudi https://github.com/kmaqsudi we need to create a new plugin for that, but it should not be too hard. Checkout the Matrix plugin that I guess have most functionality that is needed: https://github.com/sitespeedio/sitespeed.io/tree/main/lib/plugins/matrix

Do you have time @kmaqsudi https://github.com/kmaqsudi to give It a try? I can help guide you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sitespeedio/sitespeed.io/issues/3347#issuecomment-819783167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZTSQIDHD3TEB3VSFFEY3TIXVUXANCNFSM425XTFBQ .

kmaqsudi avatar Apr 14 '21 21:04 kmaqsudi

was not able to get it working

kmaqsudi avatar Apr 26 '21 14:04 kmaqsudi

Is there any blog available to use custom generic webhook endpoint?

ganeshcpote avatar Apr 29 '21 15:04 ganeshcpote

@kmaqsudi let me have a go tomorrow. I'll start with a simple example and then maybe you can verify that it works for you and then we can add more functionality? For my use case I need only the URL of the result.

soulgalore avatar May 03 '21 19:05 soulgalore

@ganeshcpote You mean blog how to use it from sitespeed.io? No not right now, but let me give it a try to see if I can add the functionality first and then some documentation.

soulgalore avatar May 03 '21 19:05 soulgalore

Sounds good. Thanks Peter.

On Mon, May 3, 2021, 3:40 PM Peter Hedenskog @.***> wrote:

@kmaqsudi https://github.com/kmaqsudi let me have a go tomorrow. I'll start with a simple example and then maybe you can verify that it works for you and then we can add more functionality? For my use case I need only the URL of the result.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sitespeedio/sitespeed.io/issues/3347#issuecomment-831486635, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZTSVNV6GMASNDP3TEZ2TTL33ZXANCNFSM425XTFBQ .

kmaqsudi avatar May 03 '21 19:05 kmaqsudi

@soulgalore for reference, this is what i'm trying to have the output of the sitespeed jobs go to with a link to the summary (same as what you do today for slack).

https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using

kmaqsudi avatar May 04 '21 11:05 kmaqsudi

@ganeshcpote You mean blog how to use it from sitespeed.io? No not right now, but let me give it a try to see if I can add the functionality first and then some documentation.

Thanks @soulgalore .. I will wait for your response since this is something very interesting and want to use this for my most of the use cases

ganeshcpote avatar May 04 '21 12:05 ganeshcpote

Hi @kmaqsudi is it easy for you to test a branch? https://github.com/sitespeedio/sitespeed.io/tree/webhook ?

I've made it as simple as possible for now and I've only tested it with https://requestbin.net

I've tested it like this: bin/sitespeed.js --webhook.url http://requestbin.net/r/ffx4mgqy https://www.sitespeed.io -n 1 --resultBaseURL https://myfiles.com/ It will post a JSON that looks like {"text": "url"} and you can your own parameters like this: bin/sitespeed.js --webhook.url http://requestbin.net/r/ffx4mgqy --webhook.secret "my secret" https://www.sitespeed.io -n 1 --resultBaseURL https://myfiles.com/

and the post will be: {"text": "url", "secret": "my secret"}

Let me know how it works out for you + what's the best formatting, is it markdown?

soulgalore avatar May 05 '21 08:05 soulgalore

Hi @soulgalore, is this webhook feature released for use?

ganeshcpote avatar May 11 '21 10:05 ganeshcpote

No @ganeshcpote I need someone to try it first.

soulgalore avatar May 11 '21 19:05 soulgalore

Hi @soulgalore, where do I find the docker container image for this webhook branch? I want to try this tomorrow with some of the use cases I have on this.

ganeshcpote avatar May 18 '21 18:05 ganeshcpote

Hi @ganeshcpote , cool, we auto build every branch so you can try the container: sitespeedio/sitespeed.io-autobuild:webhook

soulgalore avatar May 19 '21 06:05 soulgalore

Hi @ganeshcpote , cool, we auto build every branch so you can try the container: sitespeedio/sitespeed.io-autobuild:webhook

Hi @soulgalore, I was trying with my Jenkins generic webhook and it looks like port number is hardcoded in the file https://github.com/sitespeedio/sitespeed.io/blob/webhook/lib/plugins/webhook/send.js (line no: 13). We need to change the logic to get it from URL instead of. I will try with https://requestbin.net and post you the response

image

ganeshcpote avatar May 19 '21 08:05 ganeshcpote

Hi @soulgalore, I was able to successfully test this feature which sent the report URL through webhook.

Is there any chance to optimize this feature to include the following :

  • port number to be parameterized
  • send json formatted report to webhook (as additional storage if someone wants to read the json and store in their own database)

ganeshcpote avatar May 20 '21 10:05 ganeshcpote

Hi @ganeshcpote I've fixed the port so it takes it from the URL, it will take X minutes before the container is rebuilt.

About what to send: not sure about what to send, but at least I should start by doing it configurable so you can choose. Lets see if I can find some time this weekend to start doing that.

soulgalore avatar May 21 '21 12:05 soulgalore

Good start Peter. If the exact same summary as the default slack one can be sent, it would be amazing

On Fri, May 21, 2021, 8:05 AM Peter Hedenskog @.***> wrote:

Hi @ganeshcpote https://github.com/ganeshcpote I've fixed the port so it takes it from the URL, it will take X minutes before the container is rebuilt.

About what to send: not sure about what to send, but at least I should start by doing it configurable so you can choose. Lets see if I can find some time this weekend to start doing that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sitespeedio/sitespeed.io/issues/3347#issuecomment-845903505, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZTSXQJZ5K2AWA7A5EBYLTOZECBANCNFSM425XTFBQ .

kmaqsudi avatar May 21 '21 12:05 kmaqsudi

So I got stuck with this. I'm working on branch where you can configure if the message will be HTML/Markdown or plain text. I hope to be able to push that late this week.

soulgalore avatar Jun 15 '21 12:06 soulgalore

Thanks Peter. That is great news

On Tue, Jun 15, 2021, 8:03 AM Peter Hedenskog @.***> wrote:

So I got stuck with this. I'm working on branch where you can configure if the message will be HTML/Markdown or plain text. I hope to be able to push that late this week.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sitespeedio/sitespeed.io/issues/3347#issuecomment-861439942, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZTSQ3AYZIHRWRCJVOBY3TS46QXANCNFSM425XTFBQ .

kmaqsudi avatar Jun 15 '21 15:06 kmaqsudi

I pushed a couple of changes today and it would be great if someone can help me try them out and fine-tune the output. I tried first using pug to generate different output (html/markdown/text) to separate the code from the look but no luck.

I used https://webhook.site to try it out it would be great to test them in a real env. I haven't tested all different usecases yet so there are a lot that can be tuned.

Either you checkout the branch webhook and run directly from there: bin/sitespeed.js https://www.sitespeed.io --webhook.url https://webhook.site/XXXXXXX -n 1 --headless --webhook.messages pageSummary --webhook.style markdown

Or if you use Docker use the container: sitespeedio/sitespeed.io-autobuild:webhook

You can choose when to send a message:

  • on errors - if something goes wrong in your test
  • budget - the budget result
  • pageSummary - when a page has finished testing. To get a good feel of what it would like you should also set resultBaseURL,

I only did minima<l styling with markdown and HTML so please feel free to fix what's broken and send PRs to that branch I'll merge them ASAP.

soulgalore avatar Jun 20 '21 17:06 soulgalore

I totally forgot about this. I updated the branch and made a PR in https://github.com/sitespeedio/sitespeed.io/pull/4045

soulgalore avatar Dec 29 '23 06:12 soulgalore