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

All 1.3.1 dev #256

Merged
merged 12 commits into from
Jan 13, 2025
Merged

All 1.3.1 dev #256

merged 12 commits into from
Jan 13, 2025

Conversation

gouravmore
Copy link
Member

@gouravmore gouravmore commented Jan 13, 2025

Summary by CodeRabbit

Release Notes

  • Dependencies

    • Replaced telemetry SDK from @project-sunbird/telemetry-sdk to @tekdi/all-telemetry-sdk
  • New Features

    • Enhanced mechanism tracking with local storage of mechanism ID
    • Improved next button state management across mechanics components
  • Technical Improvements

    • Updated telemetry service initialization process
    • Added mechanism identification to voice analysis requests
  • Code Maintenance

    • Refined code formatting and quote consistency in telemetry service

The update focuses on improving telemetry tracking and component interaction management.

Copy link

coderabbitai bot commented Jan 13, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/App.js

Oops! Something went wrong! :(

ESLint: 7.32.0

ESLint couldn't find the config "react-app" to extend from. Please check that the name of the config is correct.

The config "react-app" was referenced from the config file in "/package.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

The pull request introduces changes to multiple files focusing on telemetry service integration and state management. The primary modifications include switching the telemetry SDK from @project-sunbird/telemetry-sdk to @tekdi/all-telemetry-sdk, updating device identification logic, and enhancing component state management. The changes affect the package configuration, application initialization, and several React components, with a particular emphasis on improving telemetry tracking and button interaction states.

Changes

File Change Summary
package.json Replaced telemetry SDK dependency from @project-sunbird/[email protected] to @tekdi/all-telemetry-sdk@^0.0.32
src/App.js Updated telemetry SDK import and initialization, modified device ID handling with visitorId
src/components/Practice/Mechanics3.jsx, src/components/Practice/Mechanics4.jsx Added isNextButtonCalled and setIsNextButtonCalled props
src/services/telementryService.js Minor formatting changes, switched to double quotes
src/utils/VoiceAnalyser.js Added mechanics_id to request body
src/views/Practice/Practice.jsx Added useEffect to store mechanism ID, introduced next button state management

Sequence Diagram

sequenceDiagram
    participant App
    participant TelemetryService
    participant LocalStorage
    participant Practice
    
    App->>LocalStorage: Retrieve/Generate visitorId
    App->>TelemetryService: Initialize(visitorId)
    Practice->>LocalStorage: Store mechanism ID
    Practice->>Mechanics: Pass next button state
    Mechanics->>VoiceAnalyser: Manage interaction state
Loading

Possibly related PRs

Finishing Touches

  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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.

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.

@gouravmore gouravmore merged commit a9a00f0 into all-1.3.1-tn-prod Jan 13, 2025
3 checks passed
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: 2

🧹 Nitpick comments (3)
src/App.js (2)

58-60: Remove commented out code.

Instead of keeping commented code, it should be removed as it can lead to confusion and technical debt. If needed, the code history can be found in version control.

- //if (!localStorage.getItem("did")) {
-   localStorage.setItem("did", visitorId);
- //}

69-71: Use optional chaining for better readability.

Replace multiple logical AND operators with optional chaining for a more concise and modern approach.

- window.telemetry &&
-   window.telemetry.syncEvents &&
-   window.telemetry.syncEvents();
+ window.telemetry?.syncEvents?.();
🧰 Tools
🪛 Biome (1.9.4)

[error] 69-71: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

src/views/Practice/Practice.jsx (1)

566-569: Consider removing the mechanism ID when empty.

Instead of storing an empty string, consider removing the item from localStorage when mechanism ID is not available. This prevents potential issues with empty string values being interpreted as valid mechanism IDs.

-  localStorage.setItem("mechanism_id", (mechanism && mechanism.id) || "");
+  if (mechanism?.id) {
+    localStorage.setItem("mechanism_id", mechanism.id);
+  } else {
+    localStorage.removeItem("mechanism_id");
+  }
🧰 Tools
🪛 Biome (1.9.4)

[error] 567-567: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4181806 and 20a0f87.

📒 Files selected for processing (7)
  • package.json (1 hunks)
  • src/App.js (2 hunks)
  • src/components/Practice/Mechanics3.jsx (2 hunks)
  • src/components/Practice/Mechanics4.jsx (4 hunks)
  • src/services/telementryService.js (2 hunks)
  • src/utils/VoiceAnalyser.js (1 hunks)
  • src/views/Practice/Practice.jsx (7 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/views/Practice/Practice.jsx

[error] 567-567: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

src/App.js

[error] 69-71: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

src/services/telementryService.js

[error] 31-31: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (10)
src/App.js (2)

11-11: LGTM: Telemetry SDK import updated.

The import statement has been correctly updated to use the new telemetry SDK.


17-22: LGTM: Device identification logic improved.

The device identification logic has been enhanced to:

  1. Accept a visitorId parameter in initService
  2. Use a consistent fallback mechanism with localStorage
src/components/Practice/Mechanics4.jsx (1)

51-52: LGTM: Next button state management props added.

The new props enhance the component's ability to manage next button state across components.

src/components/Practice/Mechanics3.jsx (1)

59-60: LGTM: Next button state management props added.

The new props are consistently added across mechanics components, maintaining a unified approach to next button state management.

src/utils/VoiceAnalyser.js (1)

365-365: LGTM: Mechanism identification added to request payload.

The mechanics_id is correctly retrieved from localStorage with a proper fallback to an empty string.

src/views/Practice/Practice.jsx (4)

897-898: LGTM!

The next button state management props are correctly passed to the Mechanics3 component.


942-943: LGTM!

The next button state management props are correctly passed to the Mechanics4 component.


1069-1070: LGTM!

The next button state management props are correctly passed to the Mechanics6 component.


1132-1133: LGTM!

The next button state management props are correctly passed to the Mechanics6 component.

package.json (1)

16-16: Verify the stability of the new telemetry SDK.

The package version (0.0.32) indicates early development stage. Please ensure:

  1. The package is stable enough for production use
  2. Breaking changes are documented
  3. Migration guide from @project-sunbird/telemetry-sdk is available

Run the following script to check the package details:

Comment on lines +220 to +222
{selectedWords?.map((elem, ind) => (
<span
key={ind}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use stable unique identifiers as keys instead of array indices.

Using array indices as keys in React's map function is an anti-pattern that can lead to rendering issues and inefficient updates. Consider using stable unique identifiers from the data if available.

If the elements have unique properties, use them as keys:

- {selectedWords?.map((elem, ind) => (
-   <span key={ind}
+ {selectedWords?.map((elem, ind) => (
+   <span key={`${elem}-${ind}`}

- {words?.map((elem, ind) => (
-   <React.Fragment key={ind}>
+ {words?.map((elem, ind) => (
+   <React.Fragment key={`${elem}-${ind}`}>

Also applies to: 273-274

Comment on lines +1 to +4
import { CsTelemetryModule } from "@project-sunbird/client-services/telemetry";

import { uniqueId } from './utilService';
import { jwtDecode } from '../../node_modules/jwt-decode/build/cjs/index';
import { uniqueId } from "./utilService";
import { jwtDecode } from "../../node_modules/jwt-decode/build/cjs/index";
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify the jwt-decode import path.

The import path for jwt-decode is unnecessarily specific and could break if the package structure changes.

-import { jwtDecode } from "../../node_modules/jwt-decode/build/cjs/index";
+import { jwtDecode } from "jwt-decode";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { CsTelemetryModule } from "@project-sunbird/client-services/telemetry";
import { uniqueId } from './utilService';
import { jwtDecode } from '../../node_modules/jwt-decode/build/cjs/index';
import { uniqueId } from "./utilService";
import { jwtDecode } from "../../node_modules/jwt-decode/build/cjs/index";
import { CsTelemetryModule } from "@project-sunbird/client-services/telemetry";
import { uniqueId } from "./utilService";
import { jwtDecode } from "jwt-decode";

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