Skip to content

Commit

Permalink
fix(analytics-types): allow an array of objects as identity value type (
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercy811 authored Nov 5, 2024
1 parent 803613a commit a6ddf9f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/analytics-core/test/identify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
3 changes: 2 additions & 1 deletion packages/analytics-types/src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export type ValidPropertyType =
| string
| boolean
| Array<string | number>
| { [key: string]: ValidPropertyType };
| { [key: string]: ValidPropertyType }
| Array<{ [key: string]: ValidPropertyType }>;

interface BaseOperationConfig {
[key: string]: ValidPropertyType;
Expand Down

0 comments on commit a6ddf9f

Please sign in to comment.