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

PDE-5636 feat(cli): include extra fields for analytics #939

Merged
merged 10 commits into from
Dec 30, 2024

Conversation

Natay
Copy link
Contributor

@Natay Natay commented Dec 20, 2024

This pull request expands the analytics functionality in the Zapier CLI by updating the way arguments are recorded and adding additional information to the analytics payload.

Changes

  • Updated analytics.js:

    • Included app_id in the analytics payload, which is fetched from the linked app configuration OR integrationid" in arguments since some commands ( like "zapier convert" ) won't have a linked app directory when called.
  • Updated ZapierBaseCommand.js:

    • Change Object.keys(this.args) to this.args. This allows us to later capture app ID argument value based on the name and populate numArgs and parts of flags . This is not meant to capture this.args in analytics as shown in tests below

Impact

The inclusion of app ID will provide better insights into CLI usage patterns. There is another ticket to track work required for adding "arguments" effectively and safely PDE-5641

Tests

Tested the changes locally

Screenshot 2024-12-23 at 9 53 27 AM
➜  zapier-platform git:(PDE-5636_expand_analyticsBody) ✗ zapier-dev convert 216691 testing5 -v 1.0.0 --debug  
(node:72410) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
⠋ Downloading integration from Zapier  zapier:analytics sending {
  command: 'convert',
  isValidCommand: true,
  numArgs: 2,
  app_id: 216691,
  flags: { version: '1.0.0', debug: true },
  cliVersion: '16.0.0',
  os: 'darwin',
  sendUserId: true
} +0ms
⠙ Downloading integration from Zapier  zapier:api >> POST undefined +0ms
  zapier:api >> {"command":"convert","isValidCommand":true,"numArgs":2,"app_id":216691,"flags":{"version":"1.0.0","debug":true},"cliVersion":"16.0.0","os":"darwin"} +1ms
  zapier:api << 200 +0ms
  zapier:api <<  +0ms
  zapier:api ------------ +0ms
  zapier:analytics success: true +122ms
  zapier:api >> GET undefined +16ms
  zapier:api << 200 +0ms
  zapier:api <<  +0ms
  zapier:api ------------ +0ms
⠹ Downloading integration from Zapier  zapier:api >> GET undefined +56ms
  zapier:api << 200 +0ms
  zapier:api <<  +0ms
  zapier:api ------------ +0ms
✔ Downloading integration from Zapier
✔ Writing .env
✔ Writing package.json
✔ Writing .zapierapprc
✔ Writing index.js
✔ Writing authentication.js
✔ Writing triggers/test_key.js
✔ Writing test/triggers/test_key.test.js
✔ Copying /Users/natay/src/github.com/zapier-platform/testing5/.env
✔ Copying /Users/natay/src/github.com/zapier-platform/testing5/.gitignore
✔ Copying /Users/natay/src/github.com/zapier-platform/testing5/.zapierapprc
✔ Copying /Users/natay/src/github.com/zapier-platform/testing5/authentication.js
✔ Copying /Users/natay/src/github.com/zapier-platform/testing5/index.js
✔ Copying /Users/natay/src/github.com/zapier-platform/testing5/package.json
✔ Copying /Users/natay/src/github.com/zapier-platform/testing5/triggers/test_key.js
✔ Copying /Users/natay/src/github.com/zapier-platform/testing5/test/triggers/test_key.test.js

@Natay Natay marked this pull request as ready for review December 23, 2024 15:41
@Natay Natay requested a review from a team as a code owner December 23, 2024 15:41
eliangcs
eliangcs previously approved these changes Dec 26, 2024
Copy link
Member

@eliangcs eliangcs left a comment

Choose a reason for hiding this comment

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

I did some quick tests to make sure commands still work. And they do! Approving.

However, while testing, I noticed the debug logs print undefined request URLs.

This may be not related to this PR. But maybe you can fix it along the way? You can fix it by replacing this line:

debug(`>> ${requestOptions.method} ${requestOptions.url}`);

with:

  debug(`>> ${requestOptions.method} ${requestOptions.url || res.url}`);

Comment on lines +40 to +43
// Some commands ( like "zapier convert" ) won't have an app directory when called.
// Instead, having the app ID in the arguments.
// In this case, we fallback to using "integrationid" in arguments ( if it's there )
// and don't want to "explode" if appID is missing
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch!

@Natay
Copy link
Contributor Author

Natay commented Dec 27, 2024

Thanks for the review and help testing @eliangcs! Followed your suggestion and fixed the debug log!

@Natay Natay requested a review from eliangcs December 29, 2024 19:09
eliangcs
eliangcs previously approved these changes Dec 30, 2024
Copy link
Member

@eliangcs eliangcs left a comment

Choose a reason for hiding this comment

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

Thanks for the change! Approved.

@Natay Natay merged commit eee9c32 into main Dec 30, 2024
14 checks passed
@Natay Natay deleted the PDE-5636_expand_analyticsBody branch December 30, 2024 14:52
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