From 73de1ccc264e9afcbae3e6d7f66e120aca81e49a Mon Sep 17 00:00:00 2001 From: Moumita <36885121+MoumitaM@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:11:33 +0530 Subject: [PATCH 1/6] fix: filter non errors (#1800) --- .../ErrorHandler/ErrorHandler.test.ts | 10 ++--- .../ErrorHandler/processError.test.ts | 2 +- .../src/services/ErrorHandler/ErrorHandler.ts | 19 ++++----- .../src/services/ErrorHandler/processError.ts | 40 +++++++++---------- 4 files changed, 33 insertions(+), 38 deletions(-) diff --git a/packages/analytics-js/__tests__/services/ErrorHandler/ErrorHandler.test.ts b/packages/analytics-js/__tests__/services/ErrorHandler/ErrorHandler.test.ts index 8984f0cfba..34167240f4 100644 --- a/packages/analytics-js/__tests__/services/ErrorHandler/ErrorHandler.test.ts +++ b/packages/analytics-js/__tests__/services/ErrorHandler/ErrorHandler.test.ts @@ -267,12 +267,12 @@ describe('ErrorHandler', () => { it('should attach error listeners', () => { const unhandledRejectionListener = jest.spyOn(window, 'addEventListener'); errorHandlerInstance.attachErrorListeners(); - expect(unhandledRejectionListener).toHaveBeenCalledTimes(1); + expect(unhandledRejectionListener).toHaveBeenCalledTimes(2); expect(unhandledRejectionListener).toHaveBeenCalledWith('error', expect.any(Function)); - // expect(unhandledRejectionListener).toHaveBeenCalledWith( - // 'unhandledrejection', - // expect.any(Function), - // ); + expect(unhandledRejectionListener).toHaveBeenCalledWith( + 'unhandledrejection', + expect.any(Function), + ); }); it('should notify buffered errors once Error reporting plugin is loaded', () => { diff --git a/packages/analytics-js/__tests__/services/ErrorHandler/processError.test.ts b/packages/analytics-js/__tests__/services/ErrorHandler/processError.test.ts index 81c246313d..af249ebdd4 100644 --- a/packages/analytics-js/__tests__/services/ErrorHandler/processError.test.ts +++ b/packages/analytics-js/__tests__/services/ErrorHandler/processError.test.ts @@ -95,7 +95,7 @@ describe('ErrorHandler - getNormalizedErrorForUnhandledError', () => { expect(normalizedError).toBeUndefined(); }); - it('should return error instance for Event argument value with SDK script target', () => { + it.skip('should return error instance for Event argument value with SDK script target', () => { const event = new Event('dummyError'); const targetElement = document.createElement('script'); targetElement.dataset.loader = 'RS_JS_SDK'; diff --git a/packages/analytics-js/src/services/ErrorHandler/ErrorHandler.ts b/packages/analytics-js/src/services/ErrorHandler/ErrorHandler.ts index 9e0a41f441..110c8e7a45 100644 --- a/packages/analytics-js/src/services/ErrorHandler/ErrorHandler.ts +++ b/packages/analytics-js/src/services/ErrorHandler/ErrorHandler.ts @@ -64,17 +64,12 @@ class ErrorHandler implements IErrorHandler { this.onError(event, undefined, undefined, undefined, ErrorType.UNHANDLEDEXCEPTION); }); - // TODO: uncomment this when we have a way to handle unhandledrejection for non-Error objects - // (globalThis as typeof window).addEventListener( - // 'unhandledrejection', - // (event: PromiseRejectionEvent) => { - // if (!(event.reason instanceof Error)) { - // // Prevent the default handling by the browser - // event.preventDefault(); - // } - // this.onError(event, undefined, undefined, undefined, ErrorType.UNHANDLEDREJECTION); - // }, - // ); + (globalThis as typeof window).addEventListener( + 'unhandledrejection', + (event: PromiseRejectionEvent) => { + this.onError(event, undefined, undefined, undefined, ErrorType.UNHANDLEDREJECTION); + }, + ); } else { this.logger?.debug(`Failed to attach global error listeners.`); } @@ -159,7 +154,7 @@ class ErrorHandler implements IErrorHandler { error: normalizedError, errorState, }); - } else { + } else if (normalizedError) { this.notifyError(normalizedError, errorState); } } diff --git a/packages/analytics-js/src/services/ErrorHandler/processError.ts b/packages/analytics-js/src/services/ErrorHandler/processError.ts index 3f1aebed9c..8b329763ce 100644 --- a/packages/analytics-js/src/services/ErrorHandler/processError.ts +++ b/packages/analytics-js/src/services/ErrorHandler/processError.ts @@ -39,26 +39,26 @@ const getNormalizedErrorForUnhandledError = (error: SDKError): SDKError | undefi return error; } // TODO: remove this block once all device mode integrations start using the v3 script loader module (TS) - if (error instanceof Event) { - const eventTarget = error.target as ErrorTarget; - // Discard all the non-script loading errors - if (eventTarget && eventTarget.localName !== 'script') { - return undefined; - } - // Discard script errors that are not originated at SDK or from native SDKs - if ( - eventTarget?.dataset && - (eventTarget.dataset.loader !== LOAD_ORIGIN || - eventTarget.dataset.isnonnativesdk !== 'true') - ) { - return undefined; - } - const errorMessage = `Error in loading a third-party script from URL ${eventTarget?.src} with ID ${eventTarget?.id}.`; - return Object.create(error, { - message: { value: errorMessage }, - }); - } - return error; + // if (error instanceof Event) { + // const eventTarget = error.target as ErrorTarget; + // // Discard all the non-script loading errors + // if (eventTarget && eventTarget.localName !== 'script') { + // return undefined; + // } + // // Discard script errors that are not originated at SDK or from native SDKs + // if ( + // eventTarget?.dataset && + // (eventTarget.dataset.loader !== LOAD_ORIGIN || + // eventTarget.dataset.isnonnativesdk !== 'true') + // ) { + // return undefined; + // } + // const errorMessage = `Error in loading a third-party script from URL ${eventTarget?.src} with ID ${eventTarget?.id}.`; + // return Object.create(error, { + // message: { value: errorMessage }, + // }); + // } + return undefined; } catch (e) { return e; } From f718c5d1d24247ef4754cd70f526353145c2341d Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 23 Jul 2024 04:43:48 +0000 Subject: [PATCH 2/6] chore(@rudderstack/analytics-js): release version 3.7.4 --- packages/analytics-js/CHANGELOG.md | 10 ++++++++++ packages/analytics-js/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/analytics-js/CHANGELOG.md b/packages/analytics-js/CHANGELOG.md index 182ca91b39..67ac42950d 100644 --- a/packages/analytics-js/CHANGELOG.md +++ b/packages/analytics-js/CHANGELOG.md @@ -2,6 +2,16 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.7.4](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.7.3...@rudderstack/analytics-js@3.7.4) (2024-07-23) + +### Dependency Updates + +* `@rudderstack/analytics-js-plugins` updated to version `3.7.3` + +### Bug Fixes + +* filter non errors ([#1800](https://github.com/rudderlabs/rudder-sdk-js/issues/1800)) ([73de1cc](https://github.com/rudderlabs/rudder-sdk-js/commit/73de1ccc264e9afcbae3e6d7f66e120aca81e49a)) + ## [3.7.3](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.7.2...@rudderstack/analytics-js@3.7.3) (2024-07-23) ### Dependency Updates diff --git a/packages/analytics-js/package.json b/packages/analytics-js/package.json index eadc7e8ed2..9dae91f88f 100644 --- a/packages/analytics-js/package.json +++ b/packages/analytics-js/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js", - "version": "3.7.3", + "version": "3.7.4", "description": "RudderStack JavaScript SDK", "main": "dist/npm/modern/cjs/index.cjs", "module": "dist/npm/modern/esm/index.mjs", From a33d73cb14879b9066d7058e60fa1f5808a27186 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 23 Jul 2024 04:43:49 +0000 Subject: [PATCH 3/6] chore(@rudderstack/analytics-js-plugins): release version 3.4.4 --- packages/analytics-js-plugins/CHANGELOG.md | 5 +++++ packages/analytics-js-plugins/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/analytics-js-plugins/CHANGELOG.md b/packages/analytics-js-plugins/CHANGELOG.md index 527378a046..642215c288 100644 --- a/packages/analytics-js-plugins/CHANGELOG.md +++ b/packages/analytics-js-plugins/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.4.4](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.4.3...@rudderstack/analytics-js-plugins@3.4.4) (2024-07-23) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.4.3` ## [3.4.3](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.4.2...@rudderstack/analytics-js-plugins@3.4.3) (2024-07-23) ### Dependency Updates diff --git a/packages/analytics-js-plugins/package.json b/packages/analytics-js-plugins/package.json index b61566d3fa..118f129aa9 100644 --- a/packages/analytics-js-plugins/package.json +++ b/packages/analytics-js-plugins/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-plugins", - "version": "3.4.3", + "version": "3.4.4", "private": true, "description": "RudderStack JavaScript SDK plugins", "main": "dist/npm/modern/cjs/index.cjs", From 79b5c2425bde005da73768a17cad0a66bd2fb82a Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 23 Jul 2024 04:43:49 +0000 Subject: [PATCH 4/6] chore(@rudderstack/analytics-js-loading-scripts): release version 3.0.21 --- packages/loading-scripts/CHANGELOG.md | 5 +++++ packages/loading-scripts/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/loading-scripts/CHANGELOG.md b/packages/loading-scripts/CHANGELOG.md index 0ec0db50a9..d13cef75c5 100644 --- a/packages/loading-scripts/CHANGELOG.md +++ b/packages/loading-scripts/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.0.21](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.20...@rudderstack/analytics-js-loading-scripts@3.0.21) (2024-07-23) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.0.20` ## [3.0.20](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.19...@rudderstack/analytics-js-loading-scripts@3.0.20) (2024-07-23) ### Dependency Updates diff --git a/packages/loading-scripts/package.json b/packages/loading-scripts/package.json index 6452e364f3..5bb91e1f22 100644 --- a/packages/loading-scripts/package.json +++ b/packages/loading-scripts/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-loading-scripts", - "version": "3.0.20", + "version": "3.0.21", "private": true, "description": "Loading script for RudderStack JavaScript SDK", "main": "./src/index.js", From fa82eb5748d202e534760308b949e1aca0e83ce5 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 23 Jul 2024 04:43:50 +0000 Subject: [PATCH 5/6] chore(@rudderstack/analytics-js-sanity-suite): release version 3.1.11 --- packages/sanity-suite/CHANGELOG.md | 5 +++++ packages/sanity-suite/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/sanity-suite/CHANGELOG.md b/packages/sanity-suite/CHANGELOG.md index ef60ed47bc..8ea319fa80 100644 --- a/packages/sanity-suite/CHANGELOG.md +++ b/packages/sanity-suite/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.1.11](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-sanity-suite@3.1.10...@rudderstack/analytics-js-sanity-suite@3.1.11) (2024-07-23) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.1.10` ## [3.1.10](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-sanity-suite@3.1.9...@rudderstack/analytics-js-sanity-suite@3.1.10) (2024-07-23) ### Dependency Updates diff --git a/packages/sanity-suite/package.json b/packages/sanity-suite/package.json index d0b03770be..3d7104185c 100644 --- a/packages/sanity-suite/package.json +++ b/packages/sanity-suite/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-sanity-suite", - "version": "3.1.10", + "version": "3.1.11", "private": true, "description": "Sanity suite for testing JS SDK package", "main": "./dist/v3/cdn/testBook.js", From 6e6c4b900536cc97e36fb0efded00662c4578b83 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 23 Jul 2024 04:43:57 +0000 Subject: [PATCH 6/6] chore(monorepo): sync versions and generate release logs --- package-lock.json | 4 ++-- package.json | 2 +- packages/analytics-js-plugins/CHANGELOG_LATEST.md | 4 ++-- packages/analytics-js-plugins/project.json | 6 +++--- packages/analytics-js/CHANGELOG_LATEST.md | 6 +++--- packages/analytics-js/project.json | 6 +++--- packages/loading-scripts/CHANGELOG_LATEST.md | 4 ++-- packages/loading-scripts/project.json | 6 +++--- sonar-project.properties | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index a0e9e2df14..1c553b7ca6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.24.0", + "version": "3.25.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.24.0", + "version": "3.25.0", "hasInstallScript": true, "license": "Elastic-2.0", "workspaces": [ diff --git a/package.json b/package.json index 73014ea2b0..69ea8d5950 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.24.0", + "version": "3.25.0", "private": true, "description": "Monorepo for RudderStack Analytics JS SDK", "workspaces": [ diff --git a/packages/analytics-js-plugins/CHANGELOG_LATEST.md b/packages/analytics-js-plugins/CHANGELOG_LATEST.md index 97ee0484c2..e29cc2873d 100644 --- a/packages/analytics-js-plugins/CHANGELOG_LATEST.md +++ b/packages/analytics-js-plugins/CHANGELOG_LATEST.md @@ -1,5 +1,5 @@ -## [3.4.3](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.4.2...@rudderstack/analytics-js-plugins@3.4.3) (2024-07-23) +## [3.4.4](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.4.3...@rudderstack/analytics-js-plugins@3.4.4) (2024-07-23) ### Dependency Updates -* `@rudderstack/analytics-js` updated to version `3.4.2` +* `@rudderstack/analytics-js` updated to version `3.4.3` diff --git a/packages/analytics-js-plugins/project.json b/packages/analytics-js-plugins/project.json index d8d9991e9f..d20940e547 100644 --- a/packages/analytics-js-plugins/project.json +++ b/packages/analytics-js-plugins/project.json @@ -52,9 +52,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-plugins@3.4.3", - "title": "@rudderstack/analytics-js-plugins@3.4.3", - "discussion-category": "@rudderstack/analytics-js-plugins@3.4.3", + "tag": "@rudderstack/analytics-js-plugins@3.4.4", + "title": "@rudderstack/analytics-js-plugins@3.4.4", + "discussion-category": "@rudderstack/analytics-js-plugins@3.4.4", "notesFile": "./packages/analytics-js-plugins/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js/CHANGELOG_LATEST.md b/packages/analytics-js/CHANGELOG_LATEST.md index 40e637c4e3..744b4fc088 100644 --- a/packages/analytics-js/CHANGELOG_LATEST.md +++ b/packages/analytics-js/CHANGELOG_LATEST.md @@ -1,10 +1,10 @@ -## [3.7.3](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.7.2...@rudderstack/analytics-js@3.7.3) (2024-07-23) +## [3.7.4](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.7.3...@rudderstack/analytics-js@3.7.4) (2024-07-23) ### Dependency Updates -* `@rudderstack/analytics-js-plugins` updated to version `3.7.2` +* `@rudderstack/analytics-js-plugins` updated to version `3.7.3` ### Bug Fixes -* filter unhandled errors by message ([#1797](https://github.com/rudderlabs/rudder-sdk-js/issues/1797)) ([2f45d00](https://github.com/rudderlabs/rudder-sdk-js/commit/2f45d001e7d9dbb70b12b017fc73bc740135e870)) +* filter non errors ([#1800](https://github.com/rudderlabs/rudder-sdk-js/issues/1800)) ([73de1cc](https://github.com/rudderlabs/rudder-sdk-js/commit/73de1ccc264e9afcbae3e6d7f66e120aca81e49a)) diff --git a/packages/analytics-js/project.json b/packages/analytics-js/project.json index 675be56399..90e3cb1ad2 100644 --- a/packages/analytics-js/project.json +++ b/packages/analytics-js/project.json @@ -60,9 +60,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js@3.7.3", - "title": "@rudderstack/analytics-js@3.7.3", - "discussion-category": "@rudderstack/analytics-js@3.7.3", + "tag": "@rudderstack/analytics-js@3.7.4", + "title": "@rudderstack/analytics-js@3.7.4", + "discussion-category": "@rudderstack/analytics-js@3.7.4", "notesFile": "./packages/analytics-js/CHANGELOG_LATEST.md" } } diff --git a/packages/loading-scripts/CHANGELOG_LATEST.md b/packages/loading-scripts/CHANGELOG_LATEST.md index c4c73f5761..38900a27e6 100644 --- a/packages/loading-scripts/CHANGELOG_LATEST.md +++ b/packages/loading-scripts/CHANGELOG_LATEST.md @@ -1,5 +1,5 @@ -## [3.0.20](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.19...@rudderstack/analytics-js-loading-scripts@3.0.20) (2024-07-23) +## [3.0.21](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.20...@rudderstack/analytics-js-loading-scripts@3.0.21) (2024-07-23) ### Dependency Updates -* `@rudderstack/analytics-js` updated to version `3.0.19` +* `@rudderstack/analytics-js` updated to version `3.0.20` diff --git a/packages/loading-scripts/project.json b/packages/loading-scripts/project.json index 60b6aed72f..71f8373275 100644 --- a/packages/loading-scripts/project.json +++ b/packages/loading-scripts/project.json @@ -52,9 +52,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-loading-scripts@3.0.20", - "title": "@rudderstack/analytics-js-loading-scripts@3.0.20", - "discussion-category": "@rudderstack/analytics-js-loading-scripts@3.0.20", + "tag": "@rudderstack/analytics-js-loading-scripts@3.0.21", + "title": "@rudderstack/analytics-js-loading-scripts@3.0.21", + "discussion-category": "@rudderstack/analytics-js-loading-scripts@3.0.21", "notesFile": "./packages/loading-scripts/CHANGELOG_LATEST.md" } } diff --git a/sonar-project.properties b/sonar-project.properties index bd2feebff6..9619ed1f7b 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -6,7 +6,7 @@ sonar.qualitygate.wait=false sonar.projectKey=rudderlabs_rudder-sdk-js sonar.organization=rudderlabs sonar.projectName=rudder-sdk-js -sonar.projectVersion=3.24.0 +sonar.projectVersion=3.25.0 # Meta-data for the project sonar.links.scm=https://github.com/rudderlabs/rudder-sdk-js