From d2469fae0ccb86323b3c5118c057c1f111974e9a Mon Sep 17 00:00:00 2001 From: Marco Mura Date: Thu, 20 Feb 2025 22:18:08 -0800 Subject: [PATCH] change switch default to true, and add switch status to telemetry --- src/analytics.ts | 47 +++++++++---------- src/lib/analyticsApi.ts | 2 +- .../startwork/startWorkWebviewController.ts | 2 +- .../atlascode/startwork/StartWorkPage.tsx | 2 +- src/vscAnalyticsApi.ts | 4 +- src/webviews/startWorkOnIssueWebview.ts | 2 +- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/analytics.ts b/src/analytics.ts index 071e77d6..6064d167 100644 --- a/src/analytics.ts +++ b/src/analytics.ts @@ -21,7 +21,7 @@ export const Registry = { }; class AnalyticsPlatform { - private static nodeJsPlatformMapping = { + private static nodeJsPlatformMapping: Record = { aix: 'desktop', android: 'android', darwin: 'mac', @@ -107,8 +107,13 @@ export async function issueCommentEvent(site: DetailedSiteInfo): Promise { - return instanceTrackEvent(site, 'workStarted', 'issue'); +export async function issueWorkStartedEvent( + site: DetailedSiteInfo, + pushBranchToRemoteChecked: boolean, +): Promise { + const attributesObject = instanceType({}, site); + attributesObject.attributes.pushBranchToRemoteChecked = pushBranchToRemoteChecked; + return instanceTrackEvent(site, 'workStarted', 'issue', attributesObject); } export async function issueUpdatedEvent( @@ -164,7 +169,7 @@ export async function prCommentEvent(site: DetailedSiteInfo): Promise { - const attributesObject: any = instanceType({}, site); + const attributesObject = instanceType({}, site); attributesObject.attributes.source = source; return trackEvent('created', 'pullRequestComment', attributesObject); } @@ -657,33 +662,27 @@ function tenantOrNull(e: Object, tenantId?: string): T { return newObj as T; } -function instanceType(eventProps: Object, site?: DetailedSiteInfo, product?: Product): Object { - let attrs: Object | undefined = undefined; - const newObj = eventProps; +function instanceType( + eventProps: Record, + site?: DetailedSiteInfo, + product?: Product, +): Record { + eventProps.attributes = eventProps.attributes || {}; if (product) { - attrs = { hostProduct: product.name }; + eventProps.attributes.hostProduct = product.name; } if (site && !isEmptySiteInfo(site)) { - const instanceType: string = site.isCloud ? 'cloud' : 'server'; - attrs = { instanceType: instanceType, hostProduct: site.product.name }; + eventProps.attributes.instanceType = instanceType; + eventProps.attributes.hostProduct = site.product.name; } - if (attrs) { - newObj['attributes'] = { ...newObj['attributes'], ...attrs }; - } - - return newObj; + return eventProps; } -function excludeFromActivity(eventProps: Object): Object { - const newObj = eventProps; - - if (newObj['attributes']) { - newObj['attributes'] = { ...newObj['attributes'], ...{ excludeFromActivity: true } }; - } else { - Object.assign(newObj, { attributes: { excludeFromActivity: true } }); - } - return newObj; +function excludeFromActivity(eventProps: Record): Record { + eventProps.attributes = eventProps.attributes || {}; + eventProps.attributes.excludeFromActivity = true; + return eventProps; } diff --git a/src/lib/analyticsApi.ts b/src/lib/analyticsApi.ts index 32d51b76..76f5e9bb 100644 --- a/src/lib/analyticsApi.ts +++ b/src/lib/analyticsApi.ts @@ -12,7 +12,7 @@ export interface AnalyticsApi { fireIssueTransitionedEvent(site: DetailedSiteInfo, issueKey: string): Promise; fireIssueUrlCopiedEvent(): Promise; fireIssueCommentEvent(site: DetailedSiteInfo): Promise; - fireIssueWorkStartedEvent(site: DetailedSiteInfo): Promise; + fireIssueWorkStartedEvent(site: DetailedSiteInfo, pushBranchToRemoteChecked: boolean): Promise; fireIssueUpdatedEvent(site: DetailedSiteInfo, issueKey: string, fieldName: string, fieldKey: string): Promise; fireStartIssueCreationEvent(source: string, product: Product): Promise; fireBBIssueCreatedEvent(site: DetailedSiteInfo): Promise; diff --git a/src/lib/webview/controller/startwork/startWorkWebviewController.ts b/src/lib/webview/controller/startwork/startWorkWebviewController.ts index 67bc8b1b..894cfb11 100644 --- a/src/lib/webview/controller/startwork/startWorkWebviewController.ts +++ b/src/lib/webview/controller/startwork/startWorkWebviewController.ts @@ -143,7 +143,7 @@ export class StartWorkWebviewController implements WebviewController { const [transitionIssueEnabled, setTransitionIssueEnabled] = useState(true); const [branchSetupEnabled, setbranchSetupEnabled] = useState(true); - const [pushBranchEnabled, setPushBranchEnabled] = useState(false); + const [pushBranchEnabled, setPushBranchEnabled] = useState(true); const [transition, setTransition] = useState(emptyTransition); const [repository, setRepository] = useState(emptyRepoData); const [branchType, setBranchType] = useState(emptyPrefix); diff --git a/src/vscAnalyticsApi.ts b/src/vscAnalyticsApi.ts index eec8705e..ec466319 100644 --- a/src/vscAnalyticsApi.ts +++ b/src/vscAnalyticsApi.ts @@ -124,8 +124,8 @@ export class VSCAnalyticsApi implements AnalyticsApi { }); } - public async fireIssueWorkStartedEvent(site: DetailedSiteInfo): Promise { - return issueWorkStartedEvent(site).then((e) => { + public async fireIssueWorkStartedEvent(site: DetailedSiteInfo, pushBranchToRemoteChecked: boolean): Promise { + return issueWorkStartedEvent(site, pushBranchToRemoteChecked).then((e) => { this._analyticsClient.sendTrackEvent(e); }); } diff --git a/src/webviews/startWorkOnIssueWebview.ts b/src/webviews/startWorkOnIssueWebview.ts index 61288e0e..d73a0d58 100644 --- a/src/webviews/startWorkOnIssueWebview.ts +++ b/src/webviews/startWorkOnIssueWebview.ts @@ -132,7 +132,7 @@ export class StartWorkOnIssueWebview : '' }`, }); - issueWorkStartedEvent(issue.siteDetails).then((e) => { + issueWorkStartedEvent(issue.siteDetails, e.pushBranchToRemote).then((e) => { Container.analyticsClient.sendTrackEvent(e); }); } catch (e) {