Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions components/bugsnag/.gitignore

This file was deleted.

50 changes: 50 additions & 0 deletions components/bugsnag/actions/create-project/create-project.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import bugsnag from "../../bugsnag.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "bugsnag-create-project",
name: "Create Project",
description: "Create a new project for a specific organization in Bugsnag. [See the documentation](https://bugsnagapiv2.docs.apiary.io/#reference/projects/projects/create-a-project-in-an-organization)",
version: "0.0.1",
type: "action",
props: {
bugsnag,
organizationId: {
propDefinition: [
bugsnag,
"organizationId",
],
},
name: {
type: "string",
label: "Project Name",
description: "The name of the project",
},
type: {
type: "string",
label: "Project Type",
description: "The new project's framework type",
options: constants.PROJECT_TYPES,
},
ignoreOldBrowsers: {
type: "boolean",
label: "Ignore Old Browsers",
description: "For javascript projects this will filter errors from older browsers",
optional: true,
},
},
async run({ $ }) {
const response = await this.bugsnag.createProject({
$,
organizationId: this.organizationId,
data: {
name: this.name,
type: this.type,
ignore_old_browsers: this.ignoreOldBrowsers,
},
});

$.export("$summary", `Created project: ${this.name}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import bugsnag from "../../bugsnag.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "bugsnag-update-error-severity",
name: "Update Error Severity",
description: "Update an the severity status of an error in Bugsnag. [See the documentation](https://bugsnagapiv2.docs.apiary.io/#reference/errors/errors/update-an-error)",
version: "0.0.1",
type: "action",
props: {
bugsnag,
organizationId: {
propDefinition: [
bugsnag,
"organizationId",
],
},
projectId: {
propDefinition: [
bugsnag,
"projectId",
(c) => ({
organizationId: c.organizationId,
}),
],
},
errorId: {
propDefinition: [
bugsnag,
"errorId",
(c) => ({
projectId: c.projectId,
}),
],
},
severity: {
type: "string",
label: "Severity",
description: "The Error's new severity. This will be reflected in the Error's overridden_severity property. This is only applicable if the override_severity option is provided.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we always pass 'override_severity', I think the last sentence in this description could be removed

Suggested change
description: "The Error's new severity. This will be reflected in the Error's overridden_severity property. This is only applicable if the override_severity option is provided.",
description: "The Error's new severity. This will be reflected in the Error's `overridden_severity` property",

options: constants.ERROR_SEVERITIES,
},
},
async run({ $ }) {
const response = await this.bugsnag.updateError({
$,
projectId: this.projectId,
errorId: this.errorId,
data: {
operation: "override_severity",
severity: this.severity,
},
});

$.export("$summary", `Updated error ${this.errorId}`);
return response;
},
};
13 changes: 0 additions & 13 deletions components/bugsnag/app/bugsnag.app.ts

This file was deleted.

198 changes: 198 additions & 0 deletions components/bugsnag/bugsnag.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "bugsnag",
propDefinitions: {
organizationId: {
type: "string",
label: "Organization ID",
description: "The ID of an organization",
async options() {
const organizations = await this.listOrganizations();
return organizations?.map(({
id: value, name: label,
}) => ({
value,
label,
})) || [];
},
},
projectId: {
type: "string",
label: "Project ID",
description: "The ID of a project",
async options({
organizationId, prevContext,
}) {
const args = {
organizationId,
returnFullResponse: true,
};
if (prevContext?.next) {
args.url = prevContext.next;
}
const {
data, headers,
} = await this.listProjects(args);
let next;
if (headers?.link) {
next = this.getNextLink(headers.link);
}
return {
options: data?.map(({
id: value, name: label,
}) => ({
value,
label,
})) || [],
context: {
next,
},
};
},
},
errorId: {
type: "string",
label: "Error ID",
description: "The ID of the error",
async options({
projectId, prevContext,
}) {
const args = {
projectId,
returnFullResponse: true,
};
if (prevContext?.next) {
args.url = prevContext.next;
}
const {
data, headers,
} = await this.listErrors(args);
let next;
if (headers?.link) {
next = this.getNextLink(headers.link);
}
return {
options: data?.map(({
id: value, message: label,
}) => ({
value,
label,
})) || [],
context: {
next,
},
};
},
},
releaseStage: {
type: "string",
label: "Release Stage",
description: "The release stage",
},
},
methods: {
_baseUrl() {
return "https://api.bugsnag.com";
},
_makeRequest({
$ = this, url, path, ...opts
}) {
return axios($, {
url: url || `${this._baseUrl()}${path}`,
headers: {
"Authorization": `token ${this.$auth.api_token}`,
},
...opts,
});
},
getNextLink(linkHeader) {
const match = linkHeader.match(/<([^>]+)>;\s*rel="next"/); // get link to next page
return match
? match[1]
: null;
},
listOrganizations(opts = {}) {
return this._makeRequest({
path: "/user/organizations",
...opts,
});
},
listProjects({
organizationId, ...opts
}) {
return this._makeRequest({
path: `/organizations/${organizationId}/projects`,
...opts,
});
},
listErrors({
projectId, ...opts
}) {
return this._makeRequest({
path: `/projects/${projectId}/errors`,
...opts,
});
},
listEvents({
projectId, ...opts
}) {
return this._makeRequest({
path: `/projects/${projectId}/events`,
...opts,
});
},
listReleases({
projectId, ...opts
}) {
return this._makeRequest({
path: `/projects/${projectId}/releases`,
...opts,
});
},
createProject({
organizationId, ...opts
}) {
return this._makeRequest({
method: "POST",
path: `/organizations/${organizationId}/projects`,
...opts,
});
},
updateError({
projectId, errorId, ...opts
}) {
return this._makeRequest({
method: "PATCH",
path: `/projects/${projectId}/errors/${errorId}`,
...opts,
});
},
async *paginate({
fn, args, max,
}) {
args = {
...args,
returnFullResponse: true,
};
let next, count = 0;
do {
const {
data, headers,
} = await fn(args);
for (const item of data) {
yield item;
if (max && ++count >= max) {
return;
}
}
next = headers?.link
? this.getNextLink(headers.link)
: false;
args.url = next;
args.params = undefined;
} while (next);
},
},
};
Loading
Loading