Skip to content

Commit d2469fa

Browse files
committed
change switch default to true, and add switch status to telemetry
1 parent 2cc0178 commit d2469fa

File tree

6 files changed

+29
-30
lines changed

6 files changed

+29
-30
lines changed

src/analytics.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const Registry = {
2121
};
2222

2323
class AnalyticsPlatform {
24-
private static nodeJsPlatformMapping = {
24+
private static nodeJsPlatformMapping: Record<string, any> = {
2525
aix: 'desktop',
2626
android: 'android',
2727
darwin: 'mac',
@@ -107,8 +107,13 @@ export async function issueCommentEvent(site: DetailedSiteInfo): Promise<TrackEv
107107
return instanceTrackEvent(site, 'created', 'issueComment');
108108
}
109109

110-
export async function issueWorkStartedEvent(site: DetailedSiteInfo): Promise<TrackEvent> {
111-
return instanceTrackEvent(site, 'workStarted', 'issue');
110+
export async function issueWorkStartedEvent(
111+
site: DetailedSiteInfo,
112+
pushBranchToRemoteChecked: boolean,
113+
): Promise<TrackEvent> {
114+
const attributesObject = instanceType({}, site);
115+
attributesObject.attributes.pushBranchToRemoteChecked = pushBranchToRemoteChecked;
116+
return instanceTrackEvent(site, 'workStarted', 'issue', attributesObject);
112117
}
113118

114119
export async function issueUpdatedEvent(
@@ -164,7 +169,7 @@ export async function prCommentEvent(site: DetailedSiteInfo): Promise<TrackEvent
164169
}
165170

166171
export async function prTaskEvent(site: DetailedSiteInfo, source: string): Promise<TrackEvent> {
167-
const attributesObject: any = instanceType({}, site);
172+
const attributesObject = instanceType({}, site);
168173
attributesObject.attributes.source = source;
169174
return trackEvent('created', 'pullRequestComment', attributesObject);
170175
}
@@ -657,33 +662,27 @@ function tenantOrNull<T>(e: Object, tenantId?: string): T {
657662
return newObj as T;
658663
}
659664

660-
function instanceType(eventProps: Object, site?: DetailedSiteInfo, product?: Product): Object {
661-
let attrs: Object | undefined = undefined;
662-
const newObj = eventProps;
665+
function instanceType(
666+
eventProps: Record<string, any>,
667+
site?: DetailedSiteInfo,
668+
product?: Product,
669+
): Record<string, any> {
670+
eventProps.attributes = eventProps.attributes || {};
663671

664672
if (product) {
665-
attrs = { hostProduct: product.name };
673+
eventProps.attributes.hostProduct = product.name;
666674
}
667675

668676
if (site && !isEmptySiteInfo(site)) {
669-
const instanceType: string = site.isCloud ? 'cloud' : 'server';
670-
attrs = { instanceType: instanceType, hostProduct: site.product.name };
677+
eventProps.attributes.instanceType = instanceType;
678+
eventProps.attributes.hostProduct = site.product.name;
671679
}
672680

673-
if (attrs) {
674-
newObj['attributes'] = { ...newObj['attributes'], ...attrs };
675-
}
676-
677-
return newObj;
681+
return eventProps;
678682
}
679683

680-
function excludeFromActivity(eventProps: Object): Object {
681-
const newObj = eventProps;
682-
683-
if (newObj['attributes']) {
684-
newObj['attributes'] = { ...newObj['attributes'], ...{ excludeFromActivity: true } };
685-
} else {
686-
Object.assign(newObj, { attributes: { excludeFromActivity: true } });
687-
}
688-
return newObj;
684+
function excludeFromActivity(eventProps: Record<string, any>): Record<string, any> {
685+
eventProps.attributes = eventProps.attributes || {};
686+
eventProps.attributes.excludeFromActivity = true;
687+
return eventProps;
689688
}

src/lib/analyticsApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface AnalyticsApi {
1212
fireIssueTransitionedEvent(site: DetailedSiteInfo, issueKey: string): Promise<void>;
1313
fireIssueUrlCopiedEvent(): Promise<void>;
1414
fireIssueCommentEvent(site: DetailedSiteInfo): Promise<void>;
15-
fireIssueWorkStartedEvent(site: DetailedSiteInfo): Promise<void>;
15+
fireIssueWorkStartedEvent(site: DetailedSiteInfo, pushBranchToRemoteChecked: boolean): Promise<void>;
1616
fireIssueUpdatedEvent(site: DetailedSiteInfo, issueKey: string, fieldName: string, fieldKey: string): Promise<void>;
1717
fireStartIssueCreationEvent(source: string, product: Product): Promise<void>;
1818
fireBBIssueCreatedEvent(site: DetailedSiteInfo): Promise<void>;

src/lib/webview/controller/startwork/startWorkWebviewController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class StartWorkWebviewController implements WebviewController<StartWorkIs
143143
branch: msg.branchSetupEnabled ? msg.targetBranch : undefined,
144144
upstream: msg.branchSetupEnabled ? msg.upstream : undefined,
145145
});
146-
this.analytics.fireIssueWorkStartedEvent(this.initData.issue.siteDetails);
146+
this.analytics.fireIssueWorkStartedEvent(this.initData.issue.siteDetails, msg.pushBranchToRemote);
147147
} catch (e) {
148148
this.logger.error(new Error(`error executing start work action: ${e}`));
149149
this.postMessage({

src/react/atlascode/startwork/StartWorkPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const StartWorkPage: React.FunctionComponent = () => {
9595

9696
const [transitionIssueEnabled, setTransitionIssueEnabled] = useState(true);
9797
const [branchSetupEnabled, setbranchSetupEnabled] = useState(true);
98-
const [pushBranchEnabled, setPushBranchEnabled] = useState(false);
98+
const [pushBranchEnabled, setPushBranchEnabled] = useState(true);
9999
const [transition, setTransition] = useState<Transition>(emptyTransition);
100100
const [repository, setRepository] = useState<RepoData>(emptyRepoData);
101101
const [branchType, setBranchType] = useState<BranchType>(emptyPrefix);

src/vscAnalyticsApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ export class VSCAnalyticsApi implements AnalyticsApi {
124124
});
125125
}
126126

127-
public async fireIssueWorkStartedEvent(site: DetailedSiteInfo): Promise<void> {
128-
return issueWorkStartedEvent(site).then((e) => {
127+
public async fireIssueWorkStartedEvent(site: DetailedSiteInfo, pushBranchToRemoteChecked: boolean): Promise<void> {
128+
return issueWorkStartedEvent(site, pushBranchToRemoteChecked).then((e) => {
129129
this._analyticsClient.sendTrackEvent(e);
130130
});
131131
}

src/webviews/startWorkOnIssueWebview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class StartWorkOnIssueWebview
132132
: ''
133133
}</ul>`,
134134
});
135-
issueWorkStartedEvent(issue.siteDetails).then((e) => {
135+
issueWorkStartedEvent(issue.siteDetails, e.pushBranchToRemote).then((e) => {
136136
Container.analyticsClient.sendTrackEvent(e);
137137
});
138138
} catch (e) {

0 commit comments

Comments
 (0)