Pārlūkot izejas kodu

Updates view usage tracking

main
Eric Amodio pirms 2 gadiem
vecāks
revīzija
926961cd9a
23 mainītis faili ar 56 papildinājumiem un 21 dzēšanām
  1. +1
    -2
      src/plus/webviews/graph/graphWebview.ts
  2. +1
    -1
      src/plus/webviews/timeline/timelineWebview.ts
  3. +1
    -2
      src/plus/webviews/timeline/timelineWebviewView.ts
  4. +21
    -1
      src/usageTracker.ts
  5. +1
    -1
      src/views/branchesView.ts
  6. +1
    -1
      src/views/commitsView.ts
  7. +1
    -1
      src/views/contributorsView.ts
  8. +1
    -1
      src/views/fileHistoryView.ts
  9. +1
    -1
      src/views/lineHistoryView.ts
  10. +1
    -1
      src/views/remotesView.ts
  11. +1
    -1
      src/views/repositoriesView.ts
  12. +1
    -1
      src/views/searchAndCompareView.ts
  13. +1
    -1
      src/views/stashesView.ts
  14. +1
    -1
      src/views/tagsView.ts
  15. +7
    -1
      src/views/viewBase.ts
  16. +1
    -1
      src/views/worktreesView.ts
  17. +1
    -1
      src/webviews/commitDetails/commitDetailsWebviewView.ts
  18. +1
    -1
      src/webviews/home/homeWebviewView.ts
  19. +1
    -0
      src/webviews/settings/settingsWebview.ts
  20. +4
    -0
      src/webviews/webviewBase.ts
  21. +3
    -0
      src/webviews/webviewViewBase.ts
  22. +3
    -1
      src/webviews/webviewWithConfigBase.ts
  23. +1
    -0
      src/webviews/welcome/welcomeWebview.ts

+ 1
- 2
src/plus/webviews/graph/graphWebview.ts Parādīt failu

