From 9ff31d0e832d76a85cb25366d030491d800acc7d Mon Sep 17 00:00:00 2001 From: Abel Toledano Date: Mon, 13 Jan 2025 18:10:33 +0100 Subject: [PATCH] fix(setQualtricsProperties): change type to match the one expected by iOS app (#189) https://github.com/Telefonica/webview-bridge/issues/179#issuecomment-2587641960 --- README.md | 6 +++--- src/__tests__/qualtrics-test.ts | 8 ++++---- src/qualtrics.ts | 13 ++++--------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index b4aa853..2d3cce9 100644 --- a/README.md +++ b/README.md @@ -1526,9 +1526,9 @@ Method to set properties in Qualtrics SDK before displaying a survey. ```ts setQualtricsProperties: ({ - stringProperties: Array>; - numberProperties: Array>; - dateTimePropertyKeys: Array; + stringProperties?: {[key: string]: string}; + numberProperties?: {[key: string]: number}; + dateTimePropertyKeys?: Array; }) => Promise; ``` diff --git a/src/__tests__/qualtrics-test.ts b/src/__tests__/qualtrics-test.ts index 689375a..9b73c0d 100644 --- a/src/__tests__/qualtrics-test.ts +++ b/src/__tests__/qualtrics-test.ts @@ -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'], }); }, @@ -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'], }); diff --git a/src/qualtrics.ts b/src/qualtrics.ts index e925b00..a518354 100644 --- a/src/qualtrics.ts +++ b/src/qualtrics.ts @@ -10,18 +10,13 @@ export const displayQualtricsIntercept = ({ payload: {interceptId}, }); -type QualtricsProperty = { - key: string; - value: T; -}; - export const setQualtricsProperties = ({ - stringProperties = [], - numberProperties = [], + stringProperties = {}, + numberProperties = {}, dateTimePropertyKeys = [], }: { - stringProperties?: Array>; - numberProperties?: Array>; + stringProperties?: {[key: string]: string}; + numberProperties?: {[key: string]: number}; dateTimePropertyKeys?: Array; }): Promise => postMessageToNativeApp({