-
Notifications
You must be signed in to change notification settings - Fork 274
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
chore(analytics): include project and user metadata when running commands with noProject #4915
base: main
Are you sure you want to change the base?
Conversation
4a992e6
to
e0a906f
Compare
2781a47
to
eea61e2
Compare
eea61e2
to
632004c
Compare
632004c
to
2bef65f
Compare
321e17f
to
c2ea32d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
I had a couple of comments but otherwise looks good.
this.identify({ | ||
userId: this.cloudUserId, | ||
anonymousId: anonymousUserId, | ||
traits: { | ||
userIdV2, | ||
customer: cloudUser?.organization.name, | ||
customer: cloudUser?.organizationName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of an awkward name. Should we skip this for non-enterprise?
await CloudApi.saveAuthToken({ log, globalConfigStore, tokenResponse, domain: cloudDomain }) | ||
|
||
try { | ||
cloudApi = await CloudApi.factory({ log, cloudDomain, skipLogging: true, globalConfigStore }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we already do this in the in line 92?
|
||
let projectConfig: ProjectConfig | undefined | ||
|
||
if (garden instanceof DummyGarden) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extract this to a separate function and update the control flow so that it doesn't have all these nested if statements?
We can instead return early with something like:
if (!projectConfig) {
return
}
// proceed...
c2ea32d
to
0cad985
Compare
f12ffca
to
0f564f9
Compare
…dity + minor cleanup
0f564f9
to
1d826c5
Compare
What this PR does / why we need it:
Optionally includes project and user metadata when running a command with
noProject = true
. Internally, we instantiate a DummyGarden instance which is not having project or user metadata available. In addition, we only set theenterpriseDomain
field if its defined in the project config.To achieve this there are a couple of notable changes:
userId
andorganizationName
for each associated domainDummyGarden
-instance, it tries to fetch the project name and cloud domain from the config + does a lookup of the cloud user profilenock
work nativefetch
nock/nock#2397)pendingRequests
for identify analytics events to make sending them more robustcloudDomain
when logged inenterpriseDomain
andenterpriseProjectId
when defined in the project configWhich issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: