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 audit metrics for authenticated access #42

Merged
merged 5 commits into from
Nov 7, 2023

Conversation

Rudge
Copy link
Contributor

@Rudge Rudge commented Oct 31, 2023

What problem is this solving?

We need to monitor the access in the app, checking the graphql operations with authentication access.

How to test it?

  • Select a product
  • Add to cart
  • Create a quote
  • Use the quote
  • Clear cart

Workspace

Screenshots or example usage:

@vtex-io-docs-bot
Copy link

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

Copy link

vtex-io-ci-cd bot commented Oct 31, 2023

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

Copy link

github-actions bot commented Oct 31, 2023

Messages
📖 ❤️ Thanks!
📖

🎉 PR additions = 230, PR deletions = 98

Generated by 🚫 dangerJS against 7031d81

@Rudge Rudge marked this pull request as ready for review November 1, 2023 13:43
@Rudge Rudge requested a review from a team November 1, 2023 13:43
@Rudge Rudge changed the title Feature/b2 bteam 1433 security metrics feat: add audit metrics for authenticated access Nov 1, 2023
node/metrics/useQuote.ts Show resolved Hide resolved
}

return metric
} as UseQuoteMetric
Copy link

Choose a reason for hiding this comment

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

You had to do this cast because you made UseQuoteMetric into a class, so Typescript won't recognize an object created directly like this one as having that type, only objects created with new UseQuoteMetric. They're not 100% equivalent in the end, so Typescript is right. Better to make UseQuoteMetric a regular type or interface like I suggested further above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested with previously code, and with 'type', the tslint had some errors and there are others problems that I commented.
image

Copy link

Choose a reason for hiding this comment

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

That's just asking you to use interface instead of type. So you'd do interface UseQuoteFieldsMetric { instead of type UseQuoteFieldsMetric = {. Note that interface in Typescript is just a way of defining an object type, it's nothing like interfaces in Java or in other languages.

Copy link

Choose a reason for hiding this comment

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

type and interface are almost the same thing in Typescript, but interface allows extending from other interfaces, which helps abstract types by their superclass names and avoiding repetition. So it's usually preferred, unless you want to do some operations that only work with type (such as &).

Copy link
Contributor Author

@Rudge Rudge Nov 6, 2023

Choose a reason for hiding this comment

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

@mairatma Is it ok to use class here, as commented?

Copy link

Choose a reason for hiding this comment

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

@Rudge it works of course, and it's ok if you insist. But it feels like you're writing in a different language, it's weird for other devs reading it. Dropping the class and keeping the duplication when creating the object directly, as the code was already doing, would be more in sync with the usual JS way of coding. Classes are generally only used when you really get the benefit of having instances due to complex calculations within methods, but they're never used just to hold data like this (this is the first time I've seen it actually hehe).

It's a language thing, I know that other languages heavily use classes, but JS is the opposite. The class syntax exists, but it's very new and it's actually not implemented in the same way behind the scenes. So you'll notice that JS codebases tend to be almost functional.

@Rudge Rudge requested review from mairatma and a team November 6, 2023 15:34
Copy link

sonarqubecloud bot commented Nov 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.17) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

@Rudge Rudge merged commit c48dbdd into master Nov 7, 2023
10 checks passed
@Rudge Rudge deleted the feature/B2BTEAM-1433-security-metrics branch November 7, 2023 13:33
Copy link

vtex-io-ci-cd bot commented Nov 7, 2023

Your PR has been merged! App is being published. 🚀
Version 2.3.1 → 2.4.0

After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:

vtex deploy [email protected]

After that your app will be updated on all accounts.

For more information on the deployment process check the docs. 📖

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.

2 participants