Skip to content

Commit 9225940

Browse files
committed
get params from URI path for Sentry ext config matching and link creation
1 parent a5c2599 commit 9225940

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"patternProperties" : {
4444
"repoMatch": {
4545
"type" : "string",
46-
"description": "Regex to match repos associated to this Sentre project, e.g. github\\.com/sourcegraph/sourcegraph"
46+
"description": "Regex to match repos associated to this Sentry project, e.g. github\\.com/sourcegraph/sourcegraph"
4747
},
4848
"fileMatch": {
4949
"type" : "string",

src/sourcegraph-sentry.ts

+23
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ function decorateEditor(editor: sourcegraph.CodeEditor): void {
3939
}
4040

4141
export function activate(context: sourcegraph.ExtensionContext): void {
42+
sourcegraph.workspace.onDidOpenTextDocument.subscribe(textDocument => {
43+
const params = getParamsFromUriPath(textDocument.uri)
44+
})
45+
4246
if (sourcegraph.app.activeWindowChanges) {
4347
const activeEditor = from(sourcegraph.app.activeWindowChanges).pipe(
4448
filter((window): window is sourcegraph.Window => window !== undefined),
@@ -50,6 +54,25 @@ export function activate(context: sourcegraph.ExtensionContext): void {
5054
}
5155
}
5256

57+
/**
58+
* Extract Sentry params from Document URI necessary to
59+
* build URL to the Sentry issues stream page, if the current
60+
* Document sends log events to Sentry.
61+
*
62+
* TODO: Implement regex match of params with Sentry extension config settings.
63+
*/
64+
function getParamsFromUriPath(textDocument: string): object {
65+
const repoPattern = /github\.com\/([^\?\#]+)/gi
66+
const filePattern = /#([^\?\#\/]+)\/.*\.tsx?$/gi
67+
const repoM = repoPattern.exec(textDocument)
68+
const fileM = filePattern.exec(textDocument)
69+
const params = {
70+
repo: repoM && repoM[1],
71+
fileValidation: fileM,
72+
}
73+
return params
74+
}
75+
5376
function buildUrl(errorQuery: string): URL {
5477
const url = new URL(
5578
'https://sentry.io/organizations/' +

0 commit comments

Comments
 (0)