diff --git a/README.md b/README.md index 9eb47845..336b6f13 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,8 @@ extensions.userLoggedOut(); const callInfo = { phoneNumber: string, // optional unless call is initiated by the widget - createEngagement: true // whether HubSpot should create an engagement for this call + createEngagement: true, // whether HubSpot should create an engagement for this call + callStartTime: number // optional unless call is initiated by the widget }; extensions.outgoingCall(callInfo); ``` diff --git a/demos/demo-react-ts/src/components/screens/KeypadScreen.tsx b/demos/demo-react-ts/src/components/screens/KeypadScreen.tsx index bb131a49..974b85fb 100644 --- a/demos/demo-react-ts/src/components/screens/KeypadScreen.tsx +++ b/demos/demo-react-ts/src/components/screens/KeypadScreen.tsx @@ -86,11 +86,13 @@ function KeypadScreen({ }; const handleStartCall = useCallback(() => { + const callStartTime = Date.now(); cti.outgoingCall({ createEngagement: true, phoneNumber: dialNumber, + callStartTime, }); - startTimer(Date.now()); + startTimer(callStartTime); handleNextScreen(); }, [cti]); diff --git a/demos/demo-react-ts/test/spec/components/screens/KeypadScreen-test.tsx b/demos/demo-react-ts/test/spec/components/screens/KeypadScreen-test.tsx index 356b1148..3d075319 100644 --- a/demos/demo-react-ts/test/spec/components/screens/KeypadScreen-test.tsx +++ b/demos/demo-react-ts/test/spec/components/screens/KeypadScreen-test.tsx @@ -84,7 +84,7 @@ describe("KeypadScreen", () => { it("Handles start call button click", () => { const { getByRole, getByTestId } = renderWithContext( - + ); const input = getByTestId("VizExInput-Input"); @@ -96,7 +96,12 @@ describe("KeypadScreen", () => { name: /start-call/i, }); button.click(); - expect(cti.outgoingCall).toHaveBeenCalled(); + + expect(cti.outgoingCall).toHaveBeenCalledWith({ + createEngagement: true, + phoneNumber: "+1617", + callStartTime: jasmine.anything(), + }); expect(props.handleNextScreen).toHaveBeenCalled(); }); });