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: error filtering of non-errors #1811

Merged
merged 7 commits into from
Jul 31, 2024

Conversation

MoumitaM
Copy link
Contributor

@MoumitaM MoumitaM commented Jul 29, 2024

PR Description

  • Fixed error filtering for non-errors
  • Enable error reporting

Linear task (optional)

Linear task link

Cross Browser Tests

Please confirm you have tested for the following browsers:

  • Chrome
  • Firefox
  • IE11

Sanity Suite

  • All sanity suite test cases pass locally

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Summary by CodeRabbit

  • New Features

    • Enhanced error reporting functionality, allowing dynamic enabling or disabling based on configuration.
    • Introduced a function to improve detection of non-error messages in error reporting logic.
  • Bug Fixes

    • Improved the overall control flow in error handling to reduce the risk of runtime errors.
    • Simplified error handling logic to enhance clarity and performance.
  • Tests

    • Added new test cases to improve coverage for error handling utilities.
    • Reactivated a previously skipped test case to validate error handling logic related to SDK script targets.

@MoumitaM MoumitaM requested a review from a team as a code owner July 29, 2024 12:10
Copy link
Contributor

coderabbitai bot commented Jul 29, 2024

Walkthrough

Walkthrough

The recent changes significantly enhance the error reporting capabilities within the analytics JavaScript plugins. A new isAllowedToBeNotified function selectively filters error messages, improving notification accuracy. The normaliseError function has undergone simplification to streamline its logic and enhance performance. Additionally, various components have been updated to improve error handling and reporting efficiency, supported by updated tests to reflect these changes.

Changes

Files Change Summary
packages/analytics-js-plugins/__tests__/errorReporting/utils.test.ts Added tests for isAllowedToBeNotified, confirming its behavior with various error inputs.
packages/analytics-js-plugins/src/errorReporting/utils.ts Introduced isAllowedToBeNotified to filter specific error messages from notifications.
packages/analytics-js-plugins/src/errorReporting/event/event.ts Simplified error handling in normaliseError by removing the nested logging function and streamlining the flow.
packages/analytics-js-plugins/src/errorReporting/index.ts Enhanced error handling with additional validation checks before processing errors.
packages/analytics-js/src/services/ErrorHandler/ErrorHandler.ts Removed the isAllowedToBeNotified condition from notifyError, increasing the volume of error notifications.
packages/analytics-js/src/services/ErrorHandler/processError.ts Restored logic for handling script loading errors and removed the isAllowedToBeNotified export.
packages/analytics-js/src/components/configManager/util/commonUtil.ts Updated updateReportingState to ensure error reporting is re-enabled based on the current configuration.
packages/analytics-js/__tests__/components/configManager/commonUtil.test.ts Activated assertions related to isErrorReportingEnabled in the tests.
packages/analytics-js/__tests__/services/ErrorHandler/processError.test.ts Activated a previously skipped test case relevant to ErrorHandler functionality.
packages/analytics-js-plugins/src/errorReporting/constants.ts Introduced new constant ERROR_REPORTING_PLUGIN for identifying the error reporting plugin.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

codecov bot commented Jul 29, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 56.63%. Comparing base (22e43da) to head (959c5d9).

Files Patch % Lines
...ckages/analytics-js-common/src/constants/errors.ts 0.00% 3 Missing ⚠️
...ytics-js/src/services/ErrorHandler/processError.ts 81.81% 1 Missing and 1 partial ⚠️
...s/analytics-js-plugins/src/errorReporting/index.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1811      +/-   ##
===========================================
+ Coverage    56.61%   56.63%   +0.01%     
===========================================
  Files          473      473              
  Lines        16093    16108      +15     
  Branches      3219     3226       +7     
===========================================
+ Hits          9111     9122      +11     
+ Misses        5738     5737       -1     
- Partials      1244     1249       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 22e43da and 14d545f.

