Skip to content

Commit 663612f

Browse files
committed
WIP: add sentry org from settings
1 parent f082725 commit 663612f

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,21 @@
2222
"editor/title": [],
2323
"commandPalette": []
2424
},
25-
"configuration": {}
25+
"configuration": {
26+
"title": "Sentry extension settings",
27+
"properties": {
28+
"sentry.organization": {
29+
"description": "Name of the Sentry organization",
30+
"type": "string",
31+
"default": ""
32+
},
33+
"sentry.projects": {
34+
"description": "List of projects collecting logs",
35+
"type": "array",
36+
"default": []
37+
}
38+
}
39+
}
2640
},
2741
"version": "0.0.0-DEVELOPMENT",
2842
"repository": {

src/settings.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The resolved and normalized settings for this extension, the result of calling resolveSettings on a raw settings
3+
* value.
4+
*
5+
* See the "contributes.configuration" field in package.json for the canonical documentation on these properties.
6+
*/
7+
export interface Settings {
8+
['sentry.organization']?: string
9+
['sentry.projects']?: []
10+
}
11+
12+
/** Returns a copy of the extension settings with values normalized and defaults applied. */
13+
export function resolveSettings(raw: Partial<Settings>): Settings {
14+
return {
15+
['sentry.organization']: raw['sentry.organization'],
16+
['sentry.projects']: raw['sentry.projects'],
17+
}
18+
}

src/sourcegraph-sentry.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { from } from 'rxjs'
22
import { filter, switchMap } from 'rxjs/operators'
33
import * as sourcegraph from 'sourcegraph'
4+
import { resolveSettings, Settings } from './settings'
45

56
const CODE_PATTERNS = [
67
/throw new Error+\([\'\"]([^\'\"]+)[\'\"]\)/gi,
@@ -9,6 +10,7 @@ const CODE_PATTERNS = [
910
]
1011

1112
const DECORATION_TYPE = sourcegraph.app.createDecorationType()
13+
const SETTINGS = resolveSettings(sourcegraph.configuration.get<Settings>().value)
1214

1315
function decorateEditor(editor: sourcegraph.CodeEditor): void {
1416
const decorations: sourcegraph.TextDocumentDecoration[] = []
@@ -50,7 +52,9 @@ export function activate(context: sourcegraph.ExtensionContext): void {
5052

5153
function buildUrl(errorQuery: string): URL {
5254
const url = new URL(
53-
'https://sentry.io/organizations/sourcegraph/issues/?project=1334031&query=is%3Aunresolved+' +
55+
'https://sentry.io/organizations/' +
56+
SETTINGS['sentry.organization'] +
57+
'/issues/?project=1334031&query=is%3Aunresolved+' +
5458
errorQuery.split(' ').join('+') +
5559
'&statsPeriod=14d'
5660
)

0 commit comments

Comments
 (0)