Skip to content

Commit c7d6e34

Browse files
committed
Adds source tracking
- 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
1 parent 269c52c commit c7d6e34

File tree

32 files changed

+626
-331
lines changed

32 files changed

+626
-331
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5448,7 +5448,7 @@
54485448
"category": "GitLens"
54495449
},
54505450
{
5451-
"command": "gitlens.plus.purchase",
5451+
"command": "gitlens.plus.upgrade",
54525452
"title": "Upgrade to Pro...",
54535453
"category": "GitLens"
54545454
},
@@ -17086,7 +17086,7 @@
1708617086
},
1708717087
{
1708817088
"view": "gitlens.views.worktrees",
17089-
"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!",
17089+
"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!",
1709017090
"when": "gitlens:plus:required && gitlens:plus:state == 4"
1709117091
},
1709217092
{
@@ -17330,7 +17330,7 @@
1733017330
{
1733117331
"id": "pro-trial",
1733217332
"title": "Get Started with Pro",
17333-
"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",
17333+
"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",
1733417334
"media": {
1733517335
"markdown": "walkthroughs/welcome/pro-trial.md"
1733617336
},
@@ -17339,7 +17339,7 @@
1733917339
{
1734017340
"id": "pro-upgrade",
1734117341
"title": "Upgrade to Pro",
17342-
"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",
17342+
"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",
1734317343
"media": {
1734417344
"markdown": "walkthroughs/welcome/pro-upgrade.md"
1734517345
},

src/commands/cloudIntegrations.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import type { Source } from '../constants';
12
import { Commands } from '../constants';
23
import type { Container } from '../container';
34
import type { IssueIntegrationId } from '../plus/integrations/providers/models';
45
import { command } from '../system/command';
56
import { Command } from './base';
67

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

1717
async execute(args?: ManageCloudIntegrationsCommandArgs) {
1818
await this.container.integrations.manageCloudIntegrations(
19-
args?.source ?? 'commandPalette',
2019
args?.integrationId,
20+
args?.source ? { source: args.source, detail: args?.detail } : undefined,
2121
);
2222
}
2323
}

src/commands/gitCommands.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -875,30 +875,60 @@ export class GitCommandsCommand extends Command {
875875
return;
876876

877877
case Directive.SignIn: {
878-
const result = await Container.instance.subscription.loginOrSignUp(false);
878+
const result = await Container.instance.subscription.loginOrSignUp(false, {
879+
source: 'git-commands',
880+
detail: {
881+
action: commandsStep.command?.key,
882+
'step.title': step.title,
883+
},
884+
});
879885
resolve(result ? await commandsStep.command?.retry() : undefined);
880886
return;
881887
}
882888

883889
case Directive.StartPreview:
884-
await Container.instance.subscription.startPreviewTrial();
890+
await Container.instance.subscription.startPreviewTrial({
891+
source: 'git-commands',
892+
detail: {
893+
action: commandsStep.command?.key,
894+
'step.title': step.title,
895+
},
896+
});
885897
resolve(await commandsStep.command?.retry());
886898
return;
887899

888900
case Directive.RequiresVerification: {
889-
const result = await Container.instance.subscription.resendVerification();
901+
const result = await Container.instance.subscription.resendVerification({
902+
source: 'git-commands',
903+
detail: {
904+
action: commandsStep.command?.key,
905+
'step.title': step.title,
906+
},
907+
});
890908
resolve(result ? await commandsStep.command?.retry() : undefined);
891909
return;
892910
}
893911

894912
case Directive.StartProTrial: {
895-
const result = await Container.instance.subscription.loginOrSignUp(true);
913+
const result = await Container.instance.subscription.loginOrSignUp(true, {
914+
source: 'git-commands',
915+
detail: {
916+
action: commandsStep.command?.key,
917+
'step.title': step.title,
918+
},
919+
});
896920
resolve(result ? await commandsStep.command?.retry() : undefined);
897921
return;
898922
}
899923

900924
case Directive.RequiresPaidSubscription:
901-
void Container.instance.subscription.purchase();
925+
void Container.instance.subscription.upgrade({
926+
source: 'git-commands',
927+
detail: {
928+
action: commandsStep.command?.key,
929+
'step.title': step.title,
930+
},
931+
});
902932
resolve(undefined);
903933
return;
904934
}

src/commands/walkthroughs.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { TelemetrySources, WalkthroughSteps } from '../constants';
1+
import type { Source, Sources, WalkthroughSteps } from '../constants';
22
import { Commands } from '../constants';
33
import type { Container } from '../container';
44
import { command } from '../system/command';
@@ -11,18 +11,16 @@ export class GetStartedCommand extends Command {
1111
super(Commands.GetStarted);
1212
}
1313

14-
execute(extensionIdOrsource?: TelemetrySources) {
14+
execute(extensionIdOrsource?: Sources) {
1515
// 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
1616
const source = extensionIdOrsource !== this.container.context.extension.id ? undefined : extensionIdOrsource;
1717
openWalkthrough(this.container, source ? { source: source } : undefined);
1818
}
1919
}
2020

21-
export type OpenWalkthroughCommandArgs = {
21+
export interface OpenWalkthroughCommandArgs extends Source {
2222
step?: WalkthroughSteps | undefined;
23-
source: TelemetrySources;
24-
detail?: string;
25-
};
23+
}
2624

2725
@command()
2826
export class OpenWalkthroughCommand extends Command {
@@ -37,11 +35,11 @@ export class OpenWalkthroughCommand extends Command {
3735

3836
function openWalkthrough(container: Container, args?: OpenWalkthroughCommandArgs) {
3937
if (container.telemetry.enabled) {
40-
container.telemetry.sendEvent('walkthrough', {
41-
step: args?.step,
42-
source: args?.source ?? 'commandPalette',
43-
detail: args?.detail,
44-
});
38+
container.telemetry.sendEvent(
39+
'walkthrough',
40+
{ step: args?.step },
41+
args?.source ? { source: args.source, detail: args?.detail } : undefined,
42+
);
4543
}
4644

4745
void openWalkthroughCore(container.context.extension.id, 'welcome', args?.step, false);

src/constants.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { AttributeValue } from '@opentelemetry/api';
12
import type { AnthropicModels } from './ai/anthropicProvider';
23
import type { GeminiModels } from './ai/geminiProvider';
34
import type { OpenAIModels } from './ai/openaiProvider';
@@ -32,6 +33,7 @@ export const urls = Object.freeze({
3233
cloudPatches: 'https://gitkraken.com/solutions/cloud-patches?utm_source=gitlens-extension&utm_medium=in-app-links',
3334
launchpad: 'https://gitkraken.com/solutions/launchpad?utm_source=gitlens-extension&utm_medium=in-app-links',
3435
platform: 'https://gitkraken.com/devex?utm_source=gitlens-extension&utm_medium=in-app-links',
36+
pricing: 'https://gitkraken.com/gitlens/pricing?utm_source=gitlens-extension&utm_medium=in-app-links',
3537
proFeatures: 'https://gitkraken.com/gitlens/pro-features?utm_source=gitlens-extension&utm_medium=in-app-links',
3638
security: 'https://help.gitkraken.com/gitlens/security?utm_source=gitlens-extension&utm_medium=in-app-links',
3739
workspaces: 'https://gitkraken.com/solutions/workspaces?utm_source=gitlens-extension&utm_medium=in-app-links',
@@ -276,13 +278,13 @@ export const enum Commands {
276278
PlusLogout = 'gitlens.plus.logout',
277279
PlusManage = 'gitlens.plus.manage',
278280
PlusManageCloudIntegrations = 'gitlens.plus.cloudIntegrations.manage',
279-
PlusPurchase = 'gitlens.plus.purchase',
280281
PlusReactivateProTrial = 'gitlens.plus.reactivateProTrial',
281282
PlusResendVerification = 'gitlens.plus.resendVerification',
282283
PlusRestore = 'gitlens.plus.restore',
283284
PlusShowPlans = 'gitlens.plus.showPlans',
284285
PlusSignUp = 'gitlens.plus.signUp',
285286
PlusStartPreviewTrial = 'gitlens.plus.startPreviewTrial',
287+
PlusUpgrade = 'gitlens.plus.upgrade',
286288
PlusValidate = 'gitlens.plus.validate',
287289
QuickOpenFileHistory = 'gitlens.quickOpenFileHistory',
288290
RefreshLaunchpad = 'gitlens.launchpad.refresh',
@@ -855,22 +857,40 @@ export type TelemetryEvents =
855857
| 'repository/opened'
856858
| 'repository/visibility'
857859
| 'subscription'
860+
| 'subscription/action'
858861
| 'subscription/changed'
859862
| 'usage/track'
860863
| 'walkthrough';
861864

862-
export type TelemetrySources =
865+
export type Sources =
866+
| 'account'
867+
| 'code-suggest'
863868
| 'cloud-patches'
864869
| 'commandPalette'
870+
| 'deeplink'
871+
| 'git-commands'
872+
| 'graph'
865873
| 'home'
874+
| 'inspect'
875+
| 'inspect-overview'
876+
| 'integrations'
866877
| 'launchpad'
867878
| 'launchpad-indicator'
868879
| 'notification'
880+
| 'patchDetails'
869881
| 'prompt'
882+
| 'settings'
883+
| 'timeline'
870884
| 'trial-indicator'
885+
| 'subscription'
871886
| 'walkthrough'
872887
| 'welcome';
873888

889+
export interface Source {
890+
source: Sources;
891+
detail?: string | Record<string, AttributeValue | null | undefined>;
892+
}
893+
874894
export type AIProviders = 'anthropic' | 'gemini' | 'openai';
875895
export type AIModels<Provider extends AIProviders = AIProviders> = Provider extends 'openai'
876896
? OpenAIModels

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
236236
'activation.mode': mode?.name,
237237
...flatCfg,
238238
},
239+
undefined,
239240
startTime,
240241
endTime,
241242
);

src/plus/focus/enrichmentService.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ export class EnrichmentService implements Disposable {
114114
const scope = getLogScope();
115115

116116
try {
117-
if (!(await ensureAccount('Pinning is a Preview feature and requires an account.', this.container))) {
117+
if (
118+
!(await ensureAccount(this.container, 'Pinning is a Preview feature and requires an account.', {
119+
source: 'launchpad',
120+
detail: 'pin',
121+
}))
122+
) {
118123
throw new Error('Unable to pin item: account required');
119124
}
120125

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

159164
try {
160-
if (!(await ensureAccount('Snoozing is a Preview feature and requires an acccount.', this.container))) {
165+
if (
166+
!(await ensureAccount(this.container, 'Snoozing is a Preview feature and requires an acccount.', {
167+
source: 'launchpad',
168+
detail: 'snooze',
169+
}))
170+
) {
161171
throw new Error('Unable to snooze item: subscription required');
162172
}
163173

0 commit comments

Comments
 (0)