From 92826a4f2e87dd2d0d755016592e36e4708f34d4 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju <88789928+saikumarrs@users.noreply.github.com> Date: Tue, 25 Jun 2024 16:07:24 +0530 Subject: [PATCH 1/7] feat: create new package for cookie utilities (#1759) * feat: create new package for cookie utilities * feat: finish the utility integration * chore: clean up exports * fix: improve test coverage * fix: address ai bot review comments * chore: fix readme * fix: pkg exports --- .eslintrc.json | 3 +- jest.preset.js | 2 +- package-lock.json | 14 ++ packages/analytics-js-cookies/.jscpd.json | 17 ++ packages/analytics-js-cookies/.size-limit.js | 11 + packages/analytics-js-cookies/CHANGELOG.md | 3 + .../analytics-js-cookies/CHANGELOG_LATEST.md | 0 packages/analytics-js-cookies/LICENSE | 21 ++ packages/analytics-js-cookies/README.md | 78 +++++++ .../__tests__}/component-cookie/index.test.ts | 52 ++++- .../__tests__/cookieUtilities.test.ts | 122 ++++++++++ .../analytics-js-cookies/babel.config.json | 14 ++ packages/analytics-js-cookies/jest.config.mjs | 14 ++ packages/analytics-js-cookies/package.json | 102 ++++++++ packages/analytics-js-cookies/project.json | 111 +++++++++ .../analytics-js-cookies/rollup.config.mjs | 173 ++++++++++++++ .../src}/component-cookie/README.md | 0 .../src}/component-cookie/index.ts | 4 +- .../src/constants/cookies.ts | 37 +++ .../src/constants/logMessages.ts | 3 + .../src/cookiesUtilities.ts | 36 +++ packages/analytics-js-cookies/src/index.ts | 13 ++ packages/analytics-js-cookies/tsconfig.json | 14 ++ .../analytics-js-cookies/tsconfig.spec.json | 25 ++ .../analytics-js-plugins/rollup.config.mjs | 4 + .../src/shared-chunks/common.ts | 3 +- .../src/storageEncryption/constants.ts | 1 - .../src/storageEncryption/encryptionUtils.ts | 14 -- .../src/storageEncryption/index.ts | 8 +- .../src/storageMigrator/index.ts | 8 +- packages/analytics-js-plugins/tsconfig.json | 1 + .../analytics-js/__fixtures__/fixtures.ts | 220 +++++++++--------- .../configManager/ConfigManager.test.ts | 4 +- .../components/configManager/validate.test.ts | 4 +- .../components/core/Analytics.test.ts | 24 +- .../eventManager/RudderEventFactory.test.ts | 28 +-- .../components/eventManager/utilities.test.ts | 6 +- .../UserSessionManager.test.ts | 42 ++-- .../components/utilities/page.test.ts | 4 +- .../StoreManager/top-domain/index.test.ts | 10 +- packages/analytics-js/package.json | 1 + packages/analytics-js/project.json | 3 +- packages/analytics-js/rollup.config.mjs | 4 + .../capabilitiesManager/detection/dom.ts | 1 + .../userSessionManager/UserSessionManager.ts | 17 +- .../userSessionManager/constants.ts | 18 +- .../components/userSessionManager/types.ts | 4 +- .../analytics-js/src/constants/logMessages.ts | 3 - .../src/services/StoreManager/StoreManager.ts | 4 +- .../StoreManager/storages/CookieStorage.ts | 2 +- .../services/StoreManager/top-domain/index.ts | 2 +- packages/analytics-js/tsconfig.json | 3 +- scripts/commitizen.js | 1 + scripts/fix-reports-path-in-github-runner.sh | 2 +- scripts/generate-last-release-changelog.sh | 2 +- scripts/sync-tags-in-nx-projects.sh | 2 +- sonar-project.properties | 6 +- tsconfig.json | 3 +- tsconfig.paths.json | 3 +- 59 files changed, 1080 insertions(+), 251 deletions(-) create mode 100644 packages/analytics-js-cookies/.jscpd.json create mode 100644 packages/analytics-js-cookies/.size-limit.js create mode 100644 packages/analytics-js-cookies/CHANGELOG.md create mode 100644 packages/analytics-js-cookies/CHANGELOG_LATEST.md create mode 100644 packages/analytics-js-cookies/LICENSE create mode 100644 packages/analytics-js-cookies/README.md rename packages/{analytics-js/__tests__/services/StoreManager => analytics-js-cookies/__tests__}/component-cookie/index.test.ts (50%) create mode 100644 packages/analytics-js-cookies/__tests__/cookieUtilities.test.ts create mode 100644 packages/analytics-js-cookies/babel.config.json create mode 100644 packages/analytics-js-cookies/jest.config.mjs create mode 100644 packages/analytics-js-cookies/package.json create mode 100644 packages/analytics-js-cookies/project.json create mode 100644 packages/analytics-js-cookies/rollup.config.mjs rename packages/{analytics-js/src/services/StoreManager => analytics-js-cookies/src}/component-cookie/README.md (100%) rename packages/{analytics-js/src/services/StoreManager => analytics-js-cookies/src}/component-cookie/index.ts (95%) create mode 100644 packages/analytics-js-cookies/src/constants/cookies.ts create mode 100644 packages/analytics-js-cookies/src/constants/logMessages.ts create mode 100644 packages/analytics-js-cookies/src/cookiesUtilities.ts create mode 100644 packages/analytics-js-cookies/src/index.ts create mode 100644 packages/analytics-js-cookies/tsconfig.json create mode 100644 packages/analytics-js-cookies/tsconfig.spec.json delete mode 100644 packages/analytics-js-plugins/src/storageEncryption/constants.ts delete mode 100644 packages/analytics-js-plugins/src/storageEncryption/encryptionUtils.ts diff --git a/.eslintrc.json b/.eslintrc.json index 372f070d4..8fcf9ae64 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -29,7 +29,8 @@ "cancelAnimationFrame", "navigator.sendBeacon", "Uint8Array", - "Set" + "Set", + "atob" ] }, "env": { diff --git a/jest.preset.js b/jest.preset.js index 32e925971..3bf0c9132 100644 --- a/jest.preset.js +++ b/jest.preset.js @@ -71,7 +71,7 @@ module.exports = { }, testEnvironmentOptions: { ...nxPreset.testEnvironmentOptions, - url: 'http://www.test-host.com', + url: 'https://www.test-host.com', runScripts: 'dangerously', resources: 'usable', }, diff --git a/package-lock.json b/package-lock.json index b47b50f13..0d0a2962a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5726,6 +5726,10 @@ "resolved": "packages/analytics-js-common", "link": true }, + "node_modules/@rudderstack/analytics-js-cookies": { + "resolved": "packages/analytics-js-cookies", + "link": true + }, "node_modules/@rudderstack/analytics-js-integrations": { "resolved": "packages/analytics-js-integrations", "link": true @@ -24951,6 +24955,7 @@ "dependencies": { "@preact/signals-core": "1.6.1", "@rudderstack/analytics-js-common": "*", + "@rudderstack/analytics-js-cookies": "*", "@rudderstack/analytics-js-plugins": "*", "ramda": "0.30.1", "storejs": "2.1.0" @@ -24974,6 +24979,15 @@ }, "devDependencies": {} }, + "packages/analytics-js-cookies": { + "name": "@rudderstack/analytics-js-cookies", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@rudderstack/analytics-js-common": "*" + }, + "devDependencies": {} + }, "packages/analytics-js-integrations": { "name": "@rudderstack/analytics-js-integrations", "version": "3.4.0", diff --git a/packages/analytics-js-cookies/.jscpd.json b/packages/analytics-js-cookies/.jscpd.json new file mode 100644 index 000000000..7ecbbf2fe --- /dev/null +++ b/packages/analytics-js-cookies/.jscpd.json @@ -0,0 +1,17 @@ +{ + "threshold": 5, + "reporters": ["html", "console"], + "pattern": "**/*", + "ignore": [ + "**/__tests__/**", + "**/__mocks__/**", + "**/__fixtures__/**", + "**/node_modules/**", + "*.test.*" + ], + "absolute": true, + "gitignore": true, + "output": "./reports/", + "mode": "strict", + "format": ["typescript", "tsx"] +} diff --git a/packages/analytics-js-cookies/.size-limit.js b/packages/analytics-js-cookies/.size-limit.js new file mode 100644 index 000000000..4fcadb4a7 --- /dev/null +++ b/packages/analytics-js-cookies/.size-limit.js @@ -0,0 +1,11 @@ +/** + * DO NOT EDIT the size limits configured in this file. + * Should you update them, please contact CODEOWNERS. + */ +module.exports = [ + { + name: 'Cookies Utilities', + path: 'dist/**/*.js', + limit: '2 KiB', + }, +]; diff --git a/packages/analytics-js-cookies/CHANGELOG.md b/packages/analytics-js-cookies/CHANGELOG.md new file mode 100644 index 000000000..99e9777f2 --- /dev/null +++ b/packages/analytics-js-cookies/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). diff --git a/packages/analytics-js-cookies/CHANGELOG_LATEST.md b/packages/analytics-js-cookies/CHANGELOG_LATEST.md new file mode 100644 index 000000000..e69de29bb diff --git a/packages/analytics-js-cookies/LICENSE b/packages/analytics-js-cookies/LICENSE new file mode 100644 index 000000000..2abc92cbc --- /dev/null +++ b/packages/analytics-js-cookies/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 RudderStack + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/analytics-js-cookies/README.md b/packages/analytics-js-cookies/README.md new file mode 100644 index 000000000..bec6566c3 --- /dev/null +++ b/packages/analytics-js-cookies/README.md @@ -0,0 +1,78 @@ +## [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](https://www.typescriptlang.org/) + +

+ + RudderStack + +
+ The Customer Data Platform for Developers +

+

+ + Website + · + Documentation + · + Community Slack + +

+ +--- + +# @rudderstack/analytics-js-cookies + +RudderStack JavaScript SDK utility for cookies. + +## APIs + +### `getDecryptedCookie` + +This function decrypts and returns the RudderStack JavaScript SDK cookie values. + +The return type is either a `string` or an `object` as some cookies like user ID, anonymous user ID have string values while user traits are objects. + +It returns `null` in either of the following scenarios: + +- If the cookie is not present. +- If the cookie is not properly encrypted. + - It only decrypts the cookies that are created by the RudderStack JavaScript SDK encryption version "v3". +- If the decrypted cookie value is not a valid JSON string. +- If the provided cookie name is not a valid RudderStack JavaScript SDK cookie name. + +> If unencrypted, the cookie value will be returned as is. + +> Any errors during decryption are swallowed by the function, returning `null`. + +The following are the available cookie key exports: +- `userIdKey`: The key for the user ID cookie. +- `userTraitsKey`: The key for the user traits cookie. +- `anonymousUserIdKey`: The key for the anonymous user ID cookie. +- `groupIdKey`: The key for the group ID cookie. +- `groupTraitsKey`: The key for the group traits cookie. +- `pageInitialReferrerKey`: The key for the page initial referrer cookie. +- `pageInitialReferringDomainKey`: The key for the page initial referring domain cookie. +- `sessionInfoKey`: The key for the session ID cookie. +- `authTokenKey`: The key for the auth token cookie. + + +```javascript +import { + getDecryptedCookie, + anonymousUserIdKey, + userTraitsKey, +} from '@rudderstack/analytics-js-cookies'; + +const anonymousId = getDecryptedCookie(anonymousUserIdKey); +console.log('Anonymous User ID: ', anonymousId); +// Output: Anonymous User ID: 2c5b6d48-ea90-43a2-a2f6-457d27f90328 + +const userTraits = getDecryptedCookie(userTraitsKey); +console.log('User Traits: ', userTraits); +// Output: User Traits: {"email":"abc@xyz.com","name":"John Doe"} + +const invalidCookie = getDecryptedCookie('invalid-cookie-name'); +console.log('Invalid Cookie: ', invalidCookie); +// Output: Invalid Cookie: null +``` + +> For detailed documentation on the RudderStack JavaScript SDK, click [**here**](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/). diff --git a/packages/analytics-js/__tests__/services/StoreManager/component-cookie/index.test.ts b/packages/analytics-js-cookies/__tests__/component-cookie/index.test.ts similarity index 50% rename from packages/analytics-js/__tests__/services/StoreManager/component-cookie/index.test.ts rename to packages/analytics-js-cookies/__tests__/component-cookie/index.test.ts index 7556328a3..01ad344a3 100644 --- a/packages/analytics-js/__tests__/services/StoreManager/component-cookie/index.test.ts +++ b/packages/analytics-js-cookies/__tests__/component-cookie/index.test.ts @@ -1,7 +1,21 @@ -import { cookie } from '../../../../src/services/StoreManager/component-cookie'; +import type { ILogger } from '@rudderstack/analytics-js-common/types/Logger'; +import { cookie } from '../../src/component-cookie'; + +class MockLogger implements ILogger { + error = jest.fn(); +} + +const mockLoggerInstance = new MockLogger(); + +beforeEach(() => { + const allCookies = cookie(); + Object.keys(allCookies).forEach(cookieName => { + cookie(cookieName, null); + }); +}); // TODO: clean up structure here, clean up cookie before each test -describe('cookie(name, value)', () => { +describe('cookies', () => { it('should set a cookie', () => { cookie('name', 'tobi'); expect('tobi').toEqual(cookie('name')); @@ -23,7 +37,29 @@ describe('cookie(name, value)', () => { it('should ignore URIError', () => { cookie('bad', '%'); cookie('bad', null); - expect(undefined).toEqual(cookie('bad')); + + cookie('bad', '\ud83d', undefined, mockLoggerInstance); + expect(mockLoggerInstance.error).toHaveBeenCalledTimes(1); + expect(mockLoggerInstance.error).toHaveBeenNthCalledWith( + 1, + 'Failed to encode the cookie data.', + expect.any(Error), + ); + + expect(cookie('bad')).toEqual('undefined'); + }); + + it('should return undefined if the cookies are not encoded properly', () => { + document.cookie = 'name=tobi%ferret'; + expect(cookie('name')).toEqual(undefined); + + // delete cookie + document.cookie = 'name=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + }); + + it('should set cookie as per the options', () => { + cookie('name', 'tobi', { domain: '.test-host.com', path: '/', secure: true, samesite: 'None' }); + expect(document.cookie.includes('name=tobi')).toBeTruthy(); }); }); @@ -62,4 +98,14 @@ describe('cookie()', () => { expect('loki').toEqual(obj.name); expect('ferret').toEqual(obj.species); }); + + it('should return all cookies if the first argument is not a valid string', () => { + cookie('name', 'loki'); + cookie('species', 'ferret'); + const obj = cookie(false); + + expect(2).toEqual(Object.keys(obj).length); + expect('loki').toEqual(obj.name); + expect('ferret').toEqual(obj.species); + }); }); diff --git a/packages/analytics-js-cookies/__tests__/cookieUtilities.test.ts b/packages/analytics-js-cookies/__tests__/cookieUtilities.test.ts new file mode 100644 index 000000000..0b9bd496f --- /dev/null +++ b/packages/analytics-js-cookies/__tests__/cookieUtilities.test.ts @@ -0,0 +1,122 @@ +import { + anonymousUserIdKey, + authTokenKey, + groupIdKey, + groupTraitsKey, + pageInitialReferrerKey, + pageInitialReferringDomainKey, + sessionInfoKey, + userIdKey, + userTraitsKey, +} from '../src'; +import { encrypt, decrypt, getDecryptedCookie } from '../src/cookiesUtilities'; + +describe('Cookie Utilities', () => { + describe('encrypt', () => { + it('should encrypt the value', () => { + expect(encrypt('test-data')).toBe('RS_ENC_v3_dGVzdC1kYXRh'); + }); + }); + + describe('decrypt', () => { + it('should decrypt the value', () => { + expect(decrypt('RS_ENC_v3_dGVzdC1kYXRh')).toBe('test-data'); + }); + + it('should return same data if it is not a supported encryption format', () => { + expect(decrypt('test-data')).toBe('test-data'); + }); + + it('should throw error if the value is not properly encrypted', () => { + expect(() => decrypt('RS_ENC_v3_dGVzdC1kYXRh-some-random-data')).toThrow(); + }); + }); + + describe('getDecryptedCookie', () => { + it('should return the decrypted cookie value', () => { + // JSON.stringify('test-data') -> '"test-data"' + document.cookie = 'rl_anonymous_id=RS_ENC_v3_InRlc3QtZGF0YSI='; + expect(getDecryptedCookie('rl_anonymous_id')).toBe('test-data'); + + // delete cookie + document.cookie = 'rl_anonymous_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + }); + + it('should return null if the cookie is not present', () => { + expect(getDecryptedCookie('rl_anonymous_id')).toBeNull(); + }); + + it('should return value if the cookie is not encrypted', () => { + document.cookie = 'rl_anonymous_id="test-data"'; + expect(getDecryptedCookie('rl_anonymous_id')).toBe('test-data'); + + // delete cookie + document.cookie = 'rl_anonymous_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + }); + + it('should return null if the cookie is not properly encrypted', () => { + document.cookie = 'rl_anonymous_id=RS_ENC_v3_InRlc3QtZGF0YQ=='; + expect(getDecryptedCookie('rl_anonymous_id')).toBeNull(); + + // delete cookie + document.cookie = 'rl_anonymous_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + }); + + it('should return null if the cookie value is not parsable', () => { + // the encrypted value is '"test-data' (missing closing double quote) + + document.cookie = 'rl_anonymous_id=RS_ENC_v3_InRlc3QtZGF0YQ=='; + expect(getDecryptedCookie('rl_anonymous_id')).toBeNull(); + + // delete cookie + document.cookie = 'rl_anonymous_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + }); + + it('should return null if the provided cookie name is not valid', () => { + expect(getDecryptedCookie('invalid_cookie_name')).toBeNull(); + }); + + it('should return decrypted cookie value if the cookie value is an object', () => { + document.cookie = 'rl_trait=RS_ENC_v3_ewogICJ0ZXN0LWtleSI6ICJ0ZXN0LXZhbHVlIgp9'; + expect(getDecryptedCookie('rl_trait')).toEqual({ 'test-key': 'test-value' }); + + // delete cookie + document.cookie = 'rl_trait=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + }); + + it('should return decrypted cookie values for all the allowed cookies', () => { + document.cookie = 'rl_user_id=RS_ENC_v3_InRlc3QtdXNlcl9pZCI='; + document.cookie = 'rl_trait=RS_ENC_v3_ewogICJ0ZXN0LWtleSI6ICJ0ZXN0LXZhbHVlIgp9'; + document.cookie = 'rl_anonymous_id=RS_ENC_v3_InRlc3QtZGF0YSI='; + document.cookie = 'rl_group_id=RS_ENC_v3_InRlc3QtZ3JvdXBfaWQi'; + document.cookie = 'rl_group_trait=RS_ENC_v3_ewogICJ0ZXN0LWtleSI6ICJ0ZXN0LXZhbHVlIgp9'; + document.cookie = 'rl_page_init_referrer=RS_ENC_v3_InRlc3QtcGFnZV9pbml0X3JlZmVycmVyIg=='; + document.cookie = + 'rl_page_init_referring_domain=RS_ENC_v3_InRlc3QtcGFnZV9pbml0X3JlZmVycmluZ19kb21haW4i'; + document.cookie = 'rl_session=RS_ENC_v3_ewogICJ0ZXN0LWtleSI6ICJ0ZXN0LXZhbHVlIgp9'; + document.cookie = 'rl_auth_token=RS_ENC_v3_InRlc3QtdG9rZW4i'; + expect(getDecryptedCookie(userIdKey)).toBe('test-user_id'); + expect(getDecryptedCookie(userTraitsKey)).toEqual({ 'test-key': 'test-value' }); + expect(getDecryptedCookie(anonymousUserIdKey)).toBe('test-data'); + expect(getDecryptedCookie(groupIdKey)).toBe('test-group_id'); + expect(getDecryptedCookie(groupTraitsKey)).toEqual({ 'test-key': 'test-value' }); + expect(getDecryptedCookie(pageInitialReferrerKey)).toBe('test-page_init_referrer'); + expect(getDecryptedCookie(pageInitialReferringDomainKey)).toBe( + 'test-page_init_referring_domain', + ); + expect(getDecryptedCookie(sessionInfoKey)).toEqual({ 'test-key': 'test-value' }); + expect(getDecryptedCookie(authTokenKey)).toBe('test-token'); + + // delete cookies + document.cookie = 'rl_user_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + document.cookie = 'rl_trait=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + document.cookie = 'rl_anonymous_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + document.cookie = 'rl_group_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + document.cookie = 'rl_group_trait=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + document.cookie = 'rl_page_init_referrer=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + document.cookie = 'rl_page_init_referring_domain=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + document.cookie = 'rl_session=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + document.cookie = 'rl_auth_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC'; + }); + }); +}); diff --git a/packages/analytics-js-cookies/babel.config.json b/packages/analytics-js-cookies/babel.config.json new file mode 100644 index 000000000..b73b0a8da --- /dev/null +++ b/packages/analytics-js-cookies/babel.config.json @@ -0,0 +1,14 @@ +{ + "presets": [ + [ + "@babel/env", + { + "corejs": "3.6", + "useBuiltIns": "entry", + "bugfixes": true + } + ], + "@babel/typescript" + ], + "plugins": [] +} diff --git a/packages/analytics-js-cookies/jest.config.mjs b/packages/analytics-js-cookies/jest.config.mjs new file mode 100644 index 000000000..5c9500c85 --- /dev/null +++ b/packages/analytics-js-cookies/jest.config.mjs @@ -0,0 +1,14 @@ +/* eslint-disable */ +export default { + displayName: '@rudderstack/analytics-js-cookies', + preset: '../../jest.preset.js', + rootDir: './', + coverageThreshold: { + global: { + branches: 0, + functions: 0, + lines: 0, + statements: 0, + }, + }, +}; diff --git a/packages/analytics-js-cookies/package.json b/packages/analytics-js-cookies/package.json new file mode 100644 index 000000000..fa3ee19a2 --- /dev/null +++ b/packages/analytics-js-cookies/package.json @@ -0,0 +1,102 @@ +{ + "name": "@rudderstack/analytics-js-cookies", + "version": "1.0.0", + "description": "RudderStack JavaScript SDK Cookies Module", + "main": "dist/npm/modern/cjs/index.js", + "module": "dist/npm/modern/esm/index.js", + "exports": { + ".": { + "types": "./dist/npm/index.d.ts", + "require": "./dist/npm/modern/cjs/index.js", + "import": "./dist/npm/modern/esm/index.js" + }, + "./legacy": { + "types": "./dist/npm/index.d.ts", + "require": "./dist/npm/legacy/cjs/index.js", + "import": "./dist/npm/legacy/esm/index.js" + } + }, + "types": "./dist/npm/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "./dist/npm/index.d.ts" + ] + } + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "dist/npm", + "LICENSE", + "README.md", + "CHANGELOG.md" + ], + "keywords": [ + "analytics", + "rudder" + ], + "author": "RudderStack", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rudderlabs/rudder-sdk-js.git", + "directory": "packages/analytics-js-cookies" + }, + "bugs": { + "url": "https://github.com/rudderlabs/rudder-sdk-js/issues" + }, + "homepage": "https://github.com/rudderlabs/rudder-sdk-js/blob/main/packages/analytics-js-cookies/README.md", + "scripts": { + "clean": "rimraf -rf ./dist && rimraf -rf ./node_modules/.cache && rimraf -rf ./reports", + "start": "exit 0", + "build": "npm run build:browser && npm run build:package", + "build:browser:modern": "exit 0", + "build:browser": "exit 0", + "build:npm": "rollup -c --environment VERSION:$npm_package_version,ENV:prod,MODULE_TYPE:npm", + "build:npm:modern": "BROWSERSLIST_ENV=modern npm run build:npm", + "build:package": "npm run build:npm:modern", + "test": "nx test --maxWorkers=50%", + "test:ci": "nx test --parallel=false --configuration=ci --runInBand --maxWorkers=1 --forceExit", + "check:lint": "nx lint", + "check:lint:ci": "nx lint --configuration=ci", + "check:size:build": "npm run build", + "check:size": "npm run check:size:build && size-limit", + "check:size:json": "size-limit --json", + "check:circular": "madge --circular --extensions js,ts src || exit 0", + "check:support": "NODE_ENV=production npx browserslist --mobile-to-desktop", + "check:support:modern": "NODE_ENV=modern npx browserslist --mobile-to-desktop", + "check:duplicates": "jscpd src", + "check:security": "npm audit --recursive --audit-level=high", + "build:modern": "npm run build:browser:modern && npm run build:npm:modern", + "package": "npm pack", + "release": "npm publish" + }, + "dependencies": { + "@rudderstack/analytics-js-common": "*" + }, + "devDependencies": {}, + "overrides": {}, + "browserslist": { + "production": [ + "defaults", + "Edge >= 80", + "Firefox >= 47", + "IE >= 11", + "Chrome >= 54", + "Safari >= 7", + "Opera >= 43" + ], + "modern": [ + "defaults", + "supports es6-module-dynamic-import" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 edge version", + "last 1 safari version" + ] + } +} diff --git a/packages/analytics-js-cookies/project.json b/packages/analytics-js-cookies/project.json new file mode 100644 index 000000000..3c57eec1c --- /dev/null +++ b/packages/analytics-js-cookies/project.json @@ -0,0 +1,111 @@ +{ + "name": "@rudderstack/analytics-js-cookies", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/analytics-js-cookies/src", + "projectType": "library", + "tags": ["type:lib", "scope:analytics-v3-cookies"], + "targets": { + "start": { + "executor": "nx:run-script", + "options": { + "script": "start" + } + }, + "build": { + "executor": "nx:run-script", + "options": { + "script": "build" + } + }, + "build-npm": { + "executor": "nx:run-script", + "options": { + "script": "build:npm" + } + }, + "build-npm-modern": { + "executor": "nx:run-script", + "options": { + "script": "build:npm:modern" + } + }, + "build-package": { + "executor": "nx:run-script", + "options": { + "script": "build:package" + } + }, + "build-check-size": { + "executor": "nx:run-script", + "options": { + "script": "build:package" + }, + "dependsOn": ["build"] + }, + "clean": { + "executor": "nx:run-script", + "options": { + "script": "clean" + } + }, + "pack": { + "executor": "nx:run-script", + "options": { + "script": "package" + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "packages/analytics-js-cookies/jest.config.mjs", + "passWithNoTests": true, + "codeCoverage": true, + "watchAll": false, + "forceExit": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "hasTypeAwareRules": true, + "lintFilePatterns": [ + "packages/analytics-js-cookies/src/**/*.{ts,js}", + "packages/analytics-js-cookies/{package,project}.json" + ] + }, + "configurations": { + "ci": { + "force": true, + "outputFile": "packages/analytics-js-cookies/reports/eslint.json", + "format": "json" + } + } + }, + "version": { + "executor": "@jscutlery/semver:version", + "options": { + "baseBranch": "main", + "preset": "conventional", + "tagPrefix": "{projectName}@", + "trackDeps": true + } + }, + "github": { + "executor": "@jscutlery/semver:github", + "options": { + "tag": "@rudderstack/analytics-js-cookies@1.0.0", + "title": "@rudderstack/analytics-js-cookies@1.0.0", + "discussion-category": "@rudderstack/analytics-js-cookies@1.0.0", + "notesFile": "./packages/analytics-js-cookies/CHANGELOG_LATEST.md" + } + } + } +} diff --git a/packages/analytics-js-cookies/rollup.config.mjs b/packages/analytics-js-cookies/rollup.config.mjs new file mode 100644 index 000000000..ccb692f88 --- /dev/null +++ b/packages/analytics-js-cookies/rollup.config.mjs @@ -0,0 +1,173 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import path from 'path'; +import babel from '@rollup/plugin-babel'; +import commonjs from '@rollup/plugin-commonjs'; +import resolve from '@rollup/plugin-node-resolve'; +import replace from '@rollup/plugin-replace'; +import terser from '@rollup/plugin-terser'; +import json from '@rollup/plugin-json'; +import { visualizer } from 'rollup-plugin-visualizer'; +import filesize from 'rollup-plugin-filesize'; +import typescript from 'rollup-plugin-typescript2'; +import nodePolyfills from 'rollup-plugin-polyfill-node'; +import { DEFAULT_EXTENSIONS } from '@babel/core'; +import del from 'rollup-plugin-delete'; +import dts from 'rollup-plugin-dts'; +import alias from '@rollup/plugin-alias'; +import * as dotenv from 'dotenv'; +import pkg from './package.json' assert { type: 'json' }; + +dotenv.config(); +const isLegacyBuild = process.env.BROWSERSLIST_ENV !== 'modern'; +const variantSubfolder = isLegacyBuild ? '/legacy' : '/modern'; +const sourceMapType = + process.env.PROD_DEBUG === 'inline' ? 'inline' : process.env.PROD_DEBUG === 'true'; +const outDir = `dist/npm`; +let outDirNpm = `${outDir}${variantSubfolder}`; +const distName = 'rsaCookies'; +const modName = 'rsaCookies'; + + +export function getDefaultConfig(distName) { + const version = process.env.VERSION || 'dev-snapshot'; + + return { + watch: { + include: ['src/**'], + }, + external: [ + ...Object.keys(pkg.peerDependencies || {}) + ], + onwarn(warning, warn) { + // Silence 'this' has been rewritten to 'undefined' warning + // https://rollupjs.org/guide/en/#error-this-is-undefined + if (warning.code === 'THIS_IS_UNDEFINED') { + return; + } + + warn(warning); + }, + plugins: [ + replace({ + preventAssignment: true, + __PACKAGE_VERSION__: version, + }), + resolve({ + jsnext: true, + browser: true, + preferBuiltins: false, + extensions: ['.js', '.ts', '.mjs'], + }), + nodePolyfills({ + include: ['crypto'], + }), + commonjs({ + include: /node_modules/, + requireReturnsDefault: 'auto', + }), + json(), + typescript({ + tsconfig: './tsconfig.json', + useTsconfigDeclarationDir: true, + }), + babel({ + compact: true, + babelHelpers: 'bundled', + exclude: ['node_modules/@babel/**', 'node_modules/core-js/**'], + extensions: [...DEFAULT_EXTENSIONS, '.ts'], + sourcemap: sourceMapType, + }), + process.env.UGLIFY === 'true' && + terser({ + safari10: isLegacyBuild, + ecma: isLegacyBuild ? 2015 : 2017, + format: { + comments: false, + }, + }), + filesize({ + showBeforeSizes: 'build', + showBrotliSize: true, + }), + process.env.VISUALIZER === 'true' && + visualizer({ + filename: `./stats/${distName}.html`, + title: `Rollup Visualizer - ${distName}`, + sourcemap: true, + open: true, + gzipSize: true, + brotliSize: true, + }) + ], + }; +} + +const outputFilesNpm = [ + { + entryFileNames: `index.js`, + dir: outDirNpm + '/esm/', + format: 'esm', + name: modName, + sourcemap: sourceMapType, + generatedCode: { + preset: isLegacyBuild ? 'es5' : 'es2015', + }, + }, + { + entryFileNames: `index.js`, + dir: outDirNpm + '/cjs', + format: 'cjs', + name: modName, + sourcemap: sourceMapType, + generatedCode: { + preset: isLegacyBuild ? 'es5' : 'es2015', + }, + }, + { + entryFileNames: `index.js`, + dir: outDirNpm + '/umd', + format: 'umd', + name: modName, + sourcemap: sourceMapType, + generatedCode: { + preset: isLegacyBuild ? 'es5' : 'es2015', + }, + }, +]; + +const buildConfig = () => { + return { + ...getDefaultConfig(distName), + }; +}; + +const buildEntries = () => { + return [ + { + ...buildConfig(), + input: 'src/index.ts', + output: outputFilesNpm, + }, + { + input: `dist/dts/packages/analytics-js-cookies/src/index.d.ts`, + plugins: [ + alias({ + entries: [ + { + find: '@rudderstack/analytics-js-common', + replacement: path.resolve('./dist/dts/packages/analytics-js-common/src'), + } + ] + }), + dts(), + del({ hook: "buildEnd", targets: "./dist/dts" }), + ], + output: { + file: `${outDir}/index.d.ts`, + format: 'es', + }, + } + ]; +} + +export default buildEntries(); diff --git a/packages/analytics-js/src/services/StoreManager/component-cookie/README.md b/packages/analytics-js-cookies/src/component-cookie/README.md similarity index 100% rename from packages/analytics-js/src/services/StoreManager/component-cookie/README.md rename to packages/analytics-js-cookies/src/component-cookie/README.md diff --git a/packages/analytics-js/src/services/StoreManager/component-cookie/index.ts b/packages/analytics-js-cookies/src/component-cookie/index.ts similarity index 95% rename from packages/analytics-js/src/services/StoreManager/component-cookie/index.ts rename to packages/analytics-js-cookies/src/component-cookie/index.ts index fbb1a39ac..e4dcaf1a8 100644 --- a/packages/analytics-js/src/services/StoreManager/component-cookie/index.ts +++ b/packages/analytics-js-cookies/src/component-cookie/index.ts @@ -2,7 +2,7 @@ import { isNull } from '@rudderstack/analytics-js-common/utilities/checks'; import type { Nullable } from '@rudderstack/analytics-js-common/types/Nullable'; import type { CookieOptions } from '@rudderstack/analytics-js-common/types/Storage'; import type { ILogger } from '@rudderstack/analytics-js-common/types/Logger'; -import { COOKIE_DATA_ENCODING_ERROR } from '../../../constants/logMessages'; +import { COOKIE_DATA_ENCODING_ERROR } from '../constants/logMessages'; /** * Encode. @@ -62,7 +62,7 @@ const set = ( optionsConfig?: CookieOptions, logger?: ILogger, ) => { - const options: CookieOptions = { ...optionsConfig } || {}; + const options: CookieOptions = { ...(optionsConfig || {}) }; let cookieString = `${encode(name, logger)}=${encode(value, logger)}`; if (isNull(value)) { diff --git a/packages/analytics-js-cookies/src/constants/cookies.ts b/packages/analytics-js-cookies/src/constants/cookies.ts new file mode 100644 index 000000000..b60883e23 --- /dev/null +++ b/packages/analytics-js-cookies/src/constants/cookies.ts @@ -0,0 +1,37 @@ +const userIdKey = 'rl_user_id'; +const userTraitsKey = 'rl_trait'; +const anonymousUserIdKey = 'rl_anonymous_id'; +const groupIdKey = 'rl_group_id'; +const groupTraitsKey = 'rl_group_trait'; +const pageInitialReferrerKey = 'rl_page_init_referrer'; +const pageInitialReferringDomainKey = 'rl_page_init_referring_domain'; +const sessionInfoKey = 'rl_session'; +const authTokenKey = 'rl_auth_token'; + +const COOKIE_KEYS = { + userId: userIdKey, + userTraits: userTraitsKey, + anonymousId: anonymousUserIdKey, + groupId: groupIdKey, + groupTraits: groupTraitsKey, + initialReferrer: pageInitialReferrerKey, + initialReferringDomain: pageInitialReferringDomainKey, + sessionInfo: sessionInfoKey, + authToken: authTokenKey, +}; + +const ENCRYPTION_PREFIX_V3 = 'RS_ENC_v3_'; + +export { + COOKIE_KEYS, + ENCRYPTION_PREFIX_V3, + userIdKey, + userTraitsKey, + anonymousUserIdKey, + groupIdKey, + groupTraitsKey, + pageInitialReferrerKey, + pageInitialReferringDomainKey, + sessionInfoKey, + authTokenKey, +}; diff --git a/packages/analytics-js-cookies/src/constants/logMessages.ts b/packages/analytics-js-cookies/src/constants/logMessages.ts new file mode 100644 index 000000000..82f10f7b7 --- /dev/null +++ b/packages/analytics-js-cookies/src/constants/logMessages.ts @@ -0,0 +1,3 @@ +const COOKIE_DATA_ENCODING_ERROR = `Failed to encode the cookie data.`; + +export { COOKIE_DATA_ENCODING_ERROR }; diff --git a/packages/analytics-js-cookies/src/cookiesUtilities.ts b/packages/analytics-js-cookies/src/cookiesUtilities.ts new file mode 100644 index 000000000..6a8785485 --- /dev/null +++ b/packages/analytics-js-cookies/src/cookiesUtilities.ts @@ -0,0 +1,36 @@ +import { fromBase64, toBase64 } from '@rudderstack/analytics-js-common/utilities/string'; +import type { Nullable } from '@rudderstack/analytics-js-common/types/Nullable'; +import { isNullOrUndefined } from '@rudderstack/analytics-js-common/utilities/checks'; +import type { ApiObject } from '@rudderstack/analytics-js-common/types/ApiObject'; +import { COOKIE_KEYS, ENCRYPTION_PREFIX_V3 } from './constants/cookies'; +import { cookie } from './component-cookie'; + +const encrypt = (value: string): string => `${ENCRYPTION_PREFIX_V3}${toBase64(value)}`; + +const decrypt = (value: string | undefined): string | undefined => { + if (value?.startsWith(ENCRYPTION_PREFIX_V3)) { + return fromBase64(value.substring(ENCRYPTION_PREFIX_V3.length)); + } + + return value; +}; + +const getDecryptedCookie = (cookieKey: string): Nullable => { + const fallbackValue = null; + try { + if (Object.values(COOKIE_KEYS).includes(cookieKey)) { + const decryptedVal = decrypt(cookie(cookieKey)); + + if (isNullOrUndefined(decryptedVal)) { + return fallbackValue; + } + + return JSON.parse(decryptedVal as string); + } + return fallbackValue; + } catch (err) { + return fallbackValue; + } +}; + +export { getDecryptedCookie, encrypt, decrypt }; diff --git a/packages/analytics-js-cookies/src/index.ts b/packages/analytics-js-cookies/src/index.ts new file mode 100644 index 000000000..0fce670e7 --- /dev/null +++ b/packages/analytics-js-cookies/src/index.ts @@ -0,0 +1,13 @@ +export { getDecryptedCookie } from './cookiesUtilities'; + +export { + userIdKey, + userTraitsKey, + anonymousUserIdKey, + groupIdKey, + groupTraitsKey, + pageInitialReferrerKey, + pageInitialReferringDomainKey, + sessionInfoKey, + authTokenKey, +} from './constants/cookies'; diff --git a/packages/analytics-js-cookies/tsconfig.json b/packages/analytics-js-cookies/tsconfig.json new file mode 100644 index 000000000..dff056e74 --- /dev/null +++ b/packages/analytics-js-cookies/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.build.json", + "compilerOptions": { + "target": "es5", + "declarationDir": "./dist/dts" + }, + "include": [ + "./package.json", + "./src/**/*", + "../../types/**/*", + "../analytics-js-common/src/**/*" + ], + "references": [] +} diff --git a/packages/analytics-js-cookies/tsconfig.spec.json b/packages/analytics-js-cookies/tsconfig.spec.json new file mode 100644 index 000000000..c86bfb803 --- /dev/null +++ b/packages/analytics-js-cookies/tsconfig.spec.json @@ -0,0 +1,25 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "rootDir": "./", + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "noEmit": true, + "sourceMap": true, + "inlineSourceMap": true, + "isolatedModules": true, + "verbatimModuleSyntax": false, + "types": ["jest", "node"], + "target": "es6" + }, + "include": [ + "jest.config.mjs", + "__tests__/**/*.ts", + "__mocks__/**/*.ts", + "__fixtures__/**/*.ts", + "src/**/*.ts", + "src/**/*.d.ts", + "./package.json", + "../analytics-js-common/src/**/*" + ] +} diff --git a/packages/analytics-js-plugins/rollup.config.mjs b/packages/analytics-js-plugins/rollup.config.mjs index cf85ddb0d..679297d3d 100644 --- a/packages/analytics-js-plugins/rollup.config.mjs +++ b/packages/analytics-js-plugins/rollup.config.mjs @@ -228,6 +228,10 @@ const buildEntries = () => { { find: '@rudderstack/analytics-js-common', replacement: path.resolve('./dist/dts/packages/analytics-js-common/src'), + }, + { + find: '@rudderstack/analytics-js-cookies', + replacement: path.resolve('./dist/dts/packages/analytics-js-cookies/src'), } ] }), diff --git a/packages/analytics-js-plugins/src/shared-chunks/common.ts b/packages/analytics-js-plugins/src/shared-chunks/common.ts index 03e42e4b8..4d54b8536 100644 --- a/packages/analytics-js-plugins/src/shared-chunks/common.ts +++ b/packages/analytics-js-plugins/src/shared-chunks/common.ts @@ -7,7 +7,6 @@ export * as http from '@rudderstack/analytics-js-common/utilities/http'; export * as string from '@rudderstack/analytics-js-common/utilities/string'; export * as json from '@rudderstack/analytics-js-common/utilities/json'; export * as timestamp from '@rudderstack/analytics-js-common/utilities/timestamp'; +export { encrypt, decrypt } from '@rudderstack/analytics-js-cookies/cookiesUtilities'; // eslint-disable-next-line import/no-cycle export * as eventsDelivery from '../utilities/eventsDelivery'; -// eslint-disable-next-line import/no-cycle -export * as encryption from '../storageEncryption/encryptionUtils'; diff --git a/packages/analytics-js-plugins/src/storageEncryption/constants.ts b/packages/analytics-js-plugins/src/storageEncryption/constants.ts deleted file mode 100644 index e8bf6ef6f..000000000 --- a/packages/analytics-js-plugins/src/storageEncryption/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const ENCRYPTION_PREFIX_V3 = 'RS_ENC_v3_'; diff --git a/packages/analytics-js-plugins/src/storageEncryption/encryptionUtils.ts b/packages/analytics-js-plugins/src/storageEncryption/encryptionUtils.ts deleted file mode 100644 index 07c5930ca..000000000 --- a/packages/analytics-js-plugins/src/storageEncryption/encryptionUtils.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { fromBase64, toBase64 } from '@rudderstack/analytics-js-common/utilities/string'; -import { ENCRYPTION_PREFIX_V3 } from './constants'; - -const encrypt = (value: string): string => `${ENCRYPTION_PREFIX_V3}${toBase64(value)}`; - -const decrypt = (value: string): string => { - if (value.startsWith(ENCRYPTION_PREFIX_V3)) { - return fromBase64(value.substring(ENCRYPTION_PREFIX_V3.length)); - } - - return value; -}; - -export { encrypt, decrypt }; diff --git a/packages/analytics-js-plugins/src/storageEncryption/index.ts b/packages/analytics-js-plugins/src/storageEncryption/index.ts index 455ffeb0f..c57cb48b9 100644 --- a/packages/analytics-js-plugins/src/storageEncryption/index.ts +++ b/packages/analytics-js-plugins/src/storageEncryption/index.ts @@ -2,7 +2,7 @@ import type { ApplicationState } from '@rudderstack/analytics-js-common/types/ApplicationState'; import type { ExtensionPlugin } from '@rudderstack/analytics-js-common/types/PluginEngine'; import type { PluginName } from '@rudderstack/analytics-js-common/types/PluginsManager'; -import { encryption } from '../shared-chunks/common'; +import { encrypt, decrypt } from '../shared-chunks/common'; const pluginName: PluginName = 'StorageEncryption'; @@ -13,10 +13,10 @@ const StorageEncryption = (): ExtensionPlugin => ({ }, storage: { encrypt(value: any): string { - return encryption.encrypt(value); + return encrypt(value); }, - decrypt(value: string): string { - return encryption.decrypt(value); + decrypt(value: string): string | undefined { + return decrypt(value); }, }, }); diff --git a/packages/analytics-js-plugins/src/storageMigrator/index.ts b/packages/analytics-js-plugins/src/storageMigrator/index.ts index 607ff8ea7..3ffad2a8f 100644 --- a/packages/analytics-js-plugins/src/storageMigrator/index.ts +++ b/packages/analytics-js-plugins/src/storageMigrator/index.ts @@ -7,7 +7,7 @@ import type { ILogger } from '@rudderstack/analytics-js-common/types/Logger'; import type { Nullable } from '@rudderstack/analytics-js-common/types/Nullable'; import type { IErrorHandler } from '@rudderstack/analytics-js-common/types/ErrorHandler'; import type { PluginName } from '@rudderstack/analytics-js-common/types/PluginsManager'; -import { checks, encryption } from '../shared-chunks/common'; +import { checks, decrypt } from '../shared-chunks/common'; import { decrypt as decryptLegacy } from '../storageEncryptionLegacy/legacyEncryptionUtils'; import { STORAGE_MIGRATION_ERROR } from './logMessages'; import { STORAGE_MIGRATOR_PLUGIN } from './constants'; @@ -32,12 +32,12 @@ const StorageMigrator = (): ExtensionPlugin => ({ return null; } - let decryptedVal = decryptLegacy(storedVal as string); + let decryptedVal: string | undefined = decryptLegacy(storedVal as string); // The value is not encrypted using legacy encryption // Try latest if (decryptedVal === storedVal) { - decryptedVal = encryption.decrypt(storedVal); + decryptedVal = decrypt(storedVal); } if (checks.isNullOrUndefined(decryptedVal)) { @@ -45,7 +45,7 @@ const StorageMigrator = (): ExtensionPlugin => ({ } // storejs that is used in localstorage engine already deserializes json strings but swallows errors - return JSON.parse(decryptedVal); + return JSON.parse(decryptedVal as string); } catch (err) { errorHandler?.onError(err, STORAGE_MIGRATOR_PLUGIN, STORAGE_MIGRATION_ERROR(key)); return null; diff --git a/packages/analytics-js-plugins/tsconfig.json b/packages/analytics-js-plugins/tsconfig.json index 8307249fc..278c6606d 100644 --- a/packages/analytics-js-plugins/tsconfig.json +++ b/packages/analytics-js-plugins/tsconfig.json @@ -9,6 +9,7 @@ "./src/**/*", "../../types/**/*", "../analytics-js-common/src/**/*", + "../analytics-js-cookies/src/**/*", "../analytics-js/src/**/*" ] } diff --git a/packages/analytics-js/__fixtures__/fixtures.ts b/packages/analytics-js/__fixtures__/fixtures.ts index ff93587b3..63634805d 100644 --- a/packages/analytics-js/__fixtures__/fixtures.ts +++ b/packages/analytics-js/__fixtures__/fixtures.ts @@ -1,5 +1,5 @@ -import { SourceConfigResponse } from '@rudderstack/analytics-js/components/configManager/types'; -import { USER_SESSION_STORAGE_KEYS } from '@rudderstack/analytics-js/components/userSessionManager/constants'; +import type { SourceConfigResponse } from '@rudderstack/analytics-js/components/configManager/types'; +import { COOKIE_KEYS } from '@rudderstack/analytics-js-cookies/constants/cookies'; const identifyRequestPayload = { userId: '123456', @@ -230,312 +230,312 @@ const dummySourceConfigResponse: SourceConfigResponse = { const entriesWithOnlyCookieStorage = { userId: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; const entriesWithOnlyLocalStorage = { userId: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; const entriesWithoutCookieStorage = { userId: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; const entriesWithoutCookieAndLocalStorage = { userId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; const entriesWithOnlyNoStorage = { userId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; const entriesWithOnlySessionStorage = { userId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; const entriesWithMixStorage = { userId: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; const entriesWithMixStorageButWithoutNone = { userId: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; @@ -572,39 +572,39 @@ const postConsentStorageEntryOptions = { const entriesWithInMemoryFallback = { userId: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; @@ -623,117 +623,117 @@ const loadOptionWithInvalidEntry = { const entriesWithStorageOnlyForSession = { userId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; const anonymousIdWithNoStorageEntries = { userId: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; const entriesWithStorageOnlyForAnonymousId = { userId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; diff --git a/packages/analytics-js/__tests__/components/configManager/ConfigManager.test.ts b/packages/analytics-js/__tests__/components/configManager/ConfigManager.test.ts index 72a02c601..df73dd4f0 100644 --- a/packages/analytics-js/__tests__/components/configManager/ConfigManager.test.ts +++ b/packages/analytics-js/__tests__/components/configManager/ConfigManager.test.ts @@ -246,7 +246,7 @@ describe('ConfigManager', () => { configManagerInstance.init(); - expect(state.serverCookies.dataServiceUrl.value).toBe('http://test-host.com/my/own/endpoint'); + expect(state.serverCookies.dataServiceUrl.value).toBe('https://test-host.com/my/own/endpoint'); }); it('should set the data server URL in state with default endpoint if server side cookies feature is enabled and dataServiceEndpoint is not provided', () => { @@ -259,7 +259,7 @@ describe('ConfigManager', () => { configManagerInstance.init(); - expect(state.serverCookies.dataServiceUrl.value).toBe('http://test-host.com/rsaRequest'); + expect(state.serverCookies.dataServiceUrl.value).toBe('https://test-host.com/rsaRequest'); }); it('should disable server side cookies feature if provided endpoint is invalid', () => { diff --git a/packages/analytics-js/__tests__/components/configManager/validate.test.ts b/packages/analytics-js/__tests__/components/configManager/validate.test.ts index 33a3cf715..86f55a0f4 100644 --- a/packages/analytics-js/__tests__/components/configManager/validate.test.ts +++ b/packages/analytics-js/__tests__/components/configManager/validate.test.ts @@ -47,11 +47,11 @@ describe('Config manager util - validate load arguments', () => { describe('getDataServiceUrl', () => { it('should return dataServiceUrl', () => { const dataServiceUrl = getDataServiceUrl('endpoint'); - expect(dataServiceUrl).toBe('http://test-host.com/endpoint'); + expect(dataServiceUrl).toBe('https://test-host.com/endpoint'); }); it('should prepare the dataServiceUrl with endpoint without leading slash', () => { const dataServiceUrl = getDataServiceUrl('/endpoint'); - expect(dataServiceUrl).toBe('http://test-host.com/endpoint'); + expect(dataServiceUrl).toBe('https://test-host.com/endpoint'); }); }); }); diff --git a/packages/analytics-js/__tests__/components/core/Analytics.test.ts b/packages/analytics-js/__tests__/components/core/Analytics.test.ts index 9672fbf8f..6bcdb7cda 100644 --- a/packages/analytics-js/__tests__/components/core/Analytics.test.ts +++ b/packages/analytics-js/__tests__/components/core/Analytics.test.ts @@ -1,9 +1,9 @@ import type { IPluginsManager } from '@rudderstack/analytics-js-common/types/PluginsManager'; -import type { IEventManager } from '@rudderstack/analytics-js/components/eventManager/types'; -import type { IUserSessionManager } from '@rudderstack/analytics-js/components/userSessionManager/types'; import type { IStoreManager } from '@rudderstack/analytics-js-common/types/Store'; -import { USER_SESSION_STORAGE_KEYS } from '@rudderstack/analytics-js/components/userSessionManager/constants'; +import { COOKIE_KEYS } from '@rudderstack/analytics-js-cookies/constants/cookies'; import { batch } from '@preact/signals-core'; +import type { IUserSessionManager } from '../../../src/components/userSessionManager/types'; +import type { IEventManager } from '../../../src/components/eventManager/types'; import { entriesWithMixStorage, entriesWithOnlyCookieStorage, @@ -569,39 +569,39 @@ describe('Core - Analytics', () => { expect(state.storage.entries.value).toStrictEqual({ userId: { type: 'sessionStorage', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, userTraits: { type: 'localStorage', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, anonymousId: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, groupId: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, groupTraits: { type: 'memoryStorage', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, initialReferrer: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, initialReferringDomain: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, sessionInfo: { type: 'cookieStorage', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, authToken: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }); diff --git a/packages/analytics-js/__tests__/components/eventManager/RudderEventFactory.test.ts b/packages/analytics-js/__tests__/components/eventManager/RudderEventFactory.test.ts index 3766c5180..c6fc18f09 100644 --- a/packages/analytics-js/__tests__/components/eventManager/RudderEventFactory.test.ts +++ b/packages/analytics-js/__tests__/components/eventManager/RudderEventFactory.test.ts @@ -110,8 +110,8 @@ describe('RudderEventFactory', () => { referring_domain: 'https://sample.com', search: '', title: '', - url: 'http://www.test-host.com/', - tab_url: 'http://www.test-host.com/', + url: 'https://www.test-host.com/', + tab_url: 'https://www.test-host.com/', initial_referrer: 'https://test.com/page', initial_referring_domain: 'https://test.com', }, @@ -127,8 +127,8 @@ describe('RudderEventFactory', () => { referring_domain: 'https://sample.com', search: '', title: '', - url: 'http://www.test-host.com/', - tab_url: 'http://www.test-host.com/', + url: 'https://www.test-host.com/', + tab_url: 'https://www.test-host.com/', initial_referrer: 'https://test.com/page', initial_referring_domain: 'https://test.com', }, @@ -192,8 +192,8 @@ describe('RudderEventFactory', () => { referring_domain: '', search: '', title: '', - url: 'http://www.test-host.com/', - tab_url: 'http://www.test-host.com/', + url: 'https://www.test-host.com/', + tab_url: 'https://www.test-host.com/', initial_referrer: 'https://test.com/page', initial_referring_domain: 'https://test.com', }, @@ -261,8 +261,8 @@ describe('RudderEventFactory', () => { referring_domain: '', search: '', title: '', - url: 'http://www.test-host.com/', - tab_url: 'http://www.test-host.com/', + url: 'https://www.test-host.com/', + tab_url: 'https://www.test-host.com/', initial_referrer: 'https://test.com/page', initial_referring_domain: 'https://test.com', }, @@ -343,8 +343,8 @@ describe('RudderEventFactory', () => { referring_domain: '', search: '', title: '', - url: 'http://www.test-host.com/', - tab_url: 'http://www.test-host.com/', + url: 'https://www.test-host.com/', + tab_url: 'https://www.test-host.com/', initial_referrer: 'https://test.com/page', initial_referring_domain: 'https://test.com', }, @@ -405,8 +405,8 @@ describe('RudderEventFactory', () => { referring_domain: '', search: '', title: '', - url: 'http://www.test-host.com/', - tab_url: 'http://www.test-host.com/', + url: 'https://www.test-host.com/', + tab_url: 'https://www.test-host.com/', initial_referrer: 'https://test.com/page', initial_referring_domain: 'https://test.com', }, @@ -481,8 +481,8 @@ describe('RudderEventFactory', () => { referring_domain: '', search: '', title: '', - url: 'http://www.test-host.com/', - tab_url: 'http://www.test-host.com/', + url: 'https://www.test-host.com/', + tab_url: 'https://www.test-host.com/', initial_referrer: 'https://test.com/page', initial_referring_domain: 'https://test.com', }, diff --git a/packages/analytics-js/__tests__/components/eventManager/utilities.test.ts b/packages/analytics-js/__tests__/components/eventManager/utilities.test.ts index a7c18e8c5..f3427e330 100644 --- a/packages/analytics-js/__tests__/components/eventManager/utilities.test.ts +++ b/packages/analytics-js/__tests__/components/eventManager/utilities.test.ts @@ -218,7 +218,7 @@ describe('Event Manager - Utilities', () => { title: pageProperties.title, url: pageProperties.url, referring_domain: pageProperties.referring_domain, - tab_url: 'http://www.test-host.com/', + tab_url: 'https://www.test-host.com/', initial_referrer: state.session.initialReferrer.value, initial_referring_domain: state.session.initialReferringDomain.value, anonymousId: pageProperties.anonymousId, @@ -323,8 +323,8 @@ describe('Event Manager - Utilities', () => { referring_domain: '', search: '', title: '', - url: 'http://www.test-host.com/', - tab_url: 'http://www.test-host.com/', + url: 'https://www.test-host.com/', + tab_url: 'https://www.test-host.com/', initial_referrer: 'https://test.com/page', initial_referring_domain: 'https://test.com', }, diff --git a/packages/analytics-js/__tests__/components/userSessionManager/UserSessionManager.test.ts b/packages/analytics-js/__tests__/components/userSessionManager/UserSessionManager.test.ts index 7a3e89ea6..db602712a 100644 --- a/packages/analytics-js/__tests__/components/userSessionManager/UserSessionManager.test.ts +++ b/packages/analytics-js/__tests__/components/userSessionManager/UserSessionManager.test.ts @@ -1,10 +1,8 @@ import type { IPluginsManager } from '@rudderstack/analytics-js-common/types/PluginsManager'; import { stringifyWithoutCircular } from '@rudderstack/analytics-js-common/utilities/json'; +import { COOKIE_KEYS } from '@rudderstack/analytics-js-cookies/constants/cookies'; import { UserSessionManager } from '../../../src/components/userSessionManager'; -import { - DEFAULT_USER_SESSION_VALUES, - USER_SESSION_STORAGE_KEYS, -} from '../../../src/components/userSessionManager/constants'; +import { DEFAULT_USER_SESSION_VALUES } from '../../../src/components/userSessionManager/constants'; import { StoreManager } from '../../../src/services/StoreManager'; import type { Store } from '../../../src/services/StoreManager/Store'; import { state, resetState } from '../../../src/state'; @@ -74,7 +72,7 @@ describe('User session manager', () => { }; const clearStorage = () => { - Object.values(USER_SESSION_STORAGE_KEYS).forEach(key => { + Object.values(COOKIE_KEYS).forEach(key => { clientDataStoreCookie.remove(key); clientDataStoreLS.remove(key); clientDataStoreSession.remove(key); @@ -601,7 +599,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, anonymousId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, }; userSessionManager.init(); @@ -651,7 +649,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, userId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, }; userSessionManager.init(); @@ -684,7 +682,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, userTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, }; userSessionManager.init(); @@ -717,7 +715,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, groupId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, }; userSessionManager.init(); @@ -750,7 +748,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, groupTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, }; userSessionManager.init(); @@ -788,7 +786,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, initialReferrer: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, }; userSessionManager.init(); @@ -822,7 +820,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, initialReferringDomain: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, }; userSessionManager.init(); @@ -855,7 +853,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, authToken: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; userSessionManager.init(); @@ -893,7 +891,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, sessionInfo: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.sessionInfo, + key: COOKIE_KEYS.sessionInfo, }, }; userSessionManager.init(); @@ -916,7 +914,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, anonymousId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.anonymousId, + key: COOKIE_KEYS.anonymousId, }, }; userSessionManager.init(); @@ -948,7 +946,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, userId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userId, + key: COOKIE_KEYS.userId, }, }; userSessionManager.init(); @@ -978,7 +976,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, userTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.userTraits, + key: COOKIE_KEYS.userTraits, }, }; userSessionManager.init(); @@ -1012,7 +1010,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, groupId: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupId, + key: COOKIE_KEYS.groupId, }, }; userSessionManager.init(); @@ -1042,7 +1040,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, groupTraits: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.groupTraits, + key: COOKIE_KEYS.groupTraits, }, }; userSessionManager.init(); @@ -1076,7 +1074,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, initialReferrer: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferrer, + key: COOKIE_KEYS.initialReferrer, }, }; userSessionManager.init(); @@ -1107,7 +1105,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, initialReferringDomain: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.initialReferringDomain, + key: COOKIE_KEYS.initialReferringDomain, }, }; userSessionManager.init(); @@ -1141,7 +1139,7 @@ describe('User session manager', () => { ...entriesWithOnlyCookieStorage, authToken: { type: 'none', - key: USER_SESSION_STORAGE_KEYS.authToken, + key: COOKIE_KEYS.authToken, }, }; userSessionManager.init(); diff --git a/packages/analytics-js/__tests__/components/utilities/page.test.ts b/packages/analytics-js/__tests__/components/utilities/page.test.ts index 9a3620874..24f801a69 100644 --- a/packages/analytics-js/__tests__/components/utilities/page.test.ts +++ b/packages/analytics-js/__tests__/components/utilities/page.test.ts @@ -222,13 +222,13 @@ describe('utilities - page', () => { documentSpy.mockRestore(); expect(getDefaultPageProperties()).toEqual({ - url: 'http://www.test-host.com/', + url: 'https://www.test-host.com/', path: '/', search: '', title: '', referrer: '$direct', referring_domain: '', - tab_url: 'http://www.test-host.com/', + tab_url: 'https://www.test-host.com/', }); }); }); diff --git a/packages/analytics-js/__tests__/services/StoreManager/top-domain/index.test.ts b/packages/analytics-js/__tests__/services/StoreManager/top-domain/index.test.ts index 541a197e4..dc1e77410 100644 --- a/packages/analytics-js/__tests__/services/StoreManager/top-domain/index.test.ts +++ b/packages/analytics-js/__tests__/services/StoreManager/top-domain/index.test.ts @@ -1,14 +1,12 @@ import type { Nullable } from '@rudderstack/analytics-js-common/types/Nullable'; -import type { CookieOptions } from '@rudderstack/analytics-js-common/types/Store'; +import type { CookieOptions } from '@rudderstack/analytics-js-common/types/Storage'; +import { cookie } from '@rudderstack/analytics-js-cookies/component-cookie'; import { domain } from '../../../../src/services/StoreManager/top-domain'; -import { cookie } from '../../../../src/services/StoreManager/component-cookie'; let cookies: Record = {}; -jest.mock('../../../../src/services/StoreManager/component-cookie', () => { - const originalModule = jest.requireActual( - '../../../../src/services/StoreManager/component-cookie', - ); +jest.mock('@rudderstack/analytics-js-cookies/component-cookie', () => { + const originalModule = jest.requireActual('@rudderstack/analytics-js-cookies/component-cookie'); return { __esModule: true, diff --git a/packages/analytics-js/package.json b/packages/analytics-js/package.json index 6c6a14c7e..1c42fa207 100644 --- a/packages/analytics-js/package.json +++ b/packages/analytics-js/package.json @@ -111,6 +111,7 @@ }, "dependencies": { "@rudderstack/analytics-js-common": "*", + "@rudderstack/analytics-js-cookies": "*", "@rudderstack/analytics-js-plugins": "*", "@preact/signals-core": "1.6.1", "ramda": "0.30.1", diff --git a/packages/analytics-js/project.json b/packages/analytics-js/project.json index 7b7bbacc2..fcad3a401 100644 --- a/packages/analytics-js/project.json +++ b/packages/analytics-js/project.json @@ -84,7 +84,8 @@ }, "configurations": { "ci": { - "ci": true + "ci": true, + "codeCoverage": true } }, "dependsOn": ["build-browser"] diff --git a/packages/analytics-js/rollup.config.mjs b/packages/analytics-js/rollup.config.mjs index e718611a1..d40bbdb21 100644 --- a/packages/analytics-js/rollup.config.mjs +++ b/packages/analytics-js/rollup.config.mjs @@ -369,6 +369,10 @@ const buildEntries = () => { { find: '@rudderstack/analytics-js-common', replacement: path.resolve('./dist/dts/packages/analytics-js-common/src'), + }, + { + find: '@rudderstack/analytics-js-cookies', + replacement: path.resolve('./dist/dts/packages/analytics-js-cookies/src'), } ] }), diff --git a/packages/analytics-js/src/components/capabilitiesManager/detection/dom.ts b/packages/analytics-js/src/components/capabilitiesManager/detection/dom.ts index 48822612e..9373ddace 100644 --- a/packages/analytics-js/src/components/capabilitiesManager/detection/dom.ts +++ b/packages/analytics-js/src/components/capabilitiesManager/detection/dom.ts @@ -36,6 +36,7 @@ const legacyJSEngineRequiredPolyfills: Record boolean> = { // Note, the polyfill service serves both ArrayBuffer and Uint8Array under the same feature name, "ArrayBuffer". ArrayBuffer: () => !isFunction(globalThis.Uint8Array), Set: () => !isFunction(globalThis.Set), + atob: () => !isFunction(globalThis.atob), }; const isLegacyJSEngine = (): boolean => { diff --git a/packages/analytics-js/src/components/userSessionManager/UserSessionManager.ts b/packages/analytics-js/src/components/userSessionManager/UserSessionManager.ts index b51a0bd64..61c17d543 100644 --- a/packages/analytics-js/src/components/userSessionManager/UserSessionManager.ts +++ b/packages/analytics-js/src/components/userSessionManager/UserSessionManager.ts @@ -32,6 +32,7 @@ import type { IHttpClient, } from '@rudderstack/analytics-js-common/types/HttpClient'; import { stringifyWithoutCircular } from '@rudderstack/analytics-js-common/utilities/json'; +import { COOKIE_KEYS } from '@rudderstack/analytics-js-cookies/constants/cookies'; import { CLIENT_DATA_STORE_COOKIE, CLIENT_DATA_STORE_LS, @@ -60,11 +61,7 @@ import { } from './utils'; import { getReferringDomain } from '../utilities/url'; import { getReferrer } from '../utilities/page'; -import { - DEFAULT_USER_SESSION_VALUES, - SERVER_SIDE_COOKIES_DEBOUNCE_TIME, - USER_SESSION_STORAGE_KEYS, -} from './constants'; +import { DEFAULT_USER_SESSION_VALUES, SERVER_SIDE_COOKIES_DEBOUNCE_TIME } from './constants'; import type { CallbackFunction, CookieData, @@ -189,12 +186,12 @@ class UserSessionManager implements IUserSessionManager { storageClientDataStoreNameMap[storage] as string, ); if (store && storage !== currentStorage) { - const value = store.get(USER_SESSION_STORAGE_KEYS[key]); + const value = store.get(COOKIE_KEYS[key]); if (isDefinedNotNullAndNotEmptyString(value)) { - curStore.set(USER_SESSION_STORAGE_KEYS[key], value); + curStore.set(COOKIE_KEYS[key], value); } - store.remove(USER_SESSION_STORAGE_KEYS[key]); + store.remove(COOKIE_KEYS[key]); } }); } @@ -220,8 +217,8 @@ class UserSessionManager implements IUserSessionManager { } }); - Object.keys(USER_SESSION_STORAGE_KEYS).forEach(storageKey => { - const storageEntry = USER_SESSION_STORAGE_KEYS[storageKey as UserSessionStorageKeysType]; + Object.keys(COOKIE_KEYS).forEach(storageKey => { + const storageEntry = COOKIE_KEYS[storageKey as UserSessionStorageKeysType]; stores.forEach(store => { const migratedVal = this.pluginsManager?.invokeSingle( 'storage.migrate', diff --git a/packages/analytics-js/src/components/userSessionManager/constants.ts b/packages/analytics-js/src/components/userSessionManager/constants.ts index 3463fd3bb..b9bec7a24 100644 --- a/packages/analytics-js/src/components/userSessionManager/constants.ts +++ b/packages/analytics-js/src/components/userSessionManager/constants.ts @@ -1,18 +1,6 @@ import type { ApiObject } from '@rudderstack/analytics-js-common/types/ApiObject'; import type { SessionInfo } from '@rudderstack/analytics-js-common/types/Session'; -const USER_SESSION_STORAGE_KEYS = { - userId: 'rl_user_id', - userTraits: 'rl_trait', - anonymousId: 'rl_anonymous_id', - groupId: 'rl_group_id', - groupTraits: 'rl_group_trait', - initialReferrer: 'rl_page_init_referrer', - initialReferringDomain: 'rl_page_init_referring_domain', - sessionInfo: 'rl_session', - authToken: 'rl_auth_token', -}; - const DEFAULT_USER_SESSION_VALUES = { userId: '', userTraits: {} as ApiObject, @@ -27,8 +15,4 @@ const DEFAULT_USER_SESSION_VALUES = { const SERVER_SIDE_COOKIES_DEBOUNCE_TIME = 10; // milliseconds -export { - USER_SESSION_STORAGE_KEYS, - DEFAULT_USER_SESSION_VALUES, - SERVER_SIDE_COOKIES_DEBOUNCE_TIME, -}; +export { DEFAULT_USER_SESSION_VALUES, SERVER_SIDE_COOKIES_DEBOUNCE_TIME }; diff --git a/packages/analytics-js/src/components/userSessionManager/types.ts b/packages/analytics-js/src/components/userSessionManager/types.ts index 8d598b347..31df01e18 100644 --- a/packages/analytics-js/src/components/userSessionManager/types.ts +++ b/packages/analytics-js/src/components/userSessionManager/types.ts @@ -2,7 +2,7 @@ import type { IStoreManager } from '@rudderstack/analytics-js-common/types/Store import type { AnonymousIdOptions } from '@rudderstack/analytics-js-common/types/LoadOptions'; import type { Nullable } from '@rudderstack/analytics-js-common/types/Nullable'; import type { ApiObject } from '@rudderstack/analytics-js-common/types/ApiObject'; -import type { USER_SESSION_STORAGE_KEYS } from './constants'; +import type { COOKIE_KEYS } from '@rudderstack/analytics-js-cookies/constants/cookies'; export interface IUserSessionManager { storeManager?: IStoreManager; @@ -26,7 +26,7 @@ export interface IUserSessionManager { setAuthToken(token: Nullable): void; } -export type UserSessionStorageKeysType = keyof typeof USER_SESSION_STORAGE_KEYS; +export type UserSessionStorageKeysType = keyof typeof COOKIE_KEYS; export type CookieData = { name: string; diff --git a/packages/analytics-js/src/constants/logMessages.ts b/packages/analytics-js/src/constants/logMessages.ts index 927a13ec6..644294599 100644 --- a/packages/analytics-js/src/constants/logMessages.ts +++ b/packages/analytics-js/src/constants/logMessages.ts @@ -208,8 +208,6 @@ const INVALID_CONFIG_URL_WARNING = (context: string, configUrl: string | undefin const POLYFILL_SCRIPT_LOAD_ERROR = (scriptId: string, url: string): string => `Failed to load the polyfill script with ID "${scriptId}" from URL ${url}.`; -const COOKIE_DATA_ENCODING_ERROR = `Failed to encode the cookie data.`; - const UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY = ( context: string, selectedStrategy: StorageStrategy | undefined, @@ -294,7 +292,6 @@ export { API_CALLBACK_INVOKE_ERROR, INVALID_CONFIG_URL_WARNING, POLYFILL_SCRIPT_LOAD_ERROR, - COOKIE_DATA_ENCODING_ERROR, UNSUPPORTED_PRE_CONSENT_STORAGE_STRATEGY, UNSUPPORTED_PRE_CONSENT_EVENTS_DELIVERY_TYPE, SOURCE_CONFIG_RESOLUTION_ERROR, diff --git a/packages/analytics-js/src/services/StoreManager/StoreManager.ts b/packages/analytics-js/src/services/StoreManager/StoreManager.ts index 13cf8f5cc..26d8ee108 100644 --- a/packages/analytics-js/src/services/StoreManager/StoreManager.ts +++ b/packages/analytics-js/src/services/StoreManager/StoreManager.ts @@ -25,8 +25,8 @@ import { import type { UserSessionKey } from '@rudderstack/analytics-js-common/types/UserSessionStorage'; import { batch } from '@preact/signals-core'; import { isDefined } from '@rudderstack/analytics-js-common/utilities/checks'; +import { COOKIE_KEYS } from '@rudderstack/analytics-js-cookies/constants/cookies'; import { USER_SESSION_KEYS } from '../../constants/storage'; -import { USER_SESSION_STORAGE_KEYS } from '../../components/userSessionManager/constants'; import { STORAGE_UNAVAILABLE_WARNING } from '../../constants/logMessages'; import { type StoreManagerOptions, storageClientDataStoreNameMap } from './types'; import { state } from '../../state'; @@ -148,7 +148,7 @@ class StoreManager implements IStoreManager { ...storageEntries, [sessionKey]: { type: finalStorageType, - key: USER_SESSION_STORAGE_KEYS[storageKey], + key: COOKIE_KEYS[storageKey], }, }; }); diff --git a/packages/analytics-js/src/services/StoreManager/storages/CookieStorage.ts b/packages/analytics-js/src/services/StoreManager/storages/CookieStorage.ts index 94687197e..1a9dca416 100644 --- a/packages/analytics-js/src/services/StoreManager/storages/CookieStorage.ts +++ b/packages/analytics-js/src/services/StoreManager/storages/CookieStorage.ts @@ -4,8 +4,8 @@ import type { Nullable } from '@rudderstack/analytics-js-common/types/Nullable'; import type { ILogger } from '@rudderstack/analytics-js-common/types/Logger'; import { COOKIE_STORAGE } from '@rudderstack/analytics-js-common/constants/storages'; import { mergeDeepRight } from '@rudderstack/analytics-js-common/utilities/object'; +import { cookie } from '@rudderstack/analytics-js-cookies/component-cookie'; import { isStorageAvailable } from '../../../components/capabilitiesManager/detection'; -import { cookie } from '../component-cookie'; import { getDefaultCookieOptions } from './defaultOptions'; /** diff --git a/packages/analytics-js/src/services/StoreManager/top-domain/index.ts b/packages/analytics-js/src/services/StoreManager/top-domain/index.ts index 78638e92d..cf5d2af38 100644 --- a/packages/analytics-js/src/services/StoreManager/top-domain/index.ts +++ b/packages/analytics-js/src/services/StoreManager/top-domain/index.ts @@ -1,5 +1,5 @@ +import { cookie } from '@rudderstack/analytics-js-cookies/component-cookie'; import { STORAGE_TEST_TOP_LEVEL_DOMAIN } from '../../../constants/storage'; -import { cookie } from '../component-cookie'; const legacyGetHostname = (href: string): string => { const l = document.createElement('a'); diff --git a/packages/analytics-js/tsconfig.json b/packages/analytics-js/tsconfig.json index eb61d0af3..8ed2d2730 100644 --- a/packages/analytics-js/tsconfig.json +++ b/packages/analytics-js/tsconfig.json @@ -9,6 +9,7 @@ "./src/**/*", "../../types/**/*", "../analytics-js-plugins/src/**/*", - "../analytics-js-common/src/**/*" + "../analytics-js-common/src/**/*", + "../analytics-js-cookies/src/**/*" ] } diff --git a/scripts/commitizen.js b/scripts/commitizen.js index 1f7da82a7..1e876bdc9 100644 --- a/scripts/commitizen.js +++ b/scripts/commitizen.js @@ -20,6 +20,7 @@ module.exports = custom({ 'rudder-sdk-js', 'analytics-js-sanity-suite', 'analytics-js-loading-scripts', + 'analytics-js-cookies', 'deps', 'examples', ], diff --git a/scripts/fix-reports-path-in-github-runner.sh b/scripts/fix-reports-path-in-github-runner.sh index f9a9fe190..6dab2ddde 100755 --- a/scripts/fix-reports-path-in-github-runner.sh +++ b/scripts/fix-reports-path-in-github-runner.sh @@ -5,7 +5,7 @@ defaultAbsolutePathPrefix="home/runner/work/rudder-sdk-js/rudder-sdk-js" selfHostedAbsolutePathPrefix="runner/_work/rudder-sdk-js/rudder-sdk-js" absolutePathPrefix="$selfHostedAbsolutePathPrefix" # List of package folders -projectFolderNames=("analytics-js" "analytics-js-common" "analytics-js-integrations" "analytics-js-plugins" "analytics-js-service-worker" "analytics-v1.1") +projectFolderNames=("analytics-js" "analytics-js-common" "analytics-js-integrations" "analytics-js-plugins" "analytics-js-service-worker" "analytics-v1.1" "analytics-js-cookies") # List of files to alter for projectFolder in "${projectFolderNames[@]}"; do diff --git a/scripts/generate-last-release-changelog.sh b/scripts/generate-last-release-changelog.sh index 439fce510..d7c9b0ba4 100755 --- a/scripts/generate-last-release-changelog.sh +++ b/scripts/generate-last-release-changelog.sh @@ -1,6 +1,6 @@ #!/bin/bash # List of package folders -projectFolderNames=("analytics-js" "analytics-js-common" "analytics-js-integrations" "analytics-js-plugins" "analytics-js-service-worker" "analytics-v1.1" "loading-scripts") +projectFolderNames=("analytics-js" "analytics-js-common" "analytics-js-integrations" "analytics-js-plugins" "analytics-js-service-worker" "analytics-v1.1" "loading-scripts" "analytics-js-cookies") for projectFolder in "${projectFolderNames[@]}"; do # Set of package project name diff --git a/scripts/sync-tags-in-nx-projects.sh b/scripts/sync-tags-in-nx-projects.sh index 1fdce0a3b..af2176b2c 100755 --- a/scripts/sync-tags-in-nx-projects.sh +++ b/scripts/sync-tags-in-nx-projects.sh @@ -1,6 +1,6 @@ #!/bin/bash # List of package folders -projectFolderNames=("analytics-js" "analytics-js-common" "analytics-js-integrations" "analytics-js-plugins" "analytics-js-service-worker" "analytics-v1.1" "loading-scripts") +projectFolderNames=("analytics-js" "analytics-js-common" "analytics-js-integrations" "analytics-js-plugins" "analytics-js-service-worker" "analytics-v1.1" "loading-scripts" "analytics-js-cookies") for projectFolder in "${projectFolderNames[@]}"; do # Set of package project name diff --git a/sonar-project.properties b/sonar-project.properties index 86ef4706a..4d9ed05e9 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -13,9 +13,9 @@ sonar.links.scm=https://github.com/rudderlabs/rudder-sdk-js sonar.links.issue=https://github.com/rudderlabs/rudder-sdk-js/issues # Path to reports -sonar.javascript.lcov.reportPaths=packages/analytics-js/reports/coverage/lcov.info,packages/analytics-js-plugins/reports/coverage/lcov.info,packages/analytics-js-common/reports/coverage/lcov.info,packages/analytics-js-integrations/reports/coverage/lcov.info,packages/analytics-js-service-worker/reports/coverage/lcov.info,packages/analytics-v1.1/reports/coverage/lcov.info -sonar.testExecutionReportPaths=packages/analytics-js/reports/sonar/results-report.xml,packages/analytics-js-plugins/reports/sonar/results-report.xml,packages/analytics-js-common/reports/sonar/results-report.xml,packages/analytics-js-integrations/reports/sonar/results-report.xml,packages/analytics-js-service-worker/reports/sonar/results-report.xml,packages/analytics-v1.1/reports/sonar/results-report.xml -sonar.eslint.reportPaths=packages/analytics-js/reports/eslint.json,packages/analytics-js-plugins/reports/eslint.json,packages/analytics-js-common/reports/eslint.json,packages/analytics-js-integrations/reports/eslint.json,packages/analytics-js-service-worker/reports/eslint.json,packages/analytics-v1.1/reports/eslint.json,packages/loading-scripts/reports/eslint.json,packages/sanity-suite/reports/eslint.json +sonar.javascript.lcov.reportPaths=packages/analytics-js/reports/coverage/lcov.info,packages/analytics-js-plugins/reports/coverage/lcov.info,packages/analytics-js-common/reports/coverage/lcov.info,packages/analytics-js-integrations/reports/coverage/lcov.info,packages/analytics-js-service-worker/reports/coverage/lcov.info,packages/analytics-v1.1/reports/coverage/lcov.info,packages/analytics-js-cookies/reports/coverage/lcov.info +sonar.testExecutionReportPaths=packages/analytics-js/reports/sonar/results-report.xml,packages/analytics-js-plugins/reports/sonar/results-report.xml,packages/analytics-js-common/reports/sonar/results-report.xml,packages/analytics-js-integrations/reports/sonar/results-report.xml,packages/analytics-js-service-worker/reports/sonar/results-report.xml,packages/analytics-v1.1/reports/sonar/results-report.xml,packages/analytics-js-cookies/reports/sonar/results-report.xml +sonar.eslint.reportPaths=packages/analytics-js/reports/eslint.json,packages/analytics-js-plugins/reports/eslint.json,packages/analytics-js-common/reports/eslint.json,packages/analytics-js-integrations/reports/eslint.json,packages/analytics-js-service-worker/reports/eslint.json,packages/analytics-v1.1/reports/eslint.json,packages/loading-scripts/reports/eslint.json,packages/sanity-suite/reports/eslint.json,packages/analytics-js-cookies/reports/eslint.json # Path to sources sonar.sources=packages diff --git a/tsconfig.json b/tsconfig.json index 4c1698841..0e7bc12b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,8 @@ ], "rudder-sdk-js/*": ["./packages/analytics-v1.1/src/*"], "@rudderstack/analytics-js-loading-script/*": ["./packages/loading-scripts/src/*"], - "@rudderstack/analytics-js-sanity-suite/*": ["./packages/sanity-suite/src/*"] + "@rudderstack/analytics-js-sanity-suite/*": ["./packages/sanity-suite/src/*"], + "@rudderstack/analytics-js-cookies/*": ["./packages/analytics-js-cookies/src/*"] }, "composite": true, "outDir": "./dist", diff --git a/tsconfig.paths.json b/tsconfig.paths.json index a7dbf07c2..3637e5688 100644 --- a/tsconfig.paths.json +++ b/tsconfig.paths.json @@ -7,6 +7,7 @@ { "path": "./packages/analytics-js-service-worker/tsconfig.json" }, { "path": "./packages/analytics-v1.1/tsconfig.json" }, { "path": "./packages/loading-scripts/tsconfig.json" }, - { "path": "./packages/sanity-suite/tsconfig.json" } + { "path": "./packages/sanity-suite/tsconfig.json" }, + { "path": "./packages/analytics-js-cookies/tsconfig.json" } ] } From 47666df41ad16cb38b6186b566cd9de2c6b234d3 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 25 Jun 2024 10:41:01 +0000 Subject: [PATCH 2/7] chore(@rudderstack/analytics-js-cookies): release version 0.1.0 --- packages/analytics-js-cookies/CHANGELOG.md | 14 ++++++++++++++ packages/analytics-js-cookies/package.json | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/analytics-js-cookies/CHANGELOG.md b/packages/analytics-js-cookies/CHANGELOG.md index 99e9777f2..a9fe88209 100644 --- a/packages/analytics-js-cookies/CHANGELOG.md +++ b/packages/analytics-js-cookies/CHANGELOG.md @@ -1,3 +1,17 @@ # Changelog This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). + +## 0.1.0 (2024-06-25) + +### Dependency Updates + +* `@rudderstack/analytics-js-common` updated to version `0.1.0` + +### Features + +* create new package for cookie utilities ([#1759](https://github.com/rudderlabs/rudder-sdk-js/issues/1759)) ([92826a4](https://github.com/rudderlabs/rudder-sdk-js/commit/92826a4f2e87dd2d0d755016592e36e4708f34d4)) + +# Changelog + +This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). diff --git a/packages/analytics-js-cookies/package.json b/packages/analytics-js-cookies/package.json index fa3ee19a2..d9eb772db 100644 --- a/packages/analytics-js-cookies/package.json +++ b/packages/analytics-js-cookies/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-cookies", - "version": "1.0.0", + "version": "0.1.0", "description": "RudderStack JavaScript SDK Cookies Module", "main": "dist/npm/modern/cjs/index.js", "module": "dist/npm/modern/esm/index.js", From 20a14660536445f38d2511972f2aa06a81a2d7e7 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 25 Jun 2024 10:41:02 +0000 Subject: [PATCH 3/7] chore(@rudderstack/analytics-js-plugins): release version 3.2.0 --- packages/analytics-js-plugins/CHANGELOG.md | 11 +++++++++++ packages/analytics-js-plugins/package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/analytics-js-plugins/CHANGELOG.md b/packages/analytics-js-plugins/CHANGELOG.md index 822dfdc8f..23f83f0b7 100644 --- a/packages/analytics-js-plugins/CHANGELOG.md +++ b/packages/analytics-js-plugins/CHANGELOG.md @@ -2,6 +2,17 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.2.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.1.1...@rudderstack/analytics-js-plugins@3.2.0) (2024-06-25) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.1.1` +* `@rudderstack/analytics-js-cookies` updated to version `3.1.1` + +### Features + +* create new package for cookie utilities ([#1759](https://github.com/rudderlabs/rudder-sdk-js/issues/1759)) ([92826a4](https://github.com/rudderlabs/rudder-sdk-js/commit/92826a4f2e87dd2d0d755016592e36e4708f34d4)) + ## [3.1.1](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.1.0...@rudderstack/analytics-js-plugins@3.1.1) (2024-06-21) ### Dependency Updates diff --git a/packages/analytics-js-plugins/package.json b/packages/analytics-js-plugins/package.json index 5564ce4b3..b8825925d 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.1.1", + "version": "3.2.0", "private": true, "description": "RudderStack JavaScript SDK plugins", "main": "dist/npm/modern/cjs/index.js", From d3e7c1cebd936aefc746e5cdff42c55743dea11d Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 25 Jun 2024 10:41:02 +0000 Subject: [PATCH 4/7] chore(@rudderstack/analytics-js): release version 3.5.0 --- packages/analytics-js/CHANGELOG.md | 11 +++++++++++ packages/analytics-js/package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/analytics-js/CHANGELOG.md b/packages/analytics-js/CHANGELOG.md index c66922662..d1e34e120 100644 --- a/packages/analytics-js/CHANGELOG.md +++ b/packages/analytics-js/CHANGELOG.md @@ -2,6 +2,17 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.5.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.4.0...@rudderstack/analytics-js@3.5.0) (2024-06-25) + +### Dependency Updates + +* `@rudderstack/analytics-js-cookies` updated to version `3.4.0` +* `@rudderstack/analytics-js-plugins` updated to version `3.4.0` + +### Features + +* create new package for cookie utilities ([#1759](https://github.com/rudderlabs/rudder-sdk-js/issues/1759)) ([92826a4](https://github.com/rudderlabs/rudder-sdk-js/commit/92826a4f2e87dd2d0d755016592e36e4708f34d4)) + ## [3.4.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.3.0...@rudderstack/analytics-js@3.4.0) (2024-06-21) ### Dependency Updates diff --git a/packages/analytics-js/package.json b/packages/analytics-js/package.json index 1c42fa207..075fc4650 100644 --- a/packages/analytics-js/package.json +++ b/packages/analytics-js/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js", - "version": "3.4.0", + "version": "3.5.0", "description": "RudderStack JavaScript SDK", "main": "dist/npm/modern/cjs/index.js", "module": "dist/npm/modern/esm/index.js", From 672f42107074f11923af71d677af3b2661764ad3 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 25 Jun 2024 10:41:04 +0000 Subject: [PATCH 5/7] chore(@rudderstack/analytics-js-loading-scripts): release version 3.0.12 --- 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 5f1deeb09..1424c4506 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.12](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.11...@rudderstack/analytics-js-loading-scripts@3.0.12) (2024-06-25) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.0.11` ## [3.0.11](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.10...@rudderstack/analytics-js-loading-scripts@3.0.11) (2024-06-21) ### Dependency Updates diff --git a/packages/loading-scripts/package.json b/packages/loading-scripts/package.json index 493f552bd..65f62a802 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.11", + "version": "3.0.12", "private": true, "description": "Loading script for RudderStack JavaScript SDK", "main": "./src/index.js", From 285fa66a35f61c63a6c66b54c32694be5fd4118e Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 25 Jun 2024 10:41:05 +0000 Subject: [PATCH 6/7] chore(@rudderstack/analytics-js-sanity-suite): release version 3.1.2 --- packages/sanity-suite/CHANGELOG.md | 10 ++++++++++ packages/sanity-suite/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/sanity-suite/CHANGELOG.md b/packages/sanity-suite/CHANGELOG.md index cb1004903..12064174b 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.2](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-sanity-suite@3.1.1...@rudderstack/analytics-js-sanity-suite@3.1.2) (2024-06-25) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.1.1` + +### Bug Fixes + +* **analytics-js-sanity-suite:** avoid using iterators and force trigger mutation observer ([bbc66e4](https://github.com/rudderlabs/rudder-sdk-js/commit/bbc66e4d4f75b0c52bb8391cd6775b3d84d573ee)) + ## [3.1.1](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-sanity-suite@3.1.0...@rudderstack/analytics-js-sanity-suite@3.1.1) (2024-06-21) ### Dependency Updates diff --git a/packages/sanity-suite/package.json b/packages/sanity-suite/package.json index 9ac959eb2..48cfd767c 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.1", + "version": "3.1.2", "private": true, "description": "Sanity suite for testing JS SDK package", "main": "./dist/cdn/v3/testBook.js", From 9380a9d4ff12fab73c56a29f3aa60850aef938f0 Mon Sep 17 00:00:00 2001 From: GitHub actions Date: Tue, 25 Jun 2024 10:43:51 +0000 Subject: [PATCH 7/7] chore(monorepo): sync versions and generate release logs --- package-lock.json | 14 +++++++------- package.json | 2 +- .../analytics-js-cookies/CHANGELOG_LATEST.md | 13 +++++++++++++ packages/analytics-js-cookies/project.json | 6 +++--- .../analytics-js-plugins/CHANGELOG_LATEST.md | 11 +++++------ packages/analytics-js-plugins/project.json | 6 +++--- packages/analytics-js/CHANGELOG_LATEST.md | 16 ++++------------ packages/analytics-js/project.json | 6 +++--- packages/loading-scripts/CHANGELOG_LATEST.md | 9 ++------- packages/loading-scripts/project.json | 6 +++--- sonar-project.properties | 2 +- 11 files changed, 45 insertions(+), 46 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0d0a2962a..733951d0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.13.0", + "version": "3.14.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.13.0", + "version": "3.14.0", "hasInstallScript": true, "license": "MIT", "workspaces": [ @@ -24950,7 +24950,7 @@ }, "packages/analytics-js": { "name": "@rudderstack/analytics-js", - "version": "3.4.0", + "version": "3.5.0", "license": "MIT", "dependencies": { "@preact/signals-core": "1.6.1", @@ -24981,7 +24981,7 @@ }, "packages/analytics-js-cookies": { "name": "@rudderstack/analytics-js-cookies", - "version": "1.0.0", + "version": "0.1.0", "license": "MIT", "dependencies": { "@rudderstack/analytics-js-common": "*" @@ -25010,7 +25010,7 @@ }, "packages/analytics-js-plugins": { "name": "@rudderstack/analytics-js-plugins", - "version": "3.1.1", + "version": "3.2.0", "license": "MIT", "dependencies": { "@rudderstack/analytics-js-common": "*", @@ -25065,7 +25065,7 @@ }, "packages/loading-scripts": { "name": "@rudderstack/analytics-js-loading-scripts", - "version": "3.0.11", + "version": "3.0.12", "license": "MIT", "dependencies": { "@rudderstack/analytics-js": "*" @@ -25074,7 +25074,7 @@ }, "packages/sanity-suite": { "name": "@rudderstack/analytics-js-sanity-suite", - "version": "3.1.1", + "version": "3.1.2", "license": "MIT", "dependencies": { "@rudderstack/analytics-js": "*", diff --git a/package.json b/package.json index 94f04185b..20e548b50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.13.0", + "version": "3.14.0", "private": true, "description": "Monorepo for RudderStack Analytics JS SDK", "workspaces": [ diff --git a/packages/analytics-js-cookies/CHANGELOG_LATEST.md b/packages/analytics-js-cookies/CHANGELOG_LATEST.md index e69de29bb..abad188ac 100644 --- a/packages/analytics-js-cookies/CHANGELOG_LATEST.md +++ b/packages/analytics-js-cookies/CHANGELOG_LATEST.md @@ -0,0 +1,13 @@ +## 0.1.0 (2024-06-25) + +### Dependency Updates + +* `@rudderstack/analytics-js-common` updated to version `0.1.0` + +### Features + +* create new package for cookie utilities ([#1759](https://github.com/rudderlabs/rudder-sdk-js/issues/1759)) ([92826a4](https://github.com/rudderlabs/rudder-sdk-js/commit/92826a4f2e87dd2d0d755016592e36e4708f34d4)) + +# Changelog + +This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). diff --git a/packages/analytics-js-cookies/project.json b/packages/analytics-js-cookies/project.json index 3c57eec1c..a247e8407 100644 --- a/packages/analytics-js-cookies/project.json +++ b/packages/analytics-js-cookies/project.json @@ -101,9 +101,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-cookies@1.0.0", - "title": "@rudderstack/analytics-js-cookies@1.0.0", - "discussion-category": "@rudderstack/analytics-js-cookies@1.0.0", + "tag": "@rudderstack/analytics-js-cookies@0.1.0", + "title": "@rudderstack/analytics-js-cookies@0.1.0", + "discussion-category": "@rudderstack/analytics-js-cookies@0.1.0", "notesFile": "./packages/analytics-js-cookies/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js-plugins/CHANGELOG_LATEST.md b/packages/analytics-js-plugins/CHANGELOG_LATEST.md index 8c4f509bc..70ce30ad8 100644 --- a/packages/analytics-js-plugins/CHANGELOG_LATEST.md +++ b/packages/analytics-js-plugins/CHANGELOG_LATEST.md @@ -1,12 +1,11 @@ -## [3.1.1](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.1.0...@rudderstack/analytics-js-plugins@3.1.1) (2024-06-21) +## [3.2.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.1.1...@rudderstack/analytics-js-plugins@3.2.0) (2024-06-25) ### Dependency Updates -* `@rudderstack/analytics-js-common` updated to version `3.1.0` -* `@rudderstack/analytics-js` updated to version `3.1.0` +* `@rudderstack/analytics-js` updated to version `3.1.1` +* `@rudderstack/analytics-js-cookies` updated to version `3.1.1` -### Bug Fixes +### Features -* add state metadata even for unhandled errors ([#1755](https://github.com/rudderlabs/rudder-sdk-js/issues/1755)) ([66fc415](https://github.com/rudderlabs/rudder-sdk-js/commit/66fc415474ffccd684972b47f9926ab87c0a514c)) -* improve flushing events on page leave ([#1754](https://github.com/rudderlabs/rudder-sdk-js/issues/1754)) ([1be420f](https://github.com/rudderlabs/rudder-sdk-js/commit/1be420fae16b68629789d2ba37e16e6a6e00017c)) +* create new package for cookie utilities ([#1759](https://github.com/rudderlabs/rudder-sdk-js/issues/1759)) ([92826a4](https://github.com/rudderlabs/rudder-sdk-js/commit/92826a4f2e87dd2d0d755016592e36e4708f34d4)) diff --git a/packages/analytics-js-plugins/project.json b/packages/analytics-js-plugins/project.json index 584e0d7db..febf65d24 100644 --- a/packages/analytics-js-plugins/project.json +++ b/packages/analytics-js-plugins/project.json @@ -119,9 +119,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-plugins@3.1.1", - "title": "@rudderstack/analytics-js-plugins@3.1.1", - "discussion-category": "@rudderstack/analytics-js-plugins@3.1.1", + "tag": "@rudderstack/analytics-js-plugins@3.2.0", + "title": "@rudderstack/analytics-js-plugins@3.2.0", + "discussion-category": "@rudderstack/analytics-js-plugins@3.2.0", "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 5b17f6611..172ba212f 100644 --- a/packages/analytics-js/CHANGELOG_LATEST.md +++ b/packages/analytics-js/CHANGELOG_LATEST.md @@ -1,19 +1,11 @@ -## [3.4.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.3.0...@rudderstack/analytics-js@3.4.0) (2024-06-21) +## [3.5.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.4.0...@rudderstack/analytics-js@3.5.0) (2024-06-25) ### Dependency Updates -* `@rudderstack/analytics-js-common` updated to version `3.3.0` -* `@rudderstack/analytics-js-plugins` updated to version `3.3.0` +* `@rudderstack/analytics-js-cookies` updated to version `3.4.0` +* `@rudderstack/analytics-js-plugins` updated to version `3.4.0` ### Features -* add the ability to lock plugins version ([#1749](https://github.com/rudderlabs/rudder-sdk-js/issues/1749)) ([e2e1620](https://github.com/rudderlabs/rudder-sdk-js/commit/e2e1620677c90169fca35ed3e9057ced3b88a299)) - - -### Bug Fixes - -* add state metadata even for unhandled errors ([#1755](https://github.com/rudderlabs/rudder-sdk-js/issues/1755)) ([66fc415](https://github.com/rudderlabs/rudder-sdk-js/commit/66fc415474ffccd684972b47f9926ab87c0a514c)) -* debounce cookie requests to server ([#1752](https://github.com/rudderlabs/rudder-sdk-js/issues/1752)) ([8b25cbe](https://github.com/rudderlabs/rudder-sdk-js/commit/8b25cbea43274f71825986c0ce78919358ce5b15)) -* improve flushing events on page leave ([#1754](https://github.com/rudderlabs/rudder-sdk-js/issues/1754)) ([1be420f](https://github.com/rudderlabs/rudder-sdk-js/commit/1be420fae16b68629789d2ba37e16e6a6e00017c)) -* remove data residency feature ([#1748](https://github.com/rudderlabs/rudder-sdk-js/issues/1748)) ([870a7ec](https://github.com/rudderlabs/rudder-sdk-js/commit/870a7ecf3cd251d88c207d9815c2f16c6e9a6883)) +* create new package for cookie utilities ([#1759](https://github.com/rudderlabs/rudder-sdk-js/issues/1759)) ([92826a4](https://github.com/rudderlabs/rudder-sdk-js/commit/92826a4f2e87dd2d0d755016592e36e4708f34d4)) diff --git a/packages/analytics-js/project.json b/packages/analytics-js/project.json index fcad3a401..6b50656b6 100644 --- a/packages/analytics-js/project.json +++ b/packages/analytics-js/project.json @@ -120,9 +120,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js@3.4.0", - "title": "@rudderstack/analytics-js@3.4.0", - "discussion-category": "@rudderstack/analytics-js@3.4.0", + "tag": "@rudderstack/analytics-js@3.5.0", + "title": "@rudderstack/analytics-js@3.5.0", + "discussion-category": "@rudderstack/analytics-js@3.5.0", "notesFile": "./packages/analytics-js/CHANGELOG_LATEST.md" } } diff --git a/packages/loading-scripts/CHANGELOG_LATEST.md b/packages/loading-scripts/CHANGELOG_LATEST.md index 039c9741e..1267ad5ac 100644 --- a/packages/loading-scripts/CHANGELOG_LATEST.md +++ b/packages/loading-scripts/CHANGELOG_LATEST.md @@ -1,10 +1,5 @@ -## [3.0.11](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.10...@rudderstack/analytics-js-loading-scripts@3.0.11) (2024-06-21) +## [3.0.12](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.11...@rudderstack/analytics-js-loading-scripts@3.0.12) (2024-06-25) ### Dependency Updates -* `@rudderstack/analytics-js` updated to version `3.0.10` - -### Bug Fixes - -* improve flushing events on page leave ([#1754](https://github.com/rudderlabs/rudder-sdk-js/issues/1754)) ([1be420f](https://github.com/rudderlabs/rudder-sdk-js/commit/1be420fae16b68629789d2ba37e16e6a6e00017c)) - +* `@rudderstack/analytics-js` updated to version `3.0.11` diff --git a/packages/loading-scripts/project.json b/packages/loading-scripts/project.json index 488c4f205..d0a213654 100644 --- a/packages/loading-scripts/project.json +++ b/packages/loading-scripts/project.json @@ -89,9 +89,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-loading-scripts@3.0.11", - "title": "@rudderstack/analytics-js-loading-scripts@3.0.11", - "discussion-category": "@rudderstack/analytics-js-loading-scripts@3.0.11", + "tag": "@rudderstack/analytics-js-loading-scripts@3.0.12", + "title": "@rudderstack/analytics-js-loading-scripts@3.0.12", + "discussion-category": "@rudderstack/analytics-js-loading-scripts@3.0.12", "notesFile": "./packages/loading-scripts/CHANGELOG_LATEST.md" } } diff --git a/sonar-project.properties b/sonar-project.properties index 4d9ed05e9..1bafce22f 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.13.0 +sonar.projectVersion=3.14.0 # Meta-data for the project sonar.links.scm=https://github.com/rudderlabs/rudder-sdk-js