From 65f8ca4f67325cccb61dd791a7b06093d7956c2d Mon Sep 17 00:00:00 2001 From: Esme Ling Date: Fri, 2 Aug 2024 12:42:25 -0700 Subject: [PATCH] Send ownerId in onReady event --- demos/demo-react-ts/src/hooks/useCti.ts | 1 + src/CallingExtensions.js | 2 +- src/IFrameManager.js | 15 ++++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/demos/demo-react-ts/src/hooks/useCti.ts b/demos/demo-react-ts/src/hooks/useCti.ts index 4bfb390..86f6d9a 100644 --- a/demos/demo-react-ts/src/hooks/useCti.ts +++ b/demos/demo-react-ts/src/hooks/useCti.ts @@ -191,6 +191,7 @@ export const useCti = ( }, onCreateEngagementSucceeded: (data: any, _rawEvent: any) => { const { engagementId } = data; + setEngagementId(engagementId); }, onCreateEngagementFailed: (data: any, _rawEvent: any) => { diff --git a/src/CallingExtensions.js b/src/CallingExtensions.js index 4f8e7cf..1bbb4b9 100644 --- a/src/CallingExtensions.js +++ b/src/CallingExtensions.js @@ -60,7 +60,7 @@ class CallingExtensions { initialized(userData) { this.sendMessage({ type: messageType.INITIALIZED, - data: { ...userData }, + data: userData, }); } diff --git a/src/IFrameManager.js b/src/IFrameManager.js index 738088e..fc63be7 100644 --- a/src/IFrameManager.js +++ b/src/IFrameManager.js @@ -77,9 +77,7 @@ class IFrameManager { } static createIFrame(iFrameOptions, onLoadCallback) { - const { - src, width, height, hostElementSelector, - } = iFrameOptions; + const { src, width, height, hostElementSelector } = iFrameOptions; if (!src || !width || !height || !hostElementSelector) { throw new Error( @@ -181,9 +179,7 @@ class IFrameManager { onMessage(event) { const { data, origin } = event; - const { - type, engagementId, portalId, userId, - } = event.data; + const { type, engagementId, portalId, userId, ownerId } = event.data; if (type === messageType.SYNC) { // The iFrame host can send this message multiple times, don't respond more than once if (!this.isReady) { @@ -200,7 +196,12 @@ class IFrameManager { this.destinationHost = hostUrl || this.destinationHost; this.logDebugMessage(prefix, debugMessageType.FROM_HUBSPOT, type, data); this.sendMessage(message); - this.onReady({ engagementId, portalId, userId }); + this.onReady({ + engagementId, + portalId, + userId, + ownerId, + }); } return; }