mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
⚡ Add self hosted support to Sentry.io Node (#965)
This commit is contained in:
parent
4192e7d3b4
commit
a5655d0352
|
@ -0,0 +1,23 @@
|
|||
import {
|
||||
ICredentialType,
|
||||
NodePropertyTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class SentryIoServerApi implements ICredentialType {
|
||||
name = 'sentryIoServerApi';
|
||||
displayName = 'Sentry.io API';
|
||||
properties = [
|
||||
{
|
||||
displayName: 'Token',
|
||||
name: 'token',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
}, {
|
||||
displayName: 'URL',
|
||||
name: 'url',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
placeholder: 'https://example.com',
|
||||
},
|
||||
];
|
||||
}
|
|
@ -17,6 +17,8 @@ import {
|
|||
export async function sentryIoApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const authentication = this.getNodeParameter('authentication', 0);
|
||||
|
||||
const version = this.getNodeParameter('sentryVersion', 0);
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
headers: {},
|
||||
method,
|
||||
|
@ -37,10 +39,22 @@ export async function sentryIoApiRequest(this: IHookFunctions | IExecuteFunction
|
|||
delete options.qs.limit;
|
||||
}
|
||||
|
||||
let credentialName;
|
||||
|
||||
try {
|
||||
if (authentication === 'accessToken') {
|
||||
|
||||
const credentials = this.getCredentials('sentryIoApi');
|
||||
if (version === 'cloud') {
|
||||
credentialName = 'sentryIoApi';
|
||||
} else {
|
||||
credentialName = 'sentryIoServerApi';
|
||||
}
|
||||
|
||||
const credentials = this.getCredentials(credentialName);
|
||||
|
||||
if (credentials?.url) {
|
||||
options.uri = `${credentials?.url}${resource}`;
|
||||
}
|
||||
|
||||
options.headers = {
|
||||
Authorization: `Bearer ${credentials?.token}`,
|
||||
|
@ -50,6 +64,7 @@ export async function sentryIoApiRequest(this: IHookFunctions | IExecuteFunction
|
|||
return this.helpers.request(options);
|
||||
|
||||
} else {
|
||||
|
||||
return await this.helpers.requestOAuth2!.call(this, 'sentryIoOAuth2Api', options);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,12 @@ import {
|
|||
sentryIoApiRequest,
|
||||
sentryApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { ICommit, IPatchSet, IRef } from './Interface';
|
||||
|
||||
import {
|
||||
ICommit,
|
||||
IPatchSet,
|
||||
IRef,
|
||||
} from './Interface';
|
||||
|
||||
export class SentryIo implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
@ -71,6 +76,9 @@ export class SentryIo implements INodeType {
|
|||
authentication: [
|
||||
'oAuth2',
|
||||
],
|
||||
sentryVersion: [
|
||||
'cloud',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -82,15 +90,55 @@ export class SentryIo implements INodeType {
|
|||
authentication: [
|
||||
'accessToken',
|
||||
],
|
||||
sentryVersion: [
|
||||
'cloud',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'sentryIoServerApi',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'accessToken',
|
||||
],
|
||||
sentryVersion: [
|
||||
'server',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Sentry Version',
|
||||
name: 'sentryVersion',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Cloud',
|
||||
value: 'cloud',
|
||||
},
|
||||
{
|
||||
name: 'Server (Self Hosted)',
|
||||
value: 'server',
|
||||
},
|
||||
],
|
||||
default: 'cloud',
|
||||
},
|
||||
{
|
||||
displayName: 'Authentication',
|
||||
name: 'authentication',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
sentryVersion: [
|
||||
'cloud',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Access Token',
|
||||
|
@ -104,6 +152,26 @@ export class SentryIo implements INodeType {
|
|||
default: 'accessToken',
|
||||
description: 'The resource to operate on.',
|
||||
},
|
||||
{
|
||||
displayName: 'Authentication',
|
||||
name: 'authentication',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
sentryVersion: [
|
||||
'server',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Access Token',
|
||||
value: 'accessToken',
|
||||
},
|
||||
],
|
||||
default: 'accessToken',
|
||||
description: 'The resource to operate on.',
|
||||
},
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
|
|
|
@ -143,6 +143,7 @@
|
|||
"dist/credentials/ShopifyApi.credentials.js",
|
||||
"dist/credentials/SalesforceOAuth2Api.credentials.js",
|
||||
"dist/credentials/SentryIoApi.credentials.js",
|
||||
"dist/credentials/SentryIoServerApi.credentials.js",
|
||||
"dist/credentials/SentryIoOAuth2Api.credentials.js",
|
||||
"dist/credentials/SlackApi.credentials.js",
|
||||
"dist/credentials/SlackOAuth2Api.credentials.js",
|
||||
|
|
Loading…
Reference in a new issue