diff --git a/packages/analytics-core/test/identify.test.ts b/packages/analytics-core/test/identify.test.ts index 324d145f9..ca264cf87 100644 --- a/packages/analytics-core/test/identify.test.ts +++ b/packages/analytics-core/test/identify.test.ts @@ -186,4 +186,26 @@ describe('Identify class', () => { expect(identify.getUserProperties()).toStrictEqual(expectedProperties); }); + + test('should allow to set an array of objects', () => { + const identify = new Identify(); + const propertyValue = [ + { + key1: 'value1', + key2: 'value2', + }, + { + key1: 'value3', + key2: 'value4', + }, + ]; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore bypassing ts rules to test unexpected input + identify.set('PROPERTY_NAME', propertyValue); + const expectedProperties = { + [IdentifyOperation.SET]: { PROPERTY_NAME: propertyValue }, + }; + + expect(identify.getUserProperties()).toStrictEqual(expectedProperties); + }); }); diff --git a/packages/analytics-types/src/event.ts b/packages/analytics-types/src/event.ts index 83ee9bbf9..da5cd635c 100644 --- a/packages/analytics-types/src/event.ts +++ b/packages/analytics-types/src/event.ts @@ -39,7 +39,8 @@ export type ValidPropertyType = | string | boolean | Array - | { [key: string]: ValidPropertyType }; + | { [key: string]: ValidPropertyType } + | Array<{ [key: string]: ValidPropertyType }>; interface BaseOperationConfig { [key: string]: ValidPropertyType;