Skip to content

Commit aced349

Browse files
committed
Adds new 'source' field to various command links for tracking hover events
(#4764, #4765, PLG-139)
1 parent 71f14d2 commit aced349

25 files changed

+275
-138
lines changed

docs/telemetry-events.md

Lines changed: 24 additions & 24 deletions
Large diffs are not rendered by default.

src/annotations/blameAnnotationProvider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
184184
await GitUri.fromUri(document.uri),
185185
position.line,
186186
document,
187+
'editor:hover',
187188
)
188189
: undefined,
189190
])
@@ -208,6 +209,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
208209
format: cfg.detailsMarkdownFormat,
209210
pullRequests: cfg.pullRequests.enabled,
210211
timeout: 250,
212+
sourceName: 'editor:hover',
211213
});
212214
}
213215
}

src/annotations/gutterBlameAnnotationProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
8080
dateFormat: cfg.dateFormat === null ? configuration.get('defaultDateFormat') : cfg.dateFormat,
8181
getBranchAndTagTips: getBranchAndTagTips,
8282
tokenOptions: tokenOptions,
83+
source: { source: 'editor:hover' },
8384
};
8485

8586
const fontOptions: BlameFontOptions = {

src/annotations/gutterChangesAnnotationProvider.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,13 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase<Chan
288288
position.line >= hunk.current.position.start - 1 &&
289289
position.line <= hunk.current.position.end - (hasMoreDeletedLines ? 0 : 1)
290290
) {
291-
const markdown = await localChangesMessage(commit, this.trackedDocument.uri, position.line, hunk);
291+
const markdown = await localChangesMessage(
292+
commit,
293+
this.trackedDocument.uri,
294+
position.line,
295+
hunk,
296+
'editor:hover',
297+
);
292298
if (markdown == null) return undefined;
293299

294300
return new Hover(

src/annotations/lineAnnotationController.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ export class LineAnnotationController implements Disposable {
238238

239239
let uncommittedOnly = true;
240240

241-
let hoverOptions: RequireSome<Parameters<typeof detailsMessage>[4], 'autolinks' | 'pullRequests'> | undefined;
241+
let hoverOptions:
242+
| RequireSome<Parameters<typeof detailsMessage>[4], 'autolinks' | 'pullRequests' | 'sourceName'>
243+
| undefined;
242244
// Live Share (vsls schemes) don't support `languages.registerHoverProvider` so we'll need to add them to the decoration directly
243245
if (editor.document.uri.scheme === Schemes.Vsls || editor.document.uri.scheme === Schemes.VslsScc) {
244246
const hoverCfg = configuration.get('hovers');
@@ -247,6 +249,7 @@ export class LineAnnotationController implements Disposable {
247249
dateFormat: configuration.get('defaultDateFormat'),
248250
format: hoverCfg.detailsMarkdownFormat,
249251
pullRequests: hoverCfg.pullRequests.enabled,
252+
sourceName: 'editor:hover',
250253
};
251254
}
252255

@@ -325,6 +328,7 @@ export class LineAnnotationController implements Disposable {
325328
getBranchAndTagTips: getBranchAndTagTips,
326329
pullRequest: pr?.value,
327330
pullRequestPendingMessage: `PR ${GlyphChars.Ellipsis}`,
331+
source: { source: 'editor:hover' },
328332
},
329333
fontOptions,
330334
cfg.scrollable,

src/api/gitlens.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export interface OpenPullRequestActionContext {
3838
readonly id: string;
3939
readonly url: string;
4040
};
41+
readonly source?: Source;
4142
}
4243

4344
export interface HoverCommandsActionContext {
@@ -58,6 +59,7 @@ export interface HoverCommandsActionContext {
5859
line: number | undefined;
5960
}
6061
| undefined;
62+
readonly source?: Source;
6163
}
6264

6365
export type ActionContext = CreatePullRequestActionContext | OpenPullRequestActionContext | HoverCommandsActionContext;

src/commands/copyShaToClipboard.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { TextEditor, Uri } from 'vscode';
22
import { env } from 'vscode';
3+
import type { Source } from '../constants.telemetry';
34
import type { Container } from '../container';
45
import { GitUri } from '../git/gitUri';
56
import { shortenRevision } from '../git/utils/revision.utils';
@@ -20,14 +21,15 @@ import {
2021

2122
export interface CopyShaToClipboardCommandArgs {
2223
sha?: string;
24+
source?: Source;
2325
}
2426

2527
@command()
2628
export class CopyShaToClipboardCommand extends ActiveEditorCommand {
27-
static createMarkdownCommandLink(sha: string): string;
29+
static createMarkdownCommandLink(sha: string, source: Source): string;
2830
static createMarkdownCommandLink(args: CopyShaToClipboardCommandArgs): string;
29-
static createMarkdownCommandLink(argsOrSha: CopyShaToClipboardCommandArgs | string): string {
30-
const args = typeof argsOrSha === 'string' ? { sha: argsOrSha } : argsOrSha;
31+
static createMarkdownCommandLink(argsOrSha: CopyShaToClipboardCommandArgs | string, source?: Source): string {
32+
const args = typeof argsOrSha === 'string' ? { sha: argsOrSha, source: source } : argsOrSha;
3133
return createMarkdownCommandLink<CopyShaToClipboardCommandArgs>('gitlens.copyShaToClipboard', args);
3234
}
3335

src/commands/diffWith.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { TextDocumentShowOptions, Uri } from 'vscode';
22
import { ViewColumn } from 'vscode';
33
import { GlyphChars } from '../constants';
4+
import type { Source } from '../constants.telemetry';
45
import type { Container } from '../container';
56
import type { DiffRange } from '../git/gitProvider';
67
import type { GitCommit } from '../git/models/commit';
@@ -30,13 +31,18 @@ export interface DiffWithCommandArgs {
3031
fromComparison?: boolean;
3132
range?: DiffRange;
3233
showOptions?: TextDocumentShowOptions;
34+
source?: Source;
3335
}
3436

3537
@command()
3638
export class DiffWithCommand extends GlCommandBase {
3739
static createMarkdownCommandLink(args: DiffWithCommandArgs): string;
38-
static createMarkdownCommandLink(commit: GitCommit, range?: DiffRange): string;
39-
static createMarkdownCommandLink(argsOrCommit: DiffWithCommandArgs | GitCommit, range?: DiffRange): string {
40+
static createMarkdownCommandLink(commit: GitCommit, range?: DiffRange, source?: Source): string;
41+
static createMarkdownCommandLink(
42+
argsOrCommit: DiffWithCommandArgs | GitCommit,
43+
range?: DiffRange,
44+
source?: Source,
45+
): string {
4046
let args: DiffWithCommandArgs | GitCommit;
4147
if (isCommit(argsOrCommit)) {
4248
const commit = argsOrCommit;
@@ -51,6 +57,7 @@ export class DiffWithCommand extends GlCommandBase {
5157
lhs: { sha: 'HEAD', uri: commit.file.uri },
5258
rhs: { sha: '', uri: commit.file.uri },
5359
range: range,
60+
source: source,
5461
};
5562
} else {
5663
args = {
@@ -59,6 +66,7 @@ export class DiffWithCommand extends GlCommandBase {
5966
lhs: { sha: commit.unresolvedPreviousSha, uri: commit.file.originalUri ?? commit.file.uri },
6067
rhs: { sha: commit.sha, uri: commit.file.uri },
6168
range: range,
69+
source: source,
6270
};
6371
}
6472
} else {

src/commands/inspect.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { TextEditor, Uri } from 'vscode';
2+
import type { Source } from '../constants.telemetry';
23
import type { Container } from '../container';
34
import { showCommitInDetailsView } from '../git/actions/commit';
45
import { GitUri } from '../git/gitUri';
@@ -20,16 +21,25 @@ import { isCommandContextViewNodeHasCommit } from './commandContext.utils';
2021

2122
export interface InspectCommandArgs {
2223
ref?: GitRevisionReference;
24+
source?: Source;
2325
}
2426

2527
@command()
2628
export class InspectCommand extends ActiveEditorCommand {
27-
static createMarkdownCommandLink(sha: string, repoPath: string): string;
29+
static createMarkdownCommandLink(sha: string, repoPath: string, source?: Source): string;
2830
static createMarkdownCommandLink(args: InspectCommandArgs): string;
29-
static createMarkdownCommandLink(argsOrSha: InspectCommandArgs | string, repoPath?: string): string {
31+
static createMarkdownCommandLink(
32+
argsOrSha: InspectCommandArgs | string,
33+
repoPath?: string,
34+
source?: Source,
35+
): string {
3036
const args =
3137
typeof argsOrSha === 'string'
32-
? { ref: createReference(argsOrSha, repoPath!, { refType: 'revision' }), repoPath: repoPath }
38+
? {
39+
ref: createReference(argsOrSha, repoPath!, { refType: 'revision' }),
40+
repoPath: repoPath,
41+
source: source,
42+
}
3343
: argsOrSha;
3444
return createMarkdownCommandLink<InspectCommandArgs>('gitlens.showCommitInView', args);
3545
}

src/commands/openCommitOnRemote.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { TextEditor, Uri } from 'vscode';
2+
import type { Source } from '../constants.telemetry';
23
import type { Container } from '../container';
34
import { GitUri } from '../git/gitUri';
45
import { RemoteResourceType } from '../git/models/remoteResource';
@@ -23,14 +24,16 @@ export interface OpenCommitOnRemoteCommandArgs {
2324
clipboard?: boolean;
2425
line?: number;
2526
sha?: string;
27+
source?: Source;
2628
}
2729

2830
@command()
2931
export class OpenCommitOnRemoteCommand extends ActiveEditorCommand {
30-
static createMarkdownCommandLink(sha: string): string;
32+
static createMarkdownCommandLink(sha: string, source: Source): string;
3133
static createMarkdownCommandLink(args: OpenCommitOnRemoteCommandArgs): string;
32-
static createMarkdownCommandLink(argsOrSha: OpenCommitOnRemoteCommandArgs | string): string {
33-
const args: OpenCommitOnRemoteCommandArgs = typeof argsOrSha === 'string' ? { sha: argsOrSha } : argsOrSha;
34+
static createMarkdownCommandLink(argsOrSha: OpenCommitOnRemoteCommandArgs | string, source?: Source): string {
35+
const args: OpenCommitOnRemoteCommandArgs =
36+
typeof argsOrSha === 'string' ? { sha: argsOrSha, source: source } : argsOrSha;
3437
return createMarkdownCommandLink<OpenCommitOnRemoteCommandArgs>('gitlens.openCommitOnRemote', args);
3538
}
3639

0 commit comments

Comments
 (0)