diff --git a/package-lock.json b/package-lock.json index 1711bcdfc..649b27499 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.65.0", + "version": "3.66.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.65.0", + "version": "3.66.0", "hasInstallScript": true, "license": "Elastic-2.0", "workspaces": [ @@ -25284,7 +25284,7 @@ }, "packages/analytics-js": { "name": "@rudderstack/analytics-js", - "version": "3.11.13", + "version": "3.11.14", "license": "Elastic-2.0", "dependencies": { "@preact/signals-core": "1.8.0", @@ -25344,7 +25344,7 @@ }, "packages/analytics-js-plugins": { "name": "@rudderstack/analytics-js-plugins", - "version": "3.6.16", + "version": "3.6.17", "license": "Elastic-2.0", "dependencies": { "@rudderstack/analytics-js-common": "*", @@ -25388,7 +25388,7 @@ }, "packages/loading-scripts": { "name": "@rudderstack/analytics-js-loading-scripts", - "version": "3.0.56", + "version": "3.0.57", "license": "Elastic-2.0", "dependencies": { "@rudderstack/analytics-js": "*" @@ -25397,7 +25397,7 @@ }, "packages/sanity-suite": { "name": "@rudderstack/analytics-js-sanity-suite", - "version": "3.1.47", + "version": "3.1.48", "license": "Elastic-2.0", "dependencies": { "@rudderstack/analytics-js": "*", diff --git a/package.json b/package.json index c98e0b1e0..49b3d9c9a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.65.0", + "version": "3.66.0", "private": true, "description": "Monorepo for RudderStack Analytics JS SDK", "workspaces": [ diff --git a/packages/analytics-js-plugins/CHANGELOG.md b/packages/analytics-js-plugins/CHANGELOG.md index 64aa7b180..c9390e509 100644 --- a/packages/analytics-js-plugins/CHANGELOG.md +++ b/packages/analytics-js-plugins/CHANGELOG.md @@ -2,6 +2,12 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.6.17](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.6.16...@rudderstack/analytics-js-plugins@3.6.17) (2024-11-30) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.11.13` +* `@rudderstack/analytics-js-cookies` updated to version `0.4.15` ## [3.6.16](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.6.15...@rudderstack/analytics-js-plugins@3.6.16) (2024-11-22) ### Dependency Updates diff --git a/packages/analytics-js-plugins/CHANGELOG_LATEST.md b/packages/analytics-js-plugins/CHANGELOG_LATEST.md index 5440e480e..f162ea230 100644 --- a/packages/analytics-js-plugins/CHANGELOG_LATEST.md +++ b/packages/analytics-js-plugins/CHANGELOG_LATEST.md @@ -1,7 +1,6 @@ -## [3.6.16](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.6.15...@rudderstack/analytics-js-plugins@3.6.16) (2024-11-22) +## [3.6.17](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.6.16...@rudderstack/analytics-js-plugins@3.6.17) (2024-11-30) ### Dependency Updates -* `@rudderstack/analytics-js-common` updated to version `3.14.12` -* `@rudderstack/analytics-js` updated to version `3.11.12` -* `@rudderstack/analytics-js-cookies` updated to version `0.4.14` +* `@rudderstack/analytics-js` updated to version `3.11.13` +* `@rudderstack/analytics-js-cookies` updated to version `0.4.15` diff --git a/packages/analytics-js-plugins/package.json b/packages/analytics-js-plugins/package.json index 28ae26705..d1029dd74 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.6.16", + "version": "3.6.17", "private": true, "description": "RudderStack JavaScript SDK plugins", "main": "dist/npm/modern/cjs/index.cjs", diff --git a/packages/analytics-js-plugins/project.json b/packages/analytics-js-plugins/project.json index fd1c60f27..a2686e444 100644 --- a/packages/analytics-js-plugins/project.json +++ b/packages/analytics-js-plugins/project.json @@ -51,9 +51,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-plugins@3.6.16", - "title": "@rudderstack/analytics-js-plugins@3.6.16", - "discussion-category": "@rudderstack/analytics-js-plugins@3.6.16", + "tag": "@rudderstack/analytics-js-plugins@3.6.17", + "title": "@rudderstack/analytics-js-plugins@3.6.17", + "discussion-category": "@rudderstack/analytics-js-plugins@3.6.17", "notesFile": "./packages/analytics-js-plugins/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js/CHANGELOG.md b/packages/analytics-js/CHANGELOG.md index c30f24e00..454955f82 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.11.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.11.13...@rudderstack/analytics-js@3.11.14) (2024-11-30) + +### Dependency Updates + +* `@rudderstack/analytics-js-plugins` updated to version `3.6.17` + +### Bug Fixes + +* preload events not processed with detached load call ([#1953](https://github.com/rudderlabs/rudder-sdk-js/issues/1953)) ([6b0f66f](https://github.com/rudderlabs/rudder-sdk-js/commit/6b0f66f61745542f2b01c02c99b7514fd468db80)) + ## [3.11.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.11.12...@rudderstack/analytics-js@3.11.13) (2024-11-22) ### Dependency Updates diff --git a/packages/analytics-js/CHANGELOG_LATEST.md b/packages/analytics-js/CHANGELOG_LATEST.md index 6736f9384..bfd8ae1f1 100644 --- a/packages/analytics-js/CHANGELOG_LATEST.md +++ b/packages/analytics-js/CHANGELOG_LATEST.md @@ -1,7 +1,10 @@ -## [3.11.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.11.12...@rudderstack/analytics-js@3.11.13) (2024-11-22) +## [3.11.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.11.13...@rudderstack/analytics-js@3.11.14) (2024-11-30) ### Dependency Updates -* `@rudderstack/analytics-js-cookies` updated to version `0.4.15` -* `@rudderstack/analytics-js-common` updated to version `3.14.12` -* `@rudderstack/analytics-js-plugins` updated to version `3.6.16` +* `@rudderstack/analytics-js-plugins` updated to version `3.6.17` + +### Bug Fixes + +* preload events not processed with detached load call ([#1953](https://github.com/rudderlabs/rudder-sdk-js/issues/1953)) ([6b0f66f](https://github.com/rudderlabs/rudder-sdk-js/commit/6b0f66f61745542f2b01c02c99b7514fd468db80)) + diff --git a/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts b/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts index 690c96114..a60398986 100644 --- a/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts +++ b/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts @@ -55,27 +55,6 @@ describe('Core - Rudder Analytics Facade', () => { ]); }); - it('should return an empty array when globalThis.rudderanalytics is not an array', () => { - const rudderAnalyticsInstance = new RudderAnalytics(); - (globalThis as typeof window).rudderanalytics = undefined; - const result = rudderAnalyticsInstance.getPreloadedEvents(); - expect(result).toEqual([]); - }); - - it('should return buffered events array when globalThis.rudderanalytics is an array', () => { - const bufferedEvents = [ - ['track'], - ['consent', { sendPageEvent: true }], - ['load', 'dummyWriteKey', 'dummyDataPlaneUrl', { option1: true }], - ['consent', { sendPageEvent: false }], - ['track'], - ]; - (window as any).rudderanalytics = bufferedEvents; - const rudderAnalyticsInstance = new RudderAnalytics(); - const result = rudderAnalyticsInstance.getPreloadedEvents(); - expect(result).toEqual(bufferedEvents); - }); - it('should return the global singleton if it exists', () => { const globalSingleton = rudderAnalytics; rudderAnalytics = new RudderAnalytics(); @@ -850,7 +829,12 @@ describe('Core - Rudder Analytics Facade', () => { enabled: true, }, }); - expect(rudderAnalyticsInstance.trackPageLifecycleEvents).toHaveBeenCalledWith([], { + expect(rudderAnalyticsInstance.trackPageLifecycleEvents).toHaveBeenCalledWith([ + ['consent', { sendPageEvent: true }], + ['consent', { sendPageEvent: false }], + ['track'], + ['track'], + ], { autoTrack: { enabled: true, }, diff --git a/packages/analytics-js/package.json b/packages/analytics-js/package.json index ee19d56e0..105f9c6c6 100644 --- a/packages/analytics-js/package.json +++ b/packages/analytics-js/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js", - "version": "3.11.13", + "version": "3.11.14", "description": "RudderStack JavaScript SDK", "main": "dist/npm/modern/cjs/index.cjs", "module": "dist/npm/modern/esm/index.mjs", diff --git a/packages/analytics-js/project.json b/packages/analytics-js/project.json index 22f7f54d5..8737e14ab 100644 --- a/packages/analytics-js/project.json +++ b/packages/analytics-js/project.json @@ -59,9 +59,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js@3.11.13", - "title": "@rudderstack/analytics-js@3.11.13", - "discussion-category": "@rudderstack/analytics-js@3.11.13", + "tag": "@rudderstack/analytics-js@3.11.14", + "title": "@rudderstack/analytics-js@3.11.14", + "discussion-category": "@rudderstack/analytics-js@3.11.14", "notesFile": "./packages/analytics-js/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js/src/app/RudderAnalytics.ts b/packages/analytics-js/src/app/RudderAnalytics.ts index 05733142b..6d94926a7 100644 --- a/packages/analytics-js/src/app/RudderAnalytics.ts +++ b/packages/analytics-js/src/app/RudderAnalytics.ts @@ -31,7 +31,7 @@ import { promotePreloadedConsentEventsToTop, } from '../components/preloadBuffer'; import type { PreloadedEventCall } from '../components/preloadBuffer/types'; -import { setExposedGlobal } from '../components/utilities/globals'; +import { getExposedGlobal, setExposedGlobal } from '../components/utilities/globals'; import type { IAnalytics } from '../components/core/IAnalytics'; import { Analytics } from '../components/core/Analytics'; import { defaultLogger } from '../services/Logger/Logger'; @@ -158,7 +158,9 @@ class RudderAnalytics implements IRudderAnalytics { } this.setDefaultInstanceKey(writeKey); - const preloadedEventsArray = this.getPreloadedEvents(); + // Get the preloaded events array from global buffer instead of window.rudderanalytics + // as the constructor must have already pushed the events to the global buffer + const preloadedEventsArray = getExposedGlobal(GLOBAL_PRELOAD_BUFFER) as PreloadedEventCall[]; // Track page loaded lifecycle event if enabled this.trackPageLifecycleEvents(preloadedEventsArray, loadOptions); @@ -179,17 +181,6 @@ class RudderAnalytics implements IRudderAnalytics { } } - /** - * A function to get preloaded events array from global object - * @returns preloaded events array - */ - // eslint-disable-next-line class-methods-use-this - getPreloadedEvents() { - return Array.isArray((globalThis as typeof window).rudderanalytics) - ? ((globalThis as typeof window).rudderanalytics as unknown as PreloadedEventCall[]) - : ([] as PreloadedEventCall[]); - } - /** * A function to track page lifecycle events like page loaded and page unloaded * @param preloadedEventsArray @@ -298,7 +289,9 @@ class RudderAnalytics implements IRudderAnalytics { * remaining preloaded events array in global object */ triggerBufferedLoadEvent() { - const preloadedEventsArray = this.getPreloadedEvents(); + const preloadedEventsArray = Array.isArray((globalThis as typeof window).rudderanalytics) + ? ((globalThis as typeof window).rudderanalytics as unknown as PreloadedEventCall[]) + : ([] as PreloadedEventCall[]); // Get any load method call that is buffered if any // BTW, load method is also removed from the array @@ -306,7 +299,7 @@ class RudderAnalytics implements IRudderAnalytics { const loadEvent: PreloadedEventCall = getPreloadedLoadEvent(preloadedEventsArray); // Set the final preloaded events array in global object - setExposedGlobal(GLOBAL_PRELOAD_BUFFER, clone(preloadedEventsArray)); + setExposedGlobal(GLOBAL_PRELOAD_BUFFER, clone([...preloadedEventsArray])); // Process load method if present in the buffered requests if (loadEvent.length > 0) { diff --git a/packages/loading-scripts/CHANGELOG.md b/packages/loading-scripts/CHANGELOG.md index e6707a851..7e0e50a78 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.57](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.56...@rudderstack/analytics-js-loading-scripts@3.0.57) (2024-11-30) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.11.14` ## [3.0.56](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.55...@rudderstack/analytics-js-loading-scripts@3.0.56) (2024-11-22) ### Dependency Updates diff --git a/packages/loading-scripts/CHANGELOG_LATEST.md b/packages/loading-scripts/CHANGELOG_LATEST.md index 218385319..a100572a2 100644 --- a/packages/loading-scripts/CHANGELOG_LATEST.md +++ b/packages/loading-scripts/CHANGELOG_LATEST.md @@ -1,5 +1,5 @@ -## [3.0.56](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.55...@rudderstack/analytics-js-loading-scripts@3.0.56) (2024-11-22) +## [3.0.57](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.56...@rudderstack/analytics-js-loading-scripts@3.0.57) (2024-11-30) ### Dependency Updates -* `@rudderstack/analytics-js` updated to version `3.11.13` +* `@rudderstack/analytics-js` updated to version `3.11.14` diff --git a/packages/loading-scripts/package.json b/packages/loading-scripts/package.json index cbac6d587..2ec010597 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.56", + "version": "3.0.57", "private": true, "description": "Loading script for RudderStack JavaScript SDK", "main": "./src/index.js", diff --git a/packages/loading-scripts/project.json b/packages/loading-scripts/project.json index c87476a1e..ecd1671a0 100644 --- a/packages/loading-scripts/project.json +++ b/packages/loading-scripts/project.json @@ -51,9 +51,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-loading-scripts@3.0.56", - "title": "@rudderstack/analytics-js-loading-scripts@3.0.56", - "discussion-category": "@rudderstack/analytics-js-loading-scripts@3.0.56", + "tag": "@rudderstack/analytics-js-loading-scripts@3.0.57", + "title": "@rudderstack/analytics-js-loading-scripts@3.0.57", + "discussion-category": "@rudderstack/analytics-js-loading-scripts@3.0.57", "notesFile": "./packages/loading-scripts/CHANGELOG_LATEST.md" } } diff --git a/packages/sanity-suite/CHANGELOG.md b/packages/sanity-suite/CHANGELOG.md index 94b81b67e..2aa48a473 100644 --- a/packages/sanity-suite/CHANGELOG.md +++ b/packages/sanity-suite/CHANGELOG.md @@ -2,6 +2,16 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.1.48](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-sanity-suite@3.1.47...@rudderstack/analytics-js-sanity-suite@3.1.48) (2024-11-30) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.11.14` + +### Bug Fixes + +* preload events not processed with detached load call ([#1953](https://github.com/rudderlabs/rudder-sdk-js/issues/1953)) ([6b0f66f](https://github.com/rudderlabs/rudder-sdk-js/commit/6b0f66f61745542f2b01c02c99b7514fd468db80)) + ## [3.1.47](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-sanity-suite@3.1.46...@rudderstack/analytics-js-sanity-suite@3.1.47) (2024-11-22) ### Dependency Updates diff --git a/packages/sanity-suite/__fixtures__/sourceConfig1.json b/packages/sanity-suite/__fixtures__/sourceConfig1.json index e6b932d3a..a50a8e54c 100644 --- a/packages/sanity-suite/__fixtures__/sourceConfig1.json +++ b/packages/sanity-suite/__fixtures__/sourceConfig1.json @@ -358,7 +358,7 @@ "piiProperty": "" } ], - "overrideClientAndSessionId": true, + "overrideClientAndSessionId": false, "oneTrustCookieCategories": [ { "oneTrustCookieCategory": "" diff --git a/packages/sanity-suite/package.json b/packages/sanity-suite/package.json index 54da24018..0c9ee468c 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.47", + "version": "3.1.48", "private": true, "description": "Sanity suite for testing JS SDK package", "main": "./dist/v3/cdn/testBook.js", diff --git a/packages/sanity-suite/public/v3/manualLoadCall/index-cdn.html b/packages/sanity-suite/public/v3/manualLoadCall/index-cdn.html index eefb6197c..5ee868ab6 100644 --- a/packages/sanity-suite/public/v3/manualLoadCall/index-cdn.html +++ b/packages/sanity-suite/public/v3/manualLoadCall/index-cdn.html @@ -176,7 +176,7 @@ window.manualLoad( $('#writeKey').val(), $('#dataplaneURL').val(), - JSON.parse($('#loadOptions').val() ? $('#loadOptions').val() : {}), + JSON.parse($('#loadOptions').val() ? $('#loadOptions').val() : {}) ); }); }); diff --git a/packages/sanity-suite/public/v3/manualLoadCall/index-local.html b/packages/sanity-suite/public/v3/manualLoadCall/index-local.html index b4c862bba..8be3e6c88 100644 --- a/packages/sanity-suite/public/v3/manualLoadCall/index-local.html +++ b/packages/sanity-suite/public/v3/manualLoadCall/index-local.html @@ -179,7 +179,7 @@ window.manualLoad( $('#writeKey').val(), $('#dataplaneURL').val(), - JSON.parse($('#loadOptions').val() ? $('#loadOptions').val() : {}), + JSON.parse($('#loadOptions').val() ? $('#loadOptions').val() : {}) ); }); }); diff --git a/packages/sanity-suite/src/ignoredProperties/ignoredProperties.js b/packages/sanity-suite/src/ignoredProperties/ignoredProperties.js index 5b8767fc8..f2412de62 100644 --- a/packages/sanity-suite/src/ignoredProperties/ignoredProperties.js +++ b/packages/sanity-suite/src/ignoredProperties/ignoredProperties.js @@ -150,10 +150,12 @@ const ignoredProperties = [ { key: `message.integrations.Google Analytics 4 (GA4).sessionId`, type: 'number', + optional: true, }, { key: `message.integrations.Google Analytics 4 (GA4).clientId`, type: 'string', + optional: true, }, { key: `message.integrations.Google Analytics 4 (GA4).sessionNumber`, diff --git a/packages/sanity-suite/src/testBook/TestBook.js b/packages/sanity-suite/src/testBook/TestBook.js index 0110d2252..f99a505d5 100644 --- a/packages/sanity-suite/src/testBook/TestBook.js +++ b/packages/sanity-suite/src/testBook/TestBook.js @@ -319,10 +319,6 @@ class TestBook { const statusElement = document.getElementById(`test-case-status-${testCaseId}`); statusElement.textContent = assertionResult; statusElement.className = `badge badge-${assertionResult} testCaseStatus`; - statusElement.scrollIntoView({ - behavior: 'smooth', - block: 'center', - }); const viewDiffElement = document.getElementById(`view-diff-${testCaseId}`); if (assertionResult === 'success') { @@ -360,16 +356,6 @@ class TestBook { const resultStatusElement = document.getElementById('resultStatus'); resultStatusElement.innerHTML = finalStatus; resultStatusElement.className = `badge badge-${finalStatus}`; - - // We need to use a timeout to ensure the scrollIntoView is called after the - // last test case result scrolling has been completed - // Otherwise the scrollIntoView will not work as expected - setTimeout(() => { - resultStatusElement.scrollIntoView({ - behavior: 'smooth', - block: 'center', - }); - }, 1000); } executeNextTestCase() { diff --git a/sonar-project.properties b/sonar-project.properties index 9603d8674..769605adc 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.65.0 +sonar.projectVersion=3.66.0 # Meta-data for the project sonar.links.scm=https://github.com/rudderlabs/rudder-sdk-js