Files selected for processing (4)
  • packages/analytics-js-plugins/tests/errorReporting/utils.test.ts (1 hunks)
  • packages/analytics-js-plugins/src/errorReporting/utils.ts (1 hunks)
  • packages/analytics-js/tests/components/configManager/commonUtil.test.ts (2 hunks)
  • packages/analytics-js/src/components/configManager/util/commonUtil.ts (1 hunks)
Additional comments not posted (5)
packages/analytics-js-plugins/src/errorReporting/utils.ts (1)

147-150: LGTM! But verify the function usage in the codebase.

The new conditional check to filter out non-error messages is a good addition. The code changes are approved.

However, ensure that all function calls to isRudderSDKError are tested to verify the new behavior.

Verification successful

LGTM! The new conditional check to filter out non-error messages is a good addition. The code changes are approved.

The function isRudderSDKError is used and tested in multiple places within the codebase, confirming that the new behavior is verified.

  • Verified usage in:
    • packages/analytics-js-plugins/src/errorReporting/utils.ts
    • packages/analytics-js-plugins/src/errorReporting/index.ts
    • packages/analytics-js-plugins/src/bugsnag/utils.ts
    • packages/analytics-js-plugins/__tests__/errorReporting/utils.test.ts
    • packages/analytics-js-plugins/__tests__/bugsnag/utils.test.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `isRudderSDKError` match the new behavior.

# Test: Search for the function usage. Expect: Only occurrences of the new behavior.
rg --type python -A 5 $'isRudderSDKError'

Length of output: 71


Script:

#!/bin/bash
# Description: Verify all function calls to `isRudderSDKError` match the new behavior.

# Test: Search for the function usage. Expect: Only occurrences of the new behavior.
rg --type typescript -A 5 'isRudderSDKError'

Length of output: 79


Script:

#!/bin/bash
# Description: Verify all function calls to `isRudderSDKError` match the new behavior.

# Test: Search for the function usage in `.ts` files. Expect: Only occurrences of the new behavior.
rg 'isRudderSDKError' --glob '*.ts' -A 5

Length of output: 7454

packages/analytics-js/src/components/configManager/util/commonUtil.ts (1)

76-77: LGTM! But verify the function usage in the codebase.

The changes to dynamically enable or disable error reporting based on the current configuration are a good addition. The code changes are approved.

However, ensure that all function calls to updateReportingState are tested to verify the new behavior.

Verification successful

Let's correct the file type and search for the function updateReportingState in the TypeScript codebase.


Function usage verified and adequately tested.

The function updateReportingState is used in the main codebase and is covered by tests in commonUtil.test.ts. The new behavior is verified to be in place.

  • Code usage:

    • packages/analytics-js/src/components/configManager/ConfigManager.ts
  • Test coverage:

    • packages/analytics-js/__tests__/components/configManager/commonUtil.test.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `updateReportingState` match the new behavior.

# Test: Search for the function usage. Expect: Only occurrences of the new behavior.
rg --type python -A 5 $'updateReportingState'

Length of output: 75


Script:

#!/bin/bash
# Description: Verify all function calls to `updateReportingState` match the new behavior.

# Test: Search for the function usage. Expect: Only occurrences of the new behavior.
rg --type ts -A 5 'updateReportingState'

Length of output: 5425

packages/analytics-js-plugins/__tests__/errorReporting/utils.test.ts (1)

119-125: LGTM!

The new test case for the isRudderSDKError function correctly identifies non-error messages. The code changes are approved.

packages/analytics-js/__tests__/components/configManager/commonUtil.test.ts (2)

113-115: Confirm the uncommenting of assertions for error and metrics reporting.

The assertions for state.reporting.isErrorReportingEnabled.value and state.reporting.isMetricsReportingEnabled.value being true and mockLogger.warn not being called are now active. Ensure that these conditions are met in the codebase.


136-138: Confirm the uncommenting of assertions for error and metrics reporting.

The assertions for state.reporting.isErrorReportingEnabled.value and state.reporting.isMetricsReportingEnabled.value being true and mockLogger.warn not being called are now active. Ensure that these conditions are met in the codebase.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 29, 2024
Copy link

github-actions bot commented Jul 29, 2024

size-limit report 📦

Name Size (Base) Size (Current) Size Limit Status
Cookies Utils - Legacy - NPM (ESM) 1.54 KB 1.54 KB (0%) 2 KB
Cookies Utils - Legacy - NPM (CJS) 1.75 KB 1.75 KB (0%) 2 KB
Cookies Utils - Legacy - NPM (UMD) 1.53 KB 1.53 KB (0%) 2 KB
Cookies Utils - Modern - NPM (ESM) 1.17 KB 1.17 KB (0%) 1.5 KB
Cookies Utils - Modern - NPM (CJS) 1.4 KB 1.4 KB (0%) 1.5 KB
Cookies Utils - Modern - NPM (UMD) 1.16 KB 1.16 KB (0%) 1.5 KB
Plugins Module Federation Mapping - Legacy - CDN 332 B 332 B (0%) 512 B
Plugins - Legacy - CDN 15.82 KB 15.88 KB (+0.42% ▲) 16 KB
Plugins Module Federation Mapping - Modern - CDN 331 B 331 B (0%) 512 B
Plugins - Modern - CDN 7.19 KB 7.19 KB (0%) 7.5 KB
Common - No bundling 15.87 KB 15.92 KB (+0.31% ▲) 16.5 KB
Service Worker - Legacy - NPM (ESM) 29.46 KB 29.46 KB (0%) 30 KB
Service Worker - Legacy - NPM (CJS) 29.61 KB 29.61 KB (0%) 30 KB
Service Worker - Legacy - NPM (UMD) 29.44 KB 29.44 KB (0%) 30 KB
Service Worker - Modern - NPM (ESM) 24.59 KB 24.59 KB (0%) 25 KB
Service Worker - Modern - NPM (CJS) 24.88 KB 24.88 KB (0%) 25 KB
Service Worker - Modern - NPM (UMD) 24.67 KB 24.67 KB (0%) 25 KB
Core (v1.1) - NPM (ESM) 29.81 KB 29.81 KB (0%) 32 KB
Core (v1.1) - NPM (CJS) 29.97 KB 29.97 KB (0%) 32 KB
Core (v1.1) - NPM (UMD) 29.89 KB 29.89 KB (0%) 32 KB
Core (Content Script - v1.1) - NPM (ESM) 29.33 KB 29.33 KB (0%) 30 KB
Core (Content Script - v1.1) - NPM (CJS) 29.54 KB 29.54 KB (0%) 30 KB
Core (Content Script - v1.1) - NPM (UMD) 29.42 KB 29.42 KB (0%) 30 KB
Core - Legacy - CDN 47.46 KB 47.4 KB (-0.13% ▼) 48 KB
Core - Modern - CDN 24 KB 24.09 KB (+0.39% ▲) 24.5 KB
Load Snippet 724 B 724 B (0%) 1 KB
Core - Legacy - NPM (ESM) 47.28 KB 47.29 KB (+0.02% ▲) 47.5 KB
Core - Legacy - NPM (CJS) 47.57 KB 47.5 KB (-0.14% ▼) 48 KB
Core - Legacy - NPM (UMD) 47.32 KB 47.28 KB (-0.09% ▼) 47.5 KB
Core - Modern - NPM (ESM) 23.76 KB 23.83 KB (+0.32% ▲) 24.5 KB
Core - Modern - NPM (CJS) 23.99 KB 24.06 KB (+0.3% ▲) 24.5 KB
Core - Modern - NPM (UMD) 23.8 KB 23.86 KB (+0.28% ▲) 24.5 KB
Core (Bundled) - Legacy - NPM (ESM) 47.28 KB 47.29 KB (+0.02% ▲) 47.5 KB
Core (Bundled) - Legacy - NPM (CJS) 47.56 KB 47.53 KB (-0.06% ▼) 48 KB
Core (Bundled) - Legacy - NPM (UMD) 47.32 KB 47.28 KB (-0.09% ▼) 47.5 KB
Core (Bundled) - Modern - NPM (ESM) 38.55 KB 38.54 KB (-0.04% ▼) 39 KB
Core (Bundled) - Modern - NPM (CJS) 38.86 KB 38.8 KB (-0.17% ▼) 39 KB
Core (Bundled) - Modern - NPM (UMD) 38.57 KB 38.53 KB (-0.11% ▼) 39 KB
Core (Content Script) - Legacy - NPM (ESM) 46.75 KB 46.75 KB (+0.02% ▲) 47 KB
Core (Content Script) - Legacy - NPM (CJS) 47.05 KB 47.01 KB (-0.1% ▼) 47.5 KB
Core (Content Script) - Legacy - NPM (UMD) 46.8 KB 46.77 KB (-0.07% ▼) 47 KB
Core (Content Script) - Modern - NPM (ESM) 38.05 KB 38.01 KB (-0.11% ▼) 38.5 KB
Core (Content Script) - Modern - NPM (CJS) 38.29 KB 38.3 KB (+0.04% ▲) 38.5 KB
Core (Content Script) - Modern - NPM (UMD) 38.07 KB 37.99 KB (-0.24% ▼) 38.5 KB
All Integrations - Legacy - CDN 93.68 KB 93.68 KB (0%) 95.3 KB
All Integrations - Modern - CDN 88.71 KB 88.71 KB (0%) 91 KB

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 14d545f and 325044d.

Files selected for processing (4)
  • packages/analytics-js-plugins/src/errorReporting/event/event.ts (6 hunks)
  • packages/analytics-js-plugins/src/errorReporting/index.ts (1 hunks)
  • packages/analytics-js/tests/services/ErrorHandler/processError.test.ts (1 hunks)
  • packages/analytics-js/src/services/ErrorHandler/processError.ts (1 hunks)
Additional comments not posted (5)
packages/analytics-js/src/services/ErrorHandler/processError.ts (1)

42-60: Reintroduced script loading error handling: Verify correctness

The reintroduced code block correctly handles script loading errors by checking if the error is an instance of Event and performing specific checks on the event target. Ensure that this logic aligns with the broader error handling strategy and does not introduce any regressions.

Verification successful

Reintroduced script loading error handling: Verified correctness

The reintroduced code block correctly handles script loading errors by checking if the error is an instance of Event and performing specific checks on the event target. The logic aligns with the broader error handling strategy and is well-verified by existing tests.

  • packages/analytics-js/__tests__/services/ErrorHandler/processError.test.ts: Contains multiple tests verifying the behavior of getNormalizedErrorForUnhandledError.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the reintroduced script loading error handling logic.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type python -A 5 $'getNormalizedErrorForUnhandledError'

Length of output: 90


Script:

#!/bin/bash
# Description: Verify the correctness of the reintroduced script loading error handling logic.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type typescript -A 5 $'getNormalizedErrorForUnhandledError'

Length of output: 98


Script:

#!/bin/bash
# Description: Verify the correctness of the reintroduced script loading error handling logic.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type ts -A 5 $'getNormalizedErrorForUnhandledError'

Length of output: 8969

packages/analytics-js-plugins/src/errorReporting/index.ts (1)

87-87: Added check for errorPayload: Verify correctness

The added check for errorPayload before verifying if the first error in errorPayload.errors is a Rudder SDK error ensures that the function does not attempt to access properties of errorPayload when it is undefined or null. This change improves the robustness of the error handling logic.

packages/analytics-js/__tests__/services/ErrorHandler/processError.test.ts (1)

98-98: Re-enabled test case: Verify correctness

The re-enabled test case "should return error instance for Event argument value with SDK script target" ensures that the function correctly returns an error instance for an Event argument value with an SDK script target. This change suggests that the developers have resolved previous issues or determined that the test is now relevant for the current implementation.

packages/analytics-js-plugins/src/errorReporting/event/event.ts (2)

76-79: LGTM! But verify the function usage in the codebase.

The changes to logInputError are approved. The function now logs a warning and returns undefined, which simplifies the error handling process.

However, ensure that all function calls to logInputError are correctly handled in the codebase.

Verification successful

Verified: Function usage is correctly handled.

The logInputError function is used appropriately within the file packages/analytics-js-plugins/src/errorReporting/event/event.ts, and all instances are correctly integrated.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `logInputError` are correctly handled in the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type ts -A 5 $'logInputError'

Length of output: 3240


Line range hint 94-119:
Verify the function's behavior with various inputs.

The changes simplify the handling of non-error inputs. Ensure that the function correctly handles all input types and scenarios.

Verification successful

Verify the function's behavior with various inputs.

The normaliseError function correctly handles various input types, including strings, numbers, booleans, functions, objects, and null values. The implementation ensures that unsupported input types are logged appropriately.

  • The function is defined in packages/analytics-js-plugins/src/errorReporting/event/event.ts at lines 67-139.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the behavior of `normaliseError` with various inputs.

# Test: Create a script to test the function with different inputs. Expect: Correct handling of all input types.
cat << 'EOF' > test_normaliseError.ts
import { normaliseError } from './packages/analytics-js-plugins/src/errorReporting/event/event';

const logger = {
  warn: console.warn,
};

const testCases = [
  { input: 'string', tolerateNonErrors: false, component: 'test', expected: [new Error('string'), 1] },
  { input: 42, tolerateNonErrors: false, component: 'test', expected: [new Error('42'), 1] },
  { input: true, tolerateNonErrors: false, component: 'test', expected: [new Error('true'), 1] },
  { input: () => {}, tolerateNonErrors: false, component: 'test', expected: [undefined, 0] },
  { input: null, tolerateNonErrors: false, component: 'test', expected: [undefined, 0] },
  { input: { name: 'Error', message: 'message' }, tolerateNonErrors: false, component: 'test', expected: [new Error('message'), 1] },
  { input: new Error('error'), tolerateNonErrors: false, component: 'test', expected: [new Error('error'), 0] },
];

testCases.forEach(({ input, tolerateNonErrors, component, expected }) => {
  const result = normaliseError(input, tolerateNonErrors, component, logger);
  console.assert(JSON.stringify(result) === JSON.stringify(expected), `Test failed for input: ${input}`);
});

console.log('All tests passed.');
EOF

Length of output: 5


Script:

#!/bin/bash
# Verify the existence and implementation of the `normaliseError` function in the specified file.

# Search for the definition of the `normaliseError` function.
ast-grep --lang typescript --pattern 'function normaliseError($_, $_, $_, $_) { $$$ }'

# Search for the usage of `normaliseError` function in the codebase to understand its context and ensure it is used correctly.
rg 'normaliseError'

Length of output: 684


Script:

#!/bin/bash
# Extract the implementation of the `normaliseError` function for review.

ast-grep --lang typescript --pattern 'const normaliseError = ($_,$_, $_, $_) => { $$$ }'

Length of output: 7230

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 30, 2024
Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 325044d and 2cd884a.

Files selected for processing (6)
  • packages/analytics-js-plugins/tests/errorReporting/utils.test.ts (3 hunks)
  • packages/analytics-js-plugins/src/errorReporting/utils.ts (3 hunks)
  • packages/analytics-js/tests/services/ErrorHandler/processError.test.ts (3 hunks)
  • packages/analytics-js/src/services/ErrorHandler/ErrorHandler.ts (2 hunks)
  • packages/analytics-js/src/services/ErrorHandler/processError.ts (2 hunks)
  • packages/analytics-js/src/services/HttpClient/xhr/xhrRequestHandler.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/analytics-js/src/services/HttpClient/xhr/xhrRequestHandler.ts
Files skipped from review as they are similar to previous changes (3)
  • packages/analytics-js-plugins/tests/errorReporting/utils.test.ts
  • packages/analytics-js-plugins/src/errorReporting/utils.ts
  • packages/analytics-js/tests/services/ErrorHandler/processError.test.ts
Additional comments not posted (2)
packages/analytics-js/src/services/ErrorHandler/processError.ts (1)

41-59: Ensure the Event error handling logic is necessary.

