Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send ownerId in onReady event #209

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading