diff --git a/package-lock.json b/package-lock.json index 016b03087..f164837b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.62.0", + "version": "3.63.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.62.0", + "version": "3.63.0", "hasInstallScript": true, "license": "Elastic-2.0", "workspaces": [ @@ -25284,7 +25284,7 @@ }, "packages/analytics-js": { "name": "@rudderstack/analytics-js", - "version": "3.11.10", + "version": "3.11.11", "license": "Elastic-2.0", "dependencies": { "@preact/signals-core": "1.8.0", @@ -25298,7 +25298,7 @@ }, "packages/analytics-js-common": { "name": "@rudderstack/analytics-js-common", - "version": "3.14.9", + "version": "3.14.10", "license": "Elastic-2.0", "dependencies": { "@lukeed/uuid": "2.0.1", @@ -25315,7 +25315,7 @@ }, "packages/analytics-js-cookies": { "name": "@rudderstack/analytics-js-cookies", - "version": "0.4.12", + "version": "0.4.13", "license": "Elastic-2.0", "dependencies": { "@rudderstack/analytics-js-common": "*" @@ -25324,7 +25324,7 @@ }, "packages/analytics-js-integrations": { "name": "@rudderstack/analytics-js-integrations", - "version": "3.11.8", + "version": "3.11.9", "license": "Elastic-2.0", "dependencies": { "@lukeed/uuid": "2.0.1", @@ -25344,7 +25344,7 @@ }, "packages/analytics-js-plugins": { "name": "@rudderstack/analytics-js-plugins", - "version": "3.6.13", + "version": "3.6.14", "license": "Elastic-2.0", "dependencies": { "@rudderstack/analytics-js-common": "*", @@ -25358,7 +25358,7 @@ }, "packages/analytics-js-service-worker": { "name": "@rudderstack/analytics-js-service-worker", - "version": "3.2.12", + "version": "3.2.13", "license": "Elastic-2.0", "dependencies": { "@lukeed/uuid": "2.0.1", @@ -25379,7 +25379,7 @@ }, "packages/analytics-v1.1": { "name": "rudder-sdk-js", - "version": "2.48.37", + "version": "2.48.38", "license": "Elastic-2.0", "dependencies": { "@rudderstack/analytics-js-common": "*" @@ -25388,7 +25388,7 @@ }, "packages/loading-scripts": { "name": "@rudderstack/analytics-js-loading-scripts", - "version": "3.0.53", + "version": "3.0.54", "license": "Elastic-2.0", "dependencies": { "@rudderstack/analytics-js": "*" @@ -25397,7 +25397,7 @@ }, "packages/sanity-suite": { "name": "@rudderstack/analytics-js-sanity-suite", - "version": "3.1.44", + "version": "3.1.45", "license": "Elastic-2.0", "dependencies": { "@rudderstack/analytics-js": "*", diff --git a/package.json b/package.json index 1cb76a850..49e536363 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-monorepo", - "version": "3.62.0", + "version": "3.63.0", "private": true, "description": "Monorepo for RudderStack Analytics JS SDK", "workspaces": [ diff --git a/packages/analytics-js-common/CHANGELOG.md b/packages/analytics-js-common/CHANGELOG.md index 3a2d08d97..b884b1329 100644 --- a/packages/analytics-js-common/CHANGELOG.md +++ b/packages/analytics-js-common/CHANGELOG.md @@ -2,6 +2,13 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.14.10](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-common@3.14.9...@rudderstack/analytics-js-common@3.14.10) (2024-11-22) + + +### Bug Fixes + +* restore data sanitization changes but avoid using api overloads ([d0913ae](https://github.com/rudderlabs/rudder-sdk-js/commit/d0913ae32a8c63def26c081c7570a9960dcd1ebf)) + ## [3.14.9](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-common@3.14.8...@rudderstack/analytics-js-common@3.14.9) (2024-11-22) diff --git a/packages/analytics-js-common/CHANGELOG_LATEST.md b/packages/analytics-js-common/CHANGELOG_LATEST.md index ebfe34181..1d60c7ce1 100644 --- a/packages/analytics-js-common/CHANGELOG_LATEST.md +++ b/packages/analytics-js-common/CHANGELOG_LATEST.md @@ -1,7 +1,7 @@ -## [3.14.9](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-common@3.14.8...@rudderstack/analytics-js-common@3.14.9) (2024-11-22) +## [3.14.10](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-common@3.14.9...@rudderstack/analytics-js-common@3.14.10) (2024-11-22) ### Bug Fixes -* restore data sanitization changes ([2a13e7c](https://github.com/rudderlabs/rudder-sdk-js/commit/2a13e7c463b2d480f6d9a23f32abe4e56f6557d4)) +* restore data sanitization changes but avoid using api overloads ([d0913ae](https://github.com/rudderlabs/rudder-sdk-js/commit/d0913ae32a8c63def26c081c7570a9960dcd1ebf)) diff --git a/packages/analytics-js-common/__tests__/utilities/json.test.ts b/packages/analytics-js-common/__tests__/utilities/json.test.ts index d03cea98f..425dfa4c8 100644 --- a/packages/analytics-js-common/__tests__/utilities/json.test.ts +++ b/packages/analytics-js-common/__tests__/utilities/json.test.ts @@ -1,5 +1,6 @@ import { clone } from 'ramda'; import { + getSanitizedValue, stringifyData, stringifyWithoutCircular, } from '../../src/utilities/json'; @@ -228,7 +229,7 @@ describe('Common Utils - JSON', () => { }); }); - describe.skip('getSanitizedValue', () => { + describe('getSanitizedValue', () => { const mockLogger = { warn: jest.fn(), }; @@ -259,7 +260,7 @@ describe('Common Utils - JSON', () => { expect(getSanitizedValue(obj)).toEqual(obj); }); - it.skip('should sanitize json after replacing BigInt and circular references', () => { + it('should sanitize json after replacing BigInt and circular references', () => { const obj = { a: BigInt(1), b: undefined, @@ -332,7 +333,7 @@ describe('Common Utils - JSON', () => { ); }); - it.skip('should sanitize json even if it contains reused objects', () => { + it('should sanitize json even if it contains reused objects', () => { const obj = { a: BigInt(1), b: undefined, diff --git a/packages/analytics-js-common/package.json b/packages/analytics-js-common/package.json index 3c640ef24..8bfd14b58 100644 --- a/packages/analytics-js-common/package.json +++ b/packages/analytics-js-common/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-common", - "version": "3.14.9", + "version": "3.14.10", "private": true, "description": "RudderStack JavaScript SDK common code", "module": "dist/npm/index.js", diff --git a/packages/analytics-js-common/project.json b/packages/analytics-js-common/project.json index 9357f1c6a..80cd511c1 100644 --- a/packages/analytics-js-common/project.json +++ b/packages/analytics-js-common/project.json @@ -51,9 +51,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-common@3.14.9", - "title": "@rudderstack/analytics-js-common@3.14.9", - "discussion-category": "@rudderstack/analytics-js-common@3.14.9", + "tag": "@rudderstack/analytics-js-common@3.14.10", + "title": "@rudderstack/analytics-js-common@3.14.10", + "discussion-category": "@rudderstack/analytics-js-common@3.14.10", "notesFile": "./packages/analytics-js-common/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index 33e885792..4a7f06381 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -2,7 +2,7 @@ import { clone } from 'ramda'; import type { ApiObject } from '../types/ApiObject'; import type { ApiCallback, ApiOptions } from '../types/EventApi'; import type { Nullable } from '../types/Nullable'; -import { getSanitizedValue, isObjectLiteralAndNotNull, mergeDeepRight } from './object'; +import { isObjectLiteralAndNotNull, mergeDeepRight } from './object'; import { isDefined, isDefinedAndNotNull, isFunction, isNull, isString } from './checks'; import { tryStringify } from './string'; import type { IdentifyTraits } from '../types/traits'; @@ -56,70 +56,64 @@ const pageArgumentsToCallOptions = ( options?: Nullable | ApiCallback, callback?: ApiCallback, ): PageCallOptions => { - const sanitizedCategory = getSanitizedValue(category); - const sanitizedName = getSanitizedValue(name); - const sanitizedProperties = getSanitizedValue(properties); - const sanitizedOptions = getSanitizedValue(options); - const sanitizedCallback = getSanitizedValue(callback); - const payload: PageCallOptions = { - category: sanitizedCategory as string, - name: sanitizedName as string, - properties: sanitizedProperties as Nullable, - options: sanitizedOptions as Nullable, + category: category as string, + name: name as string, + properties: properties as Nullable, + options: options as Nullable, callback: undefined, }; - if (isFunction(sanitizedCallback)) { - payload.callback = sanitizedCallback; + if (isFunction(callback)) { + payload.callback = callback; } - if (isFunction(sanitizedOptions)) { - payload.category = sanitizedCategory as string; - payload.name = sanitizedName as string; - payload.properties = sanitizedProperties as Nullable; + if (isFunction(options)) { + payload.category = category as string; + payload.name = name as string; + payload.properties = properties as Nullable; payload.options = undefined; - payload.callback = sanitizedOptions; + payload.callback = options; } - if (isFunction(sanitizedProperties)) { - payload.category = sanitizedCategory as string; - payload.name = sanitizedName as string; + if (isFunction(properties)) { + payload.category = category as string; + payload.name = name as string; payload.properties = undefined; payload.options = undefined; - payload.callback = sanitizedProperties; + payload.callback = properties; } - if (isFunction(sanitizedName)) { - payload.category = sanitizedCategory as string; + if (isFunction(name)) { + payload.category = category as string; payload.name = undefined; payload.properties = undefined; payload.options = undefined; - payload.callback = sanitizedName; + payload.callback = name; } - if (isFunction(sanitizedCategory)) { + if (isFunction(category)) { payload.category = undefined; payload.name = undefined; payload.properties = undefined; payload.options = undefined; - payload.callback = sanitizedCategory; + payload.callback = category; } - if (isObjectLiteralAndNotNull(sanitizedCategory)) { + if (isObjectLiteralAndNotNull(category)) { payload.name = undefined; payload.category = undefined; - payload.properties = sanitizedCategory as Nullable; - if (!isFunction(sanitizedName)) { - payload.options = sanitizedName as Nullable; + payload.properties = category as Nullable; + if (!isFunction(name)) { + payload.options = name as Nullable; } else { payload.options = undefined; } - } else if (isObjectLiteralAndNotNull(sanitizedName)) { + } else if (isObjectLiteralAndNotNull(name)) { payload.name = undefined; - payload.properties = sanitizedName as Nullable; - if (!isFunction(sanitizedProperties)) { - payload.options = sanitizedProperties as Nullable; + payload.properties = name as Nullable; + if (!isFunction(properties)) { + payload.options = properties as Nullable; } else { payload.options = undefined; } @@ -127,9 +121,9 @@ const pageArgumentsToCallOptions = ( // if the category argument alone is provided b/w category and name, // use it as name and set category to undefined - if (isString(sanitizedCategory) && !isString(sanitizedName)) { + if (isString(category) && !isString(name)) { payload.category = undefined; - payload.name = sanitizedCategory; + payload.name = category; } // Rest of the code is just to clean up undefined values @@ -177,32 +171,27 @@ const trackArgumentsToCallOptions = ( options?: Nullable | ApiCallback, callback?: ApiCallback, ): TrackCallOptions => { - const sanitizedEvent = getSanitizedValue(event); - const sanitizedProperties = getSanitizedValue(properties); - const sanitizedOptions = getSanitizedValue(options); - const sanitizedCallback = getSanitizedValue(callback); - const payload: TrackCallOptions = { - name: sanitizedEvent, - properties: sanitizedProperties as Nullable, - options: sanitizedOptions as Nullable, + name: event, + properties: properties as Nullable, + options: options as Nullable, callback: undefined, }; - if (isFunction(sanitizedCallback)) { - payload.callback = sanitizedCallback; + if (isFunction(callback)) { + payload.callback = callback; } - if (isFunction(sanitizedOptions)) { - payload.properties = sanitizedProperties as Nullable; + if (isFunction(options)) { + payload.properties = properties as Nullable; payload.options = undefined; - payload.callback = sanitizedOptions; + payload.callback = options; } - if (isFunction(sanitizedProperties)) { + if (isFunction(properties)) { payload.properties = undefined; payload.options = undefined; - payload.callback = sanitizedProperties; + payload.callback = properties; } // Rest of the code is just to clean up undefined values @@ -228,43 +217,38 @@ const identifyArgumentsToCallOptions = ( options?: Nullable | ApiCallback, callback?: ApiCallback, ): IdentifyCallOptions => { - const sanitizedUserId = getSanitizedValue(userId); - const sanitizedTraits = getSanitizedValue(traits); - const sanitizedOptions = getSanitizedValue(options); - const sanitizedCallback = getSanitizedValue(callback); - const payload: IdentifyCallOptions = { - userId: sanitizedUserId as string, - traits: sanitizedTraits as Nullable, - options: sanitizedOptions as Nullable, + userId: userId as string, + traits: traits as Nullable, + options: options as Nullable, callback: undefined, }; - if (isFunction(sanitizedCallback)) { - payload.callback = sanitizedCallback; + if (isFunction(callback)) { + payload.callback = callback; } - if (isFunction(sanitizedOptions)) { - payload.userId = sanitizedUserId as string; - payload.traits = sanitizedTraits as Nullable; + if (isFunction(options)) { + payload.userId = userId as string; + payload.traits = traits as Nullable; payload.options = undefined; - payload.callback = sanitizedOptions; + payload.callback = options; } - if (isFunction(sanitizedTraits)) { - payload.userId = sanitizedUserId as string; + if (isFunction(traits)) { + payload.userId = userId as string; payload.traits = undefined; payload.options = undefined; - payload.callback = sanitizedTraits; + payload.callback = traits; } - if (isObjectLiteralAndNotNull(sanitizedUserId) || isNull(sanitizedUserId)) { + if (isObjectLiteralAndNotNull(userId) || isNull(userId)) { // Explicitly set null to prevent resetting the existing value // in the Analytics class payload.userId = null; - payload.traits = sanitizedUserId as Nullable; - if (!isFunction(sanitizedTraits)) { - payload.options = sanitizedTraits as Nullable; + payload.traits = userId as Nullable; + if (!isFunction(traits)) { + payload.options = traits as Nullable; } else { payload.options = undefined; } @@ -299,38 +283,33 @@ const aliasArgumentsToCallOptions = ( options?: Nullable | ApiCallback, callback?: ApiCallback, ): AliasCallOptions => { - const sanitizedTo = getSanitizedValue(to); - const sanitizedFrom = getSanitizedValue(from); - const sanitizedOptions = getSanitizedValue(options); - const sanitizedCallback = getSanitizedValue(callback); - const payload: AliasCallOptions = { - to: sanitizedTo, - from: sanitizedFrom as string, - options: sanitizedOptions as Nullable, + to, + from: from as string, + options: options as Nullable, callback: undefined, }; - if (isFunction(sanitizedCallback)) { - payload.callback = sanitizedCallback; + if (isFunction(callback)) { + payload.callback = callback; } - if (isFunction(sanitizedOptions)) { - payload.to = sanitizedTo; - payload.from = sanitizedFrom as string; + if (isFunction(options)) { + payload.to = to; + payload.from = from as string; payload.options = undefined; - payload.callback = sanitizedOptions; + payload.callback = options; } - if (isFunction(sanitizedFrom)) { - payload.to = sanitizedTo; + if (isFunction(from)) { + payload.to = to; payload.from = undefined; payload.options = undefined; - payload.callback = sanitizedFrom; - } else if (isObjectLiteralAndNotNull(sanitizedFrom) || isNull(sanitizedFrom)) { - payload.to = sanitizedTo; + payload.callback = from; + } else if (isObjectLiteralAndNotNull(from) || isNull(from)) { + payload.to = to; payload.from = undefined; - payload.options = sanitizedFrom as Nullable; + payload.options = from as Nullable; } // Rest of the code is just to clean up undefined values @@ -364,43 +343,38 @@ const groupArgumentsToCallOptions = ( options?: Nullable | ApiCallback, callback?: ApiCallback, ): GroupCallOptions => { - const sanitizedGroupId = getSanitizedValue(groupId); - const sanitizedTraits = getSanitizedValue(traits); - const sanitizedOptions = getSanitizedValue(options); - const sanitizedCallback = getSanitizedValue(callback); - const payload: GroupCallOptions = { - groupId: sanitizedGroupId as string, - traits: sanitizedTraits as Nullable, - options: sanitizedOptions as Nullable, + groupId: groupId as string, + traits: traits as Nullable, + options: options as Nullable, callback: undefined, }; - if (isFunction(sanitizedCallback)) { - payload.callback = sanitizedCallback; + if (isFunction(callback)) { + payload.callback = callback; } - if (isFunction(sanitizedOptions)) { - payload.groupId = sanitizedGroupId as string; - payload.traits = sanitizedTraits as Nullable; + if (isFunction(options)) { + payload.groupId = groupId as string; + payload.traits = traits as Nullable; payload.options = undefined; - payload.callback = sanitizedOptions; + payload.callback = options; } - if (isFunction(sanitizedTraits)) { - payload.groupId = sanitizedGroupId as string; + if (isFunction(traits)) { + payload.groupId = groupId as string; payload.traits = undefined; payload.options = undefined; - payload.callback = sanitizedTraits; + payload.callback = traits; } - if (isObjectLiteralAndNotNull(sanitizedGroupId) || isNull(sanitizedGroupId)) { + if (isObjectLiteralAndNotNull(groupId) || isNull(groupId)) { // Explicitly set null to prevent resetting the existing value // in the Analytics class payload.groupId = null; - payload.traits = sanitizedGroupId as Nullable; - if (!isFunction(sanitizedTraits)) { - payload.options = sanitizedTraits as Nullable; + payload.traits = groupId as Nullable; + if (!isFunction(traits)) { + payload.options = traits as Nullable; } else { payload.options = undefined; } diff --git a/packages/analytics-js-common/src/utilities/json.ts b/packages/analytics-js-common/src/utilities/json.ts index 3cb54e36b..3faadd684 100644 --- a/packages/analytics-js-common/src/utilities/json.ts +++ b/packages/analytics-js-common/src/utilities/json.ts @@ -1,12 +1,17 @@ import type { ILogger } from '../types/Logger'; import type { Nullable } from '../types/Nullable'; -import { isNull, isNullOrUndefined } from './checks'; +import { isBigInt, isNull, isNullOrUndefined } from './checks'; import { + BAD_DATA_WARNING, CIRCULAR_REFERENCE_WARNING, JSON_STRINGIFY_WARNING, } from '../constants/logMessages'; +import { isObjectLiteralAndNotNull } from './object'; const JSON_STRINGIFY = 'JSONStringify'; +const JSON_UTIL = 'JSON'; +const BIG_INT_PLACEHOLDER = '[BigInt]'; +const CIRCULAR_REFERENCE_PLACEHOLDER = '[Circular Reference]'; const getCircularReplacer = ( excludeNull?: boolean, @@ -39,7 +44,7 @@ const getCircularReplacer = ( if (ancestors.includes(value)) { logger?.warn(CIRCULAR_REFERENCE_WARNING(JSON_STRINGIFY, key)); - return '[Circular Reference]'; + return CIRCULAR_REFERENCE_PLACEHOLDER; } ancestors.push(value); @@ -89,4 +94,78 @@ const stringifyData = | any[] | number | string>( return value; }); -export { stringifyWithoutCircular, stringifyData }; +const getReplacer = (logger?: ILogger): ((key: string, value: any) => any) => { + const ancestors: any[] = []; // Array to track ancestor objects + + // Using a regular function to use `this` for the parent context + return function replacer(key, value): any { + if (isBigInt(value)) { + logger?.warn(BAD_DATA_WARNING(JSON_UTIL, key)); + return BIG_INT_PLACEHOLDER; // Replace BigInt values + } + + // `this` is the object that value is contained in, i.e., its direct parent. + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore-next-line + while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) { + ancestors.pop(); // Remove ancestors that are no longer part of the chain + } + + // Check for circular references (if the value is already in the ancestors) + if (ancestors.includes(value)) { + logger?.warn(BAD_DATA_WARNING(JSON_UTIL, key)); + return CIRCULAR_REFERENCE_PLACEHOLDER; + } + + // Add current value to ancestors + ancestors.push(value); + + return value; + }; +}; + +const traverseWithThis = (obj: any, replacer: (key: string, value: any) => any): any => { + // Create a new result object or array + const result = Array.isArray(obj) ? [] : {}; + + // Traverse object properties or array elements + // eslint-disable-next-line no-restricted-syntax + for (const key in obj) { + if (Object.hasOwnProperty.call(obj, key)) { + const value = obj[key]; + + // Recursively apply the replacer and traversal + const sanitizedValue = replacer.call(obj, key, value); + + // If the value is an object or array, continue traversal + if (isObjectLiteralAndNotNull(sanitizedValue) || Array.isArray(sanitizedValue)) { + (result as any)[key] = traverseWithThis(sanitizedValue, replacer); + } else { + (result as any)[key] = sanitizedValue; + } + } + } + + return result; +}; + +/** + * Recursively traverses an object similar to JSON.stringify, + * sanitizing BigInts and circular references + * @param value Input object + * @param logger Logger instance + * @returns Sanitized value + */ +const getSanitizedValue = (value: T, logger?: ILogger): T => { + const replacer = getReplacer(logger); + + // This is needed for registering the first ancestor + const newValue = replacer.call(value, '', value); + + if (isObjectLiteralAndNotNull(value) || Array.isArray(value)) { + return traverseWithThis(value, replacer); + } + return newValue; +}; + +export { stringifyWithoutCircular, stringifyData, getSanitizedValue }; diff --git a/packages/analytics-js-common/src/utilities/object.ts b/packages/analytics-js-common/src/utilities/object.ts index 8ffa2b985..366e605a0 100644 --- a/packages/analytics-js-common/src/utilities/object.ts +++ b/packages/analytics-js-common/src/utilities/object.ts @@ -1,7 +1,5 @@ import { clone, mergeDeepWith, path, pickBy } from 'ramda'; -import { isBigInt, isDefined, isDefinedAndNotNull, isNull } from './checks'; -import type { ILogger } from '../types/Logger'; -import { BAD_DATA_WARNING } from '../constants/logMessages'; +import { isDefined, isDefinedAndNotNull, isNull } from './checks'; const getValueByPath = (obj: Record, keyPath: string): any => { const pathParts = keyPath.split('.'); @@ -109,82 +107,6 @@ const getObjectValues = >(obj: T): any[] => { return result; }; -const JSON_UTIL = 'JSON'; - -const getReplacer = (logger?: ILogger): ((key: string, value: any) => any) => { - const ancestors: any[] = []; // Array to track ancestor objects - - // Using a regular function to use `this` for the parent context - return function replacer(key, value): any { - if (isBigInt(value)) { - logger?.warn(BAD_DATA_WARNING(JSON_UTIL, key)); - return '[BigInt]'; // Replace BigInt values - } - - // `this` is the object that value is contained in, i.e., its direct parent. - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore-next-line - while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) { - ancestors.pop(); // Remove ancestors that are no longer part of the chain - } - - // Check for circular references (if the value is already in the ancestors) - if (ancestors.includes(value)) { - logger?.warn(BAD_DATA_WARNING(JSON_UTIL, key)); - return '[Circular Reference]'; - } - - // Add current value to ancestors - ancestors.push(value); - - return value; - }; -}; - -const traverseWithThis = (obj: any, replacer: (key: string, value: any) => any): any => { - // Create a new result object or array - const result = Array.isArray(obj) ? [] : {}; - - // Traverse object properties or array elements - // eslint-disable-next-line no-restricted-syntax - for (const key in obj) { - if (Object.hasOwnProperty.call(obj, key)) { - const value = obj[key]; - - // Recursively apply the replacer and traversal - const sanitizedValue = replacer.call(obj, key, value); - - // If the value is an object or array, continue traversal - if (isObjectLiteralAndNotNull(sanitizedValue) || Array.isArray(sanitizedValue)) { - (result as any)[key] = traverseWithThis(sanitizedValue, replacer); - } else { - (result as any)[key] = sanitizedValue; - } - } - } - - return result; -}; - -/** - * Recursively traverses an object similar to JSON.stringify, - * sanitizing BigInts and circular references - * @param value Input object - * @param logger Logger instance - * @returns Sanitized value - */ -const getSanitizedValue = (value: T, logger?: ILogger): T => { - const replacer = getReplacer(logger); - - // This is needed for registering the first ancestor - const newValue = replacer.call(value, '', value); - - if (isObjectLiteralAndNotNull(value) || Array.isArray(value)) { - return traverseWithThis(value, replacer); - } - return newValue; -}; - export { getValueByPath, hasValueByPath, @@ -197,5 +119,4 @@ export { removeUndefinedAndNullValues, getObjectValues, isObject, - getSanitizedValue, }; diff --git a/packages/analytics-js-cookies/CHANGELOG.md b/packages/analytics-js-cookies/CHANGELOG.md index 3aee79ade..3bd579fdc 100644 --- a/packages/analytics-js-cookies/CHANGELOG.md +++ b/packages/analytics-js-cookies/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [0.4.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-cookies@0.4.12...@rudderstack/analytics-js-cookies@0.4.13) (2024-11-22) + +### Dependency Updates + +* `@rudderstack/analytics-js-common` updated to version `3.14.10` ## [0.4.12](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-cookies@0.4.11...@rudderstack/analytics-js-cookies@0.4.12) (2024-11-22) ### Dependency Updates diff --git a/packages/analytics-js-cookies/CHANGELOG_LATEST.md b/packages/analytics-js-cookies/CHANGELOG_LATEST.md index 1fad0a25f..8e3b05116 100644 --- a/packages/analytics-js-cookies/CHANGELOG_LATEST.md +++ b/packages/analytics-js-cookies/CHANGELOG_LATEST.md @@ -1,5 +1,5 @@ -## [0.4.12](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-cookies@0.4.11...@rudderstack/analytics-js-cookies@0.4.12) (2024-11-22) +## [0.4.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-cookies@0.4.12...@rudderstack/analytics-js-cookies@0.4.13) (2024-11-22) ### Dependency Updates -* `@rudderstack/analytics-js-common` updated to version `3.14.9` +* `@rudderstack/analytics-js-common` updated to version `3.14.10` diff --git a/packages/analytics-js-cookies/package.json b/packages/analytics-js-cookies/package.json index c40e4809a..a34ca96e0 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": "0.4.12", + "version": "0.4.13", "description": "RudderStack JavaScript SDK Cookies Utilities", "main": "dist/npm/modern/cjs/index.cjs", "module": "dist/npm/modern/esm/index.mjs", diff --git a/packages/analytics-js-cookies/project.json b/packages/analytics-js-cookies/project.json index ac384543f..bf9d19b44 100644 --- a/packages/analytics-js-cookies/project.json +++ b/packages/analytics-js-cookies/project.json @@ -51,9 +51,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-cookies@0.4.12", - "title": "@rudderstack/analytics-js-cookies@0.4.12", - "discussion-category": "@rudderstack/analytics-js-cookies@0.4.12", + "tag": "@rudderstack/analytics-js-cookies@0.4.13", + "title": "@rudderstack/analytics-js-cookies@0.4.13", + "discussion-category": "@rudderstack/analytics-js-cookies@0.4.13", "notesFile": "./packages/analytics-js-cookies/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js-integrations/CHANGELOG.md b/packages/analytics-js-integrations/CHANGELOG.md index 7baa69a7a..420c138c1 100644 --- a/packages/analytics-js-integrations/CHANGELOG.md +++ b/packages/analytics-js-integrations/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.11.9](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.11.8...@rudderstack/analytics-js-integrations@3.11.9) (2024-11-22) + +### Dependency Updates + +* `@rudderstack/analytics-js-common` updated to version `3.14.10` ## [3.11.8](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.11.7...@rudderstack/analytics-js-integrations@3.11.8) (2024-11-22) ### Dependency Updates diff --git a/packages/analytics-js-integrations/CHANGELOG_LATEST.md b/packages/analytics-js-integrations/CHANGELOG_LATEST.md index bc79ca5ff..a3ba49725 100644 --- a/packages/analytics-js-integrations/CHANGELOG_LATEST.md +++ b/packages/analytics-js-integrations/CHANGELOG_LATEST.md @@ -1,5 +1,5 @@ -## [3.11.8](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.11.7...@rudderstack/analytics-js-integrations@3.11.8) (2024-11-22) +## [3.11.9](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.11.8...@rudderstack/analytics-js-integrations@3.11.9) (2024-11-22) ### Dependency Updates -* `@rudderstack/analytics-js-common` updated to version `3.14.9` +* `@rudderstack/analytics-js-common` updated to version `3.14.10` diff --git a/packages/analytics-js-integrations/package.json b/packages/analytics-js-integrations/package.json index 45feb82bb..971ddd255 100644 --- a/packages/analytics-js-integrations/package.json +++ b/packages/analytics-js-integrations/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-integrations", - "version": "3.11.8", + "version": "3.11.9", "private": true, "description": "RudderStack JavaScript SDK device mode integrations", "main": "dist/npm/modern/cjs/index.js", diff --git a/packages/analytics-js-integrations/project.json b/packages/analytics-js-integrations/project.json index 66ae688fb..53a59c376 100644 --- a/packages/analytics-js-integrations/project.json +++ b/packages/analytics-js-integrations/project.json @@ -51,9 +51,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-integrations@3.11.8", - "title": "@rudderstack/analytics-js-integrations@3.11.8", - "discussion-category": "@rudderstack/analytics-js-integrations@3.11.8", + "tag": "@rudderstack/analytics-js-integrations@3.11.9", + "title": "@rudderstack/analytics-js-integrations@3.11.9", + "discussion-category": "@rudderstack/analytics-js-integrations@3.11.9", "notesFile": "./packages/analytics-js-integrations/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js-plugins/CHANGELOG.md b/packages/analytics-js-plugins/CHANGELOG.md index b06ef7adc..b672f5af2 100644 --- a/packages/analytics-js-plugins/CHANGELOG.md +++ b/packages/analytics-js-plugins/CHANGELOG.md @@ -2,6 +2,18 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.6.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.6.13...@rudderstack/analytics-js-plugins@3.6.14) (2024-11-22) + +### Dependency Updates + +* `@rudderstack/analytics-js-common` updated to version `3.14.10` +* `@rudderstack/analytics-js` updated to version `3.11.10` +* `@rudderstack/analytics-js-cookies` updated to version `0.4.12` + +### Bug Fixes + +* restore data sanitization changes but avoid using api overloads ([d0913ae](https://github.com/rudderlabs/rudder-sdk-js/commit/d0913ae32a8c63def26c081c7570a9960dcd1ebf)) + ## [3.6.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.6.12...@rudderstack/analytics-js-plugins@3.6.13) (2024-11-22) ### Dependency Updates diff --git a/packages/analytics-js-plugins/CHANGELOG_LATEST.md b/packages/analytics-js-plugins/CHANGELOG_LATEST.md index 01e8d6670..fad7daba7 100644 --- a/packages/analytics-js-plugins/CHANGELOG_LATEST.md +++ b/packages/analytics-js-plugins/CHANGELOG_LATEST.md @@ -1,13 +1,12 @@ -## [3.6.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.6.12...@rudderstack/analytics-js-plugins@3.6.13) (2024-11-22) +## [3.6.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.6.13...@rudderstack/analytics-js-plugins@3.6.14) (2024-11-22) ### Dependency Updates -* `@rudderstack/analytics-js-common` updated to version `3.14.9` -* `@rudderstack/analytics-js` updated to version `3.11.9` -* `@rudderstack/analytics-js-cookies` updated to version `0.4.11` +* `@rudderstack/analytics-js-common` updated to version `3.14.10` +* `@rudderstack/analytics-js` updated to version `3.11.10` +* `@rudderstack/analytics-js-cookies` updated to version `0.4.12` ### Bug Fixes -* reorganize common imports in plugins ([bc569ba](https://github.com/rudderlabs/rudder-sdk-js/commit/bc569baa4ae2211696934d489a370e2e9ca80521)) -* restore data sanitization changes ([2a13e7c](https://github.com/rudderlabs/rudder-sdk-js/commit/2a13e7c463b2d480f6d9a23f32abe4e56f6557d4)) +* restore data sanitization changes but avoid using api overloads ([d0913ae](https://github.com/rudderlabs/rudder-sdk-js/commit/d0913ae32a8c63def26c081c7570a9960dcd1ebf)) diff --git a/packages/analytics-js-plugins/package.json b/packages/analytics-js-plugins/package.json index 5b2c17e44..8cfd26435 100644 --- a/packages/analytics-js-plugins/package.json +++ b/packages/analytics-js-plugins/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-plugins", - "version": "3.6.13", + "version": "3.6.14", "private": true, "description": "RudderStack JavaScript SDK plugins", "main": "dist/npm/modern/cjs/index.cjs", diff --git a/packages/analytics-js-plugins/project.json b/packages/analytics-js-plugins/project.json index ec463dd58..dd8bbf3d1 100644 --- a/packages/analytics-js-plugins/project.json +++ b/packages/analytics-js-plugins/project.json @@ -51,9 +51,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-plugins@3.6.13", - "title": "@rudderstack/analytics-js-plugins@3.6.13", - "discussion-category": "@rudderstack/analytics-js-plugins@3.6.13", + "tag": "@rudderstack/analytics-js-plugins@3.6.14", + "title": "@rudderstack/analytics-js-plugins@3.6.14", + "discussion-category": "@rudderstack/analytics-js-plugins@3.6.14", "notesFile": "./packages/analytics-js-plugins/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js-plugins/src/deviceModeDestinations/utils.ts b/packages/analytics-js-plugins/src/deviceModeDestinations/utils.ts index b62590c00..4855302af 100644 --- a/packages/analytics-js-plugins/src/deviceModeDestinations/utils.ts +++ b/packages/analytics-js-plugins/src/deviceModeDestinations/utils.ts @@ -1,6 +1,7 @@ /* eslint-disable no-param-reassign */ /* eslint-disable @typescript-eslint/no-unused-vars */ import { clone } from 'ramda'; +import { mergeDeepRight } from '@rudderstack/analytics-js-common/utilities/object'; import type { Destination, DeviceModeDestination, @@ -26,15 +27,15 @@ import { DESTINATION_INTEGRATIONS_DATA_ERROR, DESTINATION_READY_TIMEOUT_ERROR, } from './logMessages'; -import { getSanitizedValue, isFunction, mergeDeepRight } from '../shared-chunks/common'; import { - pageArgumentsToCallOptions, - trackArgumentsToCallOptions, - identifyArgumentsToCallOptions, aliasArgumentsToCallOptions, groupArgumentsToCallOptions, + identifyArgumentsToCallOptions, isHybridModeDestination, + pageArgumentsToCallOptions, + trackArgumentsToCallOptions, } from '../shared-chunks/deviceModeDestinations'; +import { getSanitizedValue, isFunction } from '../shared-chunks/common'; /** * Determines if the destination SDK code is evaluated @@ -82,32 +83,74 @@ const createDestinationInstance = ( properties?: Nullable | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, - ) => analytics.page(pageArgumentsToCallOptions(category, name, properties, options, callback)), + ) => + analytics.page( + pageArgumentsToCallOptions( + getSanitizedValue(category), + getSanitizedValue(name), + getSanitizedValue(properties), + getSanitizedValue(options), + getSanitizedValue(callback), + ), + ), track: ( event: string, properties?: Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, - ) => analytics.track(trackArgumentsToCallOptions(event, properties, options, callback)), + ) => + analytics.track( + trackArgumentsToCallOptions( + getSanitizedValue(event), + getSanitizedValue(properties), + getSanitizedValue(options), + getSanitizedValue(callback), + ), + ), identify: ( userId: string | number | Nullable, traits?: Nullable | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, - ) => analytics.identify(identifyArgumentsToCallOptions(userId, traits, options, callback)), + ) => + analytics.identify( + identifyArgumentsToCallOptions( + getSanitizedValue(userId), + getSanitizedValue(traits), + getSanitizedValue(options), + getSanitizedValue(callback), + ), + ), alias: ( to: string, from?: string | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, - ) => analytics.alias(aliasArgumentsToCallOptions(to, from, options, callback)), + ) => + analytics.alias( + aliasArgumentsToCallOptions( + getSanitizedValue(to), + getSanitizedValue(from), + getSanitizedValue(options), + getSanitizedValue(callback), + ), + ), group: ( groupId: string | number | Nullable, traits?: Nullable | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, - ) => analytics.group(groupArgumentsToCallOptions(groupId, traits, options, callback)), - getAnonymousId: (options?: AnonymousIdOptions) => analytics.getAnonymousId(options), + ) => + analytics.group( + groupArgumentsToCallOptions( + getSanitizedValue(groupId), + getSanitizedValue(traits), + getSanitizedValue(options), + getSanitizedValue(callback), + ), + ), + getAnonymousId: (options?: AnonymousIdOptions) => + analytics.getAnonymousId(getSanitizedValue(options)), getUserId: () => analytics.getUserId(), getUserTraits: () => analytics.getUserTraits(), getGroupId: () => analytics.getGroupId(), diff --git a/packages/analytics-js-plugins/src/shared-chunks/common.ts b/packages/analytics-js-plugins/src/shared-chunks/common.ts index 1bd8fceed..afa9c2b7f 100644 --- a/packages/analytics-js-plugins/src/shared-chunks/common.ts +++ b/packages/analytics-js-plugins/src/shared-chunks/common.ts @@ -13,7 +13,10 @@ export { removeDuplicateSlashes } from '@rudderstack/analytics-js-common/utiliti export { generateUUID } from '@rudderstack/analytics-js-common/utilities/uuId'; export { isErrRetryable } from '@rudderstack/analytics-js-common/utilities/http'; export { fromBase64, toBase64 } from '@rudderstack/analytics-js-common/utilities/string'; -export { stringifyWithoutCircular } from '@rudderstack/analytics-js-common/utilities/json'; +export { + stringifyWithoutCircular, + getSanitizedValue, +} from '@rudderstack/analytics-js-common/utilities/json'; export { getCurrentTimeFormatted } from '@rudderstack/analytics-js-common/utilities/timestamp'; export { encryptBrowser as encrypt, @@ -30,7 +33,6 @@ export { mergeDeepRight, isNonEmptyObject, isObjectLiteralAndNotNull, - getSanitizedValue, } from '@rudderstack/analytics-js-common/utilities/object'; export { CDN_INT_DIR } from '@rudderstack/analytics-js-common/constants/urls'; export { METRICS_PAYLOAD_VERSION } from '@rudderstack/analytics-js-common/constants/metrics'; diff --git a/packages/analytics-js-service-worker/CHANGELOG.md b/packages/analytics-js-service-worker/CHANGELOG.md index 6da37aef1..af34fe50f 100644 --- a/packages/analytics-js-service-worker/CHANGELOG.md +++ b/packages/analytics-js-service-worker/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.2.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-service-worker@3.2.12...@rudderstack/analytics-js-service-worker@3.2.13) (2024-11-22) + +### Dependency Updates + +* `@rudderstack/analytics-js-common` updated to version `3.14.10` ## [3.2.12](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-service-worker@3.2.11...@rudderstack/analytics-js-service-worker@3.2.12) (2024-11-22) ### Dependency Updates diff --git a/packages/analytics-js-service-worker/CHANGELOG_LATEST.md b/packages/analytics-js-service-worker/CHANGELOG_LATEST.md index c71809400..bd7e01bd1 100644 --- a/packages/analytics-js-service-worker/CHANGELOG_LATEST.md +++ b/packages/analytics-js-service-worker/CHANGELOG_LATEST.md @@ -1,5 +1,5 @@ -## [3.2.12](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-service-worker@3.2.11...@rudderstack/analytics-js-service-worker@3.2.12) (2024-11-22) +## [3.2.13](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-service-worker@3.2.12...@rudderstack/analytics-js-service-worker@3.2.13) (2024-11-22) ### Dependency Updates -* `@rudderstack/analytics-js-common` updated to version `3.14.9` +* `@rudderstack/analytics-js-common` updated to version `3.14.10` diff --git a/packages/analytics-js-service-worker/package.json b/packages/analytics-js-service-worker/package.json index 29eae6257..5e737817a 100644 --- a/packages/analytics-js-service-worker/package.json +++ b/packages/analytics-js-service-worker/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js-service-worker", - "version": "3.2.12", + "version": "3.2.13", "description": "RudderStack JavaScript Service Worker SDK", "main": "dist/npm/modern/cjs/index.cjs", "module": "dist/npm/modern/esm/index.mjs", diff --git a/packages/analytics-js-service-worker/project.json b/packages/analytics-js-service-worker/project.json index c1fd1bb06..2e91908d5 100644 --- a/packages/analytics-js-service-worker/project.json +++ b/packages/analytics-js-service-worker/project.json @@ -51,9 +51,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-service-worker@3.2.12", - "title": "rudderstack/analytics-js-service-worker@3.2.12", - "discussion-category": "rudderstack/analytics-js-service-worker@3.2.12", + "tag": "@rudderstack/analytics-js-service-worker@3.2.13", + "title": "rudderstack/analytics-js-service-worker@3.2.13", + "discussion-category": "rudderstack/analytics-js-service-worker@3.2.13", "notesFile": "./packages/analytics-js-service-worker/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js/CHANGELOG.md b/packages/analytics-js/CHANGELOG.md index a96d8bd53..863e7c447 100644 --- a/packages/analytics-js/CHANGELOG.md +++ b/packages/analytics-js/CHANGELOG.md @@ -2,6 +2,18 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.11.11](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.11.10...@rudderstack/analytics-js@3.11.11) (2024-11-22) + +### Dependency Updates + +* `@rudderstack/analytics-js-cookies` updated to version `0.4.13` +* `@rudderstack/analytics-js-common` updated to version `3.14.10` +* `@rudderstack/analytics-js-plugins` updated to version `3.6.14` + +### Bug Fixes + +* restore data sanitization changes but avoid using api overloads ([d0913ae](https://github.com/rudderlabs/rudder-sdk-js/commit/d0913ae32a8c63def26c081c7570a9960dcd1ebf)) + ## [3.11.10](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.11.9...@rudderstack/analytics-js@3.11.10) (2024-11-22) ### Dependency Updates diff --git a/packages/analytics-js/CHANGELOG_LATEST.md b/packages/analytics-js/CHANGELOG_LATEST.md index cbdcb47c6..2a7c0b365 100644 --- a/packages/analytics-js/CHANGELOG_LATEST.md +++ b/packages/analytics-js/CHANGELOG_LATEST.md @@ -1,7 +1,12 @@ -## [3.11.10](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.11.9...@rudderstack/analytics-js@3.11.10) (2024-11-22) +## [3.11.11](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.11.10...@rudderstack/analytics-js@3.11.11) (2024-11-22) ### Dependency Updates -* `@rudderstack/analytics-js-cookies` updated to version `0.4.12` -* `@rudderstack/analytics-js-common` updated to version `3.14.9` -* `@rudderstack/analytics-js-plugins` updated to version `3.6.13` +* `@rudderstack/analytics-js-cookies` updated to version `0.4.13` +* `@rudderstack/analytics-js-common` updated to version `3.14.10` +* `@rudderstack/analytics-js-plugins` updated to version `3.6.14` + +### Bug Fixes + +* restore data sanitization changes but avoid using api overloads ([d0913ae](https://github.com/rudderlabs/rudder-sdk-js/commit/d0913ae32a8c63def26c081c7570a9960dcd1ebf)) + diff --git a/packages/analytics-js/package.json b/packages/analytics-js/package.json index 9fa76d3cd..231baa7e2 100644 --- a/packages/analytics-js/package.json +++ b/packages/analytics-js/package.json @@ -1,6 +1,6 @@ { "name": "@rudderstack/analytics-js", - "version": "3.11.10", + "version": "3.11.11", "description": "RudderStack JavaScript SDK", "main": "dist/npm/modern/cjs/index.cjs", "module": "dist/npm/modern/esm/index.mjs", diff --git a/packages/analytics-js/project.json b/packages/analytics-js/project.json index a87a34254..bc04d4013 100644 --- a/packages/analytics-js/project.json +++ b/packages/analytics-js/project.json @@ -59,9 +59,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js@3.11.10", - "title": "@rudderstack/analytics-js@3.11.10", - "discussion-category": "@rudderstack/analytics-js@3.11.10", + "tag": "@rudderstack/analytics-js@3.11.11", + "title": "@rudderstack/analytics-js@3.11.11", + "discussion-category": "@rudderstack/analytics-js@3.11.11", "notesFile": "./packages/analytics-js/CHANGELOG_LATEST.md" } } diff --git a/packages/analytics-js/src/app/RudderAnalytics.ts b/packages/analytics-js/src/app/RudderAnalytics.ts index e123b7a01..05733142b 100644 --- a/packages/analytics-js/src/app/RudderAnalytics.ts +++ b/packages/analytics-js/src/app/RudderAnalytics.ts @@ -24,6 +24,7 @@ import { onPageLeave } from '@rudderstack/analytics-js-common/utilities/page'; import { isString } from '@rudderstack/analytics-js-common/utilities/checks'; import { getFormattedTimestamp } from '@rudderstack/analytics-js-common/utilities/timestamp'; import { dispatchErrorEvent } from '@rudderstack/analytics-js-common/utilities/errors'; +import { getSanitizedValue } from '@rudderstack/analytics-js-common/utilities/json'; import { GLOBAL_PRELOAD_BUFFER } from '../constants/app'; import { getPreloadedLoadEvent, @@ -37,7 +38,6 @@ import { defaultLogger } from '../services/Logger/Logger'; import { PAGE_UNLOAD_ON_BEACON_DISABLED_WARNING } from '../constants/logMessages'; import { defaultErrorHandler } from '../services/ErrorHandler'; import { state } from '../state'; -import { getSanitizedValue } from '@rudderstack/analytics-js-common/utilities/object'; // TODO: add analytics restart/reset mechanism @@ -371,7 +371,13 @@ class RudderAnalytics implements IRudderAnalytics { ) { try { this.getAnalyticsInstance()?.page( - pageArgumentsToCallOptions(category, name, properties, options, callback), + pageArgumentsToCallOptions( + getSanitizedValue(category), + getSanitizedValue(name), + getSanitizedValue(properties), + getSanitizedValue(options), + getSanitizedValue(callback), + ), ); } catch (error: any) { dispatchErrorEvent(error); @@ -398,7 +404,12 @@ class RudderAnalytics implements IRudderAnalytics { ) { try { this.getAnalyticsInstance()?.track( - trackArgumentsToCallOptions(event, properties, options, callback), + trackArgumentsToCallOptions( + getSanitizedValue(event), + getSanitizedValue(properties), + getSanitizedValue(options), + getSanitizedValue(callback), + ), ); } catch (error: any) { dispatchErrorEvent(error); @@ -431,7 +442,12 @@ class RudderAnalytics implements IRudderAnalytics { ) { try { this.getAnalyticsInstance()?.identify( - identifyArgumentsToCallOptions(userId, traits, options, callback), + identifyArgumentsToCallOptions( + getSanitizedValue(userId), + getSanitizedValue(traits), + getSanitizedValue(options), + getSanitizedValue(callback), + ), ); } catch (error: any) { dispatchErrorEvent(error); @@ -453,7 +469,14 @@ class RudderAnalytics implements IRudderAnalytics { callback?: ApiCallback, ) { try { - this.getAnalyticsInstance()?.alias(aliasArgumentsToCallOptions(to, from, options, callback)); + this.getAnalyticsInstance()?.alias( + aliasArgumentsToCallOptions( + getSanitizedValue(to), + getSanitizedValue(from), + getSanitizedValue(options), + getSanitizedValue(callback), + ), + ); } catch (error: any) { dispatchErrorEvent(error); } @@ -485,7 +508,12 @@ class RudderAnalytics implements IRudderAnalytics { ) { try { this.getAnalyticsInstance()?.group( - groupArgumentsToCallOptions(groupId, traits, options, callback), + groupArgumentsToCallOptions( + getSanitizedValue(groupId), + getSanitizedValue(traits), + getSanitizedValue(options), + getSanitizedValue(callback), + ), ); } catch (error: any) { dispatchErrorEvent(error); diff --git a/packages/analytics-v1.1/CHANGELOG.md b/packages/analytics-v1.1/CHANGELOG.md index 523adf34b..3700990bc 100644 --- a/packages/analytics-v1.1/CHANGELOG.md +++ b/packages/analytics-v1.1/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [2.48.38](https://github.com/rudderlabs/rudder-sdk-js/compare/rudder-sdk-js@2.48.37...rudder-sdk-js@2.48.38) (2024-11-22) + +### Dependency Updates + +* `@rudderstack/analytics-js-common` updated to version `3.14.10` ## [2.48.37](https://github.com/rudderlabs/rudder-sdk-js/compare/rudder-sdk-js@2.48.36...rudder-sdk-js@2.48.37) (2024-11-22) ### Dependency Updates diff --git a/packages/analytics-v1.1/CHANGELOG_LATEST.md b/packages/analytics-v1.1/CHANGELOG_LATEST.md index f5aec4a63..aa407e8ea 100644 --- a/packages/analytics-v1.1/CHANGELOG_LATEST.md +++ b/packages/analytics-v1.1/CHANGELOG_LATEST.md @@ -1,5 +1,5 @@ -## [2.48.37](https://github.com/rudderlabs/rudder-sdk-js/compare/rudder-sdk-js@2.48.36...rudder-sdk-js@2.48.37) (2024-11-22) +## [2.48.38](https://github.com/rudderlabs/rudder-sdk-js/compare/rudder-sdk-js@2.48.37...rudder-sdk-js@2.48.38) (2024-11-22) ### Dependency Updates -* `@rudderstack/analytics-js-common` updated to version `3.14.9` +* `@rudderstack/analytics-js-common` updated to version `3.14.10` diff --git a/packages/analytics-v1.1/package.json b/packages/analytics-v1.1/package.json index cd642b6d2..e34c0412c 100644 --- a/packages/analytics-v1.1/package.json +++ b/packages/analytics-v1.1/package.json @@ -1,6 +1,6 @@ { "name": "rudder-sdk-js", - "version": "2.48.37", + "version": "2.48.38", "description": "RudderStack JavaScript SDK", "main": "dist/npm/index.js", "module": "dist/npm/index.es.js", diff --git a/packages/analytics-v1.1/project.json b/packages/analytics-v1.1/project.json index 61420cfd3..a223297b2 100644 --- a/packages/analytics-v1.1/project.json +++ b/packages/analytics-v1.1/project.json @@ -59,9 +59,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "rudder-sdk-js@2.48.37", - "title": "rudder-sdk-js@2.48.37", - "discussion-category": "rudder-sdk-js@2.48.37", + "tag": "rudder-sdk-js@2.48.38", + "title": "rudder-sdk-js@2.48.38", + "discussion-category": "rudder-sdk-js@2.48.38", "notesFile": "./packages/analytics-v1.1/CHANGELOG_LATEST.md" } } diff --git a/packages/loading-scripts/CHANGELOG.md b/packages/loading-scripts/CHANGELOG.md index 5d5866796..62daefcb0 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.54](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.53...@rudderstack/analytics-js-loading-scripts@3.0.54) (2024-11-22) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.11.11` ## [3.0.53](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.52...@rudderstack/analytics-js-loading-scripts@3.0.53) (2024-11-22) ### Dependency Updates diff --git a/packages/loading-scripts/CHANGELOG_LATEST.md b/packages/loading-scripts/CHANGELOG_LATEST.md index ddda5972e..9f8759021 100644 --- a/packages/loading-scripts/CHANGELOG_LATEST.md +++ b/packages/loading-scripts/CHANGELOG_LATEST.md @@ -1,5 +1,5 @@ -## [3.0.53](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.52...@rudderstack/analytics-js-loading-scripts@3.0.53) (2024-11-22) +## [3.0.54](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-loading-scripts@3.0.53...@rudderstack/analytics-js-loading-scripts@3.0.54) (2024-11-22) ### Dependency Updates -* `@rudderstack/analytics-js` updated to version `3.11.10` +* `@rudderstack/analytics-js` updated to version `3.11.11` diff --git a/packages/loading-scripts/package.json b/packages/loading-scripts/package.json index 160e07deb..7673ad68f 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.53", + "version": "3.0.54", "private": true, "description": "Loading script for RudderStack JavaScript SDK", "main": "./src/index.js", diff --git a/packages/loading-scripts/project.json b/packages/loading-scripts/project.json index 837a34487..1ac2f7e65 100644 --- a/packages/loading-scripts/project.json +++ b/packages/loading-scripts/project.json @@ -51,9 +51,9 @@ "github": { "executor": "@jscutlery/semver:github", "options": { - "tag": "@rudderstack/analytics-js-loading-scripts@3.0.53", - "title": "@rudderstack/analytics-js-loading-scripts@3.0.53", - "discussion-category": "@rudderstack/analytics-js-loading-scripts@3.0.53", + "tag": "@rudderstack/analytics-js-loading-scripts@3.0.54", + "title": "@rudderstack/analytics-js-loading-scripts@3.0.54", + "discussion-category": "@rudderstack/analytics-js-loading-scripts@3.0.54", "notesFile": "./packages/loading-scripts/CHANGELOG_LATEST.md" } } diff --git a/packages/sanity-suite/CHANGELOG.md b/packages/sanity-suite/CHANGELOG.md index 0c7007714..f371b8ccd 100644 --- a/packages/sanity-suite/CHANGELOG.md +++ b/packages/sanity-suite/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [3.1.45](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-sanity-suite@3.1.44...@rudderstack/analytics-js-sanity-suite@3.1.45) (2024-11-22) + +### Dependency Updates + +* `@rudderstack/analytics-js` updated to version `3.11.11` ## [3.1.44](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-sanity-suite@3.1.43...@rudderstack/analytics-js-sanity-suite@3.1.44) (2024-11-22) ### Dependency Updates diff --git a/packages/sanity-suite/package.json b/packages/sanity-suite/package.json index 04c104c6d..9a6ea783c 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.44", + "version": "3.1.45", "private": true, "description": "Sanity suite for testing JS SDK package", "main": "./dist/v3/cdn/testBook.js", diff --git a/sonar-project.properties b/sonar-project.properties index 7d029bebd..adc794a58 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.62.0 +sonar.projectVersion=3.63.0 # Meta-data for the project sonar.links.scm=https://github.com/rudderlabs/rudder-sdk-js