From e45ef06186cb4dc1d0568f2b39d8e786d278390a Mon Sep 17 00:00:00 2001 From: Anant Jain <62471433+anantjain45823@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:04:27 +0530 Subject: [PATCH 1/5] fix: ninetailed: modify page support (#1677) --- .../integrations/Ninetailed/browser.test.js | 11 ++++++++++- .../src/integrations/Ninetailed/browser.js | 17 ++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/analytics-js-integrations/__tests__/integrations/Ninetailed/browser.test.js b/packages/analytics-js-integrations/__tests__/integrations/Ninetailed/browser.test.js index 1b1c4de49..e20686bd0 100644 --- a/packages/analytics-js-integrations/__tests__/integrations/Ninetailed/browser.test.js +++ b/packages/analytics-js-integrations/__tests__/integrations/Ninetailed/browser.test.js @@ -46,7 +46,7 @@ describe('Ninetailed Event APIs', () => { describe('Page', () => { let nt; beforeEach(() => { - nt = new Ninetailed({}, { loglevel: 'DEBUG' }, destinationInfo); + nt = new Ninetailed({ sendPageInDevice: true }, { loglevel: 'DEBUG' }, destinationInfo); window.ninetailed.page = jest.fn(); }); afterAll(() => { @@ -79,6 +79,15 @@ describe('Ninetailed Event APIs', () => { }); expect(window.ninetailed.page.mock.calls[0][0]).toEqual(undefined); }); + test('send page events toggle off', () => { + nt = new Ninetailed({ sendPageInDevice: false }, { loglevel: 'DEBUG' }, destinationInfo); + nt.page({ + message: { + context: {}, + }, + }); + expect(window.ninetailed.page).toHaveBeenCalledTimes(0); + }); }); describe('Track', () => { let nt; diff --git a/packages/analytics-js-integrations/src/integrations/Ninetailed/browser.js b/packages/analytics-js-integrations/src/integrations/Ninetailed/browser.js index 9735f3eb1..125aa0a8f 100644 --- a/packages/analytics-js-integrations/src/integrations/Ninetailed/browser.js +++ b/packages/analytics-js-integrations/src/integrations/Ninetailed/browser.js @@ -14,6 +14,7 @@ class Ninetailed { } this.analytics = analytics; this.name = NAME; + this.sendPageEvents = config.sendPageInDevice; ({ shouldApplyDeviceModeTransformation: this.shouldApplyDeviceModeTransformation, propagateEventsUntransformedOnError: this.propagateEventsUntransformedOnError, @@ -51,14 +52,16 @@ class Ninetailed { window.ninetailed.track(event, properties); } page(rudderElement) { - const { message } = rudderElement; - const { properties } = message; - if (properties) { - properties.url = window.location.href; - window.ninetailed.page(properties); - return; + if (this.sendPageEvents) { + const { message } = rudderElement; + const { properties } = message; + if (properties) { + properties.url = window.location.href; + window.ninetailed.page(properties); + return; + } + window.ninetailed.page(); } - window.ninetailed.page(); } } From da77fff1973479fdad88c40c12ad1fe939cc8c48 Mon Sep 17 00:00:00 2001 From: Anant Jain <62471433+anantjain45823@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:17:12 +0530 Subject: [PATCH 2/5] chore: address coderabbit comments for ninetailed examples (#1679) --- .../integrations/Ninetailed/sample-apps/README.md | 9 +++++---- .../sample-apps/app-using-v3-cdn/README.md | 6 +++--- .../sample-apps/app-using-v3-cdn/src/config.js | 14 +++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/examples/integrations/Ninetailed/sample-apps/README.md b/examples/integrations/Ninetailed/sample-apps/README.md index b44f43a98..018962b7e 100644 --- a/examples/integrations/Ninetailed/sample-apps/README.md +++ b/examples/integrations/Ninetailed/sample-apps/README.md @@ -1,8 +1,9 @@ There are 3 sample apps: -1. NPM package: This is for Production Use Case where rudderstack would be installed using npm install command and the app will intialise its instance. -2. V1.1 CDN: This app can be used for any environment either for dev, staging or prod by providing the right configurations in config.js file.This uses the legacy SDK. +1. NPM package: This is for Production Use Case where rudderstack would be installed using npm install command and the app will initialise its instance. -3. V3 CDN: This app can be used for any environment either for dev, staging or prod by providing the right configurations in config.js file. This uses the V3 SDK. +2. V1.1 CDN: This app can be used for any environment either for dev, staging or prod by providing the right configurations in config.js file .This uses the legacy SDK. -For Customers: NPM one is advised and other ones are just testing purposes mainly for developers \ No newline at end of file +3. V3 CDN: This app can be used for any environment either for dev, staging or prod by providing the right configurations in config.js file . This uses the V3 SDK. + +For Customers: The NPM package is recommended for production use. The other versions are intended primarily for testing and development purposes. diff --git a/examples/integrations/Ninetailed/sample-apps/app-using-v3-cdn/README.md b/examples/integrations/Ninetailed/sample-apps/app-using-v3-cdn/README.md index 58beeaccd..95095b05c 100644 --- a/examples/integrations/Ninetailed/sample-apps/app-using-v3-cdn/README.md +++ b/examples/integrations/Ninetailed/sample-apps/app-using-v3-cdn/README.md @@ -24,7 +24,7 @@ See the section about [running tests](https://facebook.github.io/create-react-ap Builds the app for production to the `build` folder.\ It correctly bundles React in production mode and optimizes the build for the best performance. -The build is minified and the filenames include the hashes.\ +The build is minified, and the filenames include the hashes.\ Your app is ready to be deployed! See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. @@ -35,9 +35,9 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc.) right into your project so you have full control over them. All the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point, you're on your own. -You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. +You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However, we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. ## Learn More diff --git a/examples/integrations/Ninetailed/sample-apps/app-using-v3-cdn/src/config.js b/examples/integrations/Ninetailed/sample-apps/app-using-v3-cdn/src/config.js index 146a964f2..7f6fe880e 100644 --- a/examples/integrations/Ninetailed/sample-apps/app-using-v3-cdn/src/config.js +++ b/examples/integrations/Ninetailed/sample-apps/app-using-v3-cdn/src/config.js @@ -1,8 +1,8 @@ -const DATAPLANE_URL='http://localhost:8080' -const WRITE_KEY='2F4kphApmhq8LvdG4GUhYwsMH4P' -const CONFIG_URL='https://api.dev.rudderlabs.com' +const DATAPLANE_URL = 'http://localhost:8080'; +const WRITE_KEY = 'dummyWriteKey'; +const CONFIG_URL = 'https://api.dev.rudderlabs.com'; module.exports = { - DATAPLANE_URL, - WRITE_KEY, - CONFIG_URL -} \ No newline at end of file + DATAPLANE_URL, + WRITE_KEY, + CONFIG_URL, +}; From 80c76a1f7f27a93930a6146730ac94d945b19b25 Mon Sep 17 00:00:00 2001 From: Sandeep Digumarty Date: Tue, 2 Apr 2024 18:15:11 +0530 Subject: [PATCH 3/5] fix: updated isLoaded and isReady conditions for mixpanel (#1650) * fix: updated isLoaded and isReady conditions for mixpanel * chare: addressed review comments * fix: updated isLoaded and isReady conditions for mixpanel * fix: added extra tests * fix: updated tests --- .../integrations/Mixpanel/browser.test.js | 52 +++++++++++++++++++ .../src/integrations/Mixpanel/browser.js | 10 ++-- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/packages/analytics-js-integrations/__tests__/integrations/Mixpanel/browser.test.js b/packages/analytics-js-integrations/__tests__/integrations/Mixpanel/browser.test.js index 5e86a9031..f086279b0 100644 --- a/packages/analytics-js-integrations/__tests__/integrations/Mixpanel/browser.test.js +++ b/packages/analytics-js-integrations/__tests__/integrations/Mixpanel/browser.test.js @@ -18,6 +18,9 @@ afterEach(() => { }); describe('Init tests', () => { + beforeEach(() => { + window.mixpanel = []; + }); let mixpanel; test('Persistence type is missing', () => { @@ -27,6 +30,7 @@ describe('Init tests', () => { cross_subdomain_cookie: false, secure_cookie: false, persistence: 'cookie', + loaded: expect.any(Function), }); }); @@ -40,6 +44,7 @@ describe('Init tests', () => { cross_subdomain_cookie: false, secure_cookie: false, persistence: 'cookie', + loaded: expect.any(Function), }); }); @@ -54,6 +59,7 @@ describe('Init tests', () => { secure_cookie: false, persistence: 'localStorage', persistence_name: 'abc', + loaded: expect.any(Function), }); }); @@ -67,11 +73,57 @@ describe('Init tests', () => { cross_subdomain_cookie: false, secure_cookie: false, disable_persistence: true, + loaded: expect.any(Function), + }); + }); +}); + +describe('isLoaded and isReady tests', () => { + let mixpanel; + + const loadSDK = () => { + setTimeout(() => { + mixpanel.isNativeSDKLoaded = true; // Change to true after 5 seconds + }, 5000); // 5 seconds + }; + + test('isLoaded test', () => { + mixpanel = new Mixpanel({ persistence: 'none' }, { logLevel: 'debug' }); + + loadSDK(); // Call loadSDK to set isNativeSDKLoaded after 5 seconds + + return new Promise(resolve => { + const interval = setInterval(() => { + if (mixpanel.isLoaded()) { + clearInterval(interval); + expect(mixpanel.isLoaded()).toBe(true); + resolve(); // Resolve the promise once the expectation is met + } + }, 1000); + }); + }); + + test('isReady test', () => { + mixpanel = new Mixpanel({ persistence: 'none' }, { logLevel: 'debug' }); + + loadSDK(); // Call loadSDK to set isNativeSDKLoaded after 5 seconds + + return new Promise(resolve => { + const interval = setInterval(() => { + if (mixpanel.isReady()) { + clearInterval(interval); + expect(mixpanel.isReady()).toBe(true); + resolve(); // Resolve the promise once the expectation is met + } + }, 1000); }); }); }); describe('Page tests', () => { + beforeEach(() => { + window.mixpanel = []; + }); let mixpanel; test('should return a custom generated event name when useUserDefinedPageEventName setting is enabled and event template is provided', () => { mixpanel = new Mixpanel( diff --git a/packages/analytics-js-integrations/src/integrations/Mixpanel/browser.js b/packages/analytics-js-integrations/src/integrations/Mixpanel/browser.js index 104c24a11..24d918c0f 100644 --- a/packages/analytics-js-integrations/src/integrations/Mixpanel/browser.js +++ b/packages/analytics-js-integrations/src/integrations/Mixpanel/browser.js @@ -66,6 +66,7 @@ class Mixpanel { this.ignoreDnt = config.ignoreDnt || false; this.useUserDefinedPageEventName = config.useUserDefinedPageEventName || false; this.userDefinedPageEventTemplate = config.userDefinedPageEventTemplate; + this.isNativeSDKLoaded = false; } init() { @@ -93,16 +94,19 @@ class Mixpanel { if (this.ignoreDnt) { options.ignore_dnt = true; } + options.loaded = () => { + this.isNativeSDKLoaded = true; + }; window.mixpanel.init(this.token, options); + window.mixpanel.register({ mp_lib: 'Rudderstack: web' }); } isLoaded() { - window.mixpanel.register({ mp_lib: 'Rudderstack: web' }); - return !!window?.mixpanel?.config; + return this.isNativeSDKLoaded; } isReady() { - return !!window?.mixpanel?.config; + return this.isLoaded(); } /** From d3ca4f5fbca27b4cfaa8627f3a6c835e6cc0b254 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 2 Apr 2024 12:51:49 +0000 Subject: [PATCH 4/5] chore(@rudderstack/analytics-js-integrations): release version 3.0.3 --- packages/analytics-js-integrations/CHANGELOG.md | 8 ++++++++ packages/analytics-js-integrations/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/analytics-js-integrations/CHANGELOG.md b/packages/analytics-js-integrations/CHANGELOG.md index a5dec7647..338dcaf81 100644 --- a/packages/analytics-js-integrations/CHANGELOG.md +++ b/packages/analytics-js-integrations/CHANGELOG.md @@ -2,6 +2,14 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.0.3](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.0.2...@rudderstack/analytics-js-integrations@3.0.3) (2024-04-02) + + +### Bug Fixes + +* ninetailed: modify page support ([#1677](https://github.com/rudderlabs/rudder-sdk-js/issues/1677)) ([e45ef06](https://github.com/rudderlabs/rudder-sdk-js/commit/e45ef06186cb4dc1d0568f2b39d8e786d278390a)) +* updated isLoaded and isReady conditions for mixpanel ([#1650](https://github.com/rudderlabs/rudder-sdk-js/issues/1650)) ([80c76a1](https://github.com/rudderlabs/rudder-sdk-js/commit/80c76a1f7f27a93930a6146730ac94d945b19b25)) + ## [3.0.2](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.0.1...@rudderstack/analytics-js-integrations@3.0.2) (2024-03-22) ### Dependency Updates diff --git a/packages/analytics-js-integrations/package.json b/packages/analytics-js-integrations/package.json index a7486029a..033993b42 100644 --- a/packages/analytics-js-integrations/package.json +++ b/packages/analytics-js-integrations/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-integrations", - "version": "3.0.2", + "version": "3.0.3", "private": true, "description": "RudderStack JavaScript SDK device mode integrations", "main": "dist/npm/modern/cjs/index.js", From cd08e3c1380c5f5cfb8b5c23e465564166a78970 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 2 Apr 2024 12:54:33 +0000 Subject: [PATCH 5/5] chore(monorepo): sync versions and generate release logs --- package-lock.json | 6 +++--- package.json | 2 +- packages/analytics-js-integrations/CHANGELOG_LATEST.md | 9 ++++++--- packages/analytics-js-integrations/project.json | 6 +++--- sonar-project.properties | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0d700e17e..34f82b66f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.4.0", + "version": "3.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.4.0", + "version": "3.5.0", "hasInstallScript": true, "license": "MIT", "workspaces": [ @@ -23808,7 +23808,7 @@ }, "packages/analytics-js-integrations": { "name": "@rudderstack/analytics-js-integrations", - "version": "3.0.2", + "version": "3.0.3", "license": "MIT", "dependencies": { "@ndhoule/each": "2.0.1", diff --git a/package.json b/package.json index 696ba2703..a622367d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.4.0", + "version": "3.5.0", "private": true, "description": "Monorepo for RudderStack Analytics JS SDK", "workspaces": [ diff --git a/packages/analytics-js-integrations/CHANGELOG_LATEST.md b/packages/analytics-js-integrations/CHANGELOG_LATEST.md index 4f77a1392..20df5b07d 100644 --- a/packages/analytics-js-integrations/CHANGELOG_LATEST.md +++ b/packages/analytics-js-integrations/CHANGELOG_LATEST.md @@ -1,5 +1,8 @@ -## [3.0.2](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.0.1...@rudderstack/analytics-js-integrations@3.0.2) (2024-03-22) +## [3.0.3](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.0.2...@rudderstack/analytics-js-integrations@3.0.3) (2024-04-02) -### Dependency Updates -* `@rudderstack/analytics-js-common` updated to version `3.0.1` +### Bug Fixes + +* ninetailed: modify page support ([#1677](https://github.com/rudderlabs/rudder-sdk-js/issues/1677)) ([e45ef06](https://github.com/rudderlabs/rudder-sdk-js/commit/e45ef06186cb4dc1d0568f2b39d8e786d278390a)) +* updated isLoaded and isReady conditions for mixpanel ([#1650](https://github.com/rudderlabs/rudder-sdk-js/issues/1650)) ([80c76a1](https://github.com/rudderlabs/rudder-sdk-js/commit/80c76a1f7f27a93930a6146730ac94d945b19b25)) + diff --git a/packages/analytics-js-integrations/project.json b/packages/analytics-js-integrations/project.json index 45f845be9..0944ee8a6 100644 --- a/packages/analytics-js-integrations/project.json +++ b/packages/analytics-js-integrations/project.json @@ -94,9 +94,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-integrations@3.0.2", - "title": "@rudderstack/analytics-js-integrations@3.0.2", - "discussion-category": "@rudderstack/analytics-js-integrations@3.0.2", + "tag": "@rudderstack/analytics-js-integrations@3.0.3", + "title": "@rudderstack/analytics-js-integrations@3.0.3", + "discussion-category": "@rudderstack/analytics-js-integrations@3.0.3", "notesFile": "./packages/analytics-js-integrations/CHANGELOG_LATEST.md" } } diff --git a/sonar-project.properties b/sonar-project.properties index 3637f9172..056e2a867 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.4.0 +sonar.projectVersion=3.5.0 # Meta-data for the project sonar.links.scm=https://github.com/rudderlabs/rudder-sdk-js