@ -59,6 +59,7 @@ export class GraphWebview extends WebviewBase {
'graph.html',
'images/gitlens-icon.png',
'Commit Graph',
'graphWebview',
Commands.ShowGraphPage,
);
this.disposables.push(configuration.onDidChange(this.onConfigurationChanged, this), {
@ -74,8 +75,6 @@ export class GraphWebview extends WebviewBase {
override async show(column: ViewColumn = ViewColumn.Active, ...args: any[]): Promise<void> {
if (!(await ensurePlusFeaturesEnabled())) return;
void this.container.usage.track('graphWebview:shown');
if (this.container.git.repositoryCount > 1) {
const [contexts] = parseCommandContext(Commands.ShowGraphPage, undefined, ...args);
const context = Array.isArray(contexts) ? contexts[0] : contexts;

+ 1
- 1
src/plus/webviews/timeline/timelineWebview.ts Parādīt failu

@ -49,6 +49,7 @@ export class TimelineWebview extends WebviewBase {
'timeline.html',
'images/gitlens-icon.png',
'Visual File History',
'timelineWebview',
Commands.ShowTimelinePage,
);
this._context = {
@ -62,7 +63,6 @@ export class TimelineWebview extends WebviewBase {
override async show(column: ViewColumn = ViewColumn.Beside, ...args: any[]): Promise<void> {
if (!(await ensurePlusFeaturesEnabled())) return;
void this.container.usage.track('timelineWebview:shown');
return super.show(column, ...args);
}

+ 1
- 2
src/plus/webviews/timeline/timelineWebviewView.ts Parādīt failu

@ -43,7 +43,7 @@ export class TimelineWebviewView extends WebviewViewBase {
private _pendingContext: Partial<Context> | undefined;
constructor(container: Container) {
super(container, 'gitlens.views.timeline', 'timeline.html', 'Visual File History');
super(container, 'gitlens.views.timeline', 'timeline.html', 'Visual File History', 'timelineView');
this._context = {
uri: undefined,
@ -57,7 +57,6 @@ export class TimelineWebviewView extends WebviewViewBase {
override async show(options?: { preserveFocus?: boolean | undefined }): Promise<void> {
if (!(await ensurePlusFeaturesEnabled())) return;
void this.container.usage.track('timelineView:shown');
return super.show(options);
}

+ 21
- 1
src/usageTracker.ts Parādīt failu

@ -8,7 +8,27 @@ export interface TrackedUsage {
firstUsedAt: number;
lastUsedAt: number;
}
export type TrackedUsageKeys = 'graphWebview:shown' | 'timelineWebview:shown' | 'timelineView:shown';
export type TrackedUsageFeatures =
| 'branchesView'
| 'commitDetailsView'
| 'commitsView'
| 'contributorsView'
| 'fileHistoryView'
| 'graphWebview'
| 'homeView'
| 'lineHistoryView'
| 'remotesView'
| 'repositoriesView'
| 'stashesView'
| 'settingsWebview'
| 'searchAndCompareView'
| 'tagsView'
| 'timelineWebview'
| 'timelineView'
| 'welcomeWebview'
| 'workspaceView';
export type TrackedUsageKeys = `${TrackedUsageFeatures}:shown`;
export type UsageChangeEvent = {
/**

+ 1
- 1
src/views/branchesView.ts Parādīt failu

@ -97,7 +97,7 @@ export class BranchesView extends ViewBase
protected readonly configKey = 'branches';
constructor(container: Container) {
super('gitlens.views.branches', 'Branches', container);
super(container, 'gitlens.views.branches', 'Branches', 'branchesView');
}
override get canReveal(): boolean {

+ 1
- 1
src/views/commitsView.ts Parādīt failu

@ -178,7 +178,7 @@ export class CommitsView extends ViewBase {
protected readonly configKey = 'commits';
constructor(container: Container) {
super('gitlens.views.commits', 'Commits', container);
super(container, 'gitlens.views.commits', 'Commits', 'commitsView');
this.disposables.push(container.usage.onDidChange(this.onUsageChanged, this));
}

+ 1
- 1
src/views/contributorsView.ts Parādīt failu

@ -115,7 +115,7 @@ export class ContributorsView extends ViewBase
protected readonly configKey = 'contributors';
constructor(container: Container) {
super('gitlens.views.contributors', 'Contributors', container);
super(container, 'gitlens.views.contributors', 'Contributors', 'contributorsView');
}
override get canReveal(): boolean {

+ 1
- 1
src/views/fileHistoryView.ts Parādīt failu

@ -20,7 +20,7 @@ export class FileHistoryView extends ViewBase
private _followEditor: boolean = true;
constructor(container: Container) {
super('gitlens.views.fileHistory', 'File History', container);
super(container, 'gitlens.views.fileHistory', 'File History', 'fileHistoryView');
void setContext(ContextKeys.ViewsFileHistoryCursorFollowing, this._followCursor);
void setContext(ContextKeys.ViewsFileHistoryEditorFollowing, this._followEditor);

+ 1
- 1
src/views/lineHistoryView.ts Parādīt failu

@ -15,7 +15,7 @@ export class LineHistoryView extends ViewBase
protected readonly configKey = 'lineHistory';
constructor(container: Container) {
super('gitlens.views.lineHistory', 'Line History', container);
super(container, 'gitlens.views.lineHistory', 'Line History', 'lineHistoryView');
void setContext(ContextKeys.ViewsLineHistoryEditorFollowing, true);
}

+ 1
- 1
src/views/remotesView.ts Parādīt failu

@ -97,7 +97,7 @@ export class RemotesView extends ViewBase {
protected readonly configKey = 'remotes';
constructor(container: Container) {
super('gitlens.views.remotes', 'Remotes', container);
super(container, 'gitlens.views.remotes', 'Remotes', 'remotesView');
}
override get canReveal(): boolean {

+ 1
- 1
src/views/repositoriesView.ts Parādīt failu

@ -44,7 +44,7 @@ export class RepositoriesView extends ViewBase
protected readonly configKey = 'repositories';
constructor(container: Container) {
super('gitlens.views.repositories', 'Repositories', container);
super(container, 'gitlens.views.repositories', 'Repositories', 'repositoriesView');
}
private _onDidChangeAutoRefresh = new EventEmitter<void>();

+ 1
- 1
src/views/searchAndCompareView.ts Parādīt failu

@ -247,7 +247,7 @@ export class SearchAndCompareView extends ViewBase
protected readonly configKey = 'searchAndCompare';
constructor(container: Container) {
super('gitlens.views.searchAndCompare', 'Search & Compare', container);
super(container, 'gitlens.views.searchAndCompare', 'Search & Compare', 'searchAndCompareView');
void setContext(ContextKeys.ViewsSearchAndCompareKeepResults, this.keepResults);
}

+ 1
- 1
src/views/stashesView.ts Parādīt failu

@ -85,7 +85,7 @@ export class StashesView extends ViewBase {
protected readonly configKey = 'stashes';
constructor(container: Container) {
super('gitlens.views.stashes', 'Stashes', container);
super(container, 'gitlens.views.stashes', 'Stashes', 'stashesView');
}
override get canReveal(): boolean {

+ 1
- 1
src/views/tagsView.ts Parādīt failu

@ -85,7 +85,7 @@ export class TagsView extends ViewBase {
protected readonly configKey = 'tags';
constructor(container: Container) {
super('gitlens.views.tags', 'Tags', container);
super(container, 'gitlens.views.tags', 'Tags', 'tagsView');
}
override get canReveal(): boolean {

+ 7
- 1
src/views/viewBase.ts Parādīt failu

@ -33,6 +33,7 @@ import { debug, getLogScope, log } from '../system/decorators/log';
import { once } from '../system/event';
import { debounce } from '../system/function';
import { cancellable, isPromise } from '../system/promise';
import type { TrackedUsageFeatures } from '../usageTracker';
import type { BranchesView } from './branchesView';
import type { CommitsView } from './commitsView';
import type { ContributorsView } from './contributorsView';
@ -109,9 +110,10 @@ export abstract class ViewBase<
private readonly _lastKnownLimits = new Map<string, number | undefined>();
constructor(
public readonly container: Container,
public readonly id: `gitlens.views.${string}`,
public readonly name: string,
public readonly container: Container,
private readonly trackingFeature: TrackedUsageFeatures,
) {
this.disposables.push(once(container.onReady)(this.onReady, this));
@ -315,6 +317,10 @@ export abstract class ViewBase<
}
protected onVisibilityChanged(e: TreeViewVisibilityChangeEvent) {
if (e.visible) {
void this.container.usage.track(`${this.trackingFeature}:shown`);
}
this._onDidChangeVisibility.fire(e);
}

+ 1
- 1
src/views/worktreesView.ts Parādīt failu

@ -96,7 +96,7 @@ export class WorktreesView extends ViewBase
protected readonly configKey = 'worktrees';
constructor(container: Container) {
super('gitlens.views.worktrees', 'Worktrees', container);
super(container, 'gitlens.views.worktrees', 'Worktrees', 'workspaceView');
this.disposables.push(
window.registerFileDecorationProvider({

+ 1
- 1
src/webviews/commitDetails/commitDetailsWebviewView.ts Parādīt failu

@ -65,7 +65,7 @@ export class CommitDetailsWebviewView extends WebviewViewBase
private _pinned = false;
constructor(container: Container) {
super(container, 'gitlens.views.commitDetails', 'commitDetails.html', 'Commit Details');
super(container, 'gitlens.views.commitDetails', 'commitDetails.html', 'Commit Details', 'commitDetailsView');
this._context = {
pinned: false,

+ 1
- 1
src/webviews/home/homeWebviewView.ts Parādīt failu

@ -12,7 +12,7 @@ import { CompletedActions, DidChangeSubscriptionNotificationType } from './proto
export class HomeWebviewView extends WebviewViewBase<State> {
constructor(container: Container) {
super(container, 'gitlens.views.home', 'home.html', 'Home');
super(container, 'gitlens.views.home', 'home.html', 'Home', 'homeView');
this.disposables.push(this.container.subscription.onDidChange(this.onSubscriptionChanged, this));
}

+ 1
- 0
src/webviews/settings/settingsWebview.ts Parādīt failu

@ -19,6 +19,7 @@ export class SettingsWebview extends WebviewWithConfigBase {
'settings.html',
'images/gitlens-icon.png',
'GitLens Settings',
'settingsWebview',
Commands.ShowSettingsPage,
);

+ 4
- 0
src/webviews/webviewBase.ts Parādīt failu

@ -5,6 +5,7 @@ import type { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { executeCommand, registerCommand } from '../system/command';
import type { TrackedUsageFeatures } from '../usageTracker';
import type { IpcMessage, IpcMessageParams, IpcNotificationType } from './protocol';
import { ExecuteCommandType, onIpc, WebviewReadyCommandType } from './protocol';
@ -33,6 +34,7 @@ export abstract class WebviewBase implements Disposable {
private readonly fileName: string,
private readonly iconPath: string,
title: string,
private readonly trackingFeature: TrackedUsageFeatures,
showCommand: Commands,
) {
this._originalTitle = this._title = title;
@ -69,6 +71,8 @@ export abstract class WebviewBase implements Disposable {
}
async show(column: ViewColumn = ViewColumn.Beside, ..._args: any[]): Promise<void> {
void this.container.usage.track(`${this.trackingFeature}:shown`);
// Only try to open beside if there is an active tab
if (column === ViewColumn.Beside && window.tabGroups.activeTabGroup.activeTab == null) {
column = ViewColumn.Active;

+ 3
- 0
src/webviews/webviewViewBase.ts Parādīt failu

@ -13,6 +13,7 @@ import type { Container } from '../container';
import { Logger } from '../logger';
import { executeCommand } from '../system/command';
import { getLogScope, log } from '../system/decorators/log';
import type { TrackedUsageFeatures } from '../usageTracker';
import type { IpcMessage, IpcMessageParams, IpcNotificationType } from './protocol';
import { ExecuteCommandType, onIpc, WebviewReadyCommandType } from './protocol';
@ -40,6 +41,7 @@ export abstract class WebviewViewBase implements
public readonly id: `gitlens.views.${string}`,
protected readonly fileName: string,
title: string,
private readonly trackingFeature: TrackedUsageFeatures,
) {
this._title = title;
this.disposables.push(window.registerWebviewViewProvider(id, this));
@ -142,6 +144,7 @@ export abstract class WebviewViewBase implements
Logger.debug(`WebviewView(${this.id}).onViewVisibilityChanged`, `visible=${visible}`);
if (visible) {
void this.container.usage.track(`${this.trackingFeature}:shown`);
await this.refresh();
}
this.onVisibilityChanged?.(visible);

+ 3
- 1
src/webviews/webviewWithConfigBase.ts Parādīt failu

@ -8,6 +8,7 @@ import { GitCommit, GitCommitIdentity } from '../git/models/commit';
import { GitFileChange, GitFileIndexStatus } from '../git/models/file';
import { PullRequest, PullRequestState } from '../git/models/pullRequest';
import { Logger } from '../logger';
import type { TrackedUsageFeatures } from '../usageTracker';
import type { IpcMessage } from './protocol';
import {
DidChangeConfigurationNotificationType,
@ -25,9 +26,10 @@ export abstract class WebviewWithConfigBase extends WebviewBase {
fileName: string,
iconPath: string,
title: string,
trackingFeature: TrackedUsageFeatures,
showCommand: Commands,
) {
super(container, id, fileName, iconPath, title, showCommand);
super(container, id, fileName, iconPath, title, trackingFeature, showCommand);
this.disposables.push(
configuration.onDidChange(this.onConfigurationChanged, this),
configuration.onDidChangeAny(this.onAnyConfigurationChanged, this),

+ 1
- 0
src/webviews/welcome/welcomeWebview.ts Parādīt failu

@ -12,6 +12,7 @@ export class WelcomeWebview extends WebviewWithConfigBase {
'welcome.html',
'images/gitlens-icon.png',
'Welcome to GitLens',
'welcomeWebview',
Commands.ShowWelcomePage,
);
}

Notiek ielāde…
Atcelt
Saglabāt