regression: Livechat UiKit button not working (#29652)

pull/29169/head^2
Murtaza Patrawala 3 years ago committed by GitHub
parent 6923838fe9
commit dbc79dd3ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      apps/meteor/server/models/raw/LivechatRooms.ts
  2. 10
      packages/ddp-client/src/livechat/LivechatClientImpl.ts
  3. 5
      packages/ddp-client/src/livechat/types/LivechatSDK.ts
  4. 23
      packages/livechat/src/lib/uiKit.js
  5. 13
      packages/rest-typings/src/apps/index.ts

@ -2044,13 +2044,13 @@ export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILive
'metrics.response.ft': analyticsData.firstResponseTime,
}),
},
$inc: {
...(analyticsData && {
...(analyticsData && {
$inc: {
'metrics.response.total': 1,
'metrics.response.tt': analyticsData.responseTime as number,
'metrics.reaction.tt': analyticsData.reactionTime as number,
}),
},
},
}),
};
// livechat analytics : update last message timestamps

@ -324,6 +324,16 @@ export class LivechatClientImpl extends DDPSDK implements LivechatStream, Livech
});
}
async sendUiInteraction(
payload: OperationParams<'POST', '/apps/ui.interaction/:id'>,
appId: string,
): Promise<Serialized<OperationResult<'POST', '/apps/ui.interaction/:id'>>> {
if (!this.token) {
throw new Error('Invalid token');
}
return this.rest.post(`/apps/ui.interaction/${appId}`, payload, { headers: { 'x-visitor-token': this.token } });
}
// API DELETE
deleteMessage(id: string, { rid }: { rid: string }): Promise<Serialized<OperationResult<'DELETE', '/v1/livechat/message/:_id'>>> {

@ -95,4 +95,9 @@ export interface LivechatEndpoints {
id: string,
args: OperationParams<'PUT', '/v1/livechat/message/:_id'>,
): Promise<Serialized<OperationResult<'PUT', '/v1/livechat/message/:_id'>>>;
sendUiInteraction(
payload: OperationParams<'POST', '/apps/ui.interaction/:id'>,
appId: string,
): Promise<Serialized<OperationResult<'POST', '/apps/ui.interaction/:id'>>>;
}

@ -104,16 +104,19 @@ export const triggerAction = async ({ appId, type, actionId, rid, mid, viewId, c
try {
const result = await Promise.race([
Livechat.rest.post(`/apps/ui.interaction/${appId}`, {
type,
actionId,
rid,
mid,
viewId,
container,
triggerId,
payload,
}),
Livechat.sendUiInteraction(
{
type,
actionId,
rid,
mid,
viewId,
container,
triggerId,
payload,
},
appId,
),
new Promise((_, reject) => {
setTimeout(() => {

@ -251,4 +251,17 @@ export type AppsEndpoints = {
app: App;
};
};
'/apps/ui.interaction/:id': {
POST: (params: {
type: string;
actionId: string;
rid: string;
mid: string;
viewId: string;
container: string;
triggerId: string;
payload: any;
}) => any;
};
};

Loading…
Cancel
Save