community-plugins icon indicating copy to clipboard operation
community-plugins copied to clipboard

[Plugin][Rollbar Backend] Add new assingn feature

Open angeliski opened this issue 3 years ago • 2 comments

Summary

Hey team! We are looking internaly to developer a plugin to assign ocorrences to a user in rollbar, based in some rules (like the component owner and other things in the catalog)

We did a simple PoC and works nice, but I want to know if we should develop this inside the rollbar backend plugin. WDYT?

Context

The ideia is using webhooks provides a way to teams define how this issue should be assigned (based in specif rules)

I have a general ideia how to do that:

A simple route to receive the event from rollbar and try to find the owner

 router.post("/assigne", async (request, response) => {
        logger.debug(`New Item from Rollbar! ${request.body.data.url}`);

        const rollbarData = request.body.data;
        const item = rollbarData.item as RollbarItem;
        const rollbarUserId = await rollbarCheck.findOwner(item)
        const rollbarProjectToken = recoverTokenFromProject(config, item)

        const requestOptions = {
            headers: {'X-Rollbar-Access-Token': rollbarProjectToken}
        };

        axios.patch(`https://api.rollbar.com/api/1/item/${rollbarData.item?.id}`, {
            assigned_user_id: rollbarUserId,
        }, requestOptions)

        response.status(200).send();
    })

And we have a interface to implement those rules:

export interface RollbarCheckOwner {
    id: string;
    handler: (ctx: RollbarCheckOwnerContext, rollbarItem: RollbarItem) => Promise<string | undefined>;
}

const monorepoComponentChecker: RollbarCheckOwner = {
    id: "monorepoComponentChecker",
    handler: async (ctx, rollbarItem) => {
        // find the folder where the error is raised
        // find the owner from this "component" and return rollbarUserId
    }
}

and a simple builder to declare all checkers I want

const rollbarCheck = await buildRollbarManagerContextBuilder(
      {
        logger,
        config,
        ownerChecks: [
          monorepoComponentChecker
        ]
      }
  )

I will do that, I just want to check if makes sense use the current plugin in the repository or if I should just create a internal plugin

angeliski avatar Apr 12 '22 23:04 angeliski

Totally think this or worth exploring/shipping, and actually falls line pretty well with some explorations we're doing at the moment for how optional features in backend plugins can be packaged up more neatly. Nothing to share there yet, but if this is something you end up contributing (please do :grin:), then strive to keep it neatly separated from the rest of the plugin.

API-wise there are some places where I think we can add a bit more forwards-compatibility, like having the handler return Promise<{ ownerUserId: string } | undefined> or something of that sort. Can discuss that more later on though

Rugvip avatar Apr 14 '22 11:04 Rugvip

Nice @Rugvip I will try to draft a PR so we can discuss more about those topics

angeliski avatar Apr 14 '22 12:04 angeliski

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 07 '24 12:09 github-actions[bot]