Skip to content

Commit

Permalink
Adds source tracking
Browse files Browse the repository at this point in the history
 - Adds source tracking to plus commands
 - Adds source tracking to gates & badges
 - Adds explicit source to telemetry methods
 - Consolidates to unified Sources & Source object
Adds subscription tracking
Consolidates Urls
  • Loading branch information
eamodio committed May 13, 2024
1 parent 269c52c commit c7d6e34
Show file tree
Hide file tree
Showing 32 changed files with 626 additions and 331 deletions.
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -5448,7 +5448,7 @@
"category": "GitLens"
},
{
"command": "gitlens.plus.purchase",
"command": "gitlens.plus.upgrade",
"title": "Upgrade to Pro...",
"category": "GitLens"
},
Expand Down Expand Up @@ -17086,7 +17086,7 @@
},
{
"view": "gitlens.views.worktrees",
"contents": "[Upgrade to Pro](command:gitlens.plus.purchase)\n\nYour Pro trial has ended. Please upgrade for full access to Worktrees and other Pro features.\nSpecial: 50% off first seat of Pro — only $4/month!",
"contents": "[Upgrade to Pro](command:gitlens.plus.upgrade)\n\nYour Pro trial has ended. Please upgrade for full access to Worktrees and other Pro features.\nSpecial: 50% off first seat of Pro — only $4/month!",
"when": "gitlens:plus:required && gitlens:plus:state == 4"
},
{
Expand Down Expand Up @@ -17330,7 +17330,7 @@
{
"id": "pro-trial",
"title": "Get Started with Pro",
"description": "During your trial, you have access to all [Pro features](https://gitkraken.com/gitlens/pro-features?utm_source=gitlens-extension&utm_medium=in-app-links) and to the full [GitKraken DevEx platform](https://gitkraken.com/devex?utm_source=gitlens-extension&utm_medium=in-app-links). Be sure to take full advantage of these powerful features.\n\n[Upgrade to Pro](command:gitlens.plus.purchase)\n\n💡Special: 50% off first seat of Pro — only $4/month!\n**Pro Features**\n$(gitlens-graph)  [Commit Graph](command:getStarted?%22visualize%22) — visualize your repository and keep track of all work in progress\n$(rocket)  [Launchpad](command:getStarted?%22launchpad%22) — stay focused and keep your team unblocked\n$(gitlens-code-suggestion)  [Code Suggest](command:getStarted?%22patchesAndSuggest%22) — free your code reviews from unnecessary restrictions\n$(gitlens-cloud-patch)  [Cloud Patches](command:getStarted?%22patchesAndSuggest%22) — easily and securely share code with your teammates\n$(gitlens-worktrees-view)  [Worktrees](command:getStarted?%22worktrees%22) — work on multiple branches simultaneously\n$(gitlens-workspaces-view)  [Workspaces](command:getStarted?%22workspaces%22) — group and manage multiple repositories together\n$(graph-scatter)  [Visual File History](command:getStarted?%22workspaces%22) — visualize the evolution of a file and quickly identify when the most impactful changes were made and by whom",
"description": "During your trial, you have access to all [Pro features](https://gitkraken.com/gitlens/pro-features?utm_source=gitlens-extension&utm_medium=in-app-links) and to the full [GitKraken DevEx platform](https://gitkraken.com/devex?utm_source=gitlens-extension&utm_medium=in-app-links). Be sure to take full advantage of these powerful features.\n\n[Upgrade to Pro](command:gitlens.plus.upgrade)\n\n💡Special: 50% off first seat of Pro — only $4/month!\n**Pro Features**\n$(gitlens-graph)  [Commit Graph](command:getStarted?%22visualize%22) — visualize your repository and keep track of all work in progress\n$(rocket)  [Launchpad](command:getStarted?%22launchpad%22) — stay focused and keep your team unblocked\n$(gitlens-code-suggestion)  [Code Suggest](command:getStarted?%22patchesAndSuggest%22) — free your code reviews from unnecessary restrictions\n$(gitlens-cloud-patch)  [Cloud Patches](command:getStarted?%22patchesAndSuggest%22) — easily and securely share code with your teammates\n$(gitlens-worktrees-view)  [Worktrees](command:getStarted?%22worktrees%22) — work on multiple branches simultaneously\n$(gitlens-workspaces-view)  [Workspaces](command:getStarted?%22workspaces%22) — group and manage multiple repositories together\n$(graph-scatter)  [Visual File History](command:getStarted?%22workspaces%22) — visualize the evolution of a file and quickly identify when the most impactful changes were made and by whom",
"media": {
"markdown": "walkthroughs/welcome/pro-trial.md"
},
Expand All @@ -17339,7 +17339,7 @@
{
"id": "pro-upgrade",
"title": "Upgrade to Pro",
"description": "Your Pro trial has ended. Please upgrade for full access to all [Pro features](https://gitkraken.com/gitlens/pro-features?utm_source=gitlens-extension&utm_medium=in-app-links) and to the full [GitKraken DevEx platform](https://gitkraken.com/devex?utm_source=gitlens-extension&utm_medium=in-app-links).\n\n[Upgrade to Pro](command:gitlens.plus.purchase)\n\n💡Special: 50% off first seat of Pro — only $4/month!\n**Pro Features**\n$(gitlens-graph)  [Commit Graph](command:getStarted?%22visualize%22) — visualize your repository and keep track of all work in progress\n$(rocket)  [Launchpad](command:getStarted?%22launchpad%22) — stay focused and keep your team unblocked\n$(gitlens-code-suggestion)  [Code Suggest](command:getStarted?%22patchesAndSuggest%22) — free your code reviews from unnecessary restrictions\n$(gitlens-cloud-patch)  [Cloud Patches](command:getStarted?%22patchesAndSuggest%22) — easily and securely share code with your teammates\n$(gitlens-worktrees-view)  [Worktrees](command:getStarted?%22worktrees%22) — work on multiple branches simultaneously\n$(gitlens-workspaces-view)  [Workspaces](command:getStarted?%22workspaces%22) — group and manage multiple repositories together\n$(graph-scatter)  [Visual File History](command:getStarted?%22workspaces%22) — visualize the evolution of a file and quickly identify when the most impactful changes were made and by whom",
"description": "Your Pro trial has ended. Please upgrade for full access to all [Pro features](https://gitkraken.com/gitlens/pro-features?utm_source=gitlens-extension&utm_medium=in-app-links) and to the full [GitKraken DevEx platform](https://gitkraken.com/devex?utm_source=gitlens-extension&utm_medium=in-app-links).\n\n[Upgrade to Pro](command:gitlens.plus.upgrade)\n\n💡Special: 50% off first seat of Pro — only $4/month!\n**Pro Features**\n$(gitlens-graph)  [Commit Graph](command:getStarted?%22visualize%22) — visualize your repository and keep track of all work in progress\n$(rocket)  [Launchpad](command:getStarted?%22launchpad%22) — stay focused and keep your team unblocked\n$(gitlens-code-suggestion)  [Code Suggest](command:getStarted?%22patchesAndSuggest%22) — free your code reviews from unnecessary restrictions\n$(gitlens-cloud-patch)  [Cloud Patches](command:getStarted?%22patchesAndSuggest%22) — easily and securely share code with your teammates\n$(gitlens-worktrees-view)  [Worktrees](command:getStarted?%22worktrees%22) — work on multiple branches simultaneously\n$(gitlens-workspaces-view)  [Workspaces](command:getStarted?%22workspaces%22) — group and manage multiple repositories together\n$(graph-scatter)  [Visual File History](command:getStarted?%22workspaces%22) — visualize the evolution of a file and quickly identify when the most impactful changes were made and by whom",
"media": {
"markdown": "walkthroughs/welcome/pro-upgrade.md"
},
Expand Down
6 changes: 3 additions & 3 deletions src/commands/cloudIntegrations.ts
@@ -1,11 +1,11 @@
import type { Source } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import type { IssueIntegrationId } from '../plus/integrations/providers/models';
import { command } from '../system/command';
import { Command } from './base';

export interface ManageCloudIntegrationsCommandArgs {
source?: 'settings' | 'account' | 'home' | 'commitDetails';
export interface ManageCloudIntegrationsCommandArgs extends Source {
integrationId?: IssueIntegrationId.Jira;
}
@command()
Expand All @@ -16,8 +16,8 @@ export class ManageCloudIntegrationsCommand extends Command {

async execute(args?: ManageCloudIntegrationsCommandArgs) {
await this.container.integrations.manageCloudIntegrations(
args?.source ?? 'commandPalette',
args?.integrationId,
args?.source ? { source: args.source, detail: args?.detail } : undefined,
);
}
}
40 changes: 35 additions & 5 deletions src/commands/gitCommands.ts
Expand Up @@ -875,30 +875,60 @@ export class GitCommandsCommand extends Command {
return;

case Directive.SignIn: {
const result = await Container.instance.subscription.loginOrSignUp(false);
const result = await Container.instance.subscription.loginOrSignUp(false, {
source: 'git-commands',
detail: {
action: commandsStep.command?.key,
'step.title': step.title,
},
});
resolve(result ? await commandsStep.command?.retry() : undefined);
return;
}

case Directive.StartPreview:
await Container.instance.subscription.startPreviewTrial();
await Container.instance.subscription.startPreviewTrial({
source: 'git-commands',
detail: {
action: commandsStep.command?.key,
'step.title': step.title,
},
});
resolve(await commandsStep.command?.retry());
return;

case Directive.RequiresVerification: {
const result = await Container.instance.subscription.resendVerification();
const result = await Container.instance.subscription.resendVerification({
source: 'git-commands',
detail: {
action: commandsStep.command?.key,
'step.title': step.title,
},
});
resolve(result ? await commandsStep.command?.retry() : undefined);
return;
}

case Directive.StartProTrial: {
const result = await Container.instance.subscription.loginOrSignUp(true);
const result = await Container.instance.subscription.loginOrSignUp(true, {
source: 'git-commands',
detail: {
action: commandsStep.command?.key,
'step.title': step.title,
},
});
resolve(result ? await commandsStep.command?.retry() : undefined);
return;
}

case Directive.RequiresPaidSubscription:
void Container.instance.subscription.purchase();
void Container.instance.subscription.upgrade({
source: 'git-commands',
detail: {
action: commandsStep.command?.key,
'step.title': step.title,
},
});
resolve(undefined);
return;
}
Expand Down
20 changes: 9 additions & 11 deletions src/commands/walkthroughs.ts
@@ -1,4 +1,4 @@
import type { TelemetrySources, WalkthroughSteps } from '../constants';
import type { Source, Sources, WalkthroughSteps } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import { command } from '../system/command';
Expand All @@ -11,18 +11,16 @@ export class GetStartedCommand extends Command {
super(Commands.GetStarted);
}

execute(extensionIdOrsource?: TelemetrySources) {
execute(extensionIdOrsource?: Sources) {
// If the extensionIdOrsource is the same as the current extension, then it came from the extension content menu in the extension view, so don't pass the source
const source = extensionIdOrsource !== this.container.context.extension.id ? undefined : extensionIdOrsource;
openWalkthrough(this.container, source ? { source: source } : undefined);
}
}

export type OpenWalkthroughCommandArgs = {
export interface OpenWalkthroughCommandArgs extends Source {
step?: WalkthroughSteps | undefined;
source: TelemetrySources;
detail?: string;
};
}

@command()
export class OpenWalkthroughCommand extends Command {
Expand All @@ -37,11 +35,11 @@ export class OpenWalkthroughCommand extends Command {

function openWalkthrough(container: Container, args?: OpenWalkthroughCommandArgs) {
if (container.telemetry.enabled) {
container.telemetry.sendEvent('walkthrough', {
step: args?.step,
source: args?.source ?? 'commandPalette',
detail: args?.detail,
});
container.telemetry.sendEvent(
'walkthrough',
{ step: args?.step },
args?.source ? { source: args.source, detail: args?.detail } : undefined,
);
}

void openWalkthroughCore(container.context.extension.id, 'welcome', args?.step, false);
Expand Down
24 changes: 22 additions & 2 deletions src/constants.ts
@@ -1,3 +1,4 @@
import type { AttributeValue } from '@opentelemetry/api';
import type { AnthropicModels } from './ai/anthropicProvider';
import type { GeminiModels } from './ai/geminiProvider';
import type { OpenAIModels } from './ai/openaiProvider';
Expand Down Expand Up @@ -32,6 +33,7 @@ export const urls = Object.freeze({
cloudPatches: 'https://gitkraken.com/solutions/cloud-patches?utm_source=gitlens-extension&utm_medium=in-app-links',
launchpad: 'https://gitkraken.com/solutions/launchpad?utm_source=gitlens-extension&utm_medium=in-app-links',
platform: 'https://gitkraken.com/devex?utm_source=gitlens-extension&utm_medium=in-app-links',
pricing: 'https://gitkraken.com/gitlens/pricing?utm_source=gitlens-extension&utm_medium=in-app-links',
proFeatures: 'https://gitkraken.com/gitlens/pro-features?utm_source=gitlens-extension&utm_medium=in-app-links',
security: 'https://help.gitkraken.com/gitlens/security?utm_source=gitlens-extension&utm_medium=in-app-links',
workspaces: 'https://gitkraken.com/solutions/workspaces?utm_source=gitlens-extension&utm_medium=in-app-links',
Expand Down Expand Up @@ -276,13 +278,13 @@ export const enum Commands {
PlusLogout = 'gitlens.plus.logout',
PlusManage = 'gitlens.plus.manage',
PlusManageCloudIntegrations = 'gitlens.plus.cloudIntegrations.manage',
PlusPurchase = 'gitlens.plus.purchase',
PlusReactivateProTrial = 'gitlens.plus.reactivateProTrial',
PlusResendVerification = 'gitlens.plus.resendVerification',
PlusRestore = 'gitlens.plus.restore',
PlusShowPlans = 'gitlens.plus.showPlans',
PlusSignUp = 'gitlens.plus.signUp',
PlusStartPreviewTrial = 'gitlens.plus.startPreviewTrial',
PlusUpgrade = 'gitlens.plus.upgrade',
PlusValidate = 'gitlens.plus.validate',
QuickOpenFileHistory = 'gitlens.quickOpenFileHistory',
RefreshLaunchpad = 'gitlens.launchpad.refresh',
Expand Down Expand Up @@ -855,22 +857,40 @@ export type TelemetryEvents =
| 'repository/opened'
| 'repository/visibility'
| 'subscription'
| 'subscription/action'
| 'subscription/changed'
| 'usage/track'
| 'walkthrough';

export type TelemetrySources =
export type Sources =
| 'account'
| 'code-suggest'
| 'cloud-patches'
| 'commandPalette'
| 'deeplink'
| 'git-commands'
| 'graph'
| 'home'
| 'inspect'
| 'inspect-overview'
| 'integrations'
| 'launchpad'
| 'launchpad-indicator'
| 'notification'
| 'patchDetails'
| 'prompt'
| 'settings'
| 'timeline'
| 'trial-indicator'
| 'subscription'
| 'walkthrough'
| 'welcome';

export interface Source {
source: Sources;
detail?: string | Record<string, AttributeValue | null | undefined>;
}

export type AIProviders = 'anthropic' | 'gemini' | 'openai';
export type AIModels<Provider extends AIProviders = AIProviders> = Provider extends 'openai'
? OpenAIModels
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Expand Up @@ -236,6 +236,7 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
'activation.mode': mode?.name,
...flatCfg,
},
undefined,
startTime,
endTime,
);
Expand Down
14 changes: 12 additions & 2 deletions src/plus/focus/enrichmentService.ts
Expand Up @@ -114,7 +114,12 @@ export class EnrichmentService implements Disposable {
const scope = getLogScope();

try {
if (!(await ensureAccount('Pinning is a Preview feature and requires an account.', this.container))) {
if (
!(await ensureAccount(this.container, 'Pinning is a Preview feature and requires an account.', {
source: 'launchpad',
detail: 'pin',
}))
) {
throw new Error('Unable to pin item: account required');
}

Expand Down Expand Up @@ -157,7 +162,12 @@ export class EnrichmentService implements Disposable {
const scope = getLogScope();

try {
if (!(await ensureAccount('Snoozing is a Preview feature and requires an acccount.', this.container))) {
if (
!(await ensureAccount(this.container, 'Snoozing is a Preview feature and requires an acccount.', {
source: 'launchpad',
detail: 'snooze',
}))
) {
throw new Error('Unable to snooze item: subscription required');
}

Expand Down

0 comments on commit c7d6e34

Please sign in to comment.