The added code segment handles errors that are instances of Event, specifically focusing on script loading errors. This logic seems to enhance error reporting for third-party script loading failures. Verify that this logic is necessary and beneficial for the overall error handling strategy.

packages/analytics-js/src/services/ErrorHandler/ErrorHandler.ts (1)

203-203: Verify the impact of removing isAllowedToBeNotified condition.

The removal of the isAllowedToBeNotified(error) condition simplifies the control flow but may increase the number of errors reported. Ensure that this change aligns with the overall error reporting strategy and does not introduce noise in the error logs.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 30, 2024
Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2cd884a and fd70e12.

Files selected for processing (5)
  • packages/analytics-js-common/src/constants/errors.ts (1 hunks)
  • packages/analytics-js-plugins/tests/errorReporting/utils.test.ts (2 hunks)
  • packages/analytics-js-plugins/src/errorReporting/event/event.ts (3 hunks)
  • packages/analytics-js-plugins/src/errorReporting/index.ts (3 hunks)
  • packages/analytics-js-plugins/src/errorReporting/utils.ts (3 hunks)
Files skipped from review due to trivial changes (1)
  • packages/analytics-js-common/src/constants/errors.ts
Files skipped from review as they are similar to previous changes (4)
  • packages/analytics-js-plugins/tests/errorReporting/utils.test.ts
  • packages/analytics-js-plugins/src/errorReporting/event/event.ts
  • packages/analytics-js-plugins/src/errorReporting/index.ts
  • packages/analytics-js-plugins/src/errorReporting/utils.ts

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 30, 2024
}
if (maybeError !== null && isError(maybeError)) {
error = maybeError;
} else if (maybeError !== null && hasNecessaryFields(maybeError)) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we check if it is an object first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

packages/analytics-js-plugins/src/errorReporting/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd70e12 and 910806c.

Files selected for processing (5)
  • packages/analytics-js-plugins/tests/errorReporting/utils.test.ts (2 hunks)
  • packages/analytics-js-plugins/src/errorReporting/constants.ts (2 hunks)
  • packages/analytics-js-plugins/src/errorReporting/event/event.ts (3 hunks)
  • packages/analytics-js-plugins/src/errorReporting/index.ts (2 hunks)
  • packages/analytics-js-plugins/src/errorReporting/utils.ts (3 hunks)
Files skipped from review due to trivial changes (1)
  • packages/analytics-js-plugins/src/errorReporting/constants.ts
Files skipped from review as they are similar to previous changes (3)
  • packages/analytics-js-plugins/tests/errorReporting/utils.test.ts
  • packages/analytics-js-plugins/src/errorReporting/event/event.ts
  • packages/analytics-js-plugins/src/errorReporting/utils.ts
Additional comments not posted (2)
packages/analytics-js-plugins/src/errorReporting/index.ts (2)

87-89: Improved robustness: Updated check for errorPayload.

The updated check for errorPayload ensures it is defined, reducing the risk of runtime errors and enhancing the stability of the error reporting functionality.


87-89: Good addition: Added validation for error payloads.

The isAllowedToBeNotified(errorPayload.errors[0]) check ensures that only valid errors are processed, enhancing the robustness of the error handling logic.

However, verify the usage of the isAllowedToBeNotified function to ensure it is correctly implemented and tested.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 31, 2024
Copy link
Member

@saikumarrs saikumarrs left a comment

Choose a reason for hiding this comment

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

LGTM except for these minor updates.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 910806c and 959c5d9.

Files selected for processing (1)
  • packages/analytics-js-plugins/src/errorReporting/event/event.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/analytics-js-plugins/src/errorReporting/event/event.ts

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
85.0% Coverage on New Code (required ≥ 90%)

See analysis details on SonarCloud

@MoumitaM MoumitaM merged commit 7b83e16 into develop Jul 31, 2024
9 of 10 checks passed
@MoumitaM MoumitaM deleted the feature/sdk-2176-fix-error-reporting-plugin-issue branch July 31, 2024 06:13
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