mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-08-04 14:37:34 +00:00
switch to sentry-electron (#232)
This commit is contained in:
parent
50364b1977
commit
69cf89c48e
18 changed files with 403 additions and 235 deletions
|
|
@ -15,7 +15,6 @@
|
|||
import * as events from 'events';
|
||||
|
||||
import * as errors from '../infrastructure/errors';
|
||||
import {SentryErrorReporter} from '../web_app/error_reporter';
|
||||
|
||||
export interface DigitalOceanDropletSpecification {
|
||||
installCommand: string;
|
||||
|
|
@ -102,7 +101,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
constructor(public accessToken: string) {}
|
||||
|
||||
public getAccount(): Promise<Account> {
|
||||
SentryErrorReporter.logInfo('Requesting account');
|
||||
console.info('Requesting account');
|
||||
return this.request<{account: Account}>('GET', 'account/').then((response) => {
|
||||
return response.account;
|
||||
});
|
||||
|
|
@ -129,7 +128,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
return new Promise((fulfill, reject) => {
|
||||
const makeRequestRecursive = () => {
|
||||
++requestCount;
|
||||
SentryErrorReporter.logInfo(`Requesting droplet creation ${requestCount}/${MAX_REQUESTS}`);
|
||||
console.info(`Requesting droplet creation ${requestCount}/${MAX_REQUESTS}`);
|
||||
this.request<{droplet: DropletInfo}>('POST', 'droplets', {
|
||||
name: dropletName,
|
||||
region,
|
||||
|
|
@ -158,12 +157,12 @@ class RestApiSession implements DigitalOceanSession {
|
|||
}
|
||||
|
||||
public deleteDroplet(dropletId: number): Promise<void> {
|
||||
SentryErrorReporter.logInfo('Requesting droplet deletion');
|
||||
console.info('Requesting droplet deletion');
|
||||
return this.request<void>('DELETE', 'droplets/' + dropletId);
|
||||
}
|
||||
|
||||
public getRegionInfo(): Promise<RegionInfo[]> {
|
||||
SentryErrorReporter.logInfo('Requesting region info');
|
||||
console.info('Requesting region info');
|
||||
return this.request<{regions: RegionInfo[]}>('GET', 'regions').then((response) => {
|
||||
return response.regions;
|
||||
});
|
||||
|
|
@ -171,7 +170,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
|
||||
// Registers a SSH key with DigitalOcean.
|
||||
private registerKey_(keyName: string, publicKeyForSSH: string): Promise<number> {
|
||||
SentryErrorReporter.logInfo('Requesting key registration');
|
||||
console.info('Requesting key registration');
|
||||
return this
|
||||
.request<{ssh_key: {id: number}}>(
|
||||
'POST', 'account/keys', {name: keyName, public_key: publicKeyForSSH})
|
||||
|
|
@ -181,7 +180,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
}
|
||||
|
||||
public getDroplet(dropletId: number): Promise<DropletInfo> {
|
||||
SentryErrorReporter.logInfo('Requesting droplet');
|
||||
console.info('Requesting droplet');
|
||||
return this.request<{droplet: DropletInfo}>('GET', 'droplets/' + dropletId).then((response) => {
|
||||
return response.droplet;
|
||||
});
|
||||
|
|
@ -194,7 +193,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
}
|
||||
|
||||
public getDropletsByTag(tag: string): Promise<DropletInfo[]> {
|
||||
SentryErrorReporter.logInfo('Requesting droplet by tag');
|
||||
console.info('Requesting droplet by tag');
|
||||
return this.request<{droplets: DropletInfo[]}>('GET', `droplets/?tag_name=${encodeURI(tag)}`)
|
||||
.then((response) => {
|
||||
return response.droplets;
|
||||
|
|
@ -202,7 +201,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
}
|
||||
|
||||
public getDroplets(): Promise<DropletInfo[]> {
|
||||
SentryErrorReporter.logInfo('Requesting droplets');
|
||||
console.info('Requesting droplets');
|
||||
return this.request<{droplets: DropletInfo[]}>('GET', 'droplets/').then((response) => {
|
||||
return response.droplets;
|
||||
});
|
||||
|
|
@ -226,7 +225,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
} else {
|
||||
// this.response is a JSON object, whose message is an error string.
|
||||
const responseJson = JSON.parse(xhr.response);
|
||||
SentryErrorReporter.logError(`DigitalOcean request failed with status ${xhr.status}`);
|
||||
console.error(`DigitalOcean request failed with status ${xhr.status}`);
|
||||
reject(new Error(
|
||||
`XHR ${responseJson.id} failed with ${xhr.status}: ${responseJson.message}`));
|
||||
}
|
||||
|
|
@ -240,7 +239,7 @@ class RestApiSession implements DigitalOceanSession {
|
|||
// DigitalOcean (this isn't so bad because application-level
|
||||
// errors, e.g. bad request parameters and even 404s, do *not* raise
|
||||
// an onerror event).
|
||||
SentryErrorReporter.logError('Failed to perform DigitalOcean request');
|
||||
console.error('Failed to perform DigitalOcean request');
|
||||
reject(new XhrError());
|
||||
};
|
||||
xhr.send(data ? JSON.stringify(data) : undefined);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue