Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add org shape and dev hub id to telemetry #5939

Merged
merged 13 commits into from
Nov 12, 2024

Conversation

mingxuanzhangsfdx
Copy link
Member

What does this PR do?

This PR adds the org shape and dev hub id field to the telemetry including customEvents and exceptions.

What issues does this PR fix or reference?

@W-17148345@

Functionality Before

No fields of org shape and dev hub id.

Functionality After

fields of org shape will show up if the project is connected to an org, and dev hub id will show up if the org is scratch.

@mingxuanzhangsfdx mingxuanzhangsfdx marked this pull request as ready for review November 7, 2024 22:59
@mingxuanzhangsfdx mingxuanzhangsfdx requested a review from a team as a code owner November 7, 2024 22:59
const authInfo = await AuthInfo.create({ username });

const authInfoFields = authInfo.getFields();
return authInfoFields.instanceUrl?.includes('sandbox') || false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best way I found to identify a sandbox. I have tried other solutions such as AuthInfo.isSandBox and Org.isSandbox() but they did not work as expected. I found the sandbox instanceUrl always works for me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mingxuanzhangsfdx what do you mean by did not work as expected? Searching URLs for sandbox is not guaranteed over time.

Copy link
Member Author

@mingxuanzhangsfdx mingxuanzhangsfdx Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the isSandbox returns false when I literally use a sandbox org.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sandbox property is a bit complicated. These CLI commands

org create sandbox                │ Create a sandbox org.                                                                                                                                                                                
org delete sandbox               │ Delete a sandbox.                                                                                                                                                                                    
org refresh sandbox              │ Refresh a sandbox org using the sandbox name.                                                                                                                                                        
org resume sandbox     

and when managing sandboxes the property is only set when these commands are used.

Another option that might be used in combination with isSandbox is to query the Organization in the org in question.

It has a field called isSandbox, which is set during sandbox creation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mingxuanzhangsfdx this file should be in utils-vscode.

Also consider using a union type instead of enum.

I know it is here due to proximity to workspace utils, so maybe move the type to utils-vscode and retain logic here.

Copy link
Contributor

@CristiCanizales CristiCanizales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I was able to verify new data in appinsights ✅

const authInfo = await AuthInfo.create({ username });

const authInfoFields = authInfo.getFields();
return authInfoFields.instanceUrl?.includes('sandbox') || false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sandbox property is a bit complicated. These CLI commands

org create sandbox                │ Create a sandbox org.                                                                                                                                                                                
org delete sandbox               │ Delete a sandbox.                                                                                                                                                                                    
org refresh sandbox              │ Refresh a sandbox org using the sandbox name.                                                                                                                                                        
org resume sandbox     

and when managing sandboxes the property is only set when these commands are used.

Another option that might be used in combination with isSandbox is to query the Organization in the org in question.

It has a field called isSandbox, which is set during sandbox creation.


export const getOrgShape = async (username: string): Promise<OrgShape> => {
if (workspaceUtils.hasRootWorkspace()) {
if (await OrgAuthInfo.isAScratchOrg(username)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if it is a scratch org first since the implementation of isASandboxOrg return true when it is a scratch org.

@mingxuanzhangsfdx mingxuanzhangsfdx merged commit 39e42e7 into develop Nov 12, 2024
8 checks passed
@mingxuanzhangsfdx mingxuanzhangsfdx deleted the mz/telemetry-orgshape branch November 12, 2024 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants