Skip to content

Commit

Permalink
fix(setQualtricsProperties): change type to match the one expected by…
Browse files Browse the repository at this point in the history
… iOS app (#189)

#179 (comment)
  • Loading branch information
atabel authored Jan 13, 2025
1 parent 11dfd17 commit 9ff31d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1526,9 +1526,9 @@ Method to set properties in Qualtrics SDK before displaying a survey.
```ts
setQualtricsProperties: ({
stringProperties: Array<QualtricsProperty<string>>;
numberProperties: Array<QualtricsProperty<number>>;
dateTimePropertyKeys: Array<string>;
stringProperties?: {[key: string]: string};
numberProperties?: {[key: string]: number};
dateTimePropertyKeys?: Array<string>;
}) => Promise<void>;
```
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/qualtrics-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ test('setQualtricsProperties', async () => {
checkMessage: (msg) => {
expect(msg.type).toBe('SET_QUALTRICS_PROPERTIES');
expect(msg.payload).toEqual({
stringProperties: [{key: 'stringKey', value: 'stringValue'}],
numberProperties: [{key: 'numberKey', value: 42}],
stringProperties: {stringKey: 'stringValue'},
numberProperties: {numberKey: 42},
dateTimePropertyKeys: ['dateTimeKey'],
});
},
Expand All @@ -43,8 +43,8 @@ test('setQualtricsProperties', async () => {
});

const res = await setQualtricsProperties({
stringProperties: [{key: 'stringKey', value: 'stringValue'}],
numberProperties: [{key: 'numberKey', value: 42}],
stringProperties: {stringKey: 'stringValue'},
numberProperties: {numberKey: 42},
dateTimePropertyKeys: ['dateTimeKey'],
});

Expand Down
13 changes: 4 additions & 9 deletions src/qualtrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ export const displayQualtricsIntercept = ({
payload: {interceptId},
});

type QualtricsProperty<T> = {
key: string;
value: T;
};

export const setQualtricsProperties = ({
stringProperties = [],
numberProperties = [],
stringProperties = {},
numberProperties = {},
dateTimePropertyKeys = [],
}: {
stringProperties?: Array<QualtricsProperty<string>>;
numberProperties?: Array<QualtricsProperty<number>>;
stringProperties?: {[key: string]: string};
numberProperties?: {[key: string]: number};
dateTimePropertyKeys?: Array<string>;
}): Promise<void> =>
postMessageToNativeApp({
Expand Down

0 comments on commit 9ff31d0

Please sign in to comment.