Skip to content

Commit

Permalink
chore(release): pull hotfix-release/3.39.0-SDK-2469 into main (#1873)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoumitaM authored Oct 3, 2024
2 parents 0ce61dd + cbf0833 commit 3a181d7
Show file tree
Hide file tree
Showing 24 changed files with 335 additions and 86 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rudderstack/analytics-js-monorepo",
"version": "3.38.0",
"version": "3.39.0",
"private": true,
"description": "Monorepo for RudderStack Analytics JS SDK",
"workspaces": [
Expand Down
6 changes: 6 additions & 0 deletions packages/analytics-js-plugins/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [3.4.15](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.4.14...@rudderstack/analytics-js-plugins@3.4.15) (2024-10-03)

### Dependency Updates

* `@rudderstack/analytics-js` updated to version `3.7.14`
* `@rudderstack/analytics-js-cookies` updated to version `0.3.9`
## [3.4.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.4.13...@rudderstack/analytics-js-plugins@3.4.14) (2024-09-27)

### Dependency Updates
Expand Down
12 changes: 3 additions & 9 deletions packages/analytics-js-plugins/CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
## [3.4.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.4.13...@rudderstack/analytics-js-plugins@3.4.14) (2024-09-27)
## [3.4.15](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.4.14...@rudderstack/analytics-js-plugins@3.4.15) (2024-10-03)

### Dependency Updates

* `@rudderstack/analytics-js-common` updated to version `3.9.3`
* `@rudderstack/analytics-js` updated to version `3.7.13`

### Bug Fixes

* filter non error type errors ([#1865](https://github.com/rudderlabs/rudder-sdk-js/issues/1865)) ([060f66c](https://github.com/rudderlabs/rudder-sdk-js/commit/060f66cbf33500d6e0ee47c788ed687f4f619a57))
* upgrade all packages to latest to fix vulnerabilities ([#1867](https://github.com/rudderlabs/rudder-sdk-js/issues/1867)) ([389348c](https://github.com/rudderlabs/rudder-sdk-js/commit/389348cfa61f2111c5ac4f9e2bad5851a466484d))

* `@rudderstack/analytics-js` updated to version `3.7.14`
* `@rudderstack/analytics-js-cookies` updated to version `0.3.9`
2 changes: 1 addition & 1 deletion packages/analytics-js-plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rudderstack/analytics-js-plugins",
"version": "3.4.14",
"version": "3.4.15",
"private": true,
"description": "RudderStack JavaScript SDK plugins",
"main": "dist/npm/modern/cjs/index.cjs",
Expand Down
6 changes: 3 additions & 3 deletions packages/analytics-js-plugins/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "@rudderstack/analytics-js-plugins@3.4.14",
"title": "@rudderstack/analytics-js-plugins@3.4.14",
"discussion-category": "@rudderstack/analytics-js-plugins@3.4.14",
"tag": "@rudderstack/analytics-js-plugins@3.4.15",
"title": "@rudderstack/analytics-js-plugins@3.4.15",
"discussion-category": "@rudderstack/analytics-js-plugins@3.4.15",
"notesFile": "./packages/analytics-js-plugins/CHANGELOG_LATEST.md"
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/analytics-js/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [3.7.15](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.7.14...@rudderstack/analytics-js@3.7.15) (2024-10-03)

### Dependency Updates

* `@rudderstack/analytics-js-plugins` updated to version `3.4.15`

### Bug Fixes

* storage access error when cookies are blocked ([#1872](https://github.com/rudderlabs/rudder-sdk-js/issues/1872)) ([966dbc2](https://github.com/rudderlabs/rudder-sdk-js/commit/966dbc2996b0ee292a553058ef435154de73f42e))

## [3.7.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.7.13...@rudderstack/analytics-js@3.7.14) (2024-09-27)

### Dependency Updates
Expand Down
10 changes: 3 additions & 7 deletions packages/analytics-js/CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
## [3.7.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.7.13...@rudderstack/analytics-js@3.7.14) (2024-09-27)
## [3.7.15](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.7.14...@rudderstack/analytics-js@3.7.15) (2024-10-03)

### Dependency Updates

* `@rudderstack/analytics-js-cookies` updated to version `0.3.9`
* `@rudderstack/analytics-js-common` updated to version `3.9.3`
* `@rudderstack/analytics-js-plugins` updated to version `3.4.14`
* `@rudderstack/analytics-js-plugins` updated to version `3.4.15`

### Bug Fixes

* add explicit checking for setting user and group traits ([68b4293](https://github.com/rudderlabs/rudder-sdk-js/commit/68b4293a9817b3a113af5f4ad8bfcfcf1cc81e88))
* auto session tracking ([#1856](https://github.com/rudderlabs/rudder-sdk-js/issues/1856)) ([fa7cce4](https://github.com/rudderlabs/rudder-sdk-js/commit/fa7cce494a4dce00f843ce5790ceccb0fa9ce95f))
* upgrade all packages to latest to fix vulnerabilities ([#1867](https://github.com/rudderlabs/rudder-sdk-js/issues/1867)) ([389348c](https://github.com/rudderlabs/rudder-sdk-js/commit/389348cfa61f2111c5ac4f9e2bad5851a466484d))
* storage access error when cookies are blocked ([#1872](https://github.com/rudderlabs/rudder-sdk-js/issues/1872)) ([966dbc2](https://github.com/rudderlabs/rudder-sdk-js/commit/966dbc2996b0ee292a553058ef435154de73f42e))

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ILogger } from '@rudderstack/analytics-js-common/types/Logger';
import {
isStorageQuotaExceeded,
isStorageAvailable,
Expand All @@ -24,4 +25,78 @@ describe('Capabilities Detection - Storage', () => {
it('should detect if memoryStorage is available', () => {
expect(isStorageAvailable('memoryStorage', new InMemoryStorage())).toBeTruthy();
});

it('should log a warning when storage is unavailable', () => {
const mockLogger = {
warn: jest.fn(),
} as ILogger;

// Store the original descriptor so we can restore it later
const originalLsDescriptor = Object.getOwnPropertyDescriptor(window, 'localStorage');
const originalSessionStorageDescriptor = Object.getOwnPropertyDescriptor(
window,
'sessionStorage',
);

// Mock using Object.defineProperty
Object.defineProperty(window, 'localStorage', {
get: jest.fn(),
set: jest.fn(),
configurable: true,
});

// Mock using Object.defineProperty
Object.defineProperty(window, 'sessionStorage', {
get: jest.fn(),
set: jest.fn(),
configurable: true,
});

isStorageAvailable('localStorage', undefined, mockLogger);
expect(mockLogger.warn).toHaveBeenCalledWith(
'CapabilitiesManager:: The "localStorage" storage type is unavailable.',
undefined,
);

isStorageAvailable('sessionStorage', undefined, mockLogger);
expect(mockLogger.warn).toHaveBeenCalledWith(
'CapabilitiesManager:: The "sessionStorage" storage type is unavailable.',
undefined,
);

// Restore the original document.cookie descriptor
Object.defineProperty(window, 'localStorage', originalLsDescriptor as PropertyDescriptor);
Object.defineProperty(
window,
'sessionStorage',
originalSessionStorageDescriptor as PropertyDescriptor,
);
});

it('should log a warning when the local storage is full', () => {
const mockLogger = {
warn: jest.fn(),
} as ILogger;

// Store the original descriptor so we can restore it later
const originalLsDescriptor = Object.getOwnPropertyDescriptor(window, 'localStorage');

// Mock using Object.defineProperty
Object.defineProperty(window, 'localStorage', {
get: jest.fn(() => {
throw new DOMException('StorageQuotaExceeded', 'QuotaExceededError');
}),
set: jest.fn(),
configurable: true,
});

isStorageAvailable('localStorage', undefined, mockLogger);
expect(mockLogger.warn).toHaveBeenCalledWith(
'CapabilitiesManager:: The "localStorage" storage type is full.',
new DOMException('StorageQuotaExceeded', 'QuotaExceededError'),
);

// Restore the original document.cookie descriptor
Object.defineProperty(window, 'localStorage', originalLsDescriptor as PropertyDescriptor);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,26 @@ describe('SessionStorage', () => {
expect(engine.keys()).toStrictEqual([]);
expect(engine.length).toStrictEqual(0);
});

it('APIs should respond appropriate when session storage is not available', () => {
const sessionStorageEngine = getStorageEngine('sessionStorage');

sessionStorageEngine.store = undefined;

sessionStorageEngine.setItem('a', '1');
expect(sessionStorageEngine.length).toBe(0);
expect(sessionStorageEngine.getItem('a')).toBeNull();

sessionStorageEngine.removeItem('a');

expect(sessionStorageEngine.length).toBe(0);

// clear all entries
sessionStorageEngine.clear();
expect(sessionStorageEngine.length).toBe(0);

expect(sessionStorageEngine.key(0)).toBeNull();

expect(sessionStorageEngine.keys()).toEqual([]);
});
});
2 changes: 1 addition & 1 deletion packages/analytics-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rudderstack/analytics-js",
"version": "3.7.14",
"version": "3.7.15",
"description": "RudderStack JavaScript SDK",
"main": "dist/npm/modern/cjs/index.cjs",
"module": "dist/npm/modern/esm/index.mjs",
Expand Down
6 changes: 3 additions & 3 deletions packages/analytics-js/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "@rudderstack/analytics-js@3.7.14",
"title": "@rudderstack/analytics-js@3.7.14",
"discussion-category": "@rudderstack/analytics-js@3.7.14",
"tag": "@rudderstack/analytics-js@3.7.15",
"title": "@rudderstack/analytics-js@3.7.15",
"discussion-category": "@rudderstack/analytics-js@3.7.15",
"notesFile": "./packages/analytics-js/CHANGELOG_LATEST.md"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const isStorageAvailable = (
let storage;
let testData;

const msgPrefix = STORAGE_UNAVAILABILITY_ERROR_PREFIX(CAPABILITIES_MANAGER, type);
let reason = 'unavailable';
let isAccessible = true;
let errObj;

try {
switch (type) {
case MEMORY_STORAGE:
Expand All @@ -53,25 +58,29 @@ const isStorageAvailable = (
return false;
}

if (!storage) {
return false;
if (storage) {
storage.setItem(testData, 'true');
if (storage.getItem(testData)) {
storage.removeItem(testData);
return true;
}
}

storage.setItem(testData, 'true');
if (storage.getItem(testData)) {
storage.removeItem(testData);
return true;
}
return false;
isAccessible = false;
} catch (err) {
const msgPrefix = STORAGE_UNAVAILABILITY_ERROR_PREFIX(CAPABILITIES_MANAGER, type);
let reason = 'unavailable';
isAccessible = false;
errObj = err;
if (isStorageQuotaExceeded(err)) {
reason = 'full';
}
logger?.warn(`${msgPrefix}${reason}.`, err);
return false;
}

if (!isAccessible) {
logger?.warn(`${msgPrefix}${reason}.`, errObj);
}

// if we've have reached here, it means the storage is not available
return false;
};

export { isStorageQuotaExceeded, isStorageAvailable };
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CookieStorage implements IStorage {
if (options.sameDomainCookiesOnly) {
delete this.options.domain;
}
this.isSupportAvailable = isStorageAvailable(COOKIE_STORAGE, this, this.logger);
this.isSupportAvailable = isStorageAvailable(COOKIE_STORAGE, this);
this.isEnabled = Boolean(this.options.enabled && this.isSupportAvailable);
return this.options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LocalStorage implements IStorage {

configure(options: Partial<ILocalStorageOptions>): ILocalStorageOptions {
this.options = mergeDeepRight(this.options, options);
this.isSupportAvailable = isStorageAvailable(LOCAL_STORAGE, this, this.logger);
this.isSupportAvailable = isStorageAvailable(LOCAL_STORAGE);
this.isEnabled = Boolean(this.options.enabled && this.isSupportAvailable);
return this.options;
}
Expand Down
Loading

0 comments on commit 3a181d7

Please sign in to comment.