Skip to content

Commit

Permalink
Send ownerId in onReady event (#209)
Browse files Browse the repository at this point in the history
* Send ownerId in onReady event

* 0.6.0-alpha.0
  • Loading branch information
esme authored Aug 5, 2024
1 parent 8d9dc2c commit f0291ad
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
7 changes: 6 additions & 1 deletion demos/demo-minimal-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const state = {
toNumber: "+1234",
userAvailable: false,
userId: 0,
ownerId: 0,
};

const sizeInfo = {
Expand Down Expand Up @@ -47,7 +48,8 @@ function enableButtons(ids) {
const cti = new CallingExtensions({
debugMode: true,
eventHandlers: {
onReady: ({ engagementId, portalId, userId } = {}) => {
onReady: ({ engagementId, portalId, userId, ownerId } = {}) => {
debugger;
cti.initialized({
engagementId,
isLoggedIn: false,
Expand All @@ -66,6 +68,9 @@ const cti = new CallingExtensions({
if (userId) {
state.userId = userId;
}
if (ownerId) {
state.ownerId = ownerId;
}
},
onDialNumber: (data, rawEvent) => {
const { phoneNumber } = data;
Expand Down
1 change: 1 addition & 0 deletions demos/demo-react-ts/src/hooks/useCti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const useCti = (
engagementId?: number;
portalId?: number;
userId?: number;
ownerId?: number;
}) => {
const engagementId = (data && data.engagementId) || 0;

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hubspot/calling-extensions-sdk",
"version": "0.5.1",
"version": "0.6.0-alpha.0",
"description": "A JavaScript SDK for integrating calling apps into HubSpot.",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion src/CallingExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CallingExtensions {
initialized(userData) {
this.sendMessage({
type: messageType.INITIALIZED,
data: { ...userData },
data: userData,
});
}

Expand Down
11 changes: 7 additions & 4 deletions src/IFrameManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,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) {
Expand All @@ -200,7 +198,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;
}
Expand Down

0 comments on commit f0291ad

Please sign in to comment.