From a17adbd3f55a6701012e105d58af93afc6eedb67 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Sat, 6 Jul 2024 14:54:20 +0530 Subject: [PATCH 01/24] fix: event api overloads --- .../utilities/eventMethodOverloads.test.ts | 98 +++++----- .../src/types/IRudderAnalytics.ts | 175 +++++++++++++++--- .../src/utilities/eventMethodOverloads.ts | 21 ++- .../analytics-js/src/app/RudderAnalytics.ts | 79 ++++++++ 4 files changed, 296 insertions(+), 77 deletions(-) diff --git a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts index 5006f125b5..0c68d1ad20 100644 --- a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts +++ b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts @@ -20,83 +20,100 @@ describe('Core - Event Method Overloads', () => { options: { options: {} }, }); expect( - pageArgumentsToCallOptions('category', 'name', { props: {} }, callbackMock), + pageArgumentsToCallOptions('category', 'name', { props: {} }, { options: {} }), ).toStrictEqual({ - callback: callbackMock, category: 'category', name: 'name', properties: { props: {}, category: 'category', name: 'name' }, + options: { options: {} }, }); - expect(pageArgumentsToCallOptions('category', 'name', callbackMock)).toStrictEqual({ - callback: callbackMock, + expect(pageArgumentsToCallOptions('category', 'name', { props: {} })).toStrictEqual({ category: 'category', name: 'name', - properties: { category: 'category', name: 'name' }, - }); - expect(pageArgumentsToCallOptions('category', callbackMock)).toStrictEqual({ - callback: callbackMock, - name: 'category', - properties: { category: null, name: 'category' }, - }); - expect(pageArgumentsToCallOptions('category')).toStrictEqual({ - name: 'category', - properties: { category: null, name: 'category' }, + properties: { props: {}, category: 'category', name: 'name' }, }); expect(pageArgumentsToCallOptions('category', 'name')).toStrictEqual({ - name: 'name', category: 'category', + name: 'name', properties: { category: 'category', name: 'name' }, }); - expect(pageArgumentsToCallOptions('category', 'name', { props: {} })).toStrictEqual({ + + expect( + pageArgumentsToCallOptions('category', 'name', { props: {} }, callbackMock), + ).toStrictEqual({ + callback: callbackMock, + category: 'category', name: 'name', + properties: { props: {}, category: 'category', name: 'name' }, + }); + expect(pageArgumentsToCallOptions('category', 'name', { props: {} })).toStrictEqual({ category: 'category', - properties: { category: 'category', name: 'name', props: {} }, + name: 'name', + properties: { props: {}, category: 'category', name: 'name' }, }); + expect( - pageArgumentsToCallOptions('category', 'name', { props: {} }, { options: {} }), + pageArgumentsToCallOptions('name', { props: {} }, { options: {} }, callbackMock), ).toStrictEqual({ + callback: callbackMock, name: 'name', - category: 'category', options: { options: {}, }, - properties: { category: 'category', name: 'name', props: {} }, + properties: { category: null, name: 'name', props: {} }, }); - expect(pageArgumentsToCallOptions('category', { props: {} }, { options: {} })).toStrictEqual({ - name: 'category', + expect(pageArgumentsToCallOptions('name', { props: {} }, { options: {} })).toStrictEqual({ + name: 'name', options: { options: {}, }, - properties: { category: null, name: 'category', props: {} }, + properties: { category: null, name: 'name', props: {} }, }); - expect(pageArgumentsToCallOptions(undefined, 'name', callbackMock)).toStrictEqual({ + + expect(pageArgumentsToCallOptions('name', { props: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, name: 'name', - properties: { category: null, name: 'name' }, + properties: { category: null, name: 'name', props: {} }, }); - expect(pageArgumentsToCallOptions(callbackMock)).toStrictEqual({ + expect(pageArgumentsToCallOptions('name', { props: {} })).toStrictEqual({ + name: 'name', + properties: { category: null, name: 'name', props: {} }, + }); + + expect(pageArgumentsToCallOptions('name', callbackMock)).toStrictEqual({ callback: callbackMock, - properties: { category: null, name: null }, + name: 'name', + properties: { category: null, name: 'name' }, + }); + expect(pageArgumentsToCallOptions('name')).toStrictEqual({ + name: 'name', + properties: { category: null, name: 'name' }, }); + expect(pageArgumentsToCallOptions({ props: {} }, { options: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, properties: { props: {}, category: null, name: null }, options: { options: {} }, }); - expect( - pageArgumentsToCallOptions('category', { props: {} }, { options: {} }, callbackMock), - ).toStrictEqual({ - callback: callbackMock, - name: 'category', - properties: { props: {}, category: null, name: 'category' }, + expect(pageArgumentsToCallOptions({ props: {} }, { options: {} })).toStrictEqual({ + properties: { props: {}, category: null, name: null }, options: { options: {} }, }); - expect(pageArgumentsToCallOptions('category', 'name', null, {}, callbackMock)).toStrictEqual({ + + expect(pageArgumentsToCallOptions({ props: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, - category: 'category', - name: 'name', - properties: { category: 'category', name: 'name' }, - options: {}, + properties: { props: {}, category: null, name: null }, + }); + expect(pageArgumentsToCallOptions({ props: {} })).toStrictEqual({ + properties: { props: {}, category: null, name: null }, + }); + + expect(pageArgumentsToCallOptions(callbackMock)).toStrictEqual({ + callback: callbackMock, + properties: { category: null, name: null }, + }); + expect(pageArgumentsToCallOptions()).toStrictEqual({ + properties: { category: null, name: null }, }); }); @@ -228,11 +245,6 @@ describe('Core - Event Method Overloads', () => { traits: {}, groupId: 'groupId', }); - expect(groupArgumentsToCallOptions(callbackMock)).toStrictEqual({ - groupId: null, - traits: {}, - callback: callbackMock, - }); expect( groupArgumentsToCallOptions({ traits: {} }, { options: {} }, callbackMock), ).toStrictEqual({ diff --git a/packages/analytics-js-common/src/types/IRudderAnalytics.ts b/packages/analytics-js-common/src/types/IRudderAnalytics.ts index f721e04da3..709f3c4189 100644 --- a/packages/analytics-js-common/src/types/IRudderAnalytics.ts +++ b/packages/analytics-js-common/src/types/IRudderAnalytics.ts @@ -5,39 +5,168 @@ import type { ApiObject } from './ApiObject'; import type { ILogger } from './Logger'; import type { IdentifyTraits } from './traits'; +// identify(userId, traits, options, callback); +// identify(userId, traits, options); +// identify(userId, traits); + +// identify(userId, traits, callback); +// identify(userId, traits); + +// identify(userId, callback); +// identify(userId); + +// identify(traits, options, callback); +// identify(traits, options); + +// identify(traits, callback); +// identify(traits); + +// -------------- + +// identify(userId, [traits], [options], [callback]); +// identify(userId, [traits], [callback]); +// identify(userId, [callback]); + +// identify(traits, [options], [callback]); +// identify(traits, [callback]); + +// ================ +// page(category, name, properties, options, callback); +// page(category, name, properties, options); +// page(category, name, properties); +// page(category, name); + +// page(category, name, properties, callback); +// page(category, name, properties); + +// page(category, name, callback); +// page(category, name); + +// page(name, properties, options, callback); +// page(name, properties, options); + +// page(name, properties, callback); +// page(name, properties); + +// page(name, callback); +// page(name); + +// page(properties, options, callback); +// page(properties, options); + +// page(properties, callback); +// page(properties); + +// page(callback); +// page(); + +// -------------------------------- +// page(category, name, [properties], [options], [callback]); +// page(category, name, [properties], [callback]); +// page(category, name, [callback]); +// page(name, [properties], [options], [callback]); +// page(name, [properties], [callback]); +// page(name, [callback]); +// page(properties, [options], [callback]); +// page(properties, [callback]); +// page([callback]); + +// ================ + +// track(event, properties, options, callback); +// track(event, properties, options); + +// track(event, properties, callback); +// track(event, properties); + +// track(event, callback); +// track(event); + +// --------------- +// track(event, [properties], [options], [callback]); +// track(event, [properties], [callback]); +// track(event, [callback]); + +// ================================== + +// group(groupId, traits, options, callback); +// group(groupId, traits, options); +// group(groupId, traits); + +// group(groupId, traits, callback); +// group(groupId, traits); + +// group(groupId, callback); +// group(groupId); + +// group(traits, options, callback); +// group(traits, options); + +// group(traits, callback); +// group(traits); + +// ------------- +// group(groupId, [traits], [options], [callback]); +// group(groupId, [traits], [callback]); +// group(groupId, [callback]); + +// group(traits, [options], [callback]); +// group(traits, [callback]); + +// ======================= + +// alias(to, from, options, callback); +// alias(to, from, options); +// alias(to, from); + +// alias(to, from, callback); +// alias(to, from); + +// alias(to, options, callback); +// alias(to, options); + +// alias(to, callback); +// alias(to); +// ----------------------- +// alias(to, [from], [options], [callback]); +// alias(to, [from], [callback]); +// alias(to, [options], [callback]); +// alias(to, [callback]); + export type AnalyticsIdentifyMethod = { ( - userId?: string, + userId: string, traits?: Nullable, options?: Nullable, callback?: ApiCallback, ): void; - (userId: string, traits: Nullable, callback: ApiCallback): void; - (userId: string, callback: ApiCallback): void; - (traits: Nullable, options: Nullable, callback?: ApiCallback): void; + (userId: string, traits?: Nullable, callback?: ApiCallback): void; + (userId: string, callback?: ApiCallback): void; + (traits: Nullable, options?: Nullable, callback?: ApiCallback): void; (traits: Nullable, callback?: ApiCallback): void; }; export type AnalyticsPageMethod = { ( - category?: string, - name?: string, + category: string, + name: string, properties?: Nullable, options?: Nullable, callback?: ApiCallback, ): void; - (category: string, name: string, properties: Nullable, callback: ApiCallback): void; + (category: string, name: string, properties?: Nullable, callback?: ApiCallback): void; + (category: string, name: string, callback?: ApiCallback): void; ( name: string, properties?: Nullable, options?: Nullable, callback?: ApiCallback, ): void; - (category: string, name: string, callback: ApiCallback): void; - (name: string, properties: Nullable, callback: ApiCallback): void; - (name: string, callback: ApiCallback): void; - (properties: Nullable, options: Nullable, callback?: ApiCallback): void; + (name: string, properties?: Nullable, callback?: ApiCallback): void; + (name: string, callback?: ApiCallback): void; + (properties: Nullable, options?: Nullable, callback?: ApiCallback): void; (properties: Nullable, callback?: ApiCallback): void; + (callback?: ApiCallback): void; }; export type AnalyticsTrackMethod = { @@ -47,21 +176,21 @@ export type AnalyticsTrackMethod = { options?: Nullable, callback?: ApiCallback, ): void; - (event: string, properties: Nullable, callback: ApiCallback): void; - (event: string, callback: ApiCallback): void; + (event: string, properties?: Nullable, callback?: ApiCallback): void; + (event: string, callback?: ApiCallback): void; }; export type AnalyticsGroupMethod = { ( - groupId: string | number, - traits?: Nullable, + groupId: string, + traits?: Nullable, options?: Nullable, callback?: ApiCallback, ): void; - (groupId: string | number, traits: Nullable, callback: ApiCallback): void; - (groupId: string | number, callback: ApiCallback): void; - (traits: Nullable, options: Nullable, callback?: ApiCallback): void; - (traits: Nullable, callback?: ApiCallback): void; + (groupId: string, traits?: Nullable, callback?: ApiCallback): void; + (groupId: string, callback?: ApiCallback): void; + (traits: Nullable, options?: Nullable, callback?: ApiCallback): void; + (traits: Nullable, callback?: ApiCallback): void; }; export type AnalyticsAliasMethod = { @@ -71,11 +200,9 @@ export type AnalyticsAliasMethod = { options?: Nullable, callback?: ApiCallback, ): void; - (to: Nullable, from: string, callback: ApiCallback): void; - (to: Nullable, options: Nullable, callback?: ApiCallback): void; - (to: Nullable, callback: ApiCallback): void; - (to: ApiCallback): void; - (): void; + (to: Nullable, from?: string, callback?: ApiCallback): void; + (to: Nullable, options?: Nullable, callback?: ApiCallback): void; + (to: Nullable, callback?: ApiCallback): void; }; export interface IRudderAnalytics { diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index 5338d3f61f..9eac1e2934 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -103,11 +103,19 @@ const pageArgumentsToCallOptions = ( delete payload.name; delete payload.category; payload.properties = category as Nullable; - payload.options = name as Nullable; + if (!isFunction(name)) { + payload.options = name as Nullable; + } else { + delete payload.options; + } } else if (isObjectLiteralAndNotNull(name)) { delete payload.name; payload.properties = name as Nullable; - payload.options = !isFunction(properties) ? (properties as Nullable) : null; + if (!isFunction(properties)) { + payload.options = properties as Nullable; + } else { + delete payload.options; + } } // if the category argument alone is provided b/w category and name, @@ -363,14 +371,7 @@ const groupArgumentsToCallOptions = ( payload.callback = traits as ApiCallback; } - // TODO: why do we enable overload for group that only passes callback? is there any use case? - if (isFunction(groupId)) { - // Explicitly set null to prevent resetting the existing value - payload.groupId = null; - delete payload.traits; - delete payload.options; - payload.callback = groupId as ApiCallback; - } else if (isObjectLiteralAndNotNull(groupId) || isNull(groupId)) { + if (isObjectLiteralAndNotNull(groupId) || isNull(groupId)) { // Explicitly set null to prevent resetting the existing value // in the Analytics class payload.groupId = null; diff --git a/packages/analytics-js/src/app/RudderAnalytics.ts b/packages/analytics-js/src/app/RudderAnalytics.ts index 7478cd7dd1..b50ff80d15 100644 --- a/packages/analytics-js/src/app/RudderAnalytics.ts +++ b/packages/analytics-js/src/app/RudderAnalytics.ts @@ -173,6 +173,36 @@ class RudderAnalytics implements IRudderAnalytics { /** * Process page arguments and forward to page call */ + // These overloads should be same as AnalyticsPageMethod in @rudderstack/analytics-js-common/types/IRudderAnalytics + page( + category: string, + name: string, + properties?: Nullable, + options?: Nullable, + callback?: ApiCallback, + ): void; + page( + category: string, + name: string, + properties?: Nullable, + callback?: ApiCallback, + ): void; + page(category: string, name: string, callback?: ApiCallback): void; + page( + name: string, + properties?: Nullable, + options?: Nullable, + callback?: ApiCallback, + ): void; + page(name: string, properties?: Nullable, callback?: ApiCallback): void; + page(name: string, callback?: ApiCallback): void; + page( + properties: Nullable, + options?: Nullable, + callback?: ApiCallback, + ): void; + page(properties: Nullable, callback?: ApiCallback): void; + page(callback?: ApiCallback): void; page( category?: string | Nullable | ApiCallback, name?: string | Nullable | Nullable | ApiCallback, @@ -188,6 +218,15 @@ class RudderAnalytics implements IRudderAnalytics { /** * Process track arguments and forward to page call */ + // These overloads should be same as AnalyticsTrackMethod in @rudderstack/analytics-js-common/types/IRudderAnalytics + track( + event: string, + properties?: Nullable, + options?: Nullable, + callback?: ApiCallback, + ): void; + track(event: string, properties?: Nullable, callback?: ApiCallback): void; + track(event: string, callback?: ApiCallback): void; track( event: string, properties?: Nullable | ApiCallback, @@ -202,6 +241,21 @@ class RudderAnalytics implements IRudderAnalytics { /** * Process identify arguments and forward to page call */ + // These overloads should be same as AnalyticsIdentifyMethod in @rudderstack/analytics-js-common/types/IRudderAnalytics + identify( + userId: string, + traits?: Nullable, + options?: Nullable, + callback?: ApiCallback, + ): void; + identify(userId: string, traits?: Nullable, callback?: ApiCallback): void; + identify(userId: string, callback?: ApiCallback): void; + identify( + traits: Nullable, + options?: Nullable, + callback?: ApiCallback, + ): void; + identify(traits: Nullable, callback?: ApiCallback): void; identify( userId?: string | number | Nullable, traits?: Nullable | Nullable | ApiCallback, @@ -216,6 +270,16 @@ class RudderAnalytics implements IRudderAnalytics { /** * Process alias arguments and forward to page call */ + // These overloads should be same as AnalyticsAliasMethod in @rudderstack/analytics-js-common/types/IRudderAnalytics + alias( + to: Nullable, + from?: string, + options?: Nullable, + callback?: ApiCallback, + ): void; + alias(to: Nullable, from?: string, callback?: ApiCallback): void; + alias(to: Nullable, options?: Nullable, callback?: ApiCallback): void; + alias(to: Nullable, callback?: ApiCallback): void; alias( to?: Nullable | ApiCallback, from?: string | Nullable | ApiCallback, @@ -228,6 +292,21 @@ class RudderAnalytics implements IRudderAnalytics { /** * Process group arguments and forward to page call */ + // These overloads should be same as AnalyticsGroupMethod in @rudderstack/analytics-js-common/types/IRudderAnalytics + group( + groupId: string, + traits?: Nullable, + options?: Nullable, + callback?: ApiCallback, + ): void; + group(groupId: string, traits?: Nullable, callback?: ApiCallback): void; + group(groupId: string, callback?: ApiCallback): void; + group( + traits: Nullable, + options?: Nullable, + callback?: ApiCallback, + ): void; + group(traits: Nullable, callback?: ApiCallback): void; group( groupId: string | number | Nullable | ApiCallback, traits?: Nullable | Nullable | ApiCallback, From 0bc2b184bd3bcf5d5e1c4770f29e99c0d0e3a009 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Sun, 7 Jul 2024 08:37:16 +0530 Subject: [PATCH 02/24] chore: fix track api overload tests --- .../utilities/eventMethodOverloads.test.ts | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts index 0c68d1ad20..0a37a53a85 100644 --- a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts +++ b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts @@ -126,11 +126,30 @@ describe('Core - Event Method Overloads', () => { properties: { props: {} }, options: { options: {} }, }); + expect(trackArgumentsToCallOptions('event', { props: {} }, { options: {} })).toStrictEqual({ + name: 'event', + properties: { props: {} }, + options: { options: {} }, + }); + expect(trackArgumentsToCallOptions('event', { props: {} })).toStrictEqual({ + name: 'event', + properties: { props: {} }, + }); + expect(trackArgumentsToCallOptions('event')).toStrictEqual({ + name: 'event', + properties: {}, + }); + expect(trackArgumentsToCallOptions('event', { props: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, name: 'event', properties: { props: {} }, }); + expect(trackArgumentsToCallOptions('event', { props: {} })).toStrictEqual({ + name: 'event', + properties: { props: {} }, + }); + expect(trackArgumentsToCallOptions('event', callbackMock)).toStrictEqual({ callback: callbackMock, name: 'event', @@ -143,14 +162,6 @@ describe('Core - Event Method Overloads', () => { name: 'event', }, ); - expect(trackArgumentsToCallOptions('event', { properties: {} })).toStrictEqual({ - properties: { properties: {} }, - name: 'event', - }); - expect(trackArgumentsToCallOptions('event')).toStrictEqual({ - properties: {}, - name: 'event', - }); }); it('should convert facade identify method arguments to analytics identify call options', () => { From dfcae9e77c4db4f83878f6cd274e13d269b1b466 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Sun, 7 Jul 2024 11:12:18 +0530 Subject: [PATCH 03/24] fix: all issues with event api overloads --- .../utilities/eventMethodOverloads.test.ts | 91 +++++++---- .../src/types/ApiObject.ts | 2 +- .../src/types/IRudderAnalytics.ts | 141 +----------------- .../analytics-js-common/src/types/traits.ts | 4 +- .../src/utilities/eventMethodOverloads.ts | 35 ++--- .../__tests__/app/RudderAnalytics.test.ts | 2 +- .../analytics-js/src/app/RudderAnalytics.ts | 19 +-- 7 files changed, 99 insertions(+), 195 deletions(-) diff --git a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts index 0a37a53a85..673f5aa3be 100644 --- a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts +++ b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts @@ -173,15 +173,30 @@ describe('Core - Event Method Overloads', () => { traits: { traits: {} }, options: { options: {} }, }); + expect(identifyArgumentsToCallOptions(1234, { traits: {} }, { options: {} })).toStrictEqual({ + userId: '1234', + traits: { traits: {} }, + options: { options: {} }, + }); + expect(identifyArgumentsToCallOptions('userId', { traits: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, userId: 'userId', traits: { traits: {} }, }); + expect(identifyArgumentsToCallOptions('userId', { traits: {} })).toStrictEqual({ + userId: 'userId', + traits: { traits: {} }, + }); + expect(identifyArgumentsToCallOptions('userId', callbackMock)).toStrictEqual({ callback: callbackMock, userId: 'userId', }); + expect(identifyArgumentsToCallOptions('userId')).toStrictEqual({ + userId: 'userId', + }); + expect( identifyArgumentsToCallOptions({ traits: {} }, { options: {} }, callbackMock), ).toStrictEqual({ @@ -190,16 +205,20 @@ describe('Core - Event Method Overloads', () => { traits: { traits: {} }, options: { options: {} }, }); - expect(identifyArgumentsToCallOptions(1234, { traits: {} }, { options: {} })).toStrictEqual({ - userId: '1234', + expect(identifyArgumentsToCallOptions({ traits: {} }, { options: {} })).toStrictEqual({ + userId: null, traits: { traits: {} }, options: { options: {} }, }); - expect( - identifyArgumentsToCallOptions(undefined, { traits: {} }, { options: {} }), - ).toStrictEqual({ + + expect(identifyArgumentsToCallOptions({ traits: {} }, callbackMock)).toStrictEqual({ + callback: callbackMock, + userId: null, + traits: { traits: {} }, + }); + expect(identifyArgumentsToCallOptions({ traits: {} })).toStrictEqual({ + userId: null, traits: { traits: {} }, - options: { options: {} }, }); }); @@ -210,30 +229,38 @@ describe('Core - Event Method Overloads', () => { from: 'from', options: { options: {} }, }); + expect(aliasArgumentsToCallOptions('to', 'from', { options: {} })).toStrictEqual({ + to: 'to', + from: 'from', + options: { options: {} }, + }); + expect(aliasArgumentsToCallOptions('to', 'from', callbackMock)).toStrictEqual({ callback: callbackMock, to: 'to', from: 'from', }); - expect(aliasArgumentsToCallOptions('to', callbackMock)).toStrictEqual({ - callback: callbackMock, + expect(aliasArgumentsToCallOptions('to', 'from')).toStrictEqual({ to: 'to', + from: 'from', }); + expect(aliasArgumentsToCallOptions('to', { options: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, to: 'to', options: { options: {} }, }); - expect(aliasArgumentsToCallOptions(callbackMock)).toStrictEqual({ - callback: callbackMock, - }); - expect(identifyArgumentsToCallOptions(1234, { traits: {} }, { options: {} })).toStrictEqual({ - userId: '1234', - traits: { traits: {} }, + expect(aliasArgumentsToCallOptions('to', { options: {} })).toStrictEqual({ + to: 'to', options: { options: {} }, }); - expect(aliasArgumentsToCallOptions({ options: {} })).toStrictEqual({ - options: { options: {} }, + + expect(aliasArgumentsToCallOptions('to', callbackMock)).toStrictEqual({ + callback: callbackMock, + to: 'to', + }); + expect(aliasArgumentsToCallOptions('to')).toStrictEqual({ + to: 'to', }); }); @@ -246,16 +273,30 @@ describe('Core - Event Method Overloads', () => { traits: { traits: {} }, options: { options: {} }, }); + expect(groupArgumentsToCallOptions(1234, { traits: {} }, { options: {} })).toStrictEqual({ + groupId: '1234', + traits: { traits: {} }, + options: { options: {} }, + }); + expect(groupArgumentsToCallOptions('groupId', { traits: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, groupId: 'groupId', traits: { traits: {} }, }); + expect(groupArgumentsToCallOptions('groupId', { traits: {} })).toStrictEqual({ + groupId: 'groupId', + traits: { traits: {} }, + }); + expect(groupArgumentsToCallOptions('groupId', callbackMock)).toStrictEqual({ callback: callbackMock, - traits: {}, groupId: 'groupId', }); + expect(groupArgumentsToCallOptions('groupId')).toStrictEqual({ + groupId: 'groupId', + }); + expect( groupArgumentsToCallOptions({ traits: {} }, { options: {} }, callbackMock), ).toStrictEqual({ @@ -264,20 +305,20 @@ describe('Core - Event Method Overloads', () => { traits: { traits: {} }, options: { options: {} }, }); - expect(groupArgumentsToCallOptions({ traits: {} }, callbackMock)).toStrictEqual({ + expect(groupArgumentsToCallOptions({ traits: {} }, { options: {} })).toStrictEqual({ groupId: null, - callback: callbackMock, - options: null, traits: { traits: {} }, + options: { options: {} }, }); - expect(groupArgumentsToCallOptions(1234, { traits: {} }, { options: {} })).toStrictEqual({ - groupId: '1234', + + expect(groupArgumentsToCallOptions({ traits: {} }, callbackMock)).toStrictEqual({ + groupId: null, + callback: callbackMock, traits: { traits: {} }, - options: { options: {} }, }); - expect(groupArgumentsToCallOptions(undefined, { traits: {} }, { options: {} })).toStrictEqual({ + expect(groupArgumentsToCallOptions({ traits: {} })).toStrictEqual({ + groupId: null, traits: { traits: {} }, - options: { options: {} }, }); }); }); diff --git a/packages/analytics-js-common/src/types/ApiObject.ts b/packages/analytics-js-common/src/types/ApiObject.ts index 595c90591e..1265ec70d6 100644 --- a/packages/analytics-js-common/src/types/ApiObject.ts +++ b/packages/analytics-js-common/src/types/ApiObject.ts @@ -10,6 +10,6 @@ export type ApiObject = { | ApiObject | null | Date - | (string | number | boolean | null | ApiObject)[] + | (string | number | boolean | null | Date | ApiObject)[] | undefined; }; diff --git a/packages/analytics-js-common/src/types/IRudderAnalytics.ts b/packages/analytics-js-common/src/types/IRudderAnalytics.ts index 709f3c4189..c9dcdbdfbc 100644 --- a/packages/analytics-js-common/src/types/IRudderAnalytics.ts +++ b/packages/analytics-js-common/src/types/IRudderAnalytics.ts @@ -5,134 +5,6 @@ import type { ApiObject } from './ApiObject'; import type { ILogger } from './Logger'; import type { IdentifyTraits } from './traits'; -// identify(userId, traits, options, callback); -// identify(userId, traits, options); -// identify(userId, traits); - -// identify(userId, traits, callback); -// identify(userId, traits); - -// identify(userId, callback); -// identify(userId); - -// identify(traits, options, callback); -// identify(traits, options); - -// identify(traits, callback); -// identify(traits); - -// -------------- - -// identify(userId, [traits], [options], [callback]); -// identify(userId, [traits], [callback]); -// identify(userId, [callback]); - -// identify(traits, [options], [callback]); -// identify(traits, [callback]); - -// ================ -// page(category, name, properties, options, callback); -// page(category, name, properties, options); -// page(category, name, properties); -// page(category, name); - -// page(category, name, properties, callback); -// page(category, name, properties); - -// page(category, name, callback); -// page(category, name); - -// page(name, properties, options, callback); -// page(name, properties, options); - -// page(name, properties, callback); -// page(name, properties); - -// page(name, callback); -// page(name); - -// page(properties, options, callback); -// page(properties, options); - -// page(properties, callback); -// page(properties); - -// page(callback); -// page(); - -// -------------------------------- -// page(category, name, [properties], [options], [callback]); -// page(category, name, [properties], [callback]); -// page(category, name, [callback]); -// page(name, [properties], [options], [callback]); -// page(name, [properties], [callback]); -// page(name, [callback]); -// page(properties, [options], [callback]); -// page(properties, [callback]); -// page([callback]); - -// ================ - -// track(event, properties, options, callback); -// track(event, properties, options); - -// track(event, properties, callback); -// track(event, properties); - -// track(event, callback); -// track(event); - -// --------------- -// track(event, [properties], [options], [callback]); -// track(event, [properties], [callback]); -// track(event, [callback]); - -// ================================== - -// group(groupId, traits, options, callback); -// group(groupId, traits, options); -// group(groupId, traits); - -// group(groupId, traits, callback); -// group(groupId, traits); - -// group(groupId, callback); -// group(groupId); - -// group(traits, options, callback); -// group(traits, options); - -// group(traits, callback); -// group(traits); - -// ------------- -// group(groupId, [traits], [options], [callback]); -// group(groupId, [traits], [callback]); -// group(groupId, [callback]); - -// group(traits, [options], [callback]); -// group(traits, [callback]); - -// ======================= - -// alias(to, from, options, callback); -// alias(to, from, options); -// alias(to, from); - -// alias(to, from, callback); -// alias(to, from); - -// alias(to, options, callback); -// alias(to, options); - -// alias(to, callback); -// alias(to); -// ----------------------- -// alias(to, [from], [options], [callback]); -// alias(to, [from], [callback]); -// alias(to, [options], [callback]); -// alias(to, [callback]); - export type AnalyticsIdentifyMethod = { ( userId: string, @@ -194,15 +66,10 @@ export type AnalyticsGroupMethod = { }; export type AnalyticsAliasMethod = { - ( - to: Nullable, - from?: string, - options?: Nullable, - callback?: ApiCallback, - ): void; - (to: Nullable, from?: string, callback?: ApiCallback): void; - (to: Nullable, options?: Nullable, callback?: ApiCallback): void; - (to: Nullable, callback?: ApiCallback): void; + (to: string, from?: string, options?: Nullable, callback?: ApiCallback): void; + (to: string, from?: string, callback?: ApiCallback): void; + (to: string, options?: Nullable, callback?: ApiCallback): void; + (to: string, callback?: ApiCallback): void; }; export interface IRudderAnalytics { diff --git a/packages/analytics-js-common/src/types/traits.ts b/packages/analytics-js-common/src/types/traits.ts index 8b0a12f482..8cba540c74 100644 --- a/packages/analytics-js-common/src/types/traits.ts +++ b/packages/analytics-js-common/src/types/traits.ts @@ -64,7 +64,6 @@ export type IdentifyTraits = { prospect?: string | boolean; doubleOptin?: string | boolean; event_id?: string; - constructor?: Record; organization?: string; region?: string; anonymous?: string | boolean; @@ -86,6 +85,7 @@ export type IdentifyTraits = { | boolean | ApiObject | null - | (string | number | boolean | null | ApiObject)[] + | Date + | (string | number | boolean | null | Date | ApiObject)[] | undefined; }; diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index 9eac1e2934..90e80a2f4c 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -205,7 +205,7 @@ const trackArgumentsToCallOptions = ( * Normalise the overloaded arguments of the identify call facade */ const identifyArgumentsToCallOptions = ( - userId?: Nullable, + userId: string | number | Nullable, traits?: Nullable | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, @@ -239,7 +239,11 @@ const identifyArgumentsToCallOptions = ( // in the Analytics class payload.userId = null; payload.traits = userId as Nullable; - payload.options = traits as Nullable; + if (!isFunction(traits)) { + payload.options = traits as Nullable; + } else { + delete payload.options; + } } // Rest of the code is just to clean up undefined values @@ -270,7 +274,7 @@ const identifyArgumentsToCallOptions = ( * Normalise the overloaded arguments of the alias call facade */ const aliasArgumentsToCallOptions = ( - to?: Nullable | ApiCallback, + to: string, from?: string | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, @@ -303,17 +307,6 @@ const aliasArgumentsToCallOptions = ( payload.options = from as Nullable; } - if (isFunction(to)) { - delete payload.to; - delete payload.from; - delete payload.options; - payload.callback = to as ApiCallback; - } else if (isObjectLiteralAndNotNull(to) || isNull(to)) { - delete payload.to; - delete payload.from; - payload.options = to as Nullable; - } - // Rest of the code is just to clean up undefined values // and set some proper defaults // Also, to clone the incoming object type arguments @@ -342,7 +335,7 @@ const aliasArgumentsToCallOptions = ( * Normalise the overloaded arguments of the group call facade */ const groupArgumentsToCallOptions = ( - groupId: string | number | Nullable | ApiCallback, + groupId: string | number | Nullable, traits?: Nullable | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, @@ -376,7 +369,11 @@ const groupArgumentsToCallOptions = ( // in the Analytics class payload.groupId = null; payload.traits = groupId as Nullable; - payload.options = !isFunction(traits) ? (traits as Nullable) : null; + if (!isFunction(traits)) { + payload.options = traits as Nullable; + } else { + delete payload.options; + } } // Rest of the code is just to clean up undefined values @@ -388,7 +385,11 @@ const groupArgumentsToCallOptions = ( delete payload.groupId; } - payload.traits = isObjectLiteralAndNotNull(payload.traits) ? clone(payload.traits) : {}; + if (isObjectLiteralAndNotNull(payload.traits)) { + payload.traits = clone(payload.traits); + } else { + delete payload.traits; + } if (isDefined(payload.options)) { payload.options = clone(payload.options); diff --git a/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts b/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts index fb7e078537..dfabb89c04 100644 --- a/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts +++ b/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts @@ -162,7 +162,7 @@ describe('Core - Rudder Analytics Facade', () => { const groupSpy = jest.spyOn(analyticsInstance, 'group'); rudderAnalytics.group(1234); - expect(groupSpy).toHaveBeenCalledWith({ groupId: '1234', traits: {} }); + expect(groupSpy).toHaveBeenCalledWith({ groupId: '1234' }); }); it('should process reset arguments and forwards to reset call', () => { diff --git a/packages/analytics-js/src/app/RudderAnalytics.ts b/packages/analytics-js/src/app/RudderAnalytics.ts index b50ff80d15..e6805b3928 100644 --- a/packages/analytics-js/src/app/RudderAnalytics.ts +++ b/packages/analytics-js/src/app/RudderAnalytics.ts @@ -257,7 +257,7 @@ class RudderAnalytics implements IRudderAnalytics { ): void; identify(traits: Nullable, callback?: ApiCallback): void; identify( - userId?: string | number | Nullable, + userId: string | number | Nullable, traits?: Nullable | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, @@ -271,17 +271,12 @@ class RudderAnalytics implements IRudderAnalytics { * Process alias arguments and forward to page call */ // These overloads should be same as AnalyticsAliasMethod in @rudderstack/analytics-js-common/types/IRudderAnalytics + alias(to: string, from?: string, options?: Nullable, callback?: ApiCallback): void; + alias(to: string, from?: string, callback?: ApiCallback): void; + alias(to: string, options?: Nullable, callback?: ApiCallback): void; + alias(to: string, callback?: ApiCallback): void; alias( - to: Nullable, - from?: string, - options?: Nullable, - callback?: ApiCallback, - ): void; - alias(to: Nullable, from?: string, callback?: ApiCallback): void; - alias(to: Nullable, options?: Nullable, callback?: ApiCallback): void; - alias(to: Nullable, callback?: ApiCallback): void; - alias( - to?: Nullable | ApiCallback, + to: string, from?: string | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, @@ -308,7 +303,7 @@ class RudderAnalytics implements IRudderAnalytics { ): void; group(traits: Nullable, callback?: ApiCallback): void; group( - groupId: string | number | Nullable | ApiCallback, + groupId: string | number | Nullable, traits?: Nullable | Nullable | ApiCallback, options?: Nullable | ApiCallback, callback?: ApiCallback, From 602407f2cb5d5bd56a186eca38f5d4652d2a5dd0 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Wed, 10 Jul 2024 20:32:20 +0530 Subject: [PATCH 04/24] fix: page api overloads and sanity suite --- .../utilities/eventMethodOverloads.test.ts | 24 +- .../src/utilities/eventMethodOverloads.ts | 9 +- .../__tests__/app/RudderAnalytics.test.ts | 2 +- .../components/core/Analytics.test.ts | 4 +- .../eventManager/RudderEventFactory.test.ts | 2 + .../eventManager/RudderEventFactory.ts | 4 - packages/sanity-suite/.env.example | 2 +- .../sanity-suite/__fixtures__/alias5.json | 43 +-- .../sanity-suite/__fixtures__/alias6.json | 2 +- .../sanity-suite/__fixtures__/group6.json | 59 +++- .../__fixtures__/{track7.json => group7.json} | 72 ++--- .../sanity-suite/__fixtures__/identify8.json | 40 +-- .../sanity-suite/__fixtures__/identify9.json | 140 ++++++++++ .../sanity-suite/__fixtures__/page10.json | 90 ++++++ .../sanity-suite/__fixtures__/page11.json | 120 ++++++++ .../sanity-suite/__fixtures__/page12.json | 89 ++++++ packages/sanity-suite/__fixtures__/page9.json | 121 +++++++++ .../sanity-suite/__fixtures__/track5.json | 41 +-- packages/sanity-suite/package.json | 2 + .../sanity-suite/src/testBookSuites/alias.js | 140 ++++++++-- .../sanity-suite/src/testBookSuites/group.js | 130 ++++++++- .../src/testBookSuites/identify.js | 102 +++++-- .../sanity-suite/src/testBookSuites/page.js | 256 +++++++++++++++++- .../sanity-suite/src/testBookSuites/track.js | 66 ++--- 24 files changed, 1276 insertions(+), 284 deletions(-) rename packages/sanity-suite/__fixtures__/{track7.json => group7.json} (64%) create mode 100644 packages/sanity-suite/__fixtures__/identify9.json create mode 100644 packages/sanity-suite/__fixtures__/page10.json create mode 100644 packages/sanity-suite/__fixtures__/page11.json create mode 100644 packages/sanity-suite/__fixtures__/page12.json create mode 100644 packages/sanity-suite/__fixtures__/page9.json diff --git a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts index 673f5aa3be..84b6dde18a 100644 --- a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts +++ b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts @@ -60,60 +60,60 @@ describe('Core - Event Method Overloads', () => { options: { options: {}, }, - properties: { category: null, name: 'name', props: {} }, + properties: { name: 'name', props: {} }, }); expect(pageArgumentsToCallOptions('name', { props: {} }, { options: {} })).toStrictEqual({ name: 'name', options: { options: {}, }, - properties: { category: null, name: 'name', props: {} }, + properties: { name: 'name', props: {} }, }); expect(pageArgumentsToCallOptions('name', { props: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, name: 'name', - properties: { category: null, name: 'name', props: {} }, + properties: { name: 'name', props: {} }, }); expect(pageArgumentsToCallOptions('name', { props: {} })).toStrictEqual({ name: 'name', - properties: { category: null, name: 'name', props: {} }, + properties: { name: 'name', props: {} }, }); expect(pageArgumentsToCallOptions('name', callbackMock)).toStrictEqual({ callback: callbackMock, name: 'name', - properties: { category: null, name: 'name' }, + properties: { name: 'name' }, }); expect(pageArgumentsToCallOptions('name')).toStrictEqual({ name: 'name', - properties: { category: null, name: 'name' }, + properties: { name: 'name' }, }); expect(pageArgumentsToCallOptions({ props: {} }, { options: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, - properties: { props: {}, category: null, name: null }, + properties: { props: {} }, options: { options: {} }, }); expect(pageArgumentsToCallOptions({ props: {} }, { options: {} })).toStrictEqual({ - properties: { props: {}, category: null, name: null }, + properties: { props: {} }, options: { options: {} }, }); expect(pageArgumentsToCallOptions({ props: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, - properties: { props: {}, category: null, name: null }, + properties: { props: {} }, }); expect(pageArgumentsToCallOptions({ props: {} })).toStrictEqual({ - properties: { props: {}, category: null, name: null }, + properties: { props: {} }, }); expect(pageArgumentsToCallOptions(callbackMock)).toStrictEqual({ callback: callbackMock, - properties: { category: null, name: null }, + properties: {}, }); expect(pageArgumentsToCallOptions()).toStrictEqual({ - properties: { category: null, name: null }, + properties: {}, }); }); diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index 90e80a2f4c..4a54cd716b 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -144,12 +144,17 @@ const pageArgumentsToCallOptions = ( delete payload.options; } + const nameForProperties = isString(payload.name) ? payload.name : payload.properties.name; + const categoryForProperties = isString(payload.category) + ? payload.category + : payload.properties.category; + // add name and category to properties payload.properties = mergeDeepRight( isObjectLiteralAndNotNull(payload.properties) ? payload.properties : {}, { - name: isString(payload.name) ? payload.name : null, - category: isString(payload.category) ? payload.category : null, + ...(nameForProperties && { name: nameForProperties }), + ...(categoryForProperties && { category: categoryForProperties }), }, ); diff --git a/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts b/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts index dfabb89c04..a65173ba87 100644 --- a/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts +++ b/packages/analytics-js/__tests__/app/RudderAnalytics.test.ts @@ -129,7 +129,7 @@ describe('Core - Rudder Analytics Facade', () => { rudderAnalytics.page('category'); expect(pageSpy).toHaveBeenCalledWith({ name: 'category', - properties: { category: null, name: 'category' }, + properties: { name: 'category' }, }); }); diff --git a/packages/analytics-js/__tests__/components/core/Analytics.test.ts b/packages/analytics-js/__tests__/components/core/Analytics.test.ts index 6bcdb7cda8..16bac0ff5d 100644 --- a/packages/analytics-js/__tests__/components/core/Analytics.test.ts +++ b/packages/analytics-js/__tests__/components/core/Analytics.test.ts @@ -446,7 +446,7 @@ describe('Core - Analytics', () => { expect(dequeueSpy).toHaveBeenCalledTimes(2); expect(pageSpy).toHaveBeenCalledWith({ - properties: { path: '/home', category: null, name: null }, + properties: { path: '/home' }, }); expect(trackSpy).toHaveBeenCalledWith({ name: 'buttonClicked', @@ -629,7 +629,7 @@ describe('Core - Analytics', () => { expect(state.eventBuffer.toBeProcessedArray.value).toStrictEqual([ ['identify', { userId: 'test_user_id' }], ['track', { name: 'Consent Management Interaction', properties: {} }], - ['page', { properties: { category: null, name: null } }], + ['page', { properties: {} }], ]); }); }); diff --git a/packages/analytics-js/__tests__/components/eventManager/RudderEventFactory.test.ts b/packages/analytics-js/__tests__/components/eventManager/RudderEventFactory.test.ts index c6fc18f090..9b9b768875 100644 --- a/packages/analytics-js/__tests__/components/eventManager/RudderEventFactory.test.ts +++ b/packages/analytics-js/__tests__/components/eventManager/RudderEventFactory.test.ts @@ -60,6 +60,8 @@ describe('RudderEventFactory', () => { name: 'name', properties: { key: 'value', + name: 'name', + category: 'category', }, options: { page: { diff --git a/packages/analytics-js/src/components/eventManager/RudderEventFactory.ts b/packages/analytics-js/src/components/eventManager/RudderEventFactory.ts index 22e4d8eacd..2eaad0c5a4 100644 --- a/packages/analytics-js/src/components/eventManager/RudderEventFactory.ts +++ b/packages/analytics-js/src/components/eventManager/RudderEventFactory.ts @@ -26,10 +26,6 @@ class RudderEventFactory { options?: Nullable, ): RudderEvent { let props = properties ?? {}; - - props.name = name; - props.category = category; - props = getUpdatedPageProperties(props, options); const pageEvent: Partial = { diff --git a/packages/sanity-suite/.env.example b/packages/sanity-suite/.env.example index e019822c99..0e26a85361 100644 --- a/packages/sanity-suite/.env.example +++ b/packages/sanity-suite/.env.example @@ -7,7 +7,7 @@ STAGING=false # Variables required for the example for v3 #CDN_VERSION_PATH=v3 #DEST_SDK_BASE_URL=http://localhost:3005/cdn -#REMOTE_MODULES_BASE_PATH=http://localhost:3002/cdn/modern/plugins +#REMOTE_MODULES_BASE_PATH=http://localhost:3002/cdn # Variables required for the example for v1.1 #CDN_VERSION_PATH=v1.1 diff --git a/packages/sanity-suite/__fixtures__/alias5.json b/packages/sanity-suite/__fixtures__/alias5.json index ce367b8b6d..1bde22eedb 100644 --- a/packages/sanity-suite/__fixtures__/alias5.json +++ b/packages/sanity-suite/__fixtures__/alias5.json @@ -8,44 +8,7 @@ "namespace": "com.rudderlabs.javascript", "version": "2.22.2" }, - "traits": { - "name": "John Doe", - "title": "CEO", - "email": "name.surname@domain.com", - "company": "Company123", - "phone": "123-456-7890", - "rating": "Hot", - "dob": "1990-01-12T00:00:00.000Z", - "address": [ - { - "city": "Austin", - "postalCode": 12345, - "country": "US", - "street": "Sample Address", - "state": "TX", - "label": "Home", - "defaultAddress": true - }, - { - "city": "Houston", - "postalCode": 345678, - "country": "US", - "street": "Sample Address 2", - "state": "TX", - "label": "Office", - "defaultAddress": false - }, - { - "city": "Dallas", - "postalCode": 987654, - "country": "US", - "street": "Sample Address 3", - "state": "TX", - "label": "Toms place", - "defaultAddress": false - } - ] - }, + "traits": {}, "library": { "name": "RudderLabs JavaScript SDK", "version": "3.3.0", @@ -90,8 +53,8 @@ "messageId": "469fccf3-ba54-427d-9bf4-f01940382231", "originalTimestamp": "2023-01-13T08:13:58.548Z", "anonymousId": "675fccf3-ba54-j87d-9bf4-f01990382231", - "userId": "customUserID", - "previousId": "customUserID", + "userId": "newUserID", + "previousId": "customAnonId", "event": null, "properties": null, "integrations": { diff --git a/packages/sanity-suite/__fixtures__/alias6.json b/packages/sanity-suite/__fixtures__/alias6.json index edb29ffafa..3c75d9fc15 100644 --- a/packages/sanity-suite/__fixtures__/alias6.json +++ b/packages/sanity-suite/__fixtures__/alias6.json @@ -122,8 +122,8 @@ "messageId": "469fccf3-ba54-427d-9bf4-f01940382231", "originalTimestamp": "2023-01-13T08:13:58.548Z", "anonymousId": "sample anonymousId", - "userId": "customUserID", "previousId": "customUserID", + "userId": "newCustomUserID", "event": null, "properties": null, "integrations": { diff --git a/packages/sanity-suite/__fixtures__/group6.json b/packages/sanity-suite/__fixtures__/group6.json index 88f0c69166..9c5a319323 100644 --- a/packages/sanity-suite/__fixtures__/group6.json +++ b/packages/sanity-suite/__fixtures__/group6.json @@ -9,13 +9,45 @@ "version": "2.22.2" }, "traits": {}, + "key1": [1, 2, 3, 4], + "key2": "sample text", + "key3": false, + "key4": 9087654, + "key5": { + "key6": "sample text 2", + "key7": [ + { + "color": "#3456789", + "name": null + }, + { + "color": "#3456767", + "name": "Red" + } + ] + }, + "key8": null, + "externalIds": [ + { + "id": "some_external_id_1", + "type": "brazeExternalId" + } + ], + "device": { + "id": "sdfghj567-cghj5678-fghjvbn888" + }, + "metaData": { + "appVersion": "2.8.0", + "appId": "1hKOmRA4GRlm", + "release_stage": "Production" + }, + "channel": "random", "library": { "name": "RudderLabs JavaScript SDK", "version": "3.3.0", "snippetVersion": "3.0.10" }, "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", - "device": null, "os": { "name": "", "version": "" @@ -57,14 +89,35 @@ "event": null, "properties": null, "integrations": { - "All": true, + "All": false, + "Google Analytics": true, + "Amplitude": true, "Google Analytics 4 (GA4)": { "clientId": "284269621.1683957866", "sessionId": 1683957866, "sessionNumber": 1 } }, - "traits": {}, + "traits": { + "groupName": "Anime fan club", + "email": "name.surname@domain.com", + "company": "Company123", + "phone": "123-456-7890", + "rating": "Hot", + "city": "San Antonio", + "postalCode": 890465, + "country": "US", + "street": "Sample Address", + "state": "TX", + "label": "club office", + "defaultAddress": true, + "temp1": null, + "temp3": [1, 2, 3], + "temp4": { + "selectedType": "hard copy", + "typesAvailable": ["kindle edition", "audio book", "hard copy", null] + } + }, "sentAt": "2023-01-14T20:26:36.001Z" } } diff --git a/packages/sanity-suite/__fixtures__/track7.json b/packages/sanity-suite/__fixtures__/group7.json similarity index 64% rename from packages/sanity-suite/__fixtures__/track7.json rename to packages/sanity-suite/__fixtures__/group7.json index 5489197ccc..61ba013755 100644 --- a/packages/sanity-suite/__fixtures__/track7.json +++ b/packages/sanity-suite/__fixtures__/group7.json @@ -8,21 +8,16 @@ "namespace": "com.rudderlabs.javascript", "version": "2.22.2" }, - "consentManagement": { - "deniedConsentIds": ["C0002", "C0004", "C0005", "C0006"], - "allowedConsentIds": ["C0001", "C0003"], - "provider": "oneTrust", - "resolutionStrategy": "and" - }, - "timezone": "GMT+0530", "traits": {}, + "device": { + "id": "sdfghj567-cghj5678-fghjvbn888" + }, "library": { "name": "RudderLabs JavaScript SDK", "version": "3.3.0", "snippetVersion": "3.0.10" }, "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", - "device": null, "os": { "name": "", "version": "" @@ -35,43 +30,34 @@ "innerWidth": 1728, "innerHeight": 969 }, - "sessionId": 1673747756719, + "sessionId": 1673726912351, "campaign": {}, "page": { "path": "/index.html", - "referrer": "http://localhost:3001/index.html", - "referring_domain": "localhost:3001", + "referrer": "$direct", + "referring_domain": "", "search": "", "title": "RudderStack JS SDK Sanity Suite", "url": "http://localhost:3001/index.html", "tab_url": "http://localhost:3001/index.html", "initial_referrer": "$direct", "initial_referring_domain": "" - } + }, + "consentManagement": { + "deniedConsentIds": ["C0002", "C0004", "C0005", "C0006"], + "allowedConsentIds": ["C0001", "C0003"], + "provider": "oneTrust", + "resolutionStrategy": "and" + }, + "timezone": "GMT+0530" }, - "type": "track", - "messageId": "bb934032-05c6-4c8c-a2d8-5d1b6ed58bbf", + "type": "group", + "messageId": "469fccf3-ba54-427d-9bf4-f01940382231", "originalTimestamp": "2023-01-13T08:13:58.548Z", "anonymousId": "sample anonymousId", "userId": "", - "event": "Order Completed", - "properties": { - "revenue": 30, - "currency": "USD", - "user_actual_id": 12345, - "productId": "234567-sdfghj-345tygh-567890dfghj", - "productCategory": "clothing", - "paid": true, - "paymentMode": 4, - "paymentModeName": "online", - "productSizes": ["XS", "S", "M", "L", "XL", "XXL"], - "sampleObj": { - "sampleObj1": { - "newKey": "sample text" - }, - "newKey1": 3456789009876543 - } - }, + "event": null, + "properties": null, "integrations": { "All": true, "Google Analytics 4 (GA4)": { @@ -80,6 +66,26 @@ "sessionNumber": 1 } }, - "sentAt": "2023-01-15T02:37:59.230Z" + "traits": { + "groupName": "Anime fan club", + "email": "name.surname@domain.com", + "company": "Company123", + "phone": "123-456-7890", + "rating": "Hot", + "city": "San Antonio", + "postalCode": 890465, + "country": "US", + "street": "Sample Address", + "state": "TX", + "label": "club office", + "defaultAddress": true, + "temp1": null, + "temp3": [1, 2, 3], + "temp4": { + "selectedType": "hard copy", + "typesAvailable": ["kindle edition", "audio book", "hard copy", null] + } + }, + "sentAt": "2023-01-14T20:26:36.001Z" } } diff --git a/packages/sanity-suite/__fixtures__/identify8.json b/packages/sanity-suite/__fixtures__/identify8.json index 22362f5027..ea3071c0e2 100644 --- a/packages/sanity-suite/__fixtures__/identify8.json +++ b/packages/sanity-suite/__fixtures__/identify8.json @@ -8,45 +8,7 @@ "namespace": "com.rudderlabs.javascript", "version": "2.22.2" }, - "traits": { - "name": "John Snow", - "title": "CEO", - "email": "name.surname@domain.com", - "alternativeEmail": "name.surname2@domain.com", - "company": "Company123", - "phone": "123-456-7890", - "rating": "Hot", - "dob": "1990-01-12T00:00:00.000Z", - "address": [ - { - "city": "Austin", - "postalCode": 12345, - "country": "US", - "street": "Sample Address", - "state": "TX", - "label": "Home", - "defaultAddress": true - }, - { - "city": "Houston", - "postalCode": 345678, - "country": "US", - "street": "Sample Address 2", - "state": "TX", - "label": "Office", - "defaultAddress": false - }, - { - "city": "Dallas", - "postalCode": 987654, - "country": "US", - "street": "Sample Address 3", - "state": "TX", - "label": "Toms place", - "defaultAddress": false - } - ] - }, + "traits": {}, "library": { "name": "RudderLabs JavaScript SDK", "version": "3.3.0", diff --git a/packages/sanity-suite/__fixtures__/identify9.json b/packages/sanity-suite/__fixtures__/identify9.json new file mode 100644 index 0000000000..ed0ab31c9f --- /dev/null +++ b/packages/sanity-suite/__fixtures__/identify9.json @@ -0,0 +1,140 @@ +{ + "message": { + "channel": "web", + "context": { + "app": { + "installType": "cdn", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "3.3.0" + }, + "traits": { + "name": "John Doe", + "title": "CEO", + "email": "name.surname@domain.com", + "company": "Company123", + "phone": "123-456-7890", + "rating": "Hot", + "dob": "1990-01-12T00:00:00.000Z", + "address": [ + { + "city": "Austin", + "postalCode": 12345, + "country": "US", + "street": "Sample Address", + "state": "TX", + "label": "Home", + "defaultAddress": true + }, + { + "city": "Houston", + "postalCode": 345678, + "country": "US", + "street": "Sample Address 2", + "state": "TX", + "label": "Office", + "defaultAddress": false + }, + { + "city": "Dallas", + "postalCode": 987654, + "country": "US", + "street": "Sample Address 3", + "state": "TX", + "label": "Toms place", + "defaultAddress": false + } + ] + }, + "key1": [1, 2, 3, 4], + "key2": "sample text", + "key3": false, + "key4": 9087654, + "key5": { + "key6": "sample text 2", + "key7": [ + { + "color": "#3456789", + "name": null + }, + { + "color": "#3456767", + "name": "Red" + } + ] + }, + "key8": null, + "externalIds": [ + { + "id": "some_external_id_1", + "type": "brazeExternalId" + } + ], + "device": { + "id": "sdfghj567-cghj5678-fghjvbn888" + }, + "metaData": { + "appVersion": "2.8.0", + "appId": "1hKOmRA4GRlm", + "release_stage": "Production" + }, + "channel": "random", + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "3.3.0", + "snippetVersion": "3.0.10" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", + "os": { + "name": "", + "version": "" + }, + "locale": "en-US", + "screen": { + "density": 2, + "width": 1728, + "height": 1117, + "innerWidth": 1728, + "innerHeight": 969 + }, + "sessionId": 1673726912351, + "campaign": {}, + "page": { + "path": "/index.html", + "referrer": "$direct", + "referring_domain": "", + "search": "", + "title": "RudderStack JS SDK Sanity Suite", + "url": "http://localhost:3001/index.html", + "tab_url": "http://localhost:3001/index.html", + "initial_referrer": "$direct", + "initial_referring_domain": "" + }, + "consentManagement": { + "deniedConsentIds": ["C0002", "C0004", "C0005", "C0006"], + "allowedConsentIds": ["C0001", "C0003"], + "provider": "oneTrust", + "resolutionStrategy": "and" + }, + "timezone": "GMT+0530" + }, + "type": "identify", + "messageId": "469fccf3-ba54-427d-9bf4-f01940382231", + "originalTimestamp": "2023-01-13T08:13:58.548Z", + "anonymousId": "sample anonymousId", + "userId": "", + "event": null, + "properties": null, + "integrations": { + "All": false, + "Google Analytics": true, + "Amplitude": true, + "Google Analytics 4 (GA4)": { + "clientId": "284269621.1683957866", + "sessionId": 1683957866, + "sessionNumber": 1 + } + }, + "sentAt": "2023-01-14T20:26:36.001Z" + } +} diff --git a/packages/sanity-suite/__fixtures__/page10.json b/packages/sanity-suite/__fixtures__/page10.json new file mode 100644 index 0000000000..b4971bc73e --- /dev/null +++ b/packages/sanity-suite/__fixtures__/page10.json @@ -0,0 +1,90 @@ +{ + "message": { + "channel": "web", + "context": { + "app": { + "installType": "cdn", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "2.22.2" + }, + "traits": {}, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "3.3.0", + "snippetVersion": "3.0.10" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", + "device": { + "id": "sdfghj567-cghj5678-fghjvbn888" + }, + "os": { + "name": "", + "version": "" + }, + "locale": "en-US", + "screen": { + "density": 2, + "width": 1728, + "height": 1117, + "innerWidth": 1728, + "innerHeight": 969 + }, + "sessionId": 1673747756719, + "campaign": {}, + "page": { + "path": "/best-seller/1", + "referrer": "https://www.google.com/search?q=estore+bestseller", + "referring_domain": "localhost:3001", + "search": "estore bestseller", + "title": "The best sellers offered by EStore", + "url": "https://www.estore.com/best-seller/1", + "tab_url": "http://localhost:4000/", + "initial_referrer": "$direct", + "initial_referring_domain": "" + }, + "consentManagement": { + "deniedConsentIds": ["C0002", "C0004", "C0005", "C0006"], + "allowedConsentIds": ["C0001", "C0003"], + "provider": "oneTrust", + "resolutionStrategy": "and" + }, + "timezone": "GMT+0530" + }, + "type": "page", + "messageId": "bb934032-05c6-4c8c-a2d8-5d1b6ed58bbf", + "originalTimestamp": "2023-01-13T08:13:58.548Z", + "anonymousId": "sample anonymousId", + "userId": "", + "event": null, + "properties": { + "initial_referrer": "$direct", + "initial_referring_domain": "", + "name": "Cart", + "referring_domain": "", + "tab_url": "http://localhost:4000/", + "path": "/best-seller/1", + "referrer": "https://www.google.com/search?q=estore+bestseller", + "search": "estore bestseller", + "title": "The best sellers offered by EStore", + "url": "https://www.estore.com/best-seller/1", + "temp": 12345, + "temp1": null, + "temp3": [1, 2, 3], + "temp4": { + "selectedType": "hard copy", + "typesAvailable": ["kindle edition", "audio book", "hard copy", null] + } + }, + "integrations": { + "All": true, + "Google Analytics 4 (GA4)": { + "clientId": "284269621.1683957866", + "sessionId": 1683957866, + "sessionNumber": 1 + } + }, + "name": "Cart", + "sentAt": "2023-01-15T02:37:59.230Z" + } +} diff --git a/packages/sanity-suite/__fixtures__/page11.json b/packages/sanity-suite/__fixtures__/page11.json new file mode 100644 index 0000000000..e89080957d --- /dev/null +++ b/packages/sanity-suite/__fixtures__/page11.json @@ -0,0 +1,120 @@ +{ + "message": { + "channel": "web", + "context": { + "app": { + "installType": "cdn", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "2.22.2" + }, + "traits": { + "subscribed": true, + "plan": "Gold", + "endDate": "2023-04-13T08:13:58.548Z", + "startDate": "2023-01-13T08:13:58.548Z" + }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "3.3.0", + "snippetVersion": "3.0.10" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", + "device": { + "id": "sdfghj567-cghj5678-fghjvbn888" + }, + "os": { + "name": "", + "version": "" + }, + "locale": "en-US", + "screen": { + "density": 2, + "width": 1728, + "height": 1117, + "innerWidth": 1728, + "innerHeight": 969 + }, + "sessionId": 1673747756719, + "campaign": {}, + "page": { + "path": "/best-seller/1", + "referrer": "https://www.google.com/search?q=estore+bestseller", + "referring_domain": "localhost:3001", + "search": "estore bestseller", + "title": "The best sellers offered by EStore", + "url": "https://www.estore.com/best-seller/1", + "tab_url": "http://localhost:4000/", + "initial_referrer": "$direct", + "initial_referring_domain": "" + }, + "key1": [1, 2, 3, 4], + "key2": "sample text", + "key3": false, + "key4": 9087654, + "key5": { + "key6": "sample text 2", + "key7": [ + { + "color": "#3456789", + "name": null + }, + { + "color": "#3456767", + "name": "Red" + } + ] + }, + "key8": null, + "metaData": { + "appVersion": "2.8.0", + "appId": "1hKOmRA4GRlm", + "release_stage": "Production" + }, + "channel": "random", + "consentManagement": { + "deniedConsentIds": ["C0002", "C0004", "C0005", "C0006"], + "allowedConsentIds": ["C0001", "C0003"], + "provider": "oneTrust", + "resolutionStrategy": "and" + }, + "timezone": "GMT+0530" + }, + "type": "page", + "messageId": "bb934032-05c6-4c8c-a2d8-5d1b6ed58bbf", + "originalTimestamp": "2023-01-13T08:13:58.548Z", + "anonymousId": "sample anonymousId", + "userId": "", + "event": null, + "properties": { + "initial_referrer": "$direct", + "initial_referring_domain": "", + "name": "Cart Item", + "referring_domain": "", + "tab_url": "http://localhost:4000/", + "path": "/best-seller/1", + "referrer": "https://www.google.com/search?q=estore+bestseller", + "search": "estore bestseller", + "title": "The best sellers offered by EStore", + "url": "https://www.estore.com/best-seller/1", + "temp": 12345, + "temp1": null, + "temp3": [1, 2, 3], + "temp4": { + "selectedType": "hard copy", + "typesAvailable": ["kindle edition", "audio book", "hard copy", null] + } + }, + "integrations": { + "All": false, + "Google Analytics": true, + "Amplitude": true, + "Google Analytics 4 (GA4)": { + "clientId": "284269621.1683957866", + "sessionId": 1683957866, + "sessionNumber": 1 + } + }, + "sentAt": "2023-01-15T02:37:59.230Z" + } +} diff --git a/packages/sanity-suite/__fixtures__/page12.json b/packages/sanity-suite/__fixtures__/page12.json new file mode 100644 index 0000000000..136dca0bd2 --- /dev/null +++ b/packages/sanity-suite/__fixtures__/page12.json @@ -0,0 +1,89 @@ +{ + "message": { + "channel": "web", + "context": { + "app": { + "installType": "cdn", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "2.22.2" + }, + "traits": {}, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "3.3.0", + "snippetVersion": "3.0.10" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", + "device": { + "id": "sdfghj567-cghj5678-fghjvbn888" + }, + "os": { + "name": "", + "version": "" + }, + "locale": "en-US", + "screen": { + "density": 2, + "width": 1728, + "height": 1117, + "innerWidth": 1728, + "innerHeight": 969 + }, + "sessionId": 1673747756719, + "campaign": {}, + "page": { + "path": "/best-seller/1", + "referrer": "https://www.google.com/search?q=estore+bestseller", + "referring_domain": "localhost:3001", + "search": "estore bestseller", + "title": "The best sellers offered by EStore", + "url": "https://www.estore.com/best-seller/1", + "tab_url": "http://localhost:4000/", + "initial_referrer": "$direct", + "initial_referring_domain": "" + }, + "consentManagement": { + "deniedConsentIds": ["C0002", "C0004", "C0005", "C0006"], + "allowedConsentIds": ["C0001", "C0003"], + "provider": "oneTrust", + "resolutionStrategy": "and" + }, + "timezone": "GMT+0530" + }, + "type": "page", + "messageId": "bb934032-05c6-4c8c-a2d8-5d1b6ed58bbf", + "originalTimestamp": "2023-01-13T08:13:58.548Z", + "anonymousId": "sample anonymousId", + "userId": "", + "event": null, + "properties": { + "initial_referrer": "$direct", + "initial_referring_domain": "", + "name": "Cart Item", + "referring_domain": "", + "tab_url": "http://localhost:4000/", + "path": "/best-seller/1", + "referrer": "https://www.google.com/search?q=estore+bestseller", + "search": "estore bestseller", + "title": "The best sellers offered by EStore", + "url": "https://www.estore.com/best-seller/1", + "temp": 12345, + "temp1": null, + "temp3": [1, 2, 3], + "temp4": { + "selectedType": "hard copy", + "typesAvailable": ["kindle edition", "audio book", "hard copy", null] + } + }, + "integrations": { + "All": true, + "Google Analytics 4 (GA4)": { + "clientId": "284269621.1683957866", + "sessionId": 1683957866, + "sessionNumber": 1 + } + }, + "sentAt": "2023-01-15T02:37:59.230Z" + } +} diff --git a/packages/sanity-suite/__fixtures__/page9.json b/packages/sanity-suite/__fixtures__/page9.json new file mode 100644 index 0000000000..0b4420fc8c --- /dev/null +++ b/packages/sanity-suite/__fixtures__/page9.json @@ -0,0 +1,121 @@ +{ + "message": { + "channel": "web", + "context": { + "app": { + "installType": "cdn", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "2.22.2" + }, + "traits": { + "subscribed": true, + "plan": "Gold", + "endDate": "2023-04-13T08:13:58.548Z", + "startDate": "2023-01-13T08:13:58.548Z" + }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "3.3.0", + "snippetVersion": "3.0.10" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", + "device": { + "id": "sdfghj567-cghj5678-fghjvbn888" + }, + "os": { + "name": "", + "version": "" + }, + "locale": "en-US", + "screen": { + "density": 2, + "width": 1728, + "height": 1117, + "innerWidth": 1728, + "innerHeight": 969 + }, + "sessionId": 1673747756719, + "campaign": {}, + "page": { + "path": "/best-seller/1", + "referrer": "https://www.google.com/search?q=estore+bestseller", + "referring_domain": "localhost:3001", + "search": "estore bestseller", + "title": "The best sellers offered by EStore", + "url": "https://www.estore.com/best-seller/1", + "tab_url": "http://localhost:4000/", + "initial_referrer": "$direct", + "initial_referring_domain": "" + }, + "key1": [1, 2, 3, 4], + "key2": "sample text", + "key3": false, + "key4": 9087654, + "key5": { + "key6": "sample text 2", + "key7": [ + { + "color": "#3456789", + "name": null + }, + { + "color": "#3456767", + "name": "Red" + } + ] + }, + "key8": null, + "metaData": { + "appVersion": "2.8.0", + "appId": "1hKOmRA4GRlm", + "release_stage": "Production" + }, + "channel": "random", + "consentManagement": { + "deniedConsentIds": ["C0002", "C0004", "C0005", "C0006"], + "allowedConsentIds": ["C0001", "C0003"], + "provider": "oneTrust", + "resolutionStrategy": "and" + }, + "timezone": "GMT+0530" + }, + "type": "page", + "messageId": "bb934032-05c6-4c8c-a2d8-5d1b6ed58bbf", + "originalTimestamp": "2023-01-13T08:13:58.548Z", + "anonymousId": "sample anonymousId", + "userId": "", + "event": null, + "properties": { + "initial_referrer": "$direct", + "initial_referring_domain": "", + "name": "Cart", + "referring_domain": "", + "tab_url": "http://localhost:4000/", + "path": "/best-seller/1", + "referrer": "https://www.google.com/search?q=estore+bestseller", + "search": "estore bestseller", + "title": "The best sellers offered by EStore", + "url": "https://www.estore.com/best-seller/1", + "temp": 12345, + "temp1": null, + "temp3": [1, 2, 3], + "temp4": { + "selectedType": "hard copy", + "typesAvailable": ["kindle edition", "audio book", "hard copy", null] + } + }, + "integrations": { + "All": false, + "Google Analytics": true, + "Amplitude": true, + "Google Analytics 4 (GA4)": { + "clientId": "284269621.1683957866", + "sessionId": 1683957866, + "sessionNumber": 1 + } + }, + "name": "Cart", + "sentAt": "2023-01-15T02:37:59.230Z" + } +} diff --git a/packages/sanity-suite/__fixtures__/track5.json b/packages/sanity-suite/__fixtures__/track5.json index ec7cb5c9c7..5ae204f43e 100644 --- a/packages/sanity-suite/__fixtures__/track5.json +++ b/packages/sanity-suite/__fixtures__/track5.json @@ -8,44 +8,7 @@ "namespace": "com.rudderlabs.javascript", "version": "2.22.2" }, - "traits": { - "name": "John Doe", - "title": "CEO", - "email": "name.surname@domain.com", - "company": "Company123", - "phone": "123-456-7890", - "rating": "Hot", - "dob": "1990-01-12T00:00:00.000Z", - "address": [ - { - "city": "Austin", - "postalCode": 12345, - "country": "US", - "street": "Sample Address", - "state": "TX", - "label": "Home", - "defaultAddress": true - }, - { - "city": "Houston", - "postalCode": 345678, - "country": "US", - "street": "Sample Address 2", - "state": "TX", - "label": "Office", - "defaultAddress": false - }, - { - "city": "Dallas", - "postalCode": 987654, - "country": "US", - "street": "Sample Address 3", - "state": "TX", - "label": "Toms place", - "defaultAddress": false - } - ] - }, + "traits": {}, "library": { "name": "RudderLabs JavaScript SDK", "version": "3.3.0", @@ -90,7 +53,7 @@ "messageId": "bb934032-05c6-4c8c-a2d8-5d1b6ed58bbf", "originalTimestamp": "2023-01-13T08:13:58.548Z", "anonymousId": "sample anonymousId", - "userId": "customUserID", + "userId": "", "event": "Order Completed", "properties": {}, "integrations": { diff --git a/packages/sanity-suite/package.json b/packages/sanity-suite/package.json index 8719e61c21..acda5e604f 100644 --- a/packages/sanity-suite/package.json +++ b/packages/sanity-suite/package.json @@ -31,8 +31,10 @@ "release": "exit 0", "start:integrations": "npm run clean && mkdir dist && mkdir dist/local && npm run build:v1.1 && npm run build:integrations && rsync -r ../analytics-js-integrations/dist/cdn/legacy/js-integrations dist/local && npm run start:local", "build:start:local:v3": "npm run build:v3 && npm run start:local:v3", + "build:start:local:v1.1": "npm run build:v1.1 && npm run start:local:v1.1", "start:local": "DEV_SERVER=true npm run build -- --watch", "start:local:v3": "DEV_SERVER=true npm run build:local:v3 -- --watch", + "start:local:v1.1": "DEV_SERVER=true npm run build:local:v1.1 -- --watch", "start:cdn": "DEV_SERVER=true npm run build:cdn -- --watch", "start:cdn:v1.1": "DEV_SERVER=true npm run build:cdn:v1.1 -- --watch", "start:cdn:v1": "DEV_SERVER=true npm run build:cdn:v1 -- --watch", diff --git a/packages/sanity-suite/src/testBookSuites/alias.js b/packages/sanity-suite/src/testBookSuites/alias.js index c2c8809806..7a03525475 100644 --- a/packages/sanity-suite/src/testBookSuites/alias.js +++ b/packages/sanity-suite/src/testBookSuites/alias.js @@ -8,12 +8,19 @@ import alias6ExpectedData from '../../__fixtures__/alias6.json'; const aliasMethodSuite = { id: 'aliasMethod', name: 'Alias', - description: 'Alias Method: rudderanalytics.alias(to, from, [apiOptions], [callback]);', + description: + 'Alias Method: \ + rudderanalytics.alias(to, [from], [options], [callback]);\ + rudderanalytics.alias(to, [from], [callback]);\ + rudderanalytics.alias(to, [options], [callback]);\ + rudderanalytics.alias(to, [callback]);\ + ', testCases: [ { id: 'alias1', - description: 'Call with all arguments and all primitives in traits and apiOptions', + description: 'rudderanalytics.alias(to, from, options)', inputData: [ + [true], [ 'customUserID', { @@ -110,33 +117,115 @@ const aliasMethodSuite = { ], ], expectedResult: alias1ExpectedData, - triggerHandler: ['identify', 'alias'], + triggerHandler: ['reset', 'identify', 'alias'], }, { id: 'alias2', - description: 'Call with to and from as arguments', - inputData: ['newCustomUserID', 'customUserID'], + description: 'rudderanalytics.alias(to, options)', + inputData: [ + [true], + [ + 'customUserID', + { + name: 'John Doe', + title: 'CEO', + email: 'name.surname@domain.com', + company: 'Company123', + phone: '123-456-7890', + rating: 'Hot', + dob: new Date(Date.UTC(1990, 0, 12)), + address: [ + { + city: 'Austin', + postalCode: 12345, + country: 'US', + street: 'Sample Address', + state: 'TX', + label: 'Home', + defaultAddress: true, + }, + { + city: 'Houston', + postalCode: 345678, + country: 'US', + street: 'Sample Address 2', + state: 'TX', + label: 'Office', + defaultAddress: false, + }, + { + city: 'Dallas', + postalCode: 987654, + country: 'US', + street: 'Sample Address 3', + state: 'TX', + label: 'Toms place', + defaultAddress: false, + }, + ], + }, + ], + ['newCustomUserID', 'customUserID'], + ], expectedResult: alias2ExpectedData, - triggerHandler: 'alias', + triggerHandler: ['reset', 'identify', 'alias'], }, { id: 'alias3', - description: 'Call with to and from and null apiOption as arguments', - inputData: ['newCustomUserID', 'customUserID', null], + description: 'rudderanalytics.alias(to, from, null)', + inputData: [ + [true], + [ + 'customUserID', + { + name: 'John Doe', + title: 'CEO', + email: 'name.surname@domain.com', + company: 'Company123', + phone: '123-456-7890', + rating: 'Hot', + dob: new Date(Date.UTC(1990, 0, 12)), + address: [ + { + city: 'Austin', + postalCode: 12345, + country: 'US', + street: 'Sample Address', + state: 'TX', + label: 'Home', + defaultAddress: true, + }, + { + city: 'Houston', + postalCode: 345678, + country: 'US', + street: 'Sample Address 2', + state: 'TX', + label: 'Office', + defaultAddress: false, + }, + { + city: 'Dallas', + postalCode: 987654, + country: 'US', + street: 'Sample Address 3', + state: 'TX', + label: 'Toms place', + defaultAddress: false, + }, + ], + }, + ], + ['newCustomUserID', 'customUserID', null], + ], expectedResult: alias3ExpectedData, - triggerHandler: 'alias', + triggerHandler: ['reset', 'identify', 'alias'], }, { id: 'alias4', - description: 'Call with to as argument', - inputData: ['newCustomUserID'], - expectedResult: alias4ExpectedData, - triggerHandler: 'alias', - }, - { - id: 'alias5', - description: 'Call with no argument when userId exists in storage', + description: 'rudderanalytics.alias(to) with prior identify', inputData: [ + [true], [ 'customUserID', { @@ -178,15 +267,23 @@ const aliasMethodSuite = { ], }, ], - [], + ['newCustomUserID'], ], + expectedResult: alias4ExpectedData, + triggerHandler: ['reset', 'identify', 'alias'], + }, + { + id: 'alias5', + description: 'rudderanalytics.alias(to) with no prior identify', + inputData: [[true], ['customAnonId'], ['newUserID']], expectedResult: alias5ExpectedData, - triggerHandler: ['identify', 'alias'], + triggerHandler: ['reset', 'setAnonymousId', 'alias'], }, { id: 'alias6', - description: 'Call with only apiOptions arguments', + description: 'rudderanalytics.alias(to, options)', inputData: [ + [true], [ 'customUserID', { @@ -229,6 +326,7 @@ const aliasMethodSuite = { }, ], [ + 'newCustomUserID', { key1: [1, 2, 3, 4], key2: 'sample text', @@ -281,7 +379,7 @@ const aliasMethodSuite = { ], ], expectedResult: alias6ExpectedData, - triggerHandler: ['identify', 'alias'], + triggerHandler: ['reset', 'identify', 'alias'], }, ], }; diff --git a/packages/sanity-suite/src/testBookSuites/group.js b/packages/sanity-suite/src/testBookSuites/group.js index d7afe57587..64f3ff5aae 100644 --- a/packages/sanity-suite/src/testBookSuites/group.js +++ b/packages/sanity-suite/src/testBookSuites/group.js @@ -4,15 +4,23 @@ import group3ExpectedData from '../../__fixtures__/group3.json'; import group4ExpectedData from '../../__fixtures__/group4.json'; import group5ExpectedData from '../../__fixtures__/group5.json'; import group6ExpectedData from '../../__fixtures__/group6.json'; +import group7ExpectedData from '../../__fixtures__/group7.json'; const groupMethodSuite = { id: 'groupMethod', name: 'Group', - description: 'Group Method: rudderanalytics.group(groupId, [traits], [apiOptions], [callback]);', + description: + 'Group Method: \ + rudderanalytics.group(groupId, [traits], [options], [callback]);\ + rudderanalytics.group(groupId, [traits], [callback]);\ + rudderanalytics.group(groupId, [callback]);\ + rudderanalytics.group(traits, [options], [callback]);\ + rudderanalytics.group(traits, [callback]);\ + ', testCases: [ { id: 'group1', - description: 'Call with all arguments and all primitives in traits and apiOptions', + description: 'rudderanalytics.group(groupId, traits, options)', inputData: [ [true], [ @@ -94,7 +102,7 @@ const groupMethodSuite = { }, { id: 'group2', - description: 'Call with groupId, groupTraits as arguments', + description: 'rudderanalytics.group(groupId, traits)', inputData: [ [true], [ @@ -127,7 +135,7 @@ const groupMethodSuite = { }, { id: 'group3', - description: 'Call with groupId, groupTraits and null apiOptions as arguments', + description: 'rudderanalytics.group(groupId, traits, null)', inputData: [ [true], [ @@ -161,7 +169,7 @@ const groupMethodSuite = { }, { id: 'group4', - description: 'Call with groupId, null groupTraits and apiOptions as arguments', + description: 'rudderanalytics.group(groupId, null, options)', inputData: [ [true], [ @@ -223,18 +231,124 @@ const groupMethodSuite = { }, { id: 'group5', - description: 'Call with groupId as argument', + description: 'rudderanalytics.group(groupId)', inputData: [[true], ['customGroupID']], expectedResult: group5ExpectedData, triggerHandler: ['reset', 'group'], }, { id: 'group6', - description: 'Call with only callback as argument', - inputData: [[true], []], + description: 'rudderanalytics.group(traits, options)', + inputData: [ + [true], + [ + { + groupName: 'Anime fan club', + email: 'name.surname@domain.com', + company: 'Company123', + phone: '123-456-7890', + rating: 'Hot', + city: 'San Antonio', + postalCode: 890465, + country: 'US', + street: 'Sample Address', + state: 'TX', + label: 'club office', + defaultAddress: true, + temp1: null, + temp2: undefined, + temp3: [1, 2, 3], + temp4: { + selectedType: 'hard copy', + typesAvailable: ['kindle edition', 'audio book', 'hard copy', null], + }, + }, + { + key1: [1, 2, 3, 4], + key2: 'sample text', + key3: false, + key4: 9087654, + key5: { + key6: 'sample text 2', + key7: [ + { + color: '#3456789', + name: null, + }, + { + color: '#3456767', + name: 'Red', + }, + ], + }, + key8: null, + key9: undefined, + externalIds: [ + { + id: 'some_external_id_1', + type: 'brazeExternalId', + }, + ], + device: { + id: 'sdfghj567-cghj5678-fghjvbn888', + }, + library: { + name: 'Random JavaScript SDK', + version: '2.22.0', + }, + context: { + metaData: { + appVersion: '2.8.0', + appId: '1hKOmRA4GRlm', + release_stage: 'Production', + }, + }, + integrations: { + All: false, + 'Google Analytics': true, + Amplitude: true, + }, + anonymousId: 'sample anonymousId', + originalTimestamp: '2023-01-13T08:13:58.548Z', + channel: 'random', + }, + ], + ], expectedResult: group6ExpectedData, triggerHandler: ['reset', 'group'], }, + { + id: 'group7', + description: 'rudderanalytics.group(traits)', + inputData: [ + [true], + [ + { + groupName: 'Anime fan club', + email: 'name.surname@domain.com', + company: 'Company123', + phone: '123-456-7890', + rating: 'Hot', + city: 'San Antonio', + postalCode: 890465, + country: 'US', + street: 'Sample Address', + state: 'TX', + label: 'club office', + defaultAddress: true, + temp1: null, + temp2: undefined, + temp3: [1, 2, 3], + temp4: { + selectedType: 'hard copy', + typesAvailable: ['kindle edition', 'audio book', 'hard copy', null], + }, + }, + ], + ], + expectedResult: group7ExpectedData, + triggerHandler: ['reset', 'group'], + }, ], }; diff --git a/packages/sanity-suite/src/testBookSuites/identify.js b/packages/sanity-suite/src/testBookSuites/identify.js index 0bf98475ce..7fb4c9c31c 100644 --- a/packages/sanity-suite/src/testBookSuites/identify.js +++ b/packages/sanity-suite/src/testBookSuites/identify.js @@ -6,16 +6,23 @@ import identify5ExpectedData from '../../__fixtures__/identify5.json'; import identify6ExpectedData from '../../__fixtures__/identify6.json'; import identify7ExpectedData from '../../__fixtures__/identify7.json'; import identify8ExpectedData from '../../__fixtures__/identify8.json'; +import identify9ExpectedData from '../../__fixtures__/identify9.json'; const identifyMethodSuite = { id: 'identifyMethod', name: 'Identify', description: - 'Identify Method: rudderanalytics.identify(userId, [traits], [apiOptions], [callback]);', + 'Identify Method: \ + rudderanalytics.identify(userId, [traits], [options], [callback]);\ + rudderanalytics.identify(userId, [traits], [callback]);\ + rudderanalytics.identify(userId, [callback]);\ + rudderanalytics.identify(traits, [options], [callback]);\ + rudderanalytics.identify(traits, [callback]);\ + ', testCases: [ { id: 'identify1', - description: 'Call with all arguments and all primitives in traits and apiOptions', + description: 'rudderanalytics.identify(userId, traits, options)', inputData: [ [true], [ @@ -114,8 +121,9 @@ const identifyMethodSuite = { }, { id: 'identify2', - description: 'Call with userId and traits as arguments with all possible data types', + description: 'rudderanalytics.identify(userId, traits)', inputData: [ + [true], [ 'customUserID', { @@ -159,12 +167,11 @@ const identifyMethodSuite = { ], ], expectedResult: identify2ExpectedData, - triggerHandler: ['identify'], + triggerHandler: ['reset', 'identify'], }, { id: 'identify3', - description: - 'Call with userId , null traits and apiOption as arguments with all possible data types', + description: 'rudderanalytics.identify(userId, null, options)', inputData: [ [true], [ @@ -226,16 +233,16 @@ const identifyMethodSuite = { }, { id: 'identify4', - description: 'Call with only userId as argument', + description: 'rudderanalytics.identify(userId)', inputData: [[true], ['customUserID']], expectedResult: identify4ExpectedData, triggerHandler: ['reset', 'identify'], }, { id: 'identify5', - description: - 'Call with userId and traits and null apiOptions as arguments with all possible data types', + description: 'rudderanalytics.identify(userId, traits, null)', inputData: [ + [true], [ 'customUserID', { @@ -280,12 +287,13 @@ const identifyMethodSuite = { ], ], expectedResult: identify5ExpectedData, - triggerHandler: ['identify'], + triggerHandler: ['reset', 'identify'], }, { id: 'identify6', - description: 'Add or Update traits', + description: 'rudderanalytics.identify(traits)', inputData: [ + [true], [ 'customUserID', { @@ -337,12 +345,11 @@ const identifyMethodSuite = { ], ], expectedResult: identify6ExpectedData, - triggerHandler: ['identify', 'identify'], + triggerHandler: ['reset', 'identify', 'identify'], }, { id: 'identify7', - description: - 'Set custom anonymousId then call Identify with userId and traits and null apiOptions as arguments with all possible data types', + description: 'rudderanalytics.identify(userId, traits) with prior setAnonymousId call', inputData: [ [true], ['custom-anonymousId'], @@ -386,7 +393,6 @@ const identifyMethodSuite = { }, ], }, - null, ], ], expectedResult: identify7ExpectedData, @@ -395,9 +401,16 @@ const identifyMethodSuite = { { id: 'identify8', description: 'Identify with string userId and then with number userId', + inputData: [[true], ['1234567890'], [1234567890]], + expectedResult: identify8ExpectedData, + triggerHandler: ['reset', 'identify', 'identify'], + }, + { + id: 'identify9', + description: 'rudderanalytics.identify(traits, options)', inputData: [ + [true], [ - '1234567890', { name: 'John Doe', title: 'CEO', @@ -436,18 +449,59 @@ const identifyMethodSuite = { }, ], }, - null, - ], - [ - 1234567890, { - name: 'John Snow', - alternativeEmail: 'name.surname2@domain.com', + key1: [1, 2, 3, 4], + key2: 'sample text', + key3: false, + key4: 9087654, + key5: { + key6: 'sample text 2', + key7: [ + { + color: '#3456789', + name: null, + }, + { + color: '#3456767', + name: 'Red', + }, + ], + }, + key8: null, + key9: undefined, + externalIds: [ + { + id: 'some_external_id_1', + type: 'brazeExternalId', + }, + ], + device: { + id: 'sdfghj567-cghj5678-fghjvbn888', + }, + library: { + name: 'Random JavaScript SDK', + version: '2.22.0', + }, + context: { + metaData: { + appVersion: '2.8.0', + appId: '1hKOmRA4GRlm', + release_stage: 'Production', + }, + }, + integrations: { + All: false, + 'Google Analytics': true, + Amplitude: true, + }, + anonymousId: 'sample anonymousId', + originalTimestamp: '2023-01-13T08:13:58.548Z', + channel: 'random', }, ], ], - expectedResult: identify8ExpectedData, - triggerHandler: ['identify', 'identify'], + expectedResult: identify9ExpectedData, + triggerHandler: ['reset', 'identify'], }, ], }; diff --git a/packages/sanity-suite/src/testBookSuites/page.js b/packages/sanity-suite/src/testBookSuites/page.js index a101d9a493..6683589405 100644 --- a/packages/sanity-suite/src/testBookSuites/page.js +++ b/packages/sanity-suite/src/testBookSuites/page.js @@ -6,16 +6,30 @@ import page5ExpectedData from '../../__fixtures__/page5.json'; import page6ExpectedData from '../../__fixtures__/page6.json'; import page7ExpectedData from '../../__fixtures__/page7.json'; import page8ExpectedData from '../../__fixtures__/page8.json'; +import page9ExpectedData from '../../__fixtures__/page9.json'; +import page10ExpectedData from '../../__fixtures__/page10.json'; +import page11ExpectedData from '../../__fixtures__/page11.json'; +import page12ExpectedData from '../../__fixtures__/page12.json'; const pageMethodSuite = { id: 'pageMethod', name: 'Page', description: - 'Page Method: rudderanalytics.page(category, name, [properties], [apiOptions], [callback]);', + 'Page Method: \ + rudderanalytics.page(category, name, [properties], [options], [callback]);\ + rudderanalytics.page(category, name, [properties], [callback]);\ + rudderanalytics.page(category, name, [callback]);\ + rudderanalytics.page(name, [properties], [options], [callback]);\ + rudderanalytics.page(name, [properties], [callback]);\ + rudderanalytics.page(name, [callback]);\ + rudderanalytics.page(properties, [options], [callback]);\ + rudderanalytics.page(properties, [callback]);\ + rudderanalytics.page([callback]);\ + ', testCases: [ { id: 'page1', - description: 'Call with all arguments and all primitives in properties and apiOptions', + description: 'rudderanalytics.page(category, name, properties, options)', inputData: [ [true], [ @@ -97,7 +111,7 @@ const pageMethodSuite = { }, { id: 'page2', - description: 'Call with category, name, properties as arguments', + description: 'rudderanalytics.page(category, name, properties)', inputData: [ [true], [ @@ -130,7 +144,7 @@ const pageMethodSuite = { }, { id: 'page3', - description: 'Call with category, name, properties and null apiOptions as arguments', + description: 'rudderanalytics.page(category, name, properties, null)', inputData: [ [true], [ @@ -164,7 +178,7 @@ const pageMethodSuite = { }, { id: 'page4', - description: 'Call with category, name, null properties and apiOptions as arguments', + description: 'rudderanalytics.page(category, name, null, options)', inputData: [ [true], [ @@ -227,32 +241,256 @@ const pageMethodSuite = { }, { id: 'page5', - description: 'Call with category, name as arguments', + description: 'rudderanalytics.page(category, name)', inputData: [[true], ['Cart', 'Cart Item']], expectedResult: page5ExpectedData, triggerHandler: ['reset', 'page'], }, { id: 'page6', - description: 'Call with category as argument', + description: 'rudderanalytics.page(name)', inputData: [[true], ['Cart']], expectedResult: page6ExpectedData, triggerHandler: ['reset', 'page'], }, { id: 'page7', - description: 'Call with name as argument', + description: 'rudderanalytics.page(undefined, name)', inputData: [[true], [undefined, 'Cart Item']], expectedResult: page7ExpectedData, triggerHandler: ['reset', 'page'], }, { id: 'page8', - description: 'Call with no argument', + description: 'rudderanalytics.page()', inputData: [[true], []], expectedResult: page8ExpectedData, triggerHandler: ['reset', 'page'], }, + { + id: 'page9', + description: 'rudderanalytics.page(name, properties, options)', + inputData: [ + [true], + [ + 'Cart', + { + initial_referrer: '$direct', + initial_referring_domain: '', + name: 'Cart Item', + referring_domain: '', + tab_url: 'http://localhost:4000/', + path: '/best-seller/1', + referrer: 'https://www.google.com/search?q=estore+bestseller', + search: 'estore bestseller', + title: 'The best sellers offered by EStore', + url: 'https://www.estore.com/best-seller/1', + temp: 12345, + temp1: null, + temp2: undefined, + temp3: [1, 2, 3], + temp4: { + selectedType: 'hard copy', + typesAvailable: ['kindle edition', 'audio book', 'hard copy', null], + }, + }, + { + key1: [1, 2, 3, 4], + key2: 'sample text', + key3: false, + key4: 9087654, + key5: { + key6: 'sample text 2', + key7: [ + { + color: '#3456789', + name: null, + }, + { + color: '#3456767', + name: 'Red', + }, + ], + }, + key8: null, + key9: undefined, + device: { + id: 'sdfghj567-cghj5678-fghjvbn888', + }, + library: { + name: 'Random JavaScript SDK', + version: '2.22.0', + }, + context: { + metaData: { + appVersion: '2.8.0', + appId: '1hKOmRA4GRlm', + release_stage: 'Production', + }, + }, + integrations: { + All: false, + 'Google Analytics': true, + Amplitude: true, + }, + anonymousId: 'sample anonymousId', + originalTimestamp: '2023-01-13T08:13:58.548Z', + channel: 'random', + traits: { + subscribed: true, + plan: 'Gold', + endDate: '2023-04-13T08:13:58.548Z', + startDate: '2023-01-13T08:13:58.548Z', + }, + }, + ], + ], + expectedResult: page9ExpectedData, + triggerHandler: ['reset', 'page'], + }, + { + id: 'page10', + description: 'rudderanalytics.page(name, properties)', + inputData: [ + [true], + [ + 'Cart', + { + initial_referrer: '$direct', + initial_referring_domain: '', + name: 'Cart Item', + referring_domain: '', + tab_url: 'http://localhost:4000/', + path: '/best-seller/1', + referrer: 'https://www.google.com/search?q=estore+bestseller', + search: 'estore bestseller', + title: 'The best sellers offered by EStore', + url: 'https://www.estore.com/best-seller/1', + temp: 12345, + temp1: null, + temp2: undefined, + temp3: [1, 2, 3], + temp4: { + selectedType: 'hard copy', + typesAvailable: ['kindle edition', 'audio book', 'hard copy', null], + }, + }, + ], + ], + expectedResult: page10ExpectedData, + triggerHandler: ['reset', 'page'], + }, + { + id: 'page11', + description: 'rudderanalytics.page(properties, options)', + inputData: [ + [true], + [ + { + initial_referrer: '$direct', + initial_referring_domain: '', + name: 'Cart Item', + referring_domain: '', + tab_url: 'http://localhost:4000/', + path: '/best-seller/1', + referrer: 'https://www.google.com/search?q=estore+bestseller', + search: 'estore bestseller', + title: 'The best sellers offered by EStore', + url: 'https://www.estore.com/best-seller/1', + temp: 12345, + temp1: null, + temp2: undefined, + temp3: [1, 2, 3], + temp4: { + selectedType: 'hard copy', + typesAvailable: ['kindle edition', 'audio book', 'hard copy', null], + }, + }, + { + key1: [1, 2, 3, 4], + key2: 'sample text', + key3: false, + key4: 9087654, + key5: { + key6: 'sample text 2', + key7: [ + { + color: '#3456789', + name: null, + }, + { + color: '#3456767', + name: 'Red', + }, + ], + }, + key8: null, + key9: undefined, + device: { + id: 'sdfghj567-cghj5678-fghjvbn888', + }, + library: { + name: 'Random JavaScript SDK', + version: '2.22.0', + }, + context: { + metaData: { + appVersion: '2.8.0', + appId: '1hKOmRA4GRlm', + release_stage: 'Production', + }, + }, + integrations: { + All: false, + 'Google Analytics': true, + Amplitude: true, + }, + anonymousId: 'sample anonymousId', + originalTimestamp: '2023-01-13T08:13:58.548Z', + channel: 'random', + traits: { + subscribed: true, + plan: 'Gold', + endDate: '2023-04-13T08:13:58.548Z', + startDate: '2023-01-13T08:13:58.548Z', + }, + }, + ], + ], + expectedResult: page11ExpectedData, + triggerHandler: ['reset', 'page'], + }, + { + id: 'page12', + description: 'rudderanalytics.page(properties)', + inputData: [ + [true], + [ + { + initial_referrer: '$direct', + initial_referring_domain: '', + name: 'Cart Item', + referring_domain: '', + tab_url: 'http://localhost:4000/', + path: '/best-seller/1', + referrer: 'https://www.google.com/search?q=estore+bestseller', + search: 'estore bestseller', + title: 'The best sellers offered by EStore', + url: 'https://www.estore.com/best-seller/1', + temp: 12345, + temp1: null, + temp2: undefined, + temp3: [1, 2, 3], + temp4: { + selectedType: 'hard copy', + typesAvailable: ['kindle edition', 'audio book', 'hard copy', null], + }, + }, + ], + ], + expectedResult: page12ExpectedData, + triggerHandler: ['reset', 'page'], + }, ], }; diff --git a/packages/sanity-suite/src/testBookSuites/track.js b/packages/sanity-suite/src/testBookSuites/track.js index cc16ade965..ad7ea8e8dc 100644 --- a/packages/sanity-suite/src/testBookSuites/track.js +++ b/packages/sanity-suite/src/testBookSuites/track.js @@ -4,18 +4,22 @@ import track3ExpectedData from '../../__fixtures__/track3.json'; import track4ExpectedData from '../../__fixtures__/track4.json'; import track5ExpectedData from '../../__fixtures__/track5.json'; import track6ExpectedData from '../../__fixtures__/track6.json'; -import track7ExpectedData from '../../__fixtures__/track7.json'; const trackMethodSuite = { id: 'trackMethod', name: 'Track', description: - 'Track Method: rudderanalytics.track(event, [properties], [apiOptions], [callback]);', + 'Track Method: \ + rudderanalytics.track(event, [properties], [options], [callback]);\ + rudderanalytics.track(event, [properties], [callback]);\ + rudderanalytics.track(event, [callback]);\ + ', testCases: [ { id: 'track1', - description: 'Call with all arguments and all primitives in properties and apiOptions', + description: 'rudderanalytics.track(event, properties, options)', inputData: [ + [true], [ 'customUserID', { @@ -129,12 +133,13 @@ const trackMethodSuite = { ], ], expectedResult: track1ExpectedData, - triggerHandler: ['identify', 'track'], + triggerHandler: ['reset', 'identify', 'track'], }, { id: 'track2', - description: 'Call with event name, properties as arguments with all possible data types', + description: 'rudderanalytics.track(event, properties)', inputData: [ + [true], [ 'customUserID', { @@ -199,13 +204,13 @@ const trackMethodSuite = { ], ], expectedResult: track2ExpectedData, - triggerHandler: ['identify', 'track'], + triggerHandler: ['reset', 'identify', 'track'], }, { id: 'track3', - description: - 'Call with event name, properties and null apiOptions as arguments with all possible data types', + description: 'rudderanalytics.track(event, properties, null)', inputData: [ + [true], [ 'customUserID', { @@ -271,13 +276,13 @@ const trackMethodSuite = { ], ], expectedResult: track3ExpectedData, - triggerHandler: ['identify', 'track'], + triggerHandler: ['reset', 'identify', 'track'], }, { id: 'track4', - description: - 'Call with event name, null properties and apiOptions as arguments with all possible data types', + description: 'rudderanalytics.track(event, null, options)', inputData: [ + [true], [ 'customUserID', { @@ -375,18 +380,18 @@ const trackMethodSuite = { ], ], expectedResult: track4ExpectedData, - triggerHandler: ['identify', 'track'], + triggerHandler: ['reset', 'identify', 'track'], }, { id: 'track5', - description: 'Call with only event name as argument', - inputData: ['Order Completed'], + description: 'rudderanalytics.track(event)', + inputData: [[true], ['Order Completed']], expectedResult: track5ExpectedData, - triggerHandler: 'track', + triggerHandler: ['reset', 'track'], }, { id: 'track6', - description: 'Scenarios where no identify is called before track', + description: 'rudderanalytics.track(event, properties) with no prior identify', inputData: [ [true], [ @@ -413,35 +418,6 @@ const trackMethodSuite = { expectedResult: track6ExpectedData, triggerHandler: ['reset', 'track'], }, - { - id: 'track7', - description: 'Consent denied category Ids are attached to context object of track', - inputData: [ - [true], - [ - 'Order Completed', - { - revenue: 30, - currency: 'USD', - user_actual_id: 12345, - productId: '234567-sdfghj-345tygh-567890dfghj', - productCategory: 'clothing', - paid: true, - paymentMode: 4, - paymentModeName: 'online', - productSizes: ['XS', 'S', 'M', 'L', 'XL', 'XXL'], - sampleObj: { - sampleObj1: { - newKey: 'sample text', - }, - newKey1: 3456789009876543, - }, - }, - ], - ], - expectedResult: track7ExpectedData, - triggerHandler: ['reset', 'track'], - }, ], }; From dae39b212915ae52bb84f235b1bc43a0c430e3dc Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Thu, 11 Jul 2024 11:49:37 +0530 Subject: [PATCH 05/24] fix: api overloads for destination analytics instance --- .../src/deviceModeDestinations/types.ts | 36 ++--- .../src/deviceModeDestinations/utils.ts | 149 +++++++++--------- 2 files changed, 91 insertions(+), 94 deletions(-) diff --git a/packages/analytics-js-plugins/src/deviceModeDestinations/types.ts b/packages/analytics-js-plugins/src/deviceModeDestinations/types.ts index e6aeea268b..1e34ca0bfe 100644 --- a/packages/analytics-js-plugins/src/deviceModeDestinations/types.ts +++ b/packages/analytics-js-plugins/src/deviceModeDestinations/types.ts @@ -1,28 +1,22 @@ import type { IntegrationOpts } from '@rudderstack/analytics-js-common/types/Integration'; -import type { - AnalyticsAliasMethod, - AnalyticsGroupMethod, - AnalyticsIdentifyMethod, - AnalyticsPageMethod, - AnalyticsTrackMethod, -} from '@rudderstack/analytics-js-common/types/IRudderAnalytics'; -import type { ApiObject } from '@rudderstack/analytics-js-common/types/ApiObject'; -import type { Nullable } from '@rudderstack/analytics-js-common/types/Nullable'; +import type { IRudderAnalytics } from '@rudderstack/analytics-js-common/types/IRudderAnalytics'; import type { LogLevel } from '../types/plugins'; -export type DeviceModeDestinationsAnalyticsInstance = { +export type DeviceModeDestinationsAnalyticsInstance = Pick< + IRudderAnalytics, + | 'track' + | 'page' + | 'identify' + | 'group' + | 'alias' + | 'getAnonymousId' + | 'getUserId' + | 'getUserTraits' + | 'getGroupId' + | 'getGroupTraits' + | 'getSessionId' +> & { loadIntegration: boolean; logLevel: LogLevel; loadOnlyIntegrations: IntegrationOpts; - track: AnalyticsTrackMethod; - page: AnalyticsPageMethod; - identify: AnalyticsIdentifyMethod; - group: AnalyticsGroupMethod; - alias: AnalyticsAliasMethod; - getAnonymousId: () => string; - getUserId: () => Nullable | undefined; - getUserTraits: () => Nullable | undefined; - getGroupId: () => Nullable | undefined; - getGroupTraits: () => Nullable | undefined; - getSessionId: () => Nullable; }; diff --git a/packages/analytics-js-plugins/src/deviceModeDestinations/utils.ts b/packages/analytics-js-plugins/src/deviceModeDestinations/utils.ts index 76a88316c4..84077655f5 100644 --- a/packages/analytics-js-plugins/src/deviceModeDestinations/utils.ts +++ b/packages/analytics-js-plugins/src/deviceModeDestinations/utils.ts @@ -15,6 +15,7 @@ import type { IntegrationOpts } from '@rudderstack/analytics-js-common/types/Int import type { Nullable } from '@rudderstack/analytics-js-common/types/Nullable'; import type { IErrorHandler } from '@rudderstack/analytics-js-common/types/ErrorHandler'; import type { IdentifyTraits } from '@rudderstack/analytics-js-common/types/traits'; +import type { AnonymousIdOptions } from '@rudderstack/analytics-js-common/types/LoadOptions'; import { checks } from '../shared-chunks/common'; import { eventMethodOverloads, destinations } from '../shared-chunks/deviceModeDestinations'; import type { DeviceModeDestinationsAnalyticsInstance } from './types'; @@ -55,83 +56,85 @@ const createDestinationInstance = ( sdkTypeName: string, dest: Destination, state: ApplicationState, -) => { +): DeviceModeDestination => { const rAnalytics = (globalThis as any).rudderanalytics as IRudderAnalytics; const analytics = rAnalytics.getAnalyticsInstance(state.lifecycle.writeKey.value); - return new (globalThis as any)[destSDKIdentifier][sdkTypeName]( - clone(dest.config), - { - loadIntegration: state.nativeDestinations.loadIntegration.value, - logLevel: state.lifecycle.logLevel.value, - loadOnlyIntegrations: - state.consents.postConsent.value?.integrations ?? - state.nativeDestinations.loadOnlyIntegrations.value, - page: ( - category?: string | Nullable | ApiCallback, - name?: string | Nullable | Nullable | ApiCallback, - properties?: Nullable | Nullable | ApiCallback, - options?: Nullable | ApiCallback, - callback?: ApiCallback, - ) => - analytics.page( - eventMethodOverloads.pageArgumentsToCallOptions( - category, - name, - properties, - options, - callback, - ), - ), - track: ( - event: string, - properties?: Nullable | ApiCallback, - options?: Nullable | ApiCallback, - callback?: ApiCallback, - ) => - analytics.track( - eventMethodOverloads.trackArgumentsToCallOptions(event, properties, options, callback), - ), - identify: ( - userId?: string | number | Nullable, - traits?: Nullable | Nullable | ApiCallback, - options?: Nullable | ApiCallback, - callback?: ApiCallback, - ) => - analytics.identify( - eventMethodOverloads.identifyArgumentsToCallOptions(userId, traits, options, callback), - ), - alias: ( - to?: Nullable | ApiCallback, - from?: string | Nullable | ApiCallback, - options?: Nullable | ApiCallback, - callback?: ApiCallback, - ) => - analytics.alias( - eventMethodOverloads.aliasArgumentsToCallOptions(to, from, options, callback), - ), - group: ( - groupId: string | number | Nullable | ApiCallback, - traits?: Nullable | Nullable | ApiCallback, - options?: Nullable | ApiCallback, - callback?: ApiCallback, - ) => - analytics.group( - eventMethodOverloads.groupArgumentsToCallOptions(groupId, traits, options, callback), + const analyticsInstance: DeviceModeDestinationsAnalyticsInstance = { + loadIntegration: state.nativeDestinations.loadIntegration.value, + logLevel: state.lifecycle.logLevel.value, + loadOnlyIntegrations: + state.consents.postConsent.value?.integrations ?? + state.nativeDestinations.loadOnlyIntegrations.value, + page: ( + category?: string | Nullable | ApiCallback, + name?: string | Nullable | Nullable | ApiCallback, + properties?: Nullable | Nullable | ApiCallback, + options?: Nullable | ApiCallback, + callback?: ApiCallback, + ) => + analytics.page( + eventMethodOverloads.pageArgumentsToCallOptions( + category, + name, + properties, + options, + callback, ), - getAnonymousId: () => analytics.getAnonymousId(), - getUserId: () => analytics.getUserId(), - getUserTraits: () => analytics.getUserTraits(), - getGroupId: () => analytics.getGroupId(), - getGroupTraits: () => analytics.getGroupTraits(), - getSessionId: () => analytics.getSessionId(), - } as DeviceModeDestinationsAnalyticsInstance, - { - shouldApplyDeviceModeTransformation: dest.shouldApplyDeviceModeTransformation, - propagateEventsUntransformedOnError: dest.propagateEventsUntransformedOnError, - destinationId: dest.id, - }, - ); + ), + track: ( + event: string, + properties?: Nullable | ApiCallback, + options?: Nullable | ApiCallback, + callback?: ApiCallback, + ) => + analytics.track( + eventMethodOverloads.trackArgumentsToCallOptions(event, properties, options, callback), + ), + identify: ( + userId: string | number | Nullable, + traits?: Nullable | Nullable | ApiCallback, + options?: Nullable | ApiCallback, + callback?: ApiCallback, + ) => + analytics.identify( + eventMethodOverloads.identifyArgumentsToCallOptions(userId, traits, options, callback), + ), + alias: ( + to: string, + from?: string | Nullable | ApiCallback, + options?: Nullable | ApiCallback, + callback?: ApiCallback, + ) => + analytics.alias( + eventMethodOverloads.aliasArgumentsToCallOptions(to, from, options, callback), + ), + group: ( + groupId: string | number | Nullable, + traits?: Nullable | Nullable | ApiCallback, + options?: Nullable | ApiCallback, + callback?: ApiCallback, + ) => + analytics.group( + eventMethodOverloads.groupArgumentsToCallOptions(groupId, traits, options, callback), + ), + getAnonymousId: (options?: AnonymousIdOptions) => analytics.getAnonymousId(options), + getUserId: () => analytics.getUserId(), + getUserTraits: () => analytics.getUserTraits(), + getGroupId: () => analytics.getGroupId(), + getGroupTraits: () => analytics.getGroupTraits(), + getSessionId: () => analytics.getSessionId(), + }; + + const deviceModeDestination: DeviceModeDestination = new (globalThis as any)[destSDKIdentifier][ + sdkTypeName + ](clone(dest.config), analyticsInstance, { + shouldApplyDeviceModeTransformation: dest.shouldApplyDeviceModeTransformation, + propagateEventsUntransformedOnError: dest.propagateEventsUntransformedOnError, + destinationId: dest.id, + }); + + return deviceModeDestination; }; const isDestinationReady = (dest: Destination) => From 3c76329d996df1667d329ad2bc81ced0fa3191b5 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Thu, 11 Jul 2024 12:20:03 +0530 Subject: [PATCH 06/24] fix: api overloads types --- packages/analytics-js-common/src/types/EventApi.ts | 2 +- .../src/utilities/eventMethodOverloads.ts | 10 +++++----- .../components/eventManager/RudderEventFactory.ts | 12 ++++-------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/analytics-js-common/src/types/EventApi.ts b/packages/analytics-js-common/src/types/EventApi.ts index 7373864a8c..068bebf680 100644 --- a/packages/analytics-js-common/src/types/EventApi.ts +++ b/packages/analytics-js-common/src/types/EventApi.ts @@ -36,7 +36,7 @@ export type APIEvent = { callback?: () => void; userId?: Nullable; traits?: Nullable; - to?: Nullable; + to?: string; from?: string; groupId?: Nullable; }; diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index 4a54cd716b..a450b430b5 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -23,15 +23,15 @@ export type TrackCallOptions = { }; export type IdentifyCallOptions = { - userId?: string | null; + userId?: Nullable; traits?: Nullable; options?: Nullable; callback?: ApiCallback; }; export type AliasCallOptions = { - to?: Nullable; - from?: Nullable; + to?: string; + from?: string; options?: Nullable; callback?: ApiCallback; }; @@ -316,13 +316,13 @@ const aliasArgumentsToCallOptions = ( // and set some proper defaults // Also, to clone the incoming object type arguments if (isDefined(payload.to)) { - payload.to = tryStringify(payload.to); + payload.to = tryStringify(payload.to) as typeof payload.to; } else { delete payload.to; } if (isDefined(payload.from)) { - payload.from = tryStringify(payload.from); + payload.from = tryStringify(payload.from) as typeof payload.from; } else { delete payload.from; } diff --git a/packages/analytics-js/src/components/eventManager/RudderEventFactory.ts b/packages/analytics-js/src/components/eventManager/RudderEventFactory.ts index 2eaad0c5a4..48843568f5 100644 --- a/packages/analytics-js/src/components/eventManager/RudderEventFactory.ts +++ b/packages/analytics-js/src/components/eventManager/RudderEventFactory.ts @@ -20,8 +20,8 @@ class RudderEventFactory { * @param options API options */ generatePageEvent( - category?: Nullable, - name?: Nullable, + category?: string, + name?: string, properties?: Nullable, options?: Nullable, ): RudderEvent { @@ -86,11 +86,7 @@ class RudderEventFactory { * @param from Old user ID * @param options API options */ - generateAliasEvent( - to: Nullable, - from?: string, - options?: Nullable, - ): RudderEvent { + generateAliasEvent(to: string, from?: string, options?: Nullable): RudderEvent { const aliasEvent: Partial = { previousId: from, type: 'alias', @@ -151,7 +147,7 @@ class RudderEventFactory { eventObj = this.generateIdentifyEvent(event.userId, event.traits, event.options); break; case 'alias': - eventObj = this.generateAliasEvent(event.to as Nullable, event.from, event.options); + eventObj = this.generateAliasEvent(event.to as string, event.from, event.options); break; case 'group': eventObj = this.generateGroupEvent(event.groupId, event.traits, event.options); From 9ba3c445419e79eff87cac63d46f4faa1198e1e4 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Thu, 11 Jul 2024 12:48:40 +0530 Subject: [PATCH 07/24] chore: remove circular dependencies check temporarily to avoid vulnerabilities --- ...ty-code-quality-and-bundle-size-checks.yml | 1 - package-lock.json | 875 +----------------- package.json | 1 - 3 files changed, 13 insertions(+), 864 deletions(-) diff --git a/.github/workflows/security-code-quality-and-bundle-size-checks.yml b/.github/workflows/security-code-quality-and-bundle-size-checks.yml index a87d4dd2e6..29ffbeadee 100644 --- a/.github/workflows/security-code-quality-and-bundle-size-checks.yml +++ b/.github/workflows/security-code-quality-and-bundle-size-checks.yml @@ -56,7 +56,6 @@ jobs: - name: Execute code quality checks run: | - npm run check:circular npm run check:duplicates - name: Execute package linting checks diff --git a/package-lock.json b/package-lock.json index 5146f405ae..0028c8348e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -114,7 +114,6 @@ "join-component": "1.1.0", "jscpd": "4.0.4", "lint-staged": "15.2.7", - "madge": "7.0.0", "msw": "2.3.1", "nx": "19.3.0", "patch-package": "8.0.0", @@ -2491,19 +2490,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "node_modules/@dependents/detective-less": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@dependents/detective-less/-/detective-less-4.1.0.tgz", - "integrity": "sha512-KrkT6qO5NxqNfy68sBl6CTSoJ4SNDIS5iQArkibhlbGU4LaDukZ3q2HIkh8aUKDio6o4itU4xDR7t82Y2eP1Bg==", - "dev": true, - "dependencies": { - "gonzales-pe": "^4.3.0", - "node-source-walk": "^6.0.1" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/@digitalroute/cz-conventional-changelog-for-jira": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/@digitalroute/cz-conventional-changelog-for-jira/-/cz-conventional-changelog-for-jira-8.0.1.tgz", @@ -7205,12 +7191,6 @@ "node": ">=4" } }, - "node_modules/any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", - "dev": true - }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -7224,12 +7204,6 @@ "node": ">= 8" } }, - "node_modules/app-module-path": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/app-module-path/-/app-module-path-2.2.0.tgz", - "integrity": "sha512-gkco+qxENJV+8vFcDiiFhuoSvRXb2a/QPqpSoWhVz829VNJfOTnELbBmPmNKFxf3xdNnw4DWCkzkDaavcX/1YQ==", - "dev": true - }, "node_modules/aproba": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", @@ -7508,15 +7482,6 @@ "@mdn/browser-compat-data": "^5.2.34" } }, - "node_modules/ast-module-types": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ast-module-types/-/ast-module-types-5.0.0.tgz", - "integrity": "sha512-JvqziE0Wc0rXQfma0HZC/aY7URXHFuZV84fJRtP8u+lhp0JYCNd5wJzVXP45t0PH0Mej3ynlzvdyITYIu0G4LQ==", - "dev": true, - "engines": { - "node": ">=14" - } - }, "node_modules/ast-types-flow": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz", @@ -10146,33 +10111,6 @@ "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", "dev": true }, - "node_modules/dependency-tree": { - "version": "10.0.9", - "resolved": "https://registry.npmjs.org/dependency-tree/-/dependency-tree-10.0.9.tgz", - "integrity": "sha512-dwc59FRIsht+HfnTVM0BCjJaEWxdq2YAvEDy4/Hn6CwS3CBWMtFnL3aZGAkQn3XCYxk/YcTDE4jX2Q7bFTwCjA==", - "dev": true, - "dependencies": { - "commander": "^10.0.1", - "filing-cabinet": "^4.1.6", - "precinct": "^11.0.5", - "typescript": "^5.0.4" - }, - "bin": { - "dependency-tree": "bin/cli.js" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/dependency-tree/node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "dev": true, - "engines": { - "node": ">=14" - } - }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -10227,194 +10165,6 @@ "node": ">= 4.0.0" } }, - "node_modules/detective-amd": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/detective-amd/-/detective-amd-5.0.2.tgz", - "integrity": "sha512-XFd/VEQ76HSpym80zxM68ieB77unNuoMwopU2TFT/ErUk5n4KvUTwW4beafAVUugrjV48l4BmmR0rh2MglBaiA==", - "dev": true, - "dependencies": { - "ast-module-types": "^5.0.0", - "escodegen": "^2.0.0", - "get-amd-module-type": "^5.0.1", - "node-source-walk": "^6.0.1" - }, - "bin": { - "detective-amd": "bin/cli.js" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/detective-cjs": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/detective-cjs/-/detective-cjs-5.0.1.tgz", - "integrity": "sha512-6nTvAZtpomyz/2pmEmGX1sXNjaqgMplhQkskq2MLrar0ZAIkHMrDhLXkRiK2mvbu9wSWr0V5/IfiTrZqAQMrmQ==", - "dev": true, - "dependencies": { - "ast-module-types": "^5.0.0", - "node-source-walk": "^6.0.0" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/detective-es6": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/detective-es6/-/detective-es6-4.0.1.tgz", - "integrity": "sha512-k3Z5tB4LQ8UVHkuMrFOlvb3GgFWdJ9NqAa2YLUU/jTaWJIm+JJnEh4PsMc+6dfT223Y8ACKOaC0qcj7diIhBKw==", - "dev": true, - "dependencies": { - "node-source-walk": "^6.0.1" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/detective-postcss": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/detective-postcss/-/detective-postcss-6.1.3.tgz", - "integrity": "sha512-7BRVvE5pPEvk2ukUWNQ+H2XOq43xENWbH0LcdCE14mwgTBEAMoAx+Fc1rdp76SmyZ4Sp48HlV7VedUnP6GA1Tw==", - "dev": true, - "dependencies": { - "is-url": "^1.2.4", - "postcss": "^8.4.23", - "postcss-values-parser": "^6.0.2" - }, - "engines": { - "node": "^12.0.0 || ^14.0.0 || >=16.0.0" - } - }, - "node_modules/detective-sass": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/detective-sass/-/detective-sass-5.0.3.tgz", - "integrity": "sha512-YsYT2WuA8YIafp2RVF5CEfGhhyIVdPzlwQgxSjK+TUm3JoHP+Tcorbk3SfG0cNZ7D7+cYWa0ZBcvOaR0O8+LlA==", - "dev": true, - "dependencies": { - "gonzales-pe": "^4.3.0", - "node-source-walk": "^6.0.1" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/detective-scss": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/detective-scss/-/detective-scss-4.0.3.tgz", - "integrity": "sha512-VYI6cHcD0fLokwqqPFFtDQhhSnlFWvU614J42eY6G0s8c+MBhi9QAWycLwIOGxlmD8I/XvGSOUV1kIDhJ70ZPg==", - "dev": true, - "dependencies": { - "gonzales-pe": "^4.3.0", - "node-source-walk": "^6.0.1" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/detective-stylus": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/detective-stylus/-/detective-stylus-4.0.0.tgz", - "integrity": "sha512-TfPotjhszKLgFBzBhTOxNHDsutIxx9GTWjrL5Wh7Qx/ydxKhwUrlSFeLIn+ZaHPF+h0siVBkAQSuy6CADyTxgQ==", - "dev": true, - "engines": { - "node": ">=14" - } - }, - "node_modules/detective-typescript": { - "version": "11.2.0", - "resolved": "https://registry.npmjs.org/detective-typescript/-/detective-typescript-11.2.0.tgz", - "integrity": "sha512-ARFxjzizOhPqs1fYC/2NMC3N4jrQ6HvVflnXBTRqNEqJuXwyKLRr9CrJwkRcV/SnZt1sNXgsF6FPm0x57Tq0rw==", - "dev": true, - "dependencies": { - "@typescript-eslint/typescript-estree": "^5.62.0", - "ast-module-types": "^5.0.0", - "node-source-walk": "^6.0.2", - "typescript": "^5.4.4" - }, - "engines": { - "node": "^14.14.0 || >=16.0.0" - } - }, - "node_modules/detective-typescript/node_modules/@typescript-eslint/types": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", - "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/detective-typescript/node_modules/@typescript-eslint/typescript-estree": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", - "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/visitor-keys": "5.62.0", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "semver": "^7.3.7", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/detective-typescript/node_modules/@typescript-eslint/visitor-keys": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", - "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.62.0", - "eslint-visitor-keys": "^3.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/detective-typescript/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/detective-typescript/node_modules/semver": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", - "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -12327,41 +12077,6 @@ "node": ">= 0.4.0" } }, - "node_modules/filing-cabinet": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/filing-cabinet/-/filing-cabinet-4.2.0.tgz", - "integrity": "sha512-YZ21ryzRcyqxpyKggdYSoXx//d3sCJzM3lsYoaeg/FyXdADGJrUl+BW1KIglaVLJN5BBcMtWylkygY8zBp2MrQ==", - "dev": true, - "dependencies": { - "app-module-path": "^2.2.0", - "commander": "^10.0.1", - "enhanced-resolve": "^5.14.1", - "is-relative-path": "^1.0.2", - "module-definition": "^5.0.1", - "module-lookup-amd": "^8.0.5", - "resolve": "^1.22.3", - "resolve-dependency-path": "^3.0.2", - "sass-lookup": "^5.0.1", - "stylus-lookup": "^5.0.1", - "tsconfig-paths": "^4.2.0", - "typescript": "^5.0.4" - }, - "bin": { - "filing-cabinet": "bin/cli.js" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/filing-cabinet/node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "dev": true, - "engines": { - "node": ">=14" - } - }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -12684,19 +12399,6 @@ "node": ">=6.9.0" } }, - "node_modules/get-amd-module-type": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/get-amd-module-type/-/get-amd-module-type-5.0.1.tgz", - "integrity": "sha512-jb65zDeHyDjFR1loOVk0HQGM5WNwoGB8aLWy3LKCieMKol0/ProHkhO2X1JxojuN10vbz1qNn09MJ7tNp7qMzw==", - "dev": true, - "dependencies": { - "ast-module-types": "^5.0.0", - "node-source-walk": "^6.0.1" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -12736,12 +12438,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/get-own-enumerable-property-symbols": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", - "integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==", - "dev": true - }, "node_modules/get-package-type": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", @@ -13054,21 +12750,6 @@ "node": ">= 6" } }, - "node_modules/gonzales-pe": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/gonzales-pe/-/gonzales-pe-4.3.0.tgz", - "integrity": "sha512-otgSPpUmdWJ43VXyiNgEYE4luzHCL2pz4wQ0OnDluC6Eg4Ko3Vexy/SrSynglw/eR+OhkzmqFCZa/OFa/RgAOQ==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, - "bin": { - "gonzales": "bin/gonzales.js" - }, - "engines": { - "node": ">=0.6.0" - } - }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -14264,21 +13945,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-regexp": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", - "integrity": "sha512-7zjFAPO4/gwyQAAgRRmqeEeyIICSdmCqa3tsVHMdBzaXXRiqopZL4Cyghg/XulGWrtABTpbnYYzzIRffLkP4oA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-relative-path": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-relative-path/-/is-relative-path-1.0.2.tgz", - "integrity": "sha512-i1h+y50g+0hRbBD+dbnInl3JlJ702aar58snAeX+MxBAPvzXGej7sYoPMhlnykabt0ZzCJNBEyzMlekuQZN7fA==", - "dev": true - }, "node_modules/is-retry-allowed": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-2.2.0.tgz", @@ -14398,24 +14064,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-url": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz", - "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==", - "dev": true - }, - "node_modules/is-url-superb": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-url-superb/-/is-url-superb-4.0.0.tgz", - "integrity": "sha512-GI+WjezhPPcbM+tqE9LnmsY5qqjwHzTvjJ36wxYX5ujNXefSUJ/T17r5bqDV8yLhcgB59KTPNOc9O9cmHTPWsA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", @@ -17756,172 +17404,31 @@ "yallist": "^3.0.2" } }, - "node_modules/madge": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/madge/-/madge-7.0.0.tgz", - "integrity": "sha512-x9eHkBWoCJ2B8yGesWf8LRucarkbH5P3lazqgvmxe4xn5U2Meyfu906iG9mBB1RnY/f4D+gtELWdiz1k6+jAZA==", + "node_modules/magic-string": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.27.0.tgz", + "integrity": "sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==", "dev": true, "dependencies": { - "chalk": "^4.1.2", - "commander": "^7.2.0", - "commondir": "^1.0.1", - "debug": "^4.3.4", - "dependency-tree": "^10.0.9", - "ora": "^5.4.1", - "pluralize": "^8.0.0", - "precinct": "^11.0.5", - "pretty-ms": "^7.0.1", - "rc": "^1.2.8", - "stream-to-array": "^2.3.0", - "ts-graphviz": "^1.8.1", - "walkdir": "^0.4.1" - }, - "bin": { - "madge": "bin/cli.js" + "@jridgewell/sourcemap-codec": "^1.4.13" }, "engines": { - "node": ">=14" - }, - "funding": { - "type": "individual", - "url": "https://www.paypal.me/pahen" - }, - "peerDependencies": { - "typescript": "^3.9.5 || ^4.9.5 || ^5" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } + "node": ">=12" } }, - "node_modules/madge/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", "dev": true, "dependencies": { - "color-convert": "^2.0.1" + "semver": "^7.5.3" }, "engines": { - "node": ">=8" + "node": ">=10" }, "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/madge/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/madge/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/madge/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/madge/node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "dev": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/madge/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/madge/node_modules/ora": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", - "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", - "dev": true, - "dependencies": { - "bl": "^4.1.0", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-spinners": "^2.5.0", - "is-interactive": "^1.0.0", - "is-unicode-supported": "^0.1.0", - "log-symbols": "^4.1.0", - "strip-ansi": "^6.0.0", - "wcwidth": "^1.0.1" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/madge/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/magic-string": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.27.0.tgz", - "integrity": "sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==", - "dev": true, - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.13" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/make-dir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", - "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", - "dev": true, - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/make-dir/node_modules/semver": { @@ -18534,49 +18041,6 @@ "node": ">=10" } }, - "node_modules/module-definition": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/module-definition/-/module-definition-5.0.1.tgz", - "integrity": "sha512-kvw3B4G19IXk+BOXnYq/D/VeO9qfHaapMeuS7w7sNUqmGaA6hywdFHMi+VWeR9wUScXM7XjoryTffCZ5B0/8IA==", - "dev": true, - "dependencies": { - "ast-module-types": "^5.0.0", - "node-source-walk": "^6.0.1" - }, - "bin": { - "module-definition": "bin/cli.js" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/module-lookup-amd": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/module-lookup-amd/-/module-lookup-amd-8.0.5.tgz", - "integrity": "sha512-vc3rYLjDo5Frjox8NZpiyLXsNWJ5BWshztc/5KSOMzpg9k5cHH652YsJ7VKKmtM4SvaxuE9RkrYGhiSjH3Ehow==", - "dev": true, - "dependencies": { - "commander": "^10.0.1", - "glob": "^7.2.3", - "requirejs": "^2.3.6", - "requirejs-config-file": "^4.0.0" - }, - "bin": { - "lookup-amd": "bin/cli.js" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/module-lookup-amd/node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "dev": true, - "engines": { - "node": ">=14" - } - }, "node_modules/mri": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", @@ -18894,18 +18358,6 @@ "node": ">=12" } }, - "node_modules/node-source-walk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/node-source-walk/-/node-source-walk-6.0.2.tgz", - "integrity": "sha512-jn9vOIK/nfqoFCcpK89/VCVaLg1IHE6UVfDOzvqmANaJ/rWCTEdH8RZ1V278nv2jr36BJdyQXIAavBLXpzdlag==", - "dev": true, - "dependencies": { - "@babel/parser": "^7.21.8" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/nopt": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz", @@ -19961,15 +19413,6 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", "dev": true }, - "node_modules/parse-ms": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz", - "integrity": "sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", @@ -20377,110 +19820,6 @@ "node": ">= 0.4" } }, - "node_modules/postcss": { - "version": "8.4.38", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", - "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "nanoid": "^3.3.7", - "picocolors": "^1.0.0", - "source-map-js": "^1.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/postcss-values-parser": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/postcss-values-parser/-/postcss-values-parser-6.0.2.tgz", - "integrity": "sha512-YLJpK0N1brcNJrs9WatuJFtHaV9q5aAOj+S4DI5S7jgHlRfm0PIbDCAFRYMQD5SHq7Fy6xsDhyutgS0QOAs0qw==", - "dev": true, - "dependencies": { - "color-name": "^1.1.4", - "is-url-superb": "^4.0.0", - "quote-unquote": "^1.0.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "postcss": "^8.2.9" - } - }, - "node_modules/postcss-values-parser/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/postcss/node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/precinct": { - "version": "11.0.5", - "resolved": "https://registry.npmjs.org/precinct/-/precinct-11.0.5.tgz", - "integrity": "sha512-oHSWLC8cL/0znFhvln26D14KfCQFFn4KOLSw6hmLhd+LQ2SKt9Ljm89but76Pc7flM9Ty1TnXyrA2u16MfRV3w==", - "dev": true, - "dependencies": { - "@dependents/detective-less": "^4.1.0", - "commander": "^10.0.1", - "detective-amd": "^5.0.2", - "detective-cjs": "^5.0.1", - "detective-es6": "^4.0.1", - "detective-postcss": "^6.1.3", - "detective-sass": "^5.0.3", - "detective-scss": "^4.0.3", - "detective-stylus": "^4.0.0", - "detective-typescript": "^11.1.0", - "module-definition": "^5.0.1", - "node-source-walk": "^6.0.2" - }, - "bin": { - "precinct": "bin/cli.js" - }, - "engines": { - "node": "^14.14.0 || >=16.0.0" - } - }, - "node_modules/precinct/node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "dev": true, - "engines": { - "node": ">=14" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -20531,21 +19870,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/pretty-ms": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz", - "integrity": "sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q==", - "dev": true, - "dependencies": { - "parse-ms": "^2.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/proc-log": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-3.0.0.tgz", @@ -20926,12 +20250,6 @@ } ] }, - "node_modules/quote-unquote": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/quote-unquote/-/quote-unquote-1.0.0.tgz", - "integrity": "sha512-twwRO/ilhlG/FIgYeKGFqyHhoEhqgnKVkcmqMKi2r524gz3ZbDTcyFt38E9xjJI2vT+KbRNHVbnJ/e0I25Azwg==", - "dev": true - }, "node_modules/ramda": { "version": "0.30.1", "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.30.1.tgz", @@ -21539,32 +20857,6 @@ "node": ">=0.10.0" } }, - "node_modules/requirejs": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", - "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", - "dev": true, - "bin": { - "r_js": "bin/r.js", - "r.js": "bin/r.js" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/requirejs-config-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/requirejs-config-file/-/requirejs-config-file-4.0.0.tgz", - "integrity": "sha512-jnIre8cbWOyvr8a5F2KuqBnY+SDA4NXr/hzEZJG79Mxm2WiFQz2dzhC8ibtPJS7zkmBEl1mxSwp5HhC1W4qpxw==", - "dev": true, - "dependencies": { - "esprima": "^4.0.0", - "stringify-object": "^3.2.1" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", @@ -21600,15 +20892,6 @@ "node": ">=8" } }, - "node_modules/resolve-dependency-path": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/resolve-dependency-path/-/resolve-dependency-path-3.0.2.tgz", - "integrity": "sha512-Tz7zfjhLfsvR39ADOSk9us4421J/1ztVBo4rWUkF38hgHK5m0OCZ3NxFVpqHRkjctnwVa15igEUHFJp8MCS7vA==", - "dev": true, - "engines": { - "node": ">=14" - } - }, "node_modules/resolve-dir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", @@ -22257,30 +21540,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "node_modules/sass-lookup": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/sass-lookup/-/sass-lookup-5.0.1.tgz", - "integrity": "sha512-t0X5PaizPc2H4+rCwszAqHZRtr4bugo4pgiCvrBFvIX0XFxnr29g77LJcpyj9A0DcKf7gXMLcgvRjsonYI6x4g==", - "dev": true, - "dependencies": { - "commander": "^10.0.1" - }, - "bin": { - "sass-lookup": "bin/cli.js" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/sass-lookup/node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "dev": true, - "engines": { - "node": ">=14" - } - }, "node_modules/saxes": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", @@ -22996,15 +22255,6 @@ "node": ">=0.10.0" } }, - "node_modules/source-map-js": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", - "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", @@ -23142,15 +22392,6 @@ "url": "https://jaywcjlove.github.io/#/sponsor" } }, - "node_modules/stream-to-array": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/stream-to-array/-/stream-to-array-2.3.0.tgz", - "integrity": "sha512-UsZtOYEn4tWU2RGLOXr/o/xjRBftZRlG3dEWoaHr8j4GuypJ3isitGbVyjQKAuMu+xbiop8q224TjiZWc4XTZA==", - "dev": true, - "dependencies": { - "any-promise": "^1.1.0" - } - }, "node_modules/strict-event-emitter": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", @@ -23343,29 +22584,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/stringify-object": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", - "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", - "dev": true, - "dependencies": { - "get-own-enumerable-property-symbols": "^3.0.0", - "is-obj": "^1.0.1", - "is-regexp": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/stringify-object/node_modules/is-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha512-l4RyHgRqGN4Y3+9JHVrNqO+tN0rV5My76uW5/nuO4K1b6vw5G8d/cmFjP9tRfEsdhZNt0IFdZuK/c2Vr4Nb+Qg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -23453,30 +22671,6 @@ "node": ">=4" } }, - "node_modules/stylus-lookup": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/stylus-lookup/-/stylus-lookup-5.0.1.tgz", - "integrity": "sha512-tLtJEd5AGvnVy4f9UHQMw4bkJJtaAcmo54N+ovQBjDY3DuWyK9Eltxzr5+KG0q4ew6v2EHyuWWNnHeiw/Eo7rQ==", - "dev": true, - "dependencies": { - "commander": "^10.0.1" - }, - "bin": { - "stylus-lookup": "bin/cli.js" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/stylus-lookup/node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "dev": true, - "engines": { - "node": ">=14" - } - }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -23861,19 +23055,6 @@ "typescript": ">=4.2.0" } }, - "node_modules/ts-graphviz": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/ts-graphviz/-/ts-graphviz-1.8.2.tgz", - "integrity": "sha512-5YhbFoHmjxa7pgQLkB07MtGnGJ/yhvjmc9uhsnDBEICME6gkPf83SBwLDQqGDoCa3XzUMWLk1AU2Wn1u1naDtA==", - "dev": true, - "engines": { - "node": ">=14.16" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/ts-graphviz" - } - }, "node_modules/ts-jest": { "version": "29.1.5", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.5.tgz", @@ -24017,27 +23198,6 @@ "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", "dev": true }, - "node_modules/tsutils": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", - "dev": true, - "dependencies": { - "tslib": "^1.8.1" - }, - "engines": { - "node": ">= 6" - }, - "peerDependencies": { - "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" - } - }, - "node_modules/tsutils/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, "node_modules/tuf-js": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/tuf-js/-/tuf-js-1.1.7.tgz", @@ -24548,15 +23708,6 @@ "node": ">=14" } }, - "node_modules/walkdir": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/walkdir/-/walkdir-0.4.1.tgz", - "integrity": "sha512-3eBwRyEln6E1MSzcxcVpQIhRG8Q1jLvEqRmCZqS3dsfXEDR/AhOF4d+jHg1qvDCpYaVRZjENPQyrVxAkQqxPgQ==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", diff --git a/package.json b/package.json index 3f011e29f6..44906c06df 100644 --- a/package.json +++ b/package.json @@ -163,7 +163,6 @@ "join-component": "1.1.0", "jscpd": "4.0.4", "lint-staged": "15.2.7", - "madge": "7.0.0", "msw": "2.3.1", "nx": "19.3.0", "patch-package": "8.0.0", From 2e864dd4863dc0b9ac413d566f5ae743ad4fbaa4 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Thu, 11 Jul 2024 14:04:42 +0530 Subject: [PATCH 08/24] fix: avoid delete operator --- .../utilities/eventMethodOverloads.test.ts | 88 ++++++++++++++++++ .../src/utilities/eventMethodOverloads.ts | 93 ++++++++++--------- .../components/core/Analytics.test.ts | 21 ++++- 3 files changed, 156 insertions(+), 46 deletions(-) diff --git a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts index 84b6dde18a..855f39422a 100644 --- a/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts +++ b/packages/analytics-js-common/__tests__/utilities/eventMethodOverloads.test.ts @@ -26,16 +26,21 @@ describe('Core - Event Method Overloads', () => { name: 'name', properties: { props: {}, category: 'category', name: 'name' }, options: { options: {} }, + callback: undefined, }); expect(pageArgumentsToCallOptions('category', 'name', { props: {} })).toStrictEqual({ category: 'category', name: 'name', + options: undefined, properties: { props: {}, category: 'category', name: 'name' }, + callback: undefined, }); expect(pageArgumentsToCallOptions('category', 'name')).toStrictEqual({ category: 'category', name: 'name', + options: undefined, properties: { category: 'category', name: 'name' }, + callback: undefined, }); expect( @@ -45,11 +50,14 @@ describe('Core - Event Method Overloads', () => { category: 'category', name: 'name', properties: { props: {}, category: 'category', name: 'name' }, + options: undefined, }); expect(pageArgumentsToCallOptions('category', 'name', { props: {} })).toStrictEqual({ category: 'category', name: 'name', properties: { props: {}, category: 'category', name: 'name' }, + options: undefined, + callback: undefined, }); expect( @@ -61,6 +69,7 @@ describe('Core - Event Method Overloads', () => { options: {}, }, properties: { name: 'name', props: {} }, + category: undefined, }); expect(pageArgumentsToCallOptions('name', { props: {} }, { options: {} })).toStrictEqual({ name: 'name', @@ -68,52 +77,83 @@ describe('Core - Event Method Overloads', () => { options: {}, }, properties: { name: 'name', props: {} }, + category: undefined, + callback: undefined, }); expect(pageArgumentsToCallOptions('name', { props: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, name: 'name', properties: { name: 'name', props: {} }, + category: undefined, + options: undefined, }); expect(pageArgumentsToCallOptions('name', { props: {} })).toStrictEqual({ name: 'name', properties: { name: 'name', props: {} }, + category: undefined, + options: undefined, + callback: undefined, }); expect(pageArgumentsToCallOptions('name', callbackMock)).toStrictEqual({ callback: callbackMock, name: 'name', properties: { name: 'name' }, + category: undefined, + options: undefined, }); expect(pageArgumentsToCallOptions('name')).toStrictEqual({ name: 'name', properties: { name: 'name' }, + category: undefined, + options: undefined, + callback: undefined, }); expect(pageArgumentsToCallOptions({ props: {} }, { options: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, properties: { props: {} }, options: { options: {} }, + name: undefined, + category: undefined, }); expect(pageArgumentsToCallOptions({ props: {} }, { options: {} })).toStrictEqual({ properties: { props: {} }, options: { options: {} }, + name: undefined, + category: undefined, + callback: undefined, }); expect(pageArgumentsToCallOptions({ props: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, properties: { props: {} }, + name: undefined, + category: undefined, + options: undefined, }); expect(pageArgumentsToCallOptions({ props: {} })).toStrictEqual({ properties: { props: {} }, + name: undefined, + category: undefined, + options: undefined, + callback: undefined, }); expect(pageArgumentsToCallOptions(callbackMock)).toStrictEqual({ callback: callbackMock, properties: {}, + name: undefined, + category: undefined, + options: undefined, }); expect(pageArgumentsToCallOptions()).toStrictEqual({ properties: {}, + name: undefined, + category: undefined, + options: undefined, + callback: undefined, }); }); @@ -130,36 +170,46 @@ describe('Core - Event Method Overloads', () => { name: 'event', properties: { props: {} }, options: { options: {} }, + callback: undefined, }); expect(trackArgumentsToCallOptions('event', { props: {} })).toStrictEqual({ name: 'event', properties: { props: {} }, + options: undefined, + callback: undefined, }); expect(trackArgumentsToCallOptions('event')).toStrictEqual({ name: 'event', properties: {}, + options: undefined, + callback: undefined, }); expect(trackArgumentsToCallOptions('event', { props: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, name: 'event', properties: { props: {} }, + options: undefined, }); expect(trackArgumentsToCallOptions('event', { props: {} })).toStrictEqual({ name: 'event', properties: { props: {} }, + options: undefined, + callback: undefined, }); expect(trackArgumentsToCallOptions('event', callbackMock)).toStrictEqual({ callback: callbackMock, name: 'event', properties: {}, + options: undefined, }); expect(trackArgumentsToCallOptions('event', { properties: {} }, { options: {} })).toStrictEqual( { properties: { properties: {} }, options: { options: {} }, name: 'event', + callback: undefined, }, ); }); @@ -177,24 +227,33 @@ describe('Core - Event Method Overloads', () => { userId: '1234', traits: { traits: {} }, options: { options: {} }, + callback: undefined, }); expect(identifyArgumentsToCallOptions('userId', { traits: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, userId: 'userId', traits: { traits: {} }, + options: undefined, }); expect(identifyArgumentsToCallOptions('userId', { traits: {} })).toStrictEqual({ userId: 'userId', traits: { traits: {} }, + options: undefined, + callback: undefined, }); expect(identifyArgumentsToCallOptions('userId', callbackMock)).toStrictEqual({ callback: callbackMock, userId: 'userId', + traits: undefined, + options: undefined, }); expect(identifyArgumentsToCallOptions('userId')).toStrictEqual({ userId: 'userId', + traits: undefined, + options: undefined, + callback: undefined, }); expect( @@ -209,16 +268,20 @@ describe('Core - Event Method Overloads', () => { userId: null, traits: { traits: {} }, options: { options: {} }, + callback: undefined, }); expect(identifyArgumentsToCallOptions({ traits: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, userId: null, traits: { traits: {} }, + options: undefined, }); expect(identifyArgumentsToCallOptions({ traits: {} })).toStrictEqual({ userId: null, traits: { traits: {} }, + options: undefined, + callback: undefined, }); }); @@ -233,34 +296,46 @@ describe('Core - Event Method Overloads', () => { to: 'to', from: 'from', options: { options: {} }, + callback: undefined, }); expect(aliasArgumentsToCallOptions('to', 'from', callbackMock)).toStrictEqual({ callback: callbackMock, to: 'to', from: 'from', + options: undefined, }); expect(aliasArgumentsToCallOptions('to', 'from')).toStrictEqual({ to: 'to', from: 'from', + options: undefined, + callback: undefined, }); expect(aliasArgumentsToCallOptions('to', { options: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, to: 'to', options: { options: {} }, + from: undefined, }); expect(aliasArgumentsToCallOptions('to', { options: {} })).toStrictEqual({ to: 'to', options: { options: {} }, + from: undefined, + callback: undefined, }); expect(aliasArgumentsToCallOptions('to', callbackMock)).toStrictEqual({ callback: callbackMock, to: 'to', + from: undefined, + options: undefined, }); expect(aliasArgumentsToCallOptions('to')).toStrictEqual({ to: 'to', + from: undefined, + options: undefined, + callback: undefined, }); }); @@ -277,24 +352,33 @@ describe('Core - Event Method Overloads', () => { groupId: '1234', traits: { traits: {} }, options: { options: {} }, + callback: undefined, }); expect(groupArgumentsToCallOptions('groupId', { traits: {} }, callbackMock)).toStrictEqual({ callback: callbackMock, groupId: 'groupId', traits: { traits: {} }, + options: undefined, }); expect(groupArgumentsToCallOptions('groupId', { traits: {} })).toStrictEqual({ groupId: 'groupId', traits: { traits: {} }, + options: undefined, + callback: undefined, }); expect(groupArgumentsToCallOptions('groupId', callbackMock)).toStrictEqual({ callback: callbackMock, groupId: 'groupId', + traits: undefined, + options: undefined, }); expect(groupArgumentsToCallOptions('groupId')).toStrictEqual({ groupId: 'groupId', + traits: undefined, + options: undefined, + callback: undefined, }); expect( @@ -309,16 +393,20 @@ describe('Core - Event Method Overloads', () => { groupId: null, traits: { traits: {} }, options: { options: {} }, + callback: undefined, }); expect(groupArgumentsToCallOptions({ traits: {} }, callbackMock)).toStrictEqual({ groupId: null, callback: callbackMock, traits: { traits: {} }, + options: undefined, }); expect(groupArgumentsToCallOptions({ traits: {} })).toStrictEqual({ groupId: null, traits: { traits: {} }, + options: undefined, + callback: undefined, }); }); }); diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index a450b430b5..c604fe1fd0 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -61,6 +61,7 @@ const pageArgumentsToCallOptions = ( name: name as string, properties: properties as Nullable, options: options as Nullable, + callback: undefined, }; if (isFunction(callback)) { @@ -71,57 +72,57 @@ const pageArgumentsToCallOptions = ( payload.category = category as string; payload.name = name as string; payload.properties = properties as Nullable; - delete payload.options; + payload.options = undefined; payload.callback = options as ApiCallback; } if (isFunction(properties)) { payload.category = category as string; payload.name = name as string; - delete payload.properties; - delete payload.options; + payload.properties = undefined; + payload.options = undefined; payload.callback = properties as ApiCallback; } if (isFunction(name)) { payload.category = category as string; - delete payload.name; - delete payload.properties; - delete payload.options; + payload.name = undefined; + payload.properties = undefined; + payload.options = undefined; payload.callback = name as ApiCallback; } if (isFunction(category)) { - delete payload.category; - delete payload.name; - delete payload.properties; - delete payload.options; + payload.category = undefined; + payload.name = undefined; + payload.properties = undefined; + payload.options = undefined; payload.callback = category as ApiCallback; } if (isObjectLiteralAndNotNull(category)) { - delete payload.name; - delete payload.category; + payload.name = undefined; + payload.category = undefined; payload.properties = category as Nullable; if (!isFunction(name)) { payload.options = name as Nullable; } else { - delete payload.options; + payload.options = undefined; } } else if (isObjectLiteralAndNotNull(name)) { - delete payload.name; + payload.name = undefined; payload.properties = name as Nullable; if (!isFunction(properties)) { payload.options = properties as Nullable; } else { - delete payload.options; + payload.options = undefined; } } // if the category argument alone is provided b/w category and name, // use it as name and set category to undefined if (isString(category) && !isString(name)) { - delete payload.category; + payload.category = undefined; payload.name = category as string; } @@ -129,11 +130,11 @@ const pageArgumentsToCallOptions = ( // and set some proper defaults // Also, to clone the incoming object type arguments if (!isDefined(payload.category)) { - delete payload.category; + payload.category = undefined; } if (!isDefined(payload.name)) { - delete payload.name; + payload.name = undefined; } payload.properties = payload.properties ? clone(payload.properties) : {}; @@ -141,7 +142,7 @@ const pageArgumentsToCallOptions = ( if (isDefined(payload.options)) { payload.options = clone(payload.options); } else { - delete payload.options; + payload.options = undefined; } const nameForProperties = isString(payload.name) ? payload.name : payload.properties.name; @@ -174,6 +175,7 @@ const trackArgumentsToCallOptions = ( name: event, properties: properties as Nullable, options: options as Nullable, + callback: undefined, }; if (isFunction(callback)) { @@ -182,13 +184,13 @@ const trackArgumentsToCallOptions = ( if (isFunction(options)) { payload.properties = properties as Nullable; - delete payload.options; + payload.options = undefined; payload.callback = options as ApiCallback; } if (isFunction(properties)) { - delete payload.properties; - delete payload.options; + payload.properties = undefined; + payload.options = undefined; payload.callback = properties as ApiCallback; } @@ -200,7 +202,7 @@ const trackArgumentsToCallOptions = ( if (isDefined(payload.options)) { payload.options = clone(payload.options); } else { - delete payload.options; + payload.options = undefined; } return payload; @@ -219,6 +221,7 @@ const identifyArgumentsToCallOptions = ( userId: userId as string, traits: traits as Nullable, options: options as Nullable, + callback: undefined, }; if (isFunction(callback)) { @@ -228,14 +231,14 @@ const identifyArgumentsToCallOptions = ( if (isFunction(options)) { payload.userId = userId as string; payload.traits = traits as Nullable; - delete payload.options; + payload.options = undefined; payload.callback = options as ApiCallback; } if (isFunction(traits)) { payload.userId = userId as string; - delete payload.traits; - delete payload.options; + payload.traits = undefined; + payload.options = undefined; payload.callback = traits as ApiCallback; } @@ -247,7 +250,7 @@ const identifyArgumentsToCallOptions = ( if (!isFunction(traits)) { payload.options = traits as Nullable; } else { - delete payload.options; + payload.options = undefined; } } @@ -257,19 +260,19 @@ const identifyArgumentsToCallOptions = ( if (isDefined(payload.userId)) { payload.userId = tryStringify(payload.userId); } else { - delete payload.userId; + payload.userId = undefined; } if (isObjectLiteralAndNotNull(payload.traits)) { payload.traits = clone(payload.traits); } else { - delete payload.traits; + payload.traits = undefined; } if (isDefined(payload.options)) { payload.options = clone(payload.options); } else { - delete payload.options; + payload.options = undefined; } return payload; @@ -288,6 +291,7 @@ const aliasArgumentsToCallOptions = ( to: to as string, from: from as string, options: options as Nullable, + callback: undefined, }; if (isFunction(callback)) { @@ -297,18 +301,18 @@ const aliasArgumentsToCallOptions = ( if (isFunction(options)) { payload.to = to as string; payload.from = from as string; - delete payload.options; + payload.options = undefined; payload.callback = options as ApiCallback; } if (isFunction(from)) { payload.to = to as string; - delete payload.from; - delete payload.options; + payload.from = undefined; + payload.options = undefined; payload.callback = from as ApiCallback; } else if (isObjectLiteralAndNotNull(from) || isNull(from)) { payload.to = to as string; - delete payload.from; + payload.from = undefined; payload.options = from as Nullable; } @@ -318,19 +322,19 @@ const aliasArgumentsToCallOptions = ( if (isDefined(payload.to)) { payload.to = tryStringify(payload.to) as typeof payload.to; } else { - delete payload.to; + payload.to = undefined; } if (isDefined(payload.from)) { payload.from = tryStringify(payload.from) as typeof payload.from; } else { - delete payload.from; + payload.from = undefined; } if (isDefined(payload.options)) { payload.options = clone(payload.options); } else { - delete payload.options; + payload.options = undefined; } return payload; @@ -349,6 +353,7 @@ const groupArgumentsToCallOptions = ( groupId: groupId as string, traits: traits as Nullable, options: options as Nullable, + callback: undefined, }; if (isFunction(callback)) { @@ -358,14 +363,14 @@ const groupArgumentsToCallOptions = ( if (isFunction(options)) { payload.groupId = groupId as string; payload.traits = traits as Nullable; - delete payload.options; + payload.options = undefined; payload.callback = options as ApiCallback; } if (isFunction(traits)) { payload.groupId = groupId as string; - delete payload.traits; - delete payload.options; + payload.traits = undefined; + payload.options = undefined; payload.callback = traits as ApiCallback; } @@ -377,7 +382,7 @@ const groupArgumentsToCallOptions = ( if (!isFunction(traits)) { payload.options = traits as Nullable; } else { - delete payload.options; + payload.options = undefined; } } @@ -387,19 +392,19 @@ const groupArgumentsToCallOptions = ( if (isDefined(payload.groupId)) { payload.groupId = tryStringify(payload.groupId); } else { - delete payload.groupId; + payload.groupId = undefined; } if (isObjectLiteralAndNotNull(payload.traits)) { payload.traits = clone(payload.traits); } else { - delete payload.traits; + payload.traits = undefined; } if (isDefined(payload.options)) { payload.options = clone(payload.options); } else { - delete payload.options; + payload.options = undefined; } return payload; diff --git a/packages/analytics-js/__tests__/components/core/Analytics.test.ts b/packages/analytics-js/__tests__/components/core/Analytics.test.ts index 16bac0ff5d..e85709a4d6 100644 --- a/packages/analytics-js/__tests__/components/core/Analytics.test.ts +++ b/packages/analytics-js/__tests__/components/core/Analytics.test.ts @@ -628,8 +628,25 @@ describe('Core - Analytics', () => { expect(state.eventBuffer.toBeProcessedArray.value).toStrictEqual([ ['identify', { userId: 'test_user_id' }], - ['track', { name: 'Consent Management Interaction', properties: {} }], - ['page', { properties: {} }], + [ + 'track', + { + name: 'Consent Management Interaction', + properties: {}, + options: undefined, + callback: undefined, + }, + ], + [ + 'page', + { + properties: {}, + category: undefined, + name: undefined, + options: undefined, + callback: undefined, + }, + ], ]); }); }); From 41e6b174bc4d6d8fa3f2da34fd8467c230f67cee Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Thu, 11 Jul 2024 14:13:04 +0530 Subject: [PATCH 09/24] chore: address lint issues --- .../src/utilities/eventMethodOverloads.ts | 8 +++---- .../sanity-suite/src/testBookSuites/alias.js | 11 +++++----- .../sanity-suite/src/testBookSuites/group.js | 13 ++++++------ .../src/testBookSuites/identify.js | 13 ++++++------ .../sanity-suite/src/testBookSuites/page.js | 21 +++++++++---------- .../sanity-suite/src/testBookSuites/track.js | 9 ++++---- 6 files changed, 35 insertions(+), 40 deletions(-) diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index c604fe1fd0..0b6aed0045 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -288,7 +288,7 @@ const aliasArgumentsToCallOptions = ( callback?: ApiCallback, ): AliasCallOptions => { const payload: AliasCallOptions = { - to: to as string, + to: to, from: from as string, options: options as Nullable, callback: undefined, @@ -299,19 +299,19 @@ const aliasArgumentsToCallOptions = ( } if (isFunction(options)) { - payload.to = to as string; + payload.to = to; payload.from = from as string; payload.options = undefined; payload.callback = options as ApiCallback; } if (isFunction(from)) { - payload.to = to as string; + payload.to = to; payload.from = undefined; payload.options = undefined; payload.callback = from as ApiCallback; } else if (isObjectLiteralAndNotNull(from) || isNull(from)) { - payload.to = to as string; + payload.to = to; payload.from = undefined; payload.options = from as Nullable; } diff --git a/packages/sanity-suite/src/testBookSuites/alias.js b/packages/sanity-suite/src/testBookSuites/alias.js index 7a03525475..2f5ddc0b18 100644 --- a/packages/sanity-suite/src/testBookSuites/alias.js +++ b/packages/sanity-suite/src/testBookSuites/alias.js @@ -9,12 +9,11 @@ const aliasMethodSuite = { id: 'aliasMethod', name: 'Alias', description: - 'Alias Method: \ - rudderanalytics.alias(to, [from], [options], [callback]);\ - rudderanalytics.alias(to, [from], [callback]);\ - rudderanalytics.alias(to, [options], [callback]);\ - rudderanalytics.alias(to, [callback]);\ - ', + 'Alias Method: ' + + 'rudderanalytics.alias(to, [from], [options], [callback]);' + + 'rudderanalytics.alias(to, [from], [callback]);' + + 'rudderanalytics.alias(to, [options], [callback]);' + + 'rudderanalytics.alias(to, [callback]);', testCases: [ { id: 'alias1', diff --git a/packages/sanity-suite/src/testBookSuites/group.js b/packages/sanity-suite/src/testBookSuites/group.js index 64f3ff5aae..c9cc820b3b 100644 --- a/packages/sanity-suite/src/testBookSuites/group.js +++ b/packages/sanity-suite/src/testBookSuites/group.js @@ -10,13 +10,12 @@ const groupMethodSuite = { id: 'groupMethod', name: 'Group', description: - 'Group Method: \ - rudderanalytics.group(groupId, [traits], [options], [callback]);\ - rudderanalytics.group(groupId, [traits], [callback]);\ - rudderanalytics.group(groupId, [callback]);\ - rudderanalytics.group(traits, [options], [callback]);\ - rudderanalytics.group(traits, [callback]);\ - ', + 'Group Method: ' + + 'rudderanalytics.group(groupId, [traits], [options], [callback]);' + + 'rudderanalytics.group(groupId, [traits], [callback]);' + + 'rudderanalytics.group(groupId, [callback]);' + + 'rudderanalytics.group(traits, [options], [callback]);' + + 'rudderanalytics.group(traits, [callback]);', testCases: [ { id: 'group1', diff --git a/packages/sanity-suite/src/testBookSuites/identify.js b/packages/sanity-suite/src/testBookSuites/identify.js index 7fb4c9c31c..143522d112 100644 --- a/packages/sanity-suite/src/testBookSuites/identify.js +++ b/packages/sanity-suite/src/testBookSuites/identify.js @@ -12,13 +12,12 @@ const identifyMethodSuite = { id: 'identifyMethod', name: 'Identify', description: - 'Identify Method: \ - rudderanalytics.identify(userId, [traits], [options], [callback]);\ - rudderanalytics.identify(userId, [traits], [callback]);\ - rudderanalytics.identify(userId, [callback]);\ - rudderanalytics.identify(traits, [options], [callback]);\ - rudderanalytics.identify(traits, [callback]);\ - ', + 'Identify Method: ' + + 'rudderanalytics.identify(userId, [traits], [options], [callback]);' + + 'rudderanalytics.identify(userId, [traits], [callback]);' + + 'rudderanalytics.identify(userId, [callback]);' + + 'rudderanalytics.identify(traits, [options], [callback]);' + + 'rudderanalytics.identify(traits, [callback]);', testCases: [ { id: 'identify1', diff --git a/packages/sanity-suite/src/testBookSuites/page.js b/packages/sanity-suite/src/testBookSuites/page.js index 6683589405..e3bdc5b10c 100644 --- a/packages/sanity-suite/src/testBookSuites/page.js +++ b/packages/sanity-suite/src/testBookSuites/page.js @@ -15,17 +15,16 @@ const pageMethodSuite = { id: 'pageMethod', name: 'Page', description: - 'Page Method: \ - rudderanalytics.page(category, name, [properties], [options], [callback]);\ - rudderanalytics.page(category, name, [properties], [callback]);\ - rudderanalytics.page(category, name, [callback]);\ - rudderanalytics.page(name, [properties], [options], [callback]);\ - rudderanalytics.page(name, [properties], [callback]);\ - rudderanalytics.page(name, [callback]);\ - rudderanalytics.page(properties, [options], [callback]);\ - rudderanalytics.page(properties, [callback]);\ - rudderanalytics.page([callback]);\ - ', + 'Page Method: ' + + 'rudderanalytics.page(category, name, [properties], [options], [callback]);' + + 'rudderanalytics.page(category, name, [properties], [callback]);' + + 'rudderanalytics.page(category, name, [callback]);' + + 'rudderanalytics.page(name, [properties], [options], [callback]);' + + 'rudderanalytics.page(name, [properties], [callback]);' + + 'rudderanalytics.page(name, [callback]);' + + 'rudderanalytics.page(properties, [options], [callback]);' + + 'rudderanalytics.page(properties, [callback]);' + + 'rudderanalytics.page([callback]);', testCases: [ { id: 'page1', diff --git a/packages/sanity-suite/src/testBookSuites/track.js b/packages/sanity-suite/src/testBookSuites/track.js index ad7ea8e8dc..49a26ea4b9 100644 --- a/packages/sanity-suite/src/testBookSuites/track.js +++ b/packages/sanity-suite/src/testBookSuites/track.js @@ -9,11 +9,10 @@ const trackMethodSuite = { id: 'trackMethod', name: 'Track', description: - 'Track Method: \ - rudderanalytics.track(event, [properties], [options], [callback]);\ - rudderanalytics.track(event, [properties], [callback]);\ - rudderanalytics.track(event, [callback]);\ - ', + 'Track Method: ' + + 'rudderanalytics.track(event, [properties], [options], [callback]);' + + 'rudderanalytics.track(event, [properties], [callback]);' + + 'rudderanalytics.track(event, [callback]);', testCases: [ { id: 'track1', From f8615b6f66cf035ef1f392a0308956dee32fa51c Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju <88789928+saikumarrs@users.noreply.github.com> Date: Mon, 15 Jul 2024 10:11:05 +0530 Subject: [PATCH 10/24] chore: Update packages/sanity-suite/src/testBookSuites/alias.js Co-authored-by: Moumita <36885121+MoumitaM@users.noreply.github.com> --- packages/sanity-suite/src/testBookSuites/alias.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sanity-suite/src/testBookSuites/alias.js b/packages/sanity-suite/src/testBookSuites/alias.js index 2f5ddc0b18..1fba8bce6e 100644 --- a/packages/sanity-suite/src/testBookSuites/alias.js +++ b/packages/sanity-suite/src/testBookSuites/alias.js @@ -120,7 +120,7 @@ const aliasMethodSuite = { }, { id: 'alias2', - description: 'rudderanalytics.alias(to, options)', + description: 'rudderanalytics.alias(to, from)', inputData: [ [true], [ From 48a9fc136c982ce70e37f65ed5647722d332de22 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 13:13:32 +0530 Subject: [PATCH 11/24] chore: fix targets and size limit configuration --- .github/workflows/draft-new-release.yml | 1 - ...ty-code-quality-and-bundle-size-checks.yml | 2 +- nx.json | 22 ++-- package-lock.json | 3 - package.json | 16 +-- packages/analytics-js-common/.size-limit.js | 4 +- packages/analytics-js-common/package.json | 10 +- packages/analytics-js-common/project.json | 43 ------- .../src/utilities/eventMethodOverloads.ts | 2 +- packages/analytics-js-cookies/.size-limit.mjs | 34 +++++- packages/analytics-js-cookies/package.json | 7 +- packages/analytics-js-cookies/project.json | 49 -------- .../analytics-js-cookies/rollup.config.mjs | 1 - .../analytics-js-cookies/tsconfig.spec.json | 1 + .../analytics-js-integrations/.size-limit.js | 7 +- .../analytics-js-integrations/package.json | 9 +- .../analytics-js-integrations/project.json | 42 ------- .../rollup.config.mjs | 21 ++-- packages/analytics-js-plugins/.size-limit.mjs | 16 ++- packages/analytics-js-plugins/package.json | 13 +- packages/analytics-js-plugins/project.json | 67 ---------- .../analytics-js-plugins/rollup.config.mjs | 22 ++-- .../.size-limit.mjs | 37 ++++-- .../analytics-js-service-worker/package.json | 38 ++++-- .../analytics-js-service-worker/project.json | 42 ------- .../rollup.config.mjs | 20 +-- packages/analytics-js/.size-limit.mjs | 115 ++++++++++++++++-- packages/analytics-js/package.json | 37 +++++- packages/analytics-js/project.json | 70 +---------- packages/analytics-js/rollup.config.mjs | 1 - packages/analytics-v1.1/.size-limit.js | 42 ++++++- packages/analytics-v1.1/package.json | 11 +- packages/analytics-v1.1/project.json | 51 +------- .../rollup-configs/rollup.utilities.mjs | 3 +- packages/loading-scripts/.size-limit.mjs | 11 ++ packages/loading-scripts/package.json | 14 ++- packages/loading-scripts/project.json | 37 ------ packages/sanity-suite/package.json | 1 + 38 files changed, 392 insertions(+), 530 deletions(-) create mode 100644 packages/loading-scripts/.size-limit.mjs diff --git a/.github/workflows/draft-new-release.yml b/.github/workflows/draft-new-release.yml index f7f4e8dc16..7f45e55599 100644 --- a/.github/workflows/draft-new-release.yml +++ b/.github/workflows/draft-new-release.yml @@ -84,7 +84,6 @@ jobs: npm run bump-version:monorepo npx replace $CURRENT_VERSION_VALUE $NEW_VERSION_VALUE sonar-project.properties npm run clean - npm run setup git add . git commit -m "chore(monorepo): sync versions and generate release logs" -n diff --git a/.github/workflows/security-code-quality-and-bundle-size-checks.yml b/.github/workflows/security-code-quality-and-bundle-size-checks.yml index 29ffbeadee..1e768fc34e 100644 --- a/.github/workflows/security-code-quality-and-bundle-size-checks.yml +++ b/.github/workflows/security-code-quality-and-bundle-size-checks.yml @@ -31,7 +31,7 @@ jobs: install_script: setup:ci build_script: check:size:build clean_script: clean - script: npm run check:size:json:ci --silent -- --output-style=static --silent=true --exclude=@rudderstack/analytics-js-sanity-suite,@rudderstack/analytics-js-loading-scripts + script: npm run check:size:json:ci --silent -- --output-style=static --silent=true --exclude=@rudderstack/analytics-js-sanity-suite is_monorepo: true security-code-quality-checks: diff --git a/nx.json b/nx.json index 91a5bad3e1..3a3411be93 100644 --- a/nx.json +++ b/nx.json @@ -37,27 +37,23 @@ "inputs": ["default", "^production"], "cache": true }, - "build-browser": { + "build:modern": { "inputs": ["default", "^production"], "cache": true }, - "build-browser-modern": { + "build:browser": { "inputs": ["default", "^production"], "cache": true }, - "build-npm": { + "build:browser:modern": { "inputs": ["default", "^production"], "cache": true }, - "build-npm-modern": { + "build:package": { "inputs": ["default", "^production"], "cache": true }, - "build-package": { - "inputs": ["default", "^production"], - "cache": true - }, - "build-check-size": { + "build:package:modern": { "inputs": ["default", "^production"], "cache": true }, @@ -66,7 +62,12 @@ "cache": true }, "check:size:json": { - "inputs": ["default", "^production", "{projectRoot}/.size-limit.js"], + "inputs": [ + "default", + "^production", + "{projectRoot}/.size-limit.js", + "{projectRoot}/.size-limit.mjs" + ], "cache": true }, "check:pub": { @@ -95,6 +96,7 @@ "!{projectRoot}/**/*.txt", "!{projectRoot}/serve.json", "!{projectRoot}/.size-limit.js", + "!{projectRoot}/.size-limit.mjs", "!{projectRoot}/.jscpd.json", "{workspaceRoot}/tsconfig.build.json", "{workspaceRoot}/tsconfig.json", diff --git a/package-lock.json b/package-lock.json index 0028c8348e..fd68dd511e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24316,9 +24316,6 @@ "@types/ms": "0.7.34", "@types/node": "20.14.5", "jest-date-mock": "1.0.10" - }, - "engines": { - "node": ">=v12" } }, "packages/analytics-js-service-worker/node_modules/@types/node": { diff --git a/package.json b/package.json index 44906c06df..7186fa3b3f 100644 --- a/package.json +++ b/package.json @@ -7,25 +7,25 @@ "packages/*" ], "scripts": { - "setup": "npm i --include=optional && npm run build:package", + "setup": "npm i --include=optional && npm run build:package:modern", "setup:ci": "npm ci && npm i @nx/nx-linux-x64-gnu && npm run build:package", "clean": "nx run-many -t clean && nx reset && git clean -xdf node_modules", "clean:cache": "rimraf -rf ./node_modules/.cache && rimraf -rf ./.nx/cache", "start": "nx run-many --targets=start --parallel=3 --projects=@rudderstack/analytics-js-integrations,@rudderstack/analytics-js-plugins,@rudderstack/analytics-js", "start:modern": "nx run-many --targets=start-modern --parallel=3 --projects=@rudderstack/analytics-js-integrations,@rudderstack/analytics-js-plugins,@rudderstack/analytics-js", "build": "nx run-many -t build", - "build:browser": "nx run-many -t build-browser", - "build:browser:modern": "nx run-many -t build-browser-modern", - "build:npm": "nx run-many -t build-npm", - "build:npm:modern": "nx run-many -t build-npm-modern", - "build:package": "nx run-many -t build-package", + "build:modern": "nx run-many -t build:modern", + "build:browser": "nx run-many -t build:browser", + "build:browser:modern": "nx run-many -t build:browser:modern", + "build:package": "nx run-many -t build:package", + "build:package:modern": "nx run-many -t build:package:modern", "package": "nx run-many -t pack", "test": "nx run-many -t test", "test:ci": "nx run-many -t test --configuration=ci --runInBand --maxWorkers=1 --forceExit", "check:lint:ci": "nx run-many -t check:lint:ci --verbose", "check:lint": "nx run-many -t check:lint --verbose", "check:size": "nx run-many -t check:size --verbose", - "check:size:build": "nx run-many -t build-check-size", + "check:size:build": "nx run-many -t check:size:build", "check:size:json": "npm run check:size:json:ci -- --verbose", "check:size:json:ci": "nx run-many -t check:size:json", "check:circular": "nx run-many -t check:circular --verbose", @@ -41,7 +41,7 @@ "commit-msg": "commitlint --edit", "commit": "git-cz", "postinstall": "patch-package", - "build:integrations": "nx run-many --targets=build-browser,build-browser-modern --projects=@rudderstack/analytics-js-integrations", + "build:integrations": "nx run-many --targets=build:browser,build:browser:modern --projects=@rudderstack/analytics-js-integrations", "build:v3": "nx run-many -t build --exclude=rudder-sdk-js,@rudderstack/analytics-js-sanity-suite,@rudderstack/analytics-js-integrations", "build:v1.1": "nx run-many -t build --projects=rudder-sdk-js", "build:sanity": "rm -rf packages/sanity-suite/dist && nx run-many --targets=build:all --projects=@rudderstack/analytics-js-sanity-suite", diff --git a/packages/analytics-js-common/.size-limit.js b/packages/analytics-js-common/.size-limit.js index 661663e917..0df666c22f 100644 --- a/packages/analytics-js-common/.size-limit.js +++ b/packages/analytics-js-common/.size-limit.js @@ -4,8 +4,8 @@ */ module.exports = [ { - name: 'Common Code - No bundling', - path: 'dist/**/*.js', + name: 'Common - No bundling', + path: 'dist/npm/**/*.js', limit: '16.5 KiB', }, ]; diff --git a/packages/analytics-js-common/package.json b/packages/analytics-js-common/package.json index b0d427dee5..9042b1686a 100644 --- a/packages/analytics-js-common/package.json +++ b/packages/analytics-js-common/package.json @@ -31,17 +31,18 @@ "clean": "rimraf -rf ./dist && rimraf -rf ./node_modules/.cache && rimraf -rf ./reports", "start": "exit 0", "build": "npm run build:browser && npm run build:package", - "copy:src": "rsync -r src/ dist/npm", - "build:browser:modern": "exit 0", + "build:modern": "npm run build:browser:modern && npm run build:package:modern", "build:browser": "exit 0", + "build:browser:modern": "exit 0", "build:npm": "tsc", "build:npm:modern": "BROWSERSLIST_ENV=modern npm run build:npm", - "build:package": "npm run build:npm:modern", + "build:package": "npm run build:npm", + "build:package:modern": "npm run build:npm:modern", "test": "nx test --maxWorkers=50%", "test:ci": "nx test --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:build": "npm run build:browser && npm run build:browser:modern && npm run build:package && npm run build:package:modern", "check:size": "npm run check:size:build && size-limit", "check:size:json": "size-limit --json", "check:circular": "madge --circular --extensions js,ts src --warning || exit 0", @@ -50,7 +51,6 @@ "check:duplicates": "jscpd src", "check:security": "npm audit --recursive --audit-level=high", "start:modern": "exit 0", - "build:modern": "npm run build:npm:modern", "package": "npm pack", "release": "npm publish" }, diff --git a/packages/analytics-js-common/project.json b/packages/analytics-js-common/project.json index f43e24f0ee..8e21acb718 100644 --- a/packages/analytics-js-common/project.json +++ b/packages/analytics-js-common/project.json @@ -5,49 +5,6 @@ "projectType": "library", "tags": ["type:lib", "scope:common"], "targets": { - "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}"], diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index 0b6aed0045..34ae27b1ce 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -288,7 +288,7 @@ const aliasArgumentsToCallOptions = ( callback?: ApiCallback, ): AliasCallOptions => { const payload: AliasCallOptions = { - to: to, + to, from: from as string, options: options as Nullable, callback: undefined, diff --git a/packages/analytics-js-cookies/.size-limit.mjs b/packages/analytics-js-cookies/.size-limit.mjs index 7a7cda3bfa..39d70cf7a6 100644 --- a/packages/analytics-js-cookies/.size-limit.mjs +++ b/packages/analytics-js-cookies/.size-limit.mjs @@ -4,13 +4,39 @@ */ export default [ { - name: 'Cookies Utilities ESM - NPM', - path: 'dist/npm/modern/esm/index.mjs', + name: 'Cookies Utils - Legacy - NPM (ESM)', + path: 'dist/npm/legacy/esm/index.mjs', + import: "*", limit: '2 KiB', }, { - name: 'Cookies Utilities CJS - NPM', - path: 'dist/npm/modern/cjs/index.cjs', + name: 'Cookies Utils - Legacy - NPM (CJS)', + path: 'dist/npm/legacy/cjs/index.cjs', + import: "*", + limit: '2 KiB', + }, + { + name: 'Cookies Utils - Legacy - NPM (UMD)', + path: 'dist/npm/legacy/umd/index.js', + import: "*", limit: '2 KiB', }, + { + name: 'Cookies Utils - Modern - NPM (ESM)', + path: 'dist/npm/modern/esm/index.mjs', + import: "*", + limit: '1.5 KiB', + }, + { + name: 'Cookies Utils - Modern - NPM (CJS)', + path: 'dist/npm/modern/cjs/index.cjs', + import: "*", + limit: '1.5 KiB', + }, + { + name: 'Cookies Utils - Modern - NPM (UMD)', + path: 'dist/npm/modern/umd/index.js', + import: "*", + limit: '1.5 KiB', + } ]; diff --git a/packages/analytics-js-cookies/package.json b/packages/analytics-js-cookies/package.json index 2777a1c592..2ed7b9df4b 100644 --- a/packages/analytics-js-cookies/package.json +++ b/packages/analytics-js-cookies/package.json @@ -65,16 +65,18 @@ "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:modern": "npm run build:browser:modern && npm run build:package:modern", "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 && npm run build:npm", + "build:package": "npm run build:npm", + "build:package:modern": "npm run build:npm:modern", "test": "nx test --maxWorkers=50%", "test:ci": "nx test --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:build": "npm run build:browser && npm run build:browser:modern && npm run build:package && npm run build:package:modern", "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", @@ -83,7 +85,6 @@ "check:duplicates": "jscpd src", "check:security": "npm audit --recursive --audit-level=high", "check:pub": "npx publint", - "build:modern": "npm run build:browser:modern && npm run build:npm:modern", "package": "npm pack", "release": "npm publish" }, diff --git a/packages/analytics-js-cookies/project.json b/packages/analytics-js-cookies/project.json index be1cd77490..c5a75c90fa 100644 --- a/packages/analytics-js-cookies/project.json +++ b/packages/analytics-js-cookies/project.json @@ -5,55 +5,6 @@ "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}"], diff --git a/packages/analytics-js-cookies/rollup.config.mjs b/packages/analytics-js-cookies/rollup.config.mjs index 7c05d89935..19b012fedb 100644 --- a/packages/analytics-js-cookies/rollup.config.mjs +++ b/packages/analytics-js-cookies/rollup.config.mjs @@ -86,7 +86,6 @@ export function getDefaultConfig(distName) { }, }), filesize({ - showBeforeSizes: 'build', showBrotliSize: true, }), process.env.VISUALIZER === 'true' && diff --git a/packages/analytics-js-cookies/tsconfig.spec.json b/packages/analytics-js-cookies/tsconfig.spec.json index c86bfb8032..0201cf6be5 100644 --- a/packages/analytics-js-cookies/tsconfig.spec.json +++ b/packages/analytics-js-cookies/tsconfig.spec.json @@ -19,6 +19,7 @@ "__fixtures__/**/*.ts", "src/**/*.ts", "src/**/*.d.ts", + "../../types/**/*", "./package.json", "../analytics-js-common/src/**/*" ] diff --git a/packages/analytics-js-integrations/.size-limit.js b/packages/analytics-js-integrations/.size-limit.js index 57382006b2..4842419034 100644 --- a/packages/analytics-js-integrations/.size-limit.js +++ b/packages/analytics-js-integrations/.size-limit.js @@ -4,8 +4,13 @@ */ module.exports = [ { - name: 'All Integrations (legacy build) - CDN', + name: 'All Integrations - Legacy - CDN', path: 'dist/cdn/legacy/js-integrations/*.min.js', limit: '93 KiB', }, + { + name: 'All Integrations - Modern - CDN', + path: 'dist/cdn/modern/js-integrations/*.min.js', + limit: '88 KiB', + }, ]; diff --git a/packages/analytics-js-integrations/package.json b/packages/analytics-js-integrations/package.json index ddb5ef59dc..caef0bbbd8 100644 --- a/packages/analytics-js-integrations/package.json +++ b/packages/analytics-js-integrations/package.json @@ -51,17 +51,19 @@ "clean": "rimraf -rf ./dist && rimraf -rf ./node_modules/.cache && rimraf -rf ./reports", "start": "npm run build && npm run serve", "start:modern": "npm run build:modern && npm run serve", - "build": "npm run build:browser", - "build:browser:modern": "npm run build:integration:all:modern", + "build": "npm run build:browser && npm run build:package", + "build:modern": "npm run build:browser:modern && npm run build:package:modern", "build:browser": "npm run build:integration:all", + "build:browser:modern": "npm run build:integration:all:modern", "build:npm": "exit 0", "build:npm:modern": "exit 0", "build:package": "exit 0", + "build:package:modern": "exit 0", "test": "nx test --maxWorkers=50%", "test:ci": "nx test --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:build": "npm run build:browser && npm run build:browser:modern && npm run build:package && npm run build:package:modern", "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", @@ -69,7 +71,6 @@ "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", "serve": "npx serve ./dist -p 3005 --cors", "package": "exit 0", "release": "exit 0", diff --git a/packages/analytics-js-integrations/project.json b/packages/analytics-js-integrations/project.json index ac721cbfe5..cf6134dc28 100644 --- a/packages/analytics-js-integrations/project.json +++ b/packages/analytics-js-integrations/project.json @@ -5,48 +5,6 @@ "projectType": "library", "tags": ["type:sdk", "scope:integrations"], "targets": { - "start": { - "executor": "nx:run-script", - "options": { - "script": "start" - } - }, - "start-modern": { - "executor": "nx:run-script", - "options": { - "script": "start:modern" - } - }, - "build": { - "executor": "nx:run-script", - "options": { - "script": "build" - } - }, - "build-browser": { - "executor": "nx:run-script", - "options": { - "script": "build:browser" - } - }, - "build-browser-modern": { - "executor": "nx:run-script", - "options": { - "script": "build:browser:modern" - } - }, - "build-check-size": { - "executor": "nx:run-script", - "options": { - "script": "build" - } - }, - "clean": { - "executor": "nx:run-script", - "options": { - "script": "clean" - } - }, "test": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], diff --git a/packages/analytics-js-integrations/rollup.config.mjs b/packages/analytics-js-integrations/rollup.config.mjs index 943b2bc54c..b3ad617aad 100644 --- a/packages/analytics-js-integrations/rollup.config.mjs +++ b/packages/analytics-js-integrations/rollup.config.mjs @@ -12,6 +12,7 @@ import typescript from 'rollup-plugin-typescript2'; import nodePolyfills from 'rollup-plugin-polyfill-node'; import { DEFAULT_EXTENSIONS } from '@babel/core'; import alias from '@rollup/plugin-alias'; +import del from 'rollup-plugin-delete'; import * as dotenv from 'dotenv'; import pkg from './package.json' assert { type: 'json' }; @@ -32,14 +33,8 @@ const modName = `${process.env.INTG_NAME}${INTG_SUFFIX}`; export function getOutputFilePath(dirPath, distName) { const fileNamePrefix = `${distName}`; const fileNameSuffix = process.env.PROD_DEBUG === 'inline' ? '-map' : ''; - let outFilePath = ''; - - if (process.env.ENV === 'prod') { - outFilePath = `${dirPath}/${fileNamePrefix}${fileNameSuffix}.min.js`; - } else { - outFilePath = `${dirPath}/${fileNamePrefix}.js`; - } - return outFilePath; + const fileExtension = process.env.ENV === 'prod' ? 'min.js' : 'js'; + return `${dirPath}/${fileNamePrefix}${fileNameSuffix}.${fileExtension}`; } export function getDefaultConfig(distName, moduleType = 'cdn') { @@ -78,6 +73,7 @@ export function getDefaultConfig(distName, moduleType = 'cdn') { } ] }), + del({ hook: "buildEnd", targets: "./dist/dts" }), nodePolyfills(), resolve({ jsnext: true, @@ -110,7 +106,6 @@ export function getDefaultConfig(distName, moduleType = 'cdn') { }, }), filesize({ - showBeforeSizes: 'build', showBrotliSize: true, }), process.env.VISUALIZER === 'true' && @@ -138,13 +133,15 @@ const outputFiles = [ }, ]; -const buildConfig = { - ...getDefaultConfig(distName), +const buildConfig = () => { + return { + ...getDefaultConfig(distName), + }; }; export default [ { - ...buildConfig, + ...buildConfig(), input: `src/integrations/${process.env.INTG_NAME}/index.js`, output: outputFiles, }, diff --git a/packages/analytics-js-plugins/.size-limit.mjs b/packages/analytics-js-plugins/.size-limit.mjs index f737982814..084f686524 100644 --- a/packages/analytics-js-plugins/.size-limit.mjs +++ b/packages/analytics-js-plugins/.size-limit.mjs @@ -4,13 +4,23 @@ */ export default [ { - name: 'Remote Module Federation Mapping - CDN', + name: 'Plugins Module Federation Mapping - Legacy - CDN', + path: 'dist/cdn/legacy/plugins/rsa-plugins.js', + limit: '0.5 KiB', + }, + { + name: 'Plugins - Legacy - CDN', + path: 'dist/cdn/legacy/plugins/rsa-plugins-*.min.js', + limit: '15 KiB', + }, + { + name: 'Plugins Module Federation Mapping - Modern - CDN', path: 'dist/cdn/modern/plugins/rsa-plugins.js', limit: '0.5 KiB', }, { - name: 'Remote Module Federated Plugins - CDN', - path: 'dist/cdn/modern/plugins/rsa-plugins-*.js', + name: 'Plugins - Modern - CDN', + path: 'dist/cdn/modern/plugins/rsa-plugins-*.min.js', limit: '6 KiB', }, ]; diff --git a/packages/analytics-js-plugins/package.json b/packages/analytics-js-plugins/package.json index 74562180d9..c9706f7353 100644 --- a/packages/analytics-js-plugins/package.json +++ b/packages/analytics-js-plugins/package.json @@ -64,17 +64,19 @@ "clean": "rimraf -rf ./dist && rimraf -rf ./node_modules/.cache && rimraf -rf ./reports", "start": "rollup -c --watch --environment DEV_SERVER,PROD_DEBUG", "start:modern": "BROWSERSLIST_ENV=modern npm run start", - "build": "npm run build:browser", - "build:browser:modern": "BROWSERSLIST_ENV=modern npm run build:browser", + "build": "npm run build:browser && npm run build:package", + "build:modern": "npm run build:browser:modern && npm run build:package:modern", "build:browser": "rollup -c --environment VERSION:$npm_package_version,UGLIFY,PROD_DEBUG,ENV:prod", - "build:npm": "rollup -c --environment VERSION:$npm_package_version,ENV:prod,MODULE_TYPE:npm", + "build:browser:modern": "BROWSERSLIST_ENV=modern npm run build:browser", + "build:npm": "exit 0", "build:npm:modern": "BROWSERSLIST_ENV=modern npm run build:npm", - "build:package": "npm run build:npm:modern && npm run build:npm", + "build:package": "npm run build:npm", + "build:package:modern": "npm run build:npm:modern", "test": "nx test --maxWorkers=50%", "test:ci": "nx test --configuration=ci --runInBand --maxWorkers=1 --forceExit", "check:lint": "nx lint", "check:lint:ci": "nx lint --configuration=ci", - "check:size:build": "npm run build:browser:modern && npm run build:package", + "check:size:build": "npm run build:browser && npm run build:browser:modern && npm run build:package && npm run build:package:modern", "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", @@ -82,7 +84,6 @@ "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", "package": "npm pack", "release": "npm publish" }, diff --git a/packages/analytics-js-plugins/project.json b/packages/analytics-js-plugins/project.json index 97ff44feb9..57b073e934 100644 --- a/packages/analytics-js-plugins/project.json +++ b/packages/analytics-js-plugins/project.json @@ -5,73 +5,6 @@ "projectType": "library", "tags": ["type:lib", "scope:plugins"], "targets": { - "start": { - "executor": "nx:run-script", - "options": { - "script": "start" - } - }, - "start-modern": { - "executor": "nx:run-script", - "options": { - "script": "start:modern" - } - }, - "build": { - "executor": "nx:run-script", - "options": { - "script": "build" - } - }, - "build-browser": { - "executor": "nx:run-script", - "options": { - "script": "build:browser" - } - }, - "build-browser-modern": { - "executor": "nx:run-script", - "options": { - "script": "build:browser:modern" - } - }, - "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-browser-modern"] - }, - "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}"], diff --git a/packages/analytics-js-plugins/rollup.config.mjs b/packages/analytics-js-plugins/rollup.config.mjs index 36874f9539..84f3e94475 100644 --- a/packages/analytics-js-plugins/rollup.config.mjs +++ b/packages/analytics-js-plugins/rollup.config.mjs @@ -78,7 +78,6 @@ export function getDefaultConfig(distName) { preventAssignment: true, __PACKAGE_VERSION__: version, __MODULE_TYPE__: moduleType, - __BUNDLE_ALL_PLUGINS__: isLegacyBuild, __RS_BUGSNAG_API_KEY__: process.env.BUGSNAG_API_KEY || '{{__RS_BUGSNAG_API_KEY__}}', __RS_BUGSNAG_RELEASE_STAGE__: process.env.BUGSNAG_RELEASE_STAGE || 'production', __RS_BUGSNAG_SDK_URL__: bugsnagSDKUrl, @@ -108,7 +107,7 @@ export function getDefaultConfig(distName) { extensions: [...DEFAULT_EXTENSIONS, '.ts'], sourcemap: sourceMapType, }), - !isLegacyBuild && isCDNPackageBuild && + isCDNPackageBuild && federation({ name: modName, filename: remotePluginsExportsFilename, @@ -124,7 +123,6 @@ export function getDefaultConfig(distName) { }, }), filesize({ - showBeforeSizes: 'build', showBrotliSize: true, }), process.env.VISUALIZER === 'true' && @@ -171,6 +169,16 @@ const outputFilesNpm = [ preset: isLegacyBuild ? 'es5' : 'es2015', }, }, + { + entryFileNames: `index.js`, + dir: outDirNpm + '/umd', + format: 'umd', + name: modName, + sourcemap: sourceMapType, + generatedCode: { + preset: isLegacyBuild ? 'es5' : 'es2015', + }, + } ]; const outputFilesCdn = [ @@ -202,14 +210,6 @@ const buildConfig = () => { const buildEntries = () => { const outputFiles = isCDNPackageBuild ? outputFilesCdn : outputFilesNpm; - if(isCDNPackageBuild) { - return[{ - ...buildConfig(), - input: 'src/index.ts', - output: outputFiles, - }]; - } - return [ { ...buildConfig(), diff --git a/packages/analytics-js-service-worker/.size-limit.mjs b/packages/analytics-js-service-worker/.size-limit.mjs index 005f49697c..cecaa2b7cb 100644 --- a/packages/analytics-js-service-worker/.size-limit.mjs +++ b/packages/analytics-js-service-worker/.size-limit.mjs @@ -4,18 +4,39 @@ */ export default [ { - name: 'Service Worker Module ESM - NPM', - path: 'dist/npm/esm/index.mjs', - limit: '24 KiB', + name: 'Service Worker - Legacy - NPM (ESM)', + path: 'dist/npm/legacy/esm/index.mjs', + import: '*', + limit: '30 KiB', }, { - name: 'Service Worker Module CJS - NPM', - path: 'dist/npm/cjs/index.cjs', - limit: '24 KiB', + name: 'Service Worker - Legacy - NPM (CJS)', + path: 'dist/npm/legacy/cjs/index.cjs', + import: '*', + limit: '30 KiB', }, { - name: 'Service Worker Module NPM', - path: 'dist/npm/umd/index.js', + name: 'Service Worker - Legacy - NPM (UMD)', + path: 'dist/npm/legacy/umd/index.js', + import: '*', + limit: '30 KiB', + }, + { + name: 'Service Worker - Modern - NPM (ESM)', + path: 'dist/npm/modern/esm/index.mjs', + import: '*', + limit: '25 KiB', + }, + { + name: 'Service Worker - Modern - NPM (CJS)', + path: 'dist/npm/modern/cjs/index.cjs', + import: '*', + limit: '25 KiB', + }, + { + name: 'Service Worker - Modern - NPM (UMD)', + path: 'dist/npm/modern/umd/index.js', + import: '*', limit: '25 KiB', }, ]; diff --git a/packages/analytics-js-service-worker/package.json b/packages/analytics-js-service-worker/package.json index 735c2675ed..bb8194ee90 100644 --- a/packages/analytics-js-service-worker/package.json +++ b/packages/analytics-js-service-worker/package.json @@ -6,14 +6,27 @@ "module": "dist/npm/esm/index.mjs", "type": "module", "exports": { - "types": "./dist/npm/index.d.mts", - "require": { - "types": "./dist/npm/index.d.cts", - "default": "./dist/npm/cjs/index.cjs" + ".": { + "types": "./dist/npm/index.d.mts", + "require": { + "types": "./dist/npm/index.d.cts", + "default": "./dist/npm/modern/cjs/index.cjs" + }, + "import": { + "types": "./dist/npm/index.d.mts", + "default": "./dist/npm/modern/esm/index.mjs" + } }, - "import": { + "./legacy": { "types": "./dist/npm/index.d.mts", - "default": "./dist/npm/esm/index.mjs" + "require": { + "types": "./dist/npm/index.d.cts", + "default": "./dist/npm/legacy/cjs/index.cjs" + }, + "import": { + "types": "./dist/npm/index.d.mts", + "default": "./dist/npm/legacy/esm/index.mjs" + } } }, "types": "./dist/npm/index.d.mts", @@ -51,17 +64,19 @@ "scripts": { "clean": "rimraf -rf ./dist && rimraf -rf ./node_modules/.cache && rimraf -rf ./reports", "start": "rollup -c --watch --environment PROD_DEBUG", - "build": "npm run build:package", - "build:browser:modern": "exit 0", + "build": "npm run build:browser && npm run build:package", + "build:modern": "npm run build:browser:modern && npm run build:package:modern", "build:browser": "exit 0", + "build:browser:modern": "exit 0", "build:npm": "rollup -c --environment VERSION:$npm_package_version,ENV:prod", "build:npm:modern": "BROWSERSLIST_ENV=modern npm run build:npm", - "build:package": "npm run build:npm:modern", + "build:package": "npm run build:npm", + "build:package:modern": "npm run build:npm:modern", "test": "nx test --maxWorkers=50%", "test:ci": "nx test --configuration=ci --runInBand --maxWorkers=1 --forceExit", "check:lint": "nx lint", "check:lint:ci": "nx lint --configuration=ci", - "check:size:build": "npm run build:package", + "check:size:build": "npm run build:browser && npm run build:browser:modern && npm run build:package && npm run build:package:modern", "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", @@ -73,9 +88,6 @@ "package": "cd dist/npm && npm pack --pack-destination ../../", "release": "npm publish" }, - "engines": { - "node": ">=v12" - }, "dependencies": { "@lukeed/uuid": "2.0.1", "@rudderstack/analytics-js-common": "*", diff --git a/packages/analytics-js-service-worker/project.json b/packages/analytics-js-service-worker/project.json index 920da2b315..00567ee728 100644 --- a/packages/analytics-js-service-worker/project.json +++ b/packages/analytics-js-service-worker/project.json @@ -5,48 +5,6 @@ "projectType": "library", "tags": ["type:sdk", "scope:service-worker"], "targets": { - "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" - } - }, - "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}"], diff --git a/packages/analytics-js-service-worker/rollup.config.mjs b/packages/analytics-js-service-worker/rollup.config.mjs index 48c741f82d..f8f906e5c8 100644 --- a/packages/analytics-js-service-worker/rollup.config.mjs +++ b/packages/analytics-js-service-worker/rollup.config.mjs @@ -19,9 +19,12 @@ import * as dotenv from 'dotenv'; 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`; +const outDirNpmRoot = `dist/npm`; +const outDir = `${outDirNpmRoot}${variantSubfolder}`; const distName = 'index'; const modName = 'rudderServiceWorker'; @@ -75,8 +78,8 @@ export function getDefaultConfig(distName) { }), process.env.UGLIFY === 'true' && terser({ - safari10: false, - ecma: 2017, + safari10: isLegacyBuild, + ecma: isLegacyBuild ? 2015 : 2017, format: { comments: false, }, @@ -87,7 +90,6 @@ export function getDefaultConfig(distName) { ], }), filesize({ - showBeforeSizes: 'build', showBrotliSize: true, }), process.env.VISUALIZER === 'true' && @@ -111,7 +113,7 @@ const outputFilesNpm = [ name: modName, sourcemap: sourceMapType, generatedCode: { - preset: 'es5', + preset: isLegacyBuild ? 'es5' : 'es2015', } }, { @@ -121,7 +123,7 @@ const outputFilesNpm = [ name: modName, sourcemap: sourceMapType, generatedCode: { - preset: 'es5', + preset: isLegacyBuild ? 'es5' : 'es2015', } }, { @@ -131,7 +133,7 @@ const outputFilesNpm = [ name: modName, sourcemap: sourceMapType, generatedCode: { - preset: 'es5', + preset: isLegacyBuild ? 'es5' : 'es2015', } }, ]; @@ -162,11 +164,11 @@ const buildEntries = [ ], output: [ { - file: `${outDir}/index.d.mts`, + file: `${outDirNpmRoot}/index.d.mts`, format: 'es', }, { - file: `${outDir}/index.d.cts`, + file: `${outDirNpmRoot}/index.d.cts`, format: 'es', } ] diff --git a/packages/analytics-js/.size-limit.mjs b/packages/analytics-js/.size-limit.mjs index 321ac9ec56..9033d30d75 100644 --- a/packages/analytics-js/.size-limit.mjs +++ b/packages/analytics-js/.size-limit.mjs @@ -4,28 +4,121 @@ */ export default [ { - name: 'Core ESM - NPM', - path: 'dist/npm/modern/esm/index.mjs', - limit: '8 KiB', + name: 'Core - Legacy - NPM (ESM)', + path: 'dist/npm/legacy/esm/index.mjs', + import: "*", + limit: '45 KiB', }, { - name: 'Core CJS - NPM', - path: 'dist/npm/modern/cjs/index.cjs', - limit: '24 KiB', + name: 'Core - Legacy - NPM (CJS)', + path: 'dist/npm/legacy/cjs/index.cjs', + import: "*", + limit: '45 KiB', }, { - name: 'Core - NPM', - path: 'dist/npm/modern/umd/index.js', - limit: '24 KiB', + name: 'Core - Legacy - NPM (UMD)', + path: 'dist/npm/legacy/umd/index.js', + import: "*", + limit: '45 KiB', }, { - name: 'Core Legacy - CDN', + name: 'Core - Legacy - CDN', path: 'dist/cdn/legacy/iife/rsa.min.js', limit: '45 KiB', }, { - name: 'Core - CDN', + name: 'Core - Modern - NPM (ESM)', + path: 'dist/npm/modern/esm/index.mjs', + import: "*", + limit: '24.5 KiB', + }, + { + name: 'Core - Modern - NPM (CJS)', + path: 'dist/npm/modern/cjs/index.cjs', + import: "*", + limit: '24.5 KiB', + }, + { + name: 'Core - Modern - NPM (UMD)', + path: 'dist/npm/modern/umd/index.js', + import: "*", + limit: '24.5 KiB', + }, + { + name: 'Core - Modern - CDN', path: 'dist/cdn/modern/iife/rsa.min.js', limit: '24.5 KiB', }, + { + name: 'Core (Bundled) - Legacy - NPM (ESM)', + path: 'dist/npm/legacy/bundled/esm/index.mjs', + import: "*", + limit: '45 KiB', + }, + { + name: 'Core (Bundled) - Legacy - NPM (CJS)', + path: 'dist/npm/legacy/bundled/cjs/index.cjs', + import: "*", + limit: '45 KiB', + }, + { + name: 'Core (Bundled) - Legacy - NPM (UMD)', + path: 'dist/npm/legacy/bundled/umd/index.js', + import: "*", + limit: '45 KiB', + }, + { + name: 'Core (Bundled) - Modern - NPM (ESM)', + path: 'dist/npm/modern/bundled/esm/index.mjs', + import: "*", + limit: '37 KiB', + }, + { + name: 'Core (Bundled) - Modern - NPM (CJS)', + path: 'dist/npm/modern/bundled/cjs/index.cjs', + import: "*", + limit: '37 KiB', + }, + { + name: 'Core (Bundled) - Modern - NPM (UMD)', + path: 'dist/npm/modern/bundled/umd/index.js', + import: "*", + limit: '37 KiB', + }, + { + name: 'Core (Content Script) - Legacy - NPM (ESM)', + path: 'dist/npm/legacy/content-script/esm/index.mjs', + import: "*", + limit: '45 KiB', + }, + { + name: 'Core (Content Script) - Legacy - NPM (CJS)', + path: 'dist/npm/legacy/content-script/cjs/index.cjs', + import: "*", + limit: '45 KiB', + }, + { + name: 'Core (Content Script) - Legacy - NPM (UMD)', + path: 'dist/npm/legacy/content-script/umd/index.js', + import: "*", + limit: '45 KiB', + }, + { + name: 'Core (Content Script) - Modern - NPM (ESM)', + path: 'dist/npm/modern/content-script/esm/index.mjs', + import: "*", + limit: '37 KiB', + }, + { + name: 'Core (Content Script) - Modern - NPM (CJS)', + path: 'dist/npm/modern/content-script/cjs/index.cjs', + import: "*", + limit: '37 KiB', + }, + { + name: 'Core (Content Script) - Modern - NPM (UMD)', + path: 'dist/npm/modern/content-script/umd/index.js', + import: "*", + limit: '37 KiB', + }, ]; diff --git a/packages/analytics-js/package.json b/packages/analytics-js/package.json index 2919c246ec..9d543ad1b8 100644 --- a/packages/analytics-js/package.json +++ b/packages/analytics-js/package.json @@ -49,6 +49,28 @@ "types": "./dist/npm/index.d.mts", "default": "./dist/npm/modern/content-script/esm/index.mjs" } + }, + "./legacy-bundled": { + "types": "./dist/npm/index.d.mts", + "require": { + "types": "./dist/npm/index.d.cts", + "default": "./dist/npm/legacy/bundled/cjs/index.cjs" + }, + "import": { + "types": "./dist/npm/index.d.mts", + "default": "./dist/npm/legacy/bundled/esm/index.mjs" + } + }, + "./legacy-content-script": { + "types": "./dist/npm/index.d.mts", + "require": { + "types": "./dist/npm/index.d.cts", + "default": "./dist/npm/legacy/content-script/cjs/index.cjs" + }, + "import": { + "types": "./dist/npm/index.d.mts", + "default": "./dist/npm/legacy/content-script/esm/index.mjs" + } } }, "types": "./dist/npm/index.d.mts", @@ -88,19 +110,23 @@ "start": "rollup -c --watch --environment DEV_SERVER,PROD_DEBUG", "start:modern": "BROWSERSLIST_ENV=modern npm run start", "build": "npm run build:browser && npm run build:package", - "build:browser:modern": "BROWSERSLIST_ENV=modern npm run build:browser", + "build:modern": "npm run build:browser:modern && npm run build:package:modern", "build:browser": "rollup -c --environment VERSION:$npm_package_version,UGLIFY,PROD_DEBUG,ENV:prod", + "build:browser:modern": "BROWSERSLIST_ENV=modern npm run build:browser", + "build:package": "npm run build:npm && npm run build:npm:bundled && npm run build:npm:content-script", + "build:package:modern": "npm run build:npm:modern && npm run build:npm:bundled:modern && npm run build:npm:content-script:modern", "build:npm": "rollup -c --environment VERSION:$npm_package_version,ENV:prod,MODULE_TYPE:npm", - "build:npm:bundled": "BUNDLED_PLUGINS=all npm run build:npm:modern", - "build:npm:content-script": "BUNDLED_PLUGINS=all NO_EXTERNAL_HOST=true npm run build:npm:modern", "build:npm:modern": "BROWSERSLIST_ENV=modern npm run build:npm", - "build:package": "npm run build:npm:modern && npm run build:npm && npm run build:npm:bundled && npm run build:npm:content-script", + "build:npm:bundled": "BUNDLED_PLUGINS=all npm run build:npm", + "build:npm:bundled:modern": "BUNDLED_PLUGINS=all npm run build:npm:modern", + "build:npm:content-script": "BUNDLED_PLUGINS=all NO_EXTERNAL_HOST=true npm run build:npm", + "build:npm:content-script:modern": "BUNDLED_PLUGINS=all NO_EXTERNAL_HOST=true npm run build:npm:modern", "build:browser:test": "ONLY_IIFE=true npm run build:browser && sed 's/var rudderanalytics/rudderanalytics/g' dist/cdn/legacy/iife/rsa.min.js > __mocks__/cdnSDK.js", "test": "npm run build:browser:test && nx test --maxWorkers=50%", "test:ci": "npm run build:browser:test && nx test --configuration=ci --runInBand --maxWorkers=1 --forceExit", "check:lint": "nx lint", "check:lint:ci": "nx lint --configuration=ci", - "check:size:build": "npm run build:browser && npm run build:browser:modern && npm run build:package", + "check:size:build": "npm run build:browser && npm run build:browser:modern && npm run build:package && npm run build:package:modern", "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", @@ -109,7 +135,6 @@ "check:duplicates": "jscpd src", "check:security": "npm audit --recursive --audit-level=high", "check:pub": "npx publint", - "build:modern": "npm run build:browser:modern && npm run build:npm:modern", "package": "npm pack", "release": "npm publish" }, diff --git a/packages/analytics-js/project.json b/packages/analytics-js/project.json index 45fdd73404..4c05e52905 100644 --- a/packages/analytics-js/project.json +++ b/packages/analytics-js/project.json @@ -5,72 +5,12 @@ "projectType": "library", "tags": ["type:sdk", "scope:analytics-v3"], "targets": { - "start": { - "executor": "nx:run-script", + "prepare-test-mocks": { + "executor": "nx:run-commands", "options": { - "script": "start" - } - }, - "start-modern": { - "executor": "nx:run-script", - "options": { - "script": "start:modern" - } - }, - "build": { - "executor": "nx:run-script", - "options": { - "script": "build" - } - }, - "build-browser": { - "executor": "nx:run-script", - "options": { - "script": "build:browser" - } - }, - "build-browser-modern": { - "executor": "nx:run-script", - "options": { - "script": "build:browser:modern" - } - }, - "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" + "command": "sed 's/var rudderanalytics/rudderanalytics/g' packages/analytics-js/dist/cdn/legacy/iife/rsa.min.js > packages/analytics-js/__mocks__/cdnSDK.js" }, - "dependsOn": ["build-browser", "build-browser-modern"] - }, - "clean": { - "executor": "nx:run-script", - "options": { - "script": "clean" - } - }, - "pack": { - "executor": "nx:run-script", - "options": { - "script": "package" - } + "dependsOn": ["build:browser"] }, "test": { "executor": "@nx/jest:jest", @@ -88,7 +28,7 @@ "codeCoverage": true } }, - "dependsOn": ["build-browser"] + "dependsOn": ["prepare-test-mocks"] }, "lint": { "executor": "@nx/eslint:lint", diff --git a/packages/analytics-js/rollup.config.mjs b/packages/analytics-js/rollup.config.mjs index 30c007b37b..97ab262af4 100644 --- a/packages/analytics-js/rollup.config.mjs +++ b/packages/analytics-js/rollup.config.mjs @@ -241,7 +241,6 @@ export function getDefaultConfig(distName) { }, }), filesize({ - showBeforeSizes: 'build', showBrotliSize: true, }), process.env.VISUALIZER === 'true' && diff --git a/packages/analytics-v1.1/.size-limit.js b/packages/analytics-v1.1/.size-limit.js index 261aee9d0a..d0ff45f715 100644 --- a/packages/analytics-v1.1/.size-limit.js +++ b/packages/analytics-v1.1/.size-limit.js @@ -4,13 +4,49 @@ */ module.exports = [ { - name: 'Core (legacy build) - CDN - v1.1', - path: 'dist/cdn/legacy/rudder-analytics.min.js', + name: 'Core (v1.1) - NPM (ESM)', + path: 'dist/npm/index.es.js', + import: '*', limit: '32 KiB', }, { - name: 'Core - NPM - v1.1', + name: 'Core (v1.1) - NPM (CJS)', + path: 'dist/npm/index.cjs.js', + import: '*', + limit: '32 KiB', + }, + { + name: 'Core (v1.1) - NPM (UMD)', path: 'dist/npm/index.js', + import: '*', + limit: '32 KiB', + }, + { + name: 'Core (Content Script - v1.1) - NPM (ESM)', + path: 'dist/npm/content-script/index.es.js', + import: '*', + limit: '30 KiB', + }, + { + name: 'Core (Content Script - v1.1) - NPM (CJS)', + path: 'dist/npm/content-script/index.cjs.js', + import: '*', + limit: '30 KiB', + }, + { + name: 'Core (Content Script - v1.1) - NPM (UMD)', + path: 'dist/npm/content-script/index.js', + import: '*', + limit: '30 KiB', + }, + { + name: 'Core - Legacy - CDN', + path: 'dist/cdn/legacy/rudder-analytics.min.js', + limit: '32 KiB', + }, + { + name: 'Core - Modern - CDN', + path: 'dist/cdn/modern/rudder-analytics.min.js', limit: '32 KiB', }, ]; diff --git a/packages/analytics-v1.1/package.json b/packages/analytics-v1.1/package.json index 59b923db8e..5618f03f0f 100644 --- a/packages/analytics-v1.1/package.json +++ b/packages/analytics-v1.1/package.json @@ -34,19 +34,24 @@ ], "scripts": { "clean": "rimraf -rf ./dist && rimraf -rf ./node_modules/.cache && rimraf -rf ./reports", - "start": "rollup --config rollup-configs/rollup.sdk.browser.mjs --watch --environment DEV_SERVER,PROD_DEBUG:inline", + "start": "rollup --config rollup-configs/rollup.sdk.browser.mjs --watch --environment DEV_SERVER,PROD_DEBUG", + "start:modern": "BROWSERSLIST_ENV=modern npm run start", "build": "npm run build:browser && npm run build:package", - "build:browser:modern": "BROWSERSLIST_ENV=modern rollup --config rollup-configs/rollup.sdk.browser.mjs --environment VERSION:$npm_package_version,UGLIFY,PROD_DEBUG,ENV:prod", + "build:modern": "npm run build:browser:modern && npm run build:package:modern", "build:browser": "rollup --config rollup-configs/rollup.sdk.browser.mjs --environment VERSION:$npm_package_version,UGLIFY,PROD_DEBUG,ENV:prod", + "build:browser:modern": "BROWSERSLIST_ENV=modern rollup --config rollup-configs/rollup.sdk.browser.mjs --environment VERSION:$npm_package_version,UGLIFY,PROD_DEBUG,ENV:prod", "build:npm": "rollup --config rollup-configs/rollup.sdk.npm.mjs --environment VERSION:$npm_package_version,UGLIFY,ENV:prod,NPM", + "build:npm:modern": "BROWSERSLIST_ENV=modern rollup --config rollup-configs/rollup.sdk.npm.mjs --environment VERSION:$npm_package_version,UGLIFY,ENV:prod,NPM", "build:npm:content-script": "NO_EXTERNAL_HOST=true npm run build:npm", + "build:npm:content-script:modern": "BROWSERSLIST_ENV=modern NO_EXTERNAL_HOST=true npm run build:npm", "build:package": "npm run build:npm && npm run build:npm:content-script", + "build:package:modern": "npm run build:npm:modern && npm run build:npm:content-script:modern", "build:browser:test": "npm run build:browser && sed 's/var rudderanalytics/rudderanalytics/g' dist/cdn/legacy/rudder-analytics.min.js > __mocks__/cdnSDK.js", "test": "npm run build:browser:test && nx test --maxWorkers=50%", "test:ci": "npm run build:browser:test && nx test --configuration=ci --runInBand --maxWorkers=1 --forceExit", "check:lint": "nx lint", "check:lint:ci": "nx lint --configuration=ci", - "check:size:build": "npm run build:browser && npm run build:package", + "check:size:build": "npm run build:browser && npm run build:browser:modern && npm run build:package && npm run build:package:modern", "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", diff --git a/packages/analytics-v1.1/project.json b/packages/analytics-v1.1/project.json index 2d8202eecc..77723b60ef 100644 --- a/packages/analytics-v1.1/project.json +++ b/packages/analytics-v1.1/project.json @@ -5,61 +5,12 @@ "projectType": "library", "tags": ["type:sdk", "scope:analytics-v1.1"], "targets": { - "build": { - "executor": "nx:run-script", - "options": { - "script": "build" - } - }, - "build-browser": { - "executor": "nx:run-script", - "options": { - "script": "build:browser" - } - }, - "build-browser-modern": { - "executor": "nx:run-script", - "options": { - "script": "build:browser:modern" - } - }, - "build-npm": { - "executor": "nx:run-script", - "options": { - "script": "build:npm" - } - }, - "build-package": { - "executor": "nx:run-script", - "options": { - "script": "build:package" - } - }, - "build-check-size": { - "executor": "nx:run-script", - "options": { - "script": "build:package" - }, - "dependsOn": ["build-browser"] - }, - "clean": { - "executor": "nx:run-script", - "options": { - "script": "clean" - } - }, - "pack": { - "executor": "nx:run-script", - "options": { - "script": "package" - } - }, "prepare-test-mocks": { "executor": "nx:run-commands", "options": { "command": "sed 's/var rudderanalytics/rudderanalytics/g' packages/analytics-v1.1/dist/cdn/legacy/rudder-analytics.min.js > packages/analytics-v1.1/__mocks__/cdnSDK.js" }, - "dependsOn": ["build-browser"] + "dependsOn": ["build:browser"] }, "test": { "executor": "@nx/jest:jest", diff --git a/packages/analytics-v1.1/rollup-configs/rollup.utilities.mjs b/packages/analytics-v1.1/rollup-configs/rollup.utilities.mjs index 1c591d6cd3..729e5390bc 100644 --- a/packages/analytics-v1.1/rollup-configs/rollup.utilities.mjs +++ b/packages/analytics-v1.1/rollup-configs/rollup.utilities.mjs @@ -14,6 +14,7 @@ import htmlTemplate from 'rollup-plugin-generate-html-template'; import typescript from 'rollup-plugin-typescript2'; import nodePolyfills from 'rollup-plugin-polyfill-node'; import alias from "@rollup/plugin-alias"; +import del from "rollup-plugin-delete"; import * as dotenv from 'dotenv'; import { DEFAULT_EXTENSIONS } from '@babel/core'; @@ -85,6 +86,7 @@ export function getDefaultConfig(distName) { } ] }), + del({ hook: "buildEnd", targets: "./dist/dts" }), nodePolyfills(), resolve({ jsnext: true, @@ -125,7 +127,6 @@ export function getDefaultConfig(distName) { brotliSize: true, }), filesize({ - showBeforeSizes: 'build', showBrotliSize: true, }), isLocalServerEnabled && diff --git a/packages/loading-scripts/.size-limit.mjs b/packages/loading-scripts/.size-limit.mjs new file mode 100644 index 0000000000..7cdde15e8d --- /dev/null +++ b/packages/loading-scripts/.size-limit.mjs @@ -0,0 +1,11 @@ +/** + * DO NOT EDIT the size limits configured in this file. + * Should you update them, please contact CODEOWNERS. + */ +export default [ + { + name: 'Load Snippet', + path: 'dist/loading-script.min.js', + limit: '1 KiB', + }, +]; diff --git a/packages/loading-scripts/package.json b/packages/loading-scripts/package.json index e53031cdea..eec212d4e9 100644 --- a/packages/loading-scripts/package.json +++ b/packages/loading-scripts/package.json @@ -23,19 +23,25 @@ "clean": "rimraf -rf ./dist && rimraf -rf ./node_modules/.cache && rimraf -rf ./reports", "start": "rollup -c --watch --environment DEV_SERVER", "build": "npm run build:browser", + "build:original": "npm run build:browser:original", + "build:modern": "npm run build:browser:modern", "build:browser:modern": "exit 0", - "build:browser:minified": "rollup -c --environment VERSION:$npm_package_version,UGLIFY", - "build:browser": "rollup -c --environment VERSION:$npm_package_version && npm run build:browser:minified", + "build:browser:original": "rollup -c --environment VERSION:$npm_package_version", + "build:browser": "rollup -c --environment VERSION:$npm_package_version,UGLIFY", + "build:package": "exit 0", + "build:package:modern": "exit 0", "test": "nx test --maxWorkers=50%", "test:ci": "nx test --configuration=ci --runInBand --maxWorkers=1 --forceExit", "check:lint": "nx lint", "check:lint:ci": "nx lint --configuration=ci", + "check:size:build": "npm run build:browser && npm run build:browser:modern && npm run build:package && npm run build:package:modern", + "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": "exit 0", "check:duplicates": "jscpd src", - "check:security": "npm audit --recursive --audit-level=high", - "build:modern": "npm run build:browser:modern" + "check:security": "npm audit --recursive --audit-level=high" }, "dependencies": { "@rudderstack/analytics-js": "*" diff --git a/packages/loading-scripts/project.json b/packages/loading-scripts/project.json index ddeff4c557..b538ea7dd9 100644 --- a/packages/loading-scripts/project.json +++ b/packages/loading-scripts/project.json @@ -5,43 +5,6 @@ "projectType": "library", "tags": ["type:app", "scope:snippet"], "targets": { - "build": { - "executor": "nx:run-script", - "options": { - "script": "build" - } - }, - "build-browser": { - "executor": "nx:run-script", - "options": { - "script": "build:browser" - } - }, - "build-browser-minified": { - "executor": "nx:run-script", - "options": { - "script": "build:browser:minified" - } - }, - "build-browser-modern": { - "executor": "nx:run-script", - "options": { - "script": "build:browser:modern" - } - }, - "build-check-size": { - "executor": "nx:run-script", - "options": { - "script": "build:browser:minified" - }, - "dependsOn": ["build-browser"] - }, - "clean": { - "executor": "nx:run-script", - "options": { - "script": "clean" - } - }, "test": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], diff --git a/packages/sanity-suite/package.json b/packages/sanity-suite/package.json index 88890fd358..c93377f2d3 100644 --- a/packages/sanity-suite/package.json +++ b/packages/sanity-suite/package.json @@ -16,6 +16,7 @@ "build:npm": "rollup -c --environment DISTRIBUTION_TYPE:npm", "build:npm:modern": "exit 0", "build:package": "exit 0", + "build:package:modern": "exit 0", "test": "nx test --maxWorkers=50%", "test:ci": "nx test --configuration=ci --runInBand --maxWorkers=1 --forceExit", "check:lint": "nx lint", From 08c1ad0fd7a106fb335c916fb7568aa1d45f2b21 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 13:22:06 +0530 Subject: [PATCH 12/24] chore: build packages for publint --- .../security-code-quality-and-bundle-size-checks.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/security-code-quality-and-bundle-size-checks.yml b/.github/workflows/security-code-quality-and-bundle-size-checks.yml index 1e768fc34e..6e5852f30a 100644 --- a/.github/workflows/security-code-quality-and-bundle-size-checks.yml +++ b/.github/workflows/security-code-quality-and-bundle-size-checks.yml @@ -58,6 +58,11 @@ jobs: run: | npm run check:duplicates + - name: Build the project + run: | + npm run build + npm run build:modern + - name: Execute package linting checks run: | npm run check:pub From 4be7f6f63fc8ce2d3747f9d9197de7797a96d1e4 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 13:40:54 +0530 Subject: [PATCH 13/24] chore: fix pacakge.json for publint --- packages/analytics-js-service-worker/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/analytics-js-service-worker/package.json b/packages/analytics-js-service-worker/package.json index bb8194ee90..398242db22 100644 --- a/packages/analytics-js-service-worker/package.json +++ b/packages/analytics-js-service-worker/package.json @@ -2,8 +2,8 @@ "name": "@rudderstack/analytics-js-service-worker", "version": "3.1.4", "description": "RudderStack JavaScript Service Worker SDK", - "main": "dist/npm/cjs/index.cjs", - "module": "dist/npm/esm/index.mjs", + "main": "dist/npm/modern/cjs/index.cjs", + "module": "dist/npm/modern/esm/index.mjs", "type": "module", "exports": { ".": { From 9d72b4217d5269c715738b4d325161eb06cf9fad Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 13:56:25 +0530 Subject: [PATCH 14/24] chore: do not remove type declaration files --- packages/analytics-js-integrations/rollup.config.mjs | 2 -- packages/analytics-v1.1/rollup-configs/rollup.utilities.mjs | 2 -- 2 files changed, 4 deletions(-) diff --git a/packages/analytics-js-integrations/rollup.config.mjs b/packages/analytics-js-integrations/rollup.config.mjs index b3ad617aad..ceea3df47e 100644 --- a/packages/analytics-js-integrations/rollup.config.mjs +++ b/packages/analytics-js-integrations/rollup.config.mjs @@ -12,7 +12,6 @@ import typescript from 'rollup-plugin-typescript2'; import nodePolyfills from 'rollup-plugin-polyfill-node'; import { DEFAULT_EXTENSIONS } from '@babel/core'; import alias from '@rollup/plugin-alias'; -import del from 'rollup-plugin-delete'; import * as dotenv from 'dotenv'; import pkg from './package.json' assert { type: 'json' }; @@ -73,7 +72,6 @@ export function getDefaultConfig(distName, moduleType = 'cdn') { } ] }), - del({ hook: "buildEnd", targets: "./dist/dts" }), nodePolyfills(), resolve({ jsnext: true, diff --git a/packages/analytics-v1.1/rollup-configs/rollup.utilities.mjs b/packages/analytics-v1.1/rollup-configs/rollup.utilities.mjs index 729e5390bc..a7ff0dd28b 100644 --- a/packages/analytics-v1.1/rollup-configs/rollup.utilities.mjs +++ b/packages/analytics-v1.1/rollup-configs/rollup.utilities.mjs @@ -14,7 +14,6 @@ import htmlTemplate from 'rollup-plugin-generate-html-template'; import typescript from 'rollup-plugin-typescript2'; import nodePolyfills from 'rollup-plugin-polyfill-node'; import alias from "@rollup/plugin-alias"; -import del from "rollup-plugin-delete"; import * as dotenv from 'dotenv'; import { DEFAULT_EXTENSIONS } from '@babel/core'; @@ -86,7 +85,6 @@ export function getDefaultConfig(distName) { } ] }), - del({ hook: "buildEnd", targets: "./dist/dts" }), nodePolyfills(), resolve({ jsnext: true, From 2f52d63c6d560119de2546084508af6bf4e6a1b1 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 14:03:23 +0530 Subject: [PATCH 15/24] chore: use apiOptions naming --- packages/sanity-suite/src/testBookSuites/alias.js | 8 ++++---- packages/sanity-suite/src/testBookSuites/group.js | 10 +++++----- .../sanity-suite/src/testBookSuites/identify.js | 10 +++++----- packages/sanity-suite/src/testBookSuites/page.js | 14 +++++++------- packages/sanity-suite/src/testBookSuites/track.js | 6 +++--- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/sanity-suite/src/testBookSuites/alias.js b/packages/sanity-suite/src/testBookSuites/alias.js index 1fba8bce6e..881caea6d3 100644 --- a/packages/sanity-suite/src/testBookSuites/alias.js +++ b/packages/sanity-suite/src/testBookSuites/alias.js @@ -10,14 +10,14 @@ const aliasMethodSuite = { name: 'Alias', description: 'Alias Method: ' + - 'rudderanalytics.alias(to, [from], [options], [callback]);' + + 'rudderanalytics.alias(to, [from], [apiOptions], [callback]);' + 'rudderanalytics.alias(to, [from], [callback]);' + - 'rudderanalytics.alias(to, [options], [callback]);' + + 'rudderanalytics.alias(to, [apiOptions], [callback]);' + 'rudderanalytics.alias(to, [callback]);', testCases: [ { id: 'alias1', - description: 'rudderanalytics.alias(to, from, options)', + description: 'rudderanalytics.alias(to, from, apiOptions)', inputData: [ [true], [ @@ -280,7 +280,7 @@ const aliasMethodSuite = { }, { id: 'alias6', - description: 'rudderanalytics.alias(to, options)', + description: 'rudderanalytics.alias(to, apiOptions)', inputData: [ [true], [ diff --git a/packages/sanity-suite/src/testBookSuites/group.js b/packages/sanity-suite/src/testBookSuites/group.js index c9cc820b3b..9537b3c33e 100644 --- a/packages/sanity-suite/src/testBookSuites/group.js +++ b/packages/sanity-suite/src/testBookSuites/group.js @@ -11,15 +11,15 @@ const groupMethodSuite = { name: 'Group', description: 'Group Method: ' + - 'rudderanalytics.group(groupId, [traits], [options], [callback]);' + + 'rudderanalytics.group(groupId, [traits], [apiOptions], [callback]);' + 'rudderanalytics.group(groupId, [traits], [callback]);' + 'rudderanalytics.group(groupId, [callback]);' + - 'rudderanalytics.group(traits, [options], [callback]);' + + 'rudderanalytics.group(traits, [apiOptions], [callback]);' + 'rudderanalytics.group(traits, [callback]);', testCases: [ { id: 'group1', - description: 'rudderanalytics.group(groupId, traits, options)', + description: 'rudderanalytics.group(groupId, traits, apiOptions)', inputData: [ [true], [ @@ -168,7 +168,7 @@ const groupMethodSuite = { }, { id: 'group4', - description: 'rudderanalytics.group(groupId, null, options)', + description: 'rudderanalytics.group(groupId, null, apiOptions)', inputData: [ [true], [ @@ -237,7 +237,7 @@ const groupMethodSuite = { }, { id: 'group6', - description: 'rudderanalytics.group(traits, options)', + description: 'rudderanalytics.group(traits, apiOptions)', inputData: [ [true], [ diff --git a/packages/sanity-suite/src/testBookSuites/identify.js b/packages/sanity-suite/src/testBookSuites/identify.js index 143522d112..3e402aa3b5 100644 --- a/packages/sanity-suite/src/testBookSuites/identify.js +++ b/packages/sanity-suite/src/testBookSuites/identify.js @@ -13,15 +13,15 @@ const identifyMethodSuite = { name: 'Identify', description: 'Identify Method: ' + - 'rudderanalytics.identify(userId, [traits], [options], [callback]);' + + 'rudderanalytics.identify(userId, [traits], [apiOptions], [callback]);' + 'rudderanalytics.identify(userId, [traits], [callback]);' + 'rudderanalytics.identify(userId, [callback]);' + - 'rudderanalytics.identify(traits, [options], [callback]);' + + 'rudderanalytics.identify(traits, [apiOptions], [callback]);' + 'rudderanalytics.identify(traits, [callback]);', testCases: [ { id: 'identify1', - description: 'rudderanalytics.identify(userId, traits, options)', + description: 'rudderanalytics.identify(userId, traits, apiOptions)', inputData: [ [true], [ @@ -170,7 +170,7 @@ const identifyMethodSuite = { }, { id: 'identify3', - description: 'rudderanalytics.identify(userId, null, options)', + description: 'rudderanalytics.identify(userId, null, apiOptions)', inputData: [ [true], [ @@ -406,7 +406,7 @@ const identifyMethodSuite = { }, { id: 'identify9', - description: 'rudderanalytics.identify(traits, options)', + description: 'rudderanalytics.identify(traits, apiOptions)', inputData: [ [true], [ diff --git a/packages/sanity-suite/src/testBookSuites/page.js b/packages/sanity-suite/src/testBookSuites/page.js index e3bdc5b10c..86978bc29e 100644 --- a/packages/sanity-suite/src/testBookSuites/page.js +++ b/packages/sanity-suite/src/testBookSuites/page.js @@ -16,19 +16,19 @@ const pageMethodSuite = { name: 'Page', description: 'Page Method: ' + - 'rudderanalytics.page(category, name, [properties], [options], [callback]);' + + 'rudderanalytics.page(category, name, [properties], [apiOptions], [callback]);' + 'rudderanalytics.page(category, name, [properties], [callback]);' + 'rudderanalytics.page(category, name, [callback]);' + - 'rudderanalytics.page(name, [properties], [options], [callback]);' + + 'rudderanalytics.page(name, [properties], [apiOptions], [callback]);' + 'rudderanalytics.page(name, [properties], [callback]);' + 'rudderanalytics.page(name, [callback]);' + - 'rudderanalytics.page(properties, [options], [callback]);' + + 'rudderanalytics.page(properties, [apiOptions], [callback]);' + 'rudderanalytics.page(properties, [callback]);' + 'rudderanalytics.page([callback]);', testCases: [ { id: 'page1', - description: 'rudderanalytics.page(category, name, properties, options)', + description: 'rudderanalytics.page(category, name, properties, apiOptions)', inputData: [ [true], [ @@ -177,7 +177,7 @@ const pageMethodSuite = { }, { id: 'page4', - description: 'rudderanalytics.page(category, name, null, options)', + description: 'rudderanalytics.page(category, name, null, apiOptions)', inputData: [ [true], [ @@ -268,7 +268,7 @@ const pageMethodSuite = { }, { id: 'page9', - description: 'rudderanalytics.page(name, properties, options)', + description: 'rudderanalytics.page(name, properties, apiOptions)', inputData: [ [true], [ @@ -381,7 +381,7 @@ const pageMethodSuite = { }, { id: 'page11', - description: 'rudderanalytics.page(properties, options)', + description: 'rudderanalytics.page(properties, apiOptions)', inputData: [ [true], [ diff --git a/packages/sanity-suite/src/testBookSuites/track.js b/packages/sanity-suite/src/testBookSuites/track.js index 49a26ea4b9..18d7d985c4 100644 --- a/packages/sanity-suite/src/testBookSuites/track.js +++ b/packages/sanity-suite/src/testBookSuites/track.js @@ -10,13 +10,13 @@ const trackMethodSuite = { name: 'Track', description: 'Track Method: ' + - 'rudderanalytics.track(event, [properties], [options], [callback]);' + + 'rudderanalytics.track(event, [properties], [apiOptions], [callback]);' + 'rudderanalytics.track(event, [properties], [callback]);' + 'rudderanalytics.track(event, [callback]);', testCases: [ { id: 'track1', - description: 'rudderanalytics.track(event, properties, options)', + description: 'rudderanalytics.track(event, properties, apiOptions)', inputData: [ [true], [ @@ -279,7 +279,7 @@ const trackMethodSuite = { }, { id: 'track4', - description: 'rudderanalytics.track(event, null, options)', + description: 'rudderanalytics.track(event, null, apiOptions)', inputData: [ [true], [ From 60364f9e23cdfc3fefb177e481e49295f3488b2b Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 20:32:49 +0530 Subject: [PATCH 16/24] chore: fix type --- .../analytics-js-common/src/utilities/eventMethodOverloads.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index 34ae27b1ce..2303adfbda 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -30,7 +30,7 @@ export type IdentifyCallOptions = { }; export type AliasCallOptions = { - to?: string; + to: string; from?: string; options?: Nullable; callback?: ApiCallback; @@ -321,8 +321,6 @@ const aliasArgumentsToCallOptions = ( // Also, to clone the incoming object type arguments if (isDefined(payload.to)) { payload.to = tryStringify(payload.to) as typeof payload.to; - } else { - payload.to = undefined; } if (isDefined(payload.from)) { From ce643750817622eee25644a2f4a9666912ec7306 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 21:17:25 +0530 Subject: [PATCH 17/24] fix: remove unwanted code and improve coverage --- .../src/utilities/eventMethodOverloads.ts | 12 ++---------- .../__tests__/deviceModeDestinations/utils.test.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts index 2303adfbda..10eb0b38f5 100644 --- a/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts +++ b/packages/analytics-js-common/src/utilities/eventMethodOverloads.ts @@ -257,11 +257,7 @@ const identifyArgumentsToCallOptions = ( // Rest of the code is just to clean up undefined values // and set some proper defaults // Also, to clone the incoming object type arguments - if (isDefined(payload.userId)) { - payload.userId = tryStringify(payload.userId); - } else { - payload.userId = undefined; - } + payload.userId = tryStringify(payload.userId); if (isObjectLiteralAndNotNull(payload.traits)) { payload.traits = clone(payload.traits); @@ -387,11 +383,7 @@ const groupArgumentsToCallOptions = ( // Rest of the code is just to clean up undefined values // and set some proper defaults // Also, to clone the incoming object type arguments - if (isDefined(payload.groupId)) { - payload.groupId = tryStringify(payload.groupId); - } else { - payload.groupId = undefined; - } + payload.groupId = tryStringify(payload.groupId); if (isObjectLiteralAndNotNull(payload.traits)) { payload.traits = clone(payload.traits); diff --git a/packages/analytics-js-plugins/__tests__/deviceModeDestinations/utils.test.ts b/packages/analytics-js-plugins/__tests__/deviceModeDestinations/utils.test.ts index c8c89131fc..0e2c0a9315 100644 --- a/packages/analytics-js-plugins/__tests__/deviceModeDestinations/utils.test.ts +++ b/packages/analytics-js-plugins/__tests__/deviceModeDestinations/utils.test.ts @@ -113,6 +113,12 @@ describe('deviceModeDestinations utils', () => { identify = () => {}; group = () => {}; alias = () => {}; + getAnonymousId = () => 'anonymousId'; + getUserId = () => 'userId'; + getUserTraits = () => ({ trait1: 'value1' }); + getGroupId = () => 'groupId'; + getGroupTraits = () => ({ trait2: 'value2' }); + getSessionId = () => 'sessionId'; } // create two mock instances to later choose based on the write key @@ -204,6 +210,13 @@ describe('deviceModeDestinations utils', () => { getSessionId: expect.any(Function), }); + expect(destinationInstance.analytics.getAnonymousId()).toEqual('anonymousId'); + expect(destinationInstance.analytics.getUserId()).toEqual('userId'); + expect(destinationInstance.analytics.getUserTraits()).toEqual({ trait1: 'value1' }); + expect(destinationInstance.analytics.getGroupId()).toEqual('groupId'); + expect(destinationInstance.analytics.getGroupTraits()).toEqual({ trait2: 'value2' }); + expect(destinationInstance.analytics.getSessionId()).toEqual('sessionId'); + // Making sure that the call gets forwarded to the correct instance const pageCallSpy = jest.spyOn(mockAnalyticsInstance_writeKey2, 'page'); destinationInstance.analytics.page(); From 5f397fa0e174a6cdef91e3e1260d4eb4a6d85f34 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 21:41:49 +0530 Subject: [PATCH 18/24] chore: fix package script --- package.json | 2 +- packages/analytics-js-service-worker/package.json | 2 +- packages/analytics-v1.1/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7186fa3b3f..c28f5bf335 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build:browser:modern": "nx run-many -t build:browser:modern", "build:package": "nx run-many -t build:package", "build:package:modern": "nx run-many -t build:package:modern", - "package": "nx run-many -t pack", + "package": "nx run-many -t package", "test": "nx run-many -t test", "test:ci": "nx run-many -t test --configuration=ci --runInBand --maxWorkers=1 --forceExit", "check:lint:ci": "nx run-many -t check:lint:ci --verbose", diff --git a/packages/analytics-js-service-worker/package.json b/packages/analytics-js-service-worker/package.json index 398242db22..195d9e5548 100644 --- a/packages/analytics-js-service-worker/package.json +++ b/packages/analytics-js-service-worker/package.json @@ -85,7 +85,7 @@ "check:duplicates": "jscpd src", "check:security": "npm audit --recursive --audit-level=high", "check:pub": "npx publint", - "package": "cd dist/npm && npm pack --pack-destination ../../", + "package": "npm pack", "release": "npm publish" }, "dependencies": { diff --git a/packages/analytics-v1.1/package.json b/packages/analytics-v1.1/package.json index 5618f03f0f..6a7c3b2846 100644 --- a/packages/analytics-v1.1/package.json +++ b/packages/analytics-v1.1/package.json @@ -63,7 +63,7 @@ "build:browser:bundle-size": "VISUALIZER=true npm run build:browser", "build:browser:modern:bundle-size": "VISUALIZER=true npm run build:browser:modern", "build:npm:dev": "rollup --config rollup-configs/rollup.sdk.npm.mjs --environment VERSION:$npm_package_version,NPM", - "package": "cd dist/npm && npm pack --pack-destination ../../", + "package": "npm pack", "release": "npm publish" }, "keywords": [ From 595f2b669871438bca3489141d62a8694ec463bd Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 22:09:44 +0530 Subject: [PATCH 19/24] chore: update precommit hook to run for only affected projects --- nx.json | 17 +++++++++++++++++ package.json | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/nx.json b/nx.json index 3a3411be93..cfbb025dda 100644 --- a/nx.json +++ b/nx.json @@ -73,6 +73,23 @@ "check:pub": { "inputs": ["{projectRoot}/package.json"], "cache": true + }, + "test:pre-commit:affected": { + "inputs": ["default", "^test"], + "cache": true + }, + "check:size:build:pre-commit:affected": { + "inputs": ["default", "^production"], + "cache": true + }, + "check:size:json:pre-commit:affected": { + "inputs": [ + "default", + "^production", + "{projectRoot}/.size-limit.js", + "{projectRoot}/.size-limit.mjs" + ], + "cache": true } }, "generators": { diff --git a/package.json b/package.json index c28f5bf335..58124937f1 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,15 @@ "build:package:modern": "nx run-many -t build:package:modern", "package": "nx run-many -t package", "test": "nx run-many -t test", + "test:pre-commit:affected": "nx affected -t test --base=HEAD", "test:ci": "nx run-many -t test --configuration=ci --runInBand --maxWorkers=1 --forceExit", "check:lint:ci": "nx run-many -t check:lint:ci --verbose", "check:lint": "nx run-many -t check:lint --verbose", "check:size": "nx run-many -t check:size --verbose", "check:size:build": "nx run-many -t check:size:build", + "check:size:build:pre-commit:affected": "nx affected -t check:size:build --base=HEAD", "check:size:json": "npm run check:size:json:ci -- --verbose", + "check:size:json:pre-commit:affected": "nx affected -t check:size:json --base=HEAD --verbose", "check:size:json:ci": "nx run-many -t check:size:json", "check:circular": "nx run-many -t check:circular --verbose", "check:support": "NODE_ENV=production npx browserslist --mobile-to-desktop", @@ -37,7 +40,7 @@ "format": "prettier --write .", "lint:fix": "eslint . --fix", "prepare": "husky", - "pre-commit": "npm run test && npm run check:size:build && npm run check:size:json && npx lint-staged", + "pre-commit": "npm run test:pre-commit:affected && npm run check:size:build:pre-commit:affected && npm run check:size:json:pre-commit:affected && npx lint-staged", "commit-msg": "commitlint --edit", "commit": "git-cz", "postinstall": "patch-package", From 7fc1db30af77fd4cd8f278c3dbec56ace4795402 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 22:34:56 +0530 Subject: [PATCH 20/24] chore: run scripts only for affected packages --- ...security-code-quality-and-bundle-size-checks.yml | 13 +++++++++---- .github/workflows/unit-tests-and-lint.yml | 4 ++++ package.json | 10 +++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/security-code-quality-and-bundle-size-checks.yml b/.github/workflows/security-code-quality-and-bundle-size-checks.yml index 6e5852f30a..3151ad40e9 100644 --- a/.github/workflows/security-code-quality-and-bundle-size-checks.yml +++ b/.github/workflows/security-code-quality-and-bundle-size-checks.yml @@ -26,10 +26,11 @@ jobs: uses: rudderlabs/github-action-check-size-limit@v2.10.0 env: HUSKY: 0 + BASE_REF: ${{ github.event.pull_request.base.ref }} with: github_token: ${{ secrets.GITHUB_TOKEN }} install_script: setup:ci - build_script: check:size:build + build_script: check:size:build:ci clean_script: clean script: npm run check:size:json:ci --silent -- --output-style=static --silent=true --exclude=@rudderstack/analytics-js-sanity-suite is_monorepo: true @@ -59,13 +60,17 @@ jobs: npm run check:duplicates - name: Build the project + env: + BASE_REF: ${{ github.event.pull_request.base.ref }} run: | - npm run build - npm run build:modern + npm run build:ci + npm run build:modern:ci - name: Execute package linting checks + env: + BASE_REF: ${{ github.event.pull_request.base.ref }} run: | - npm run check:pub + npm run check:pub:ci - name: Execute security checks run: | diff --git a/.github/workflows/unit-tests-and-lint.yml b/.github/workflows/unit-tests-and-lint.yml index 8696e11000..e7a875c74b 100644 --- a/.github/workflows/unit-tests-and-lint.yml +++ b/.github/workflows/unit-tests-and-lint.yml @@ -35,6 +35,8 @@ jobs: npm run setup:ci - name: Execute unit tests + env: + BASE_REF: ${{ github.event.pull_request.base.ref || 'HEAD' }} run: | npm run test:ci @@ -46,6 +48,8 @@ jobs: files: ./packages/analytics-js/reports/coverage/clover.xml,./packages/analytics-js-common/reports/coverage/clover.xml,./packages/analytics-js-integrations/reports/coverage/clover.xml,./packages/analytics-js-plugins/reports/coverage/clover.xml,./packages/analytics-js-service-worker/reports/coverage/clover.xml,./packages/analytics-v1.1/reports/coverage/clover.xml,./packages/analytics-js-cookies/reports/coverage/clover.xml - name: Execute linting check + env: + BASE_REF: ${{ github.event.pull_request.base.ref || 'HEAD' }} run: | npm run check:lint:ci diff --git a/package.json b/package.json index 58124937f1..d78c54d771 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,9 @@ "start": "nx run-many --targets=start --parallel=3 --projects=@rudderstack/analytics-js-integrations,@rudderstack/analytics-js-plugins,@rudderstack/analytics-js", "start:modern": "nx run-many --targets=start-modern --parallel=3 --projects=@rudderstack/analytics-js-integrations,@rudderstack/analytics-js-plugins,@rudderstack/analytics-js", "build": "nx run-many -t build", + "build:ci": "nx affected -t build --base=$BASE_REF", "build:modern": "nx run-many -t build:modern", + "build:modern:ci": "nx affected -t build:modern --base=$BASE_REF", "build:browser": "nx run-many -t build:browser", "build:browser:modern": "nx run-many -t build:browser:modern", "build:package": "nx run-many -t build:package", @@ -22,21 +24,23 @@ "package": "nx run-many -t package", "test": "nx run-many -t test", "test:pre-commit:affected": "nx affected -t test --base=HEAD", - "test:ci": "nx run-many -t test --configuration=ci --runInBand --maxWorkers=1 --forceExit", - "check:lint:ci": "nx run-many -t check:lint:ci --verbose", + "test:ci": "nx affected -t test --base=$BASE_REF --configuration=ci --runInBand --maxWorkers=1 --forceExit", + "check:lint:ci": "nx affected -t check:lint:ci --base=$BASE_REF --verbose", "check:lint": "nx run-many -t check:lint --verbose", "check:size": "nx run-many -t check:size --verbose", "check:size:build": "nx run-many -t check:size:build", + "check:size:build:ci": "nx affected -t check:size:build --base=$BASE_REF", "check:size:build:pre-commit:affected": "nx affected -t check:size:build --base=HEAD", "check:size:json": "npm run check:size:json:ci -- --verbose", "check:size:json:pre-commit:affected": "nx affected -t check:size:json --base=HEAD --verbose", - "check:size:json:ci": "nx run-many -t check:size:json", + "check:size:json:ci": "nx affected -t check:size:json --base=$BASE_REF", "check:circular": "nx run-many -t check:circular --verbose", "check:support": "NODE_ENV=production npx browserslist --mobile-to-desktop", "check:support:modern": "NODE_ENV=modern npx browserslist --mobile-to-desktop", "check:duplicates": "nx run-many -t check:duplicates --verbose", "check:security": "npm audit --recursive --audit-level=high", "check:pub": "nx run-many -t check:pub --verbose", + "check:pub:ci": "nx affected -t check:pub --verbose --base=$BASE_REF", "format": "prettier --write .", "lint:fix": "eslint . --fix", "prepare": "husky", From f8585de03d89abbae8b5795c0f7b05e8d8886902 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 22:36:11 +0530 Subject: [PATCH 21/24] chore: fix setup:ci script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d78c54d771..17e855cc07 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ ], "scripts": { "setup": "npm i --include=optional && npm run build:package:modern", - "setup:ci": "npm ci && npm i @nx/nx-linux-x64-gnu && npm run build:package", + "setup:ci": "npm ci && npm i @nx/nx-linux-x64-gnu && npm run build:package:modern", "clean": "nx run-many -t clean && nx reset && git clean -xdf node_modules", "clean:cache": "rimraf -rf ./node_modules/.cache && rimraf -rf ./.nx/cache", "start": "nx run-many --targets=start --parallel=3 --projects=@rudderstack/analytics-js-integrations,@rudderstack/analytics-js-plugins,@rudderstack/analytics-js", From d56642770e7b991d985899b7dbec5cb7c84ecbf1 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 22:39:21 +0530 Subject: [PATCH 22/24] chore: fix base ref --- .../security-code-quality-and-bundle-size-checks.yml | 6 +++--- .github/workflows/unit-tests-and-lint.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/security-code-quality-and-bundle-size-checks.yml b/.github/workflows/security-code-quality-and-bundle-size-checks.yml index 3151ad40e9..09843859de 100644 --- a/.github/workflows/security-code-quality-and-bundle-size-checks.yml +++ b/.github/workflows/security-code-quality-and-bundle-size-checks.yml @@ -26,7 +26,7 @@ jobs: uses: rudderlabs/github-action-check-size-limit@v2.10.0 env: HUSKY: 0 - BASE_REF: ${{ github.event.pull_request.base.ref }} + BASE_REF: ${{ github.event.pull_request.base.sha }} with: github_token: ${{ secrets.GITHUB_TOKEN }} install_script: setup:ci @@ -61,14 +61,14 @@ jobs: - name: Build the project env: - BASE_REF: ${{ github.event.pull_request.base.ref }} + BASE_REF: ${{ github.event.pull_request.base.sha }} run: | npm run build:ci npm run build:modern:ci - name: Execute package linting checks env: - BASE_REF: ${{ github.event.pull_request.base.ref }} + BASE_REF: ${{ github.event.pull_request.base.sha }} run: | npm run check:pub:ci diff --git a/.github/workflows/unit-tests-and-lint.yml b/.github/workflows/unit-tests-and-lint.yml index e7a875c74b..468394af69 100644 --- a/.github/workflows/unit-tests-and-lint.yml +++ b/.github/workflows/unit-tests-and-lint.yml @@ -36,7 +36,7 @@ jobs: - name: Execute unit tests env: - BASE_REF: ${{ github.event.pull_request.base.ref || 'HEAD' }} + BASE_REF: ${{ github.event.pull_request.base.sha || 'HEAD' }} run: | npm run test:ci @@ -49,7 +49,7 @@ jobs: - name: Execute linting check env: - BASE_REF: ${{ github.event.pull_request.base.ref || 'HEAD' }} + BASE_REF: ${{ github.event.pull_request.base.sha || 'HEAD' }} run: | npm run check:lint:ci From bc996f5aff03f77210c27dde783f56aebc20b958 Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 22:48:01 +0530 Subject: [PATCH 23/24] chore: fetch all commits --- .../security-code-quality-and-bundle-size-checks.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/security-code-quality-and-bundle-size-checks.yml b/.github/workflows/security-code-quality-and-bundle-size-checks.yml index 09843859de..d0cb8ace65 100644 --- a/.github/workflows/security-code-quality-and-bundle-size-checks.yml +++ b/.github/workflows/security-code-quality-and-bundle-size-checks.yml @@ -15,6 +15,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Node uses: actions/setup-node@v4 @@ -42,6 +44,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Node uses: actions/setup-node@v4 From 811b6070043568cd49b9e8d22db63719535ef1ff Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 16 Jul 2024 23:06:49 +0530 Subject: [PATCH 24/24] chore: restore size build behavior --- .../security-code-quality-and-bundle-size-checks.yml | 5 +---- package.json | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/security-code-quality-and-bundle-size-checks.yml b/.github/workflows/security-code-quality-and-bundle-size-checks.yml index d0cb8ace65..6af603bcbe 100644 --- a/.github/workflows/security-code-quality-and-bundle-size-checks.yml +++ b/.github/workflows/security-code-quality-and-bundle-size-checks.yml @@ -15,8 +15,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup Node uses: actions/setup-node@v4 @@ -28,11 +26,10 @@ jobs: uses: rudderlabs/github-action-check-size-limit@v2.10.0 env: HUSKY: 0 - BASE_REF: ${{ github.event.pull_request.base.sha }} with: github_token: ${{ secrets.GITHUB_TOKEN }} install_script: setup:ci - build_script: check:size:build:ci + build_script: check:size:build clean_script: clean script: npm run check:size:json:ci --silent -- --output-style=static --silent=true --exclude=@rudderstack/analytics-js-sanity-suite is_monorepo: true diff --git a/package.json b/package.json index 17e855cc07..07647b15ba 100644 --- a/package.json +++ b/package.json @@ -29,11 +29,10 @@ "check:lint": "nx run-many -t check:lint --verbose", "check:size": "nx run-many -t check:size --verbose", "check:size:build": "nx run-many -t check:size:build", - "check:size:build:ci": "nx affected -t check:size:build --base=$BASE_REF", "check:size:build:pre-commit:affected": "nx affected -t check:size:build --base=HEAD", "check:size:json": "npm run check:size:json:ci -- --verbose", "check:size:json:pre-commit:affected": "nx affected -t check:size:json --base=HEAD --verbose", - "check:size:json:ci": "nx affected -t check:size:json --base=$BASE_REF", + "check:size:json:ci": "nx run-many -t check:size:json", "check:circular": "nx run-many -t check:circular --verbose", "check:support": "NODE_ENV=production npx browserslist --mobile-to-desktop", "check:support:modern": "NODE_ENV=modern npx browserslist --mobile-to-desktop",