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

fix(trading): delete suite-analytics #17459

Merged
merged 1 commit into from
Mar 7, 2025
Merged

Conversation

adderpositive
Copy link
Contributor

Description

Deleted suite-analytics from trading - not compatible with suite-native

@adderpositive adderpositive added the +Invity Related to Invity project label Mar 6, 2025
@adderpositive adderpositive requested a review from vytick March 6, 2025 16:53
@adderpositive adderpositive self-assigned this Mar 6, 2025
@adderpositive adderpositive linked an issue Mar 6, 2025 that may be closed by this pull request
6 tasks
Copy link

coderabbitai bot commented Mar 6, 2025

Walkthrough

The changes remove the dependency on the @trezor/suite-analytics package from multiple parts of the project. In the suite-common/trading/package.json, the dependency line for this package has been removed. Correspondingly, its reference has been eliminated from the tsconfig.json file in the project. In the test file (confirmTradeThunk.test.ts), all references to the analytics reporting mechanism have been updated: the previous mockAnalyticsReport spy has been replaced with a new mock function named mocktriggerAnalyticsTradeConfirmation, and associated assertions have been adjusted accordingly. In the main trade confirmation file (confirmTradeThunk.ts), the function signature has been modified to include a new property (triggerAnalyticsTradeConfirmation) in the props type, and the direct use of the analytics module’s report method has been removed in favor of calling the provided callback function.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Mar 6, 2025

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 26
  • More info

Learn more about 𝝠 Expo Github Action

Copy link
Contributor

@vytick vytick left a comment

Choose a reason for hiding this comment

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

👌 Looks good and mobile app builds again. Good job. Just a one tiny nit

@adderpositive adderpositive force-pushed the fix/trading-suite-analytics branch from 960f5d7 to 47d50cf Compare March 7, 2025 08:31
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
suite-common/trading/src/thunks/buy/__tests__/confirmTradeThunk.test.ts (2)

48-48: Fix naming convention inconsistency.

The mock function name should follow camelCase convention like other mock functions in the file.

-const mocktriggerAnalyticsTradeConfirmation = jest.fn();
+const mockTriggerAnalyticsTradeConfirmation = jest.fn();

64-64: Update mock function reference to match new name.

If you update the function name as suggested above, you'll need to update this reference as well.

-mocktriggerAnalyticsTradeConfirmation,
+mockTriggerAnalyticsTradeConfirmation,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 960f5d7 and 47d50cf.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • suite-common/trading/package.json (0 hunks)
  • suite-common/trading/src/thunks/buy/__tests__/confirmTradeThunk.test.ts (12 hunks)
  • suite-common/trading/src/thunks/buy/confirmTradeThunk.ts (2 hunks)
  • suite-common/trading/tsconfig.json (0 hunks)
💤 Files with no reviewable changes (2)
  • suite-common/trading/package.json
  • suite-common/trading/tsconfig.json
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: PR-check / node-authorizeCoinjoin cancelCoinjoinAuthorization passphrase unlockPath setBusy checkFirmwareAuthenticity keepSession cancel.test info.test resetDevice-api
  • GitHub Check: PR-check / node-override init-api-flaky
  • GitHub Check: PR-check / web-authorizeCoinjoin cancelCoinjoinAuthorization passphrase unlockPath setBusy checkFirmwareAuthenticity keepSession cancel.test info.test resetDevice-api
  • GitHub Check: PR-check / web-override init-api-flaky
  • GitHub Check: build-deploy
  • GitHub Check: build-deploy
  • GitHub Check: EAS Update
  • GitHub Check: test
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: transport-e2e-test
  • GitHub Check: build-web
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: prepare_android_test_app
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (7)
suite-common/trading/src/thunks/buy/confirmTradeThunk.ts (3)

18-18: Good addition of a function callback for analytics.

Adding a callback function for analytics reporting is a cleaner approach that decouples the trading module from the suite-analytics dependency, making it compatible with suite-native as intended by the PR.


25-31: Clean and well-structured function signature update.

The function signature has been properly updated to include the new callback parameter, maintaining consistent code style with proper destructuring.


40-40: Good replacement of direct analytics usage with callback.

The analytics reporting is now handled through the callback function, successfully removing the direct dependency on suite-analytics while maintaining the same functionality.

suite-common/trading/src/thunks/buy/__tests__/confirmTradeThunk.test.ts (4)

70-91: Well-structured test update for the no-action case.

The test case has been properly updated to use the new analytics trigger callback and verify it's not called when selectedQuote is not set.


97-126: Good test update for error handling when there's no response.

The test correctly verifies that the analytics trigger is called once even in error scenarios, which maintains consistent tracking.


129-196: Consistent test updates for all error scenarios.

All error case tests have been updated properly to use the new callback approach, ensuring thorough test coverage of the refactored code.


238-284: Good update to the success case test.

The test properly verifies that the analytics trigger is called once in the success scenario, and all other assertions remain intact.

@vytick vytick merged commit b72a510 into develop Mar 7, 2025
72 of 73 checks passed
@vytick vytick deleted the fix/trading-suite-analytics branch March 7, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
+Invity Related to Invity project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trading - code improvements
2 participants