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

Add SNS logpoints #152

Merged
merged 13 commits into from
Jul 29, 2022
4 changes: 2 additions & 2 deletions build/62.chunk.95227.js → build/62.chunk.67ade.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/62.chunk.67ade.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion build/62.chunk.95227.js.map

This file was deleted.

2 changes: 0 additions & 2 deletions build/63.chunk.61a2a.js

This file was deleted.

1 change: 0 additions & 1 deletion build/63.chunk.61a2a.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions build/63.chunk.6eaaf.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/63.chunk.6eaaf.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/bundle.fa2ae.js → build/bundle.2f360.js

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

2 changes: 1 addition & 1 deletion build/bundle.fa2ae.js.map → build/bundle.2f360.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html><head><meta charset="utf-8"><title></title><meta name="viewport" content="width=device-width,initial-scale=1"></head><body><script src="livechat/0.chunk.16385.js"></script><script src="livechat/polyfills.caf00.js"></script><script src="livechat/vendors~bundle.chunk.76887.js"></script><script src="livechat/bundle.fa2ae.js"></script></body></html>
<!doctype html><html><head><meta charset="utf-8"><title></title><meta name="viewport" content="width=device-width,initial-scale=1"></head><body><script src="livechat/0.chunk.16385.js"></script><script src="livechat/polyfills.caf00.js"></script><script src="livechat/vendors~bundle.chunk.76887.js"></script><script src="livechat/bundle.2f360.js"></script></body></html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
"dependencies": {
"@kossnocorp/desvg": "^0.2.0",
"@rocket.chat/sdk": "git+https://github.com/WideChat/Rocket.Chat.js.SDK.git#multiple-clients",
"@rocket.chat/sdk": "git+https://github.com/WideChat/Rocket.Chat.js.SDK.git#sns_logger_widget",
"@rocket.chat/ui-kit": "^0.14.1",
"aws4-browser": "^1.0.0",
"crypto-js": "^4.1.1",
Expand Down
26 changes: 25 additions & 1 deletion src/components/Messages/Message/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import format from 'date-fns/format';
import isToday from 'date-fns/isToday';
import { h } from 'preact';

import { Livechat } from '../../../api';
import I18n from '../../../i18n';
import { handleTranscript } from '../../../lib/transcript';
import { isMobile } from '../../../lib/util';
Expand Down Expand Up @@ -36,11 +37,34 @@ import {
import styles from './styles.scss';

const onClickFeedback = () => {
const { postChatUrl } = store.state;
const { postChatUrl, room: { _id: rid } = {} } = store.state;

const loggerPayload = {
room_id: rid,
category: 'Survey',
action: 'link_clicked',
properties: {},
event_type: 'customer_action',
timestamp: new Date(),
};
Livechat.sendLogsToSns(loggerPayload);

window.open(postChatUrl, '_blank');
};

const onClickTranscript = async () => {
const { room: { _id: rid } = {} } = store.state;

const loggerPayload = {
room_id: rid,
category: 'Transcript Download',
action: 'selected',
properties: {},
event_type: 'customer_action',
timestamp: new Date(),
};
Livechat.sendLogsToSns(loggerPayload);

await handleTranscript();
};

Expand Down
12 changes: 12 additions & 0 deletions src/lib/idleTimeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ export const handleIdleTimeout = async (idleTimeoutConfig) => {
const { token, room: { _id: rid } = {} } = store.state;
logger.info('Closing chat on widget timeout');

const loggerPayload = {
room_id: rid,
category: 'Chat Session',
action: 'closed',
properties: {
close_method: 'timeout',
},
event_type: 'session',
timestamp: new Date(),
};
Livechat.sendLogsToSns(loggerPayload);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ear-dev Here close_method is timeout, but it does not say using app or widget. Should we add one more property for it?

Copy link

@ear-dev ear-dev Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shailesh351 do you mean webApp vs. mobileApp? Or do you mean the timeout was set by the widget vs. set by the Salesforce app?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And.... are we distinguishing between escalated timeout vs. visitor abandonment timeout?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ear-dev I mean the session got timed out from widget timer or timer running in the RC App

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And.... are we distinguishing between escalated timeout vs. visitor abandonment timeout?

The log point for escalated timeout will be in the App

Copy link

@ear-dev ear-dev Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Shailesh351

We only use the timer in the app, so I think this is fine because I do not suspect that we will ever want to use the timer in the widget.

My only question is how we will distinguish between VA timeout and SF timeout? I understand that the events come from different sources, but on the back end is there a way to distinguish? Or do we need to add something? i.e. I don't think we have any indication in our payload to distinguish if the event is from the widget, the RC server, or one of the RC.apps?

I'm thinking that the tracking plan is missing a distinction between VA and App timeout, and that's what we should fix...... thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can directly add a log point for the timeout in the SF App for SF timeout. And for the VA timeout may be server will have handle on it or in the SF app we receive close chat event and we can use it somehow for identifying the VA timeout


// Send customer idle timeout message to close chat
if (token && rid) {
await Promise.all([
Expand Down
17 changes: 15 additions & 2 deletions src/routes/Chat/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,20 @@ export class ChatContainer extends Component {

onFinishChat = async () => {
logger.info('User closing chat from modal');
const { composerConfig } = this.props;
const { composerConfig, room: { _id: rid } = {} } = this.props;

const loggerPayload = {
room_id: rid,
category: 'Chat Session',
action: 'closed',
properties: {
close_method: 'chat window',
},
event_type: 'customer_action',
timestamp: new Date(),
};
Livechat.sendLogsToSns(loggerPayload);

if (composerConfig && composerConfig.disableText === CLOSE_CHAT) {
onChatClose();
return;
Expand All @@ -233,7 +246,7 @@ export class ChatContainer extends Component {
return;
}

const { alerts, dispatch, room: { _id: rid } = {} } = this.props;
const { alerts, dispatch } = this.props;

await dispatch({ loading: true });
try {
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1914,9 +1914,9 @@
dependencies:
eslint-plugin-import "^2.17.2"

"@rocket.chat/sdk@git+https://github.com/WideChat/Rocket.Chat.js.SDK.git#multiple-clients":
"@rocket.chat/sdk@git+https://github.com/WideChat/Rocket.Chat.js.SDK.git#sns_logger_widget":
version "1.0.0-alpha.30"
resolved "git+https://github.com/WideChat/Rocket.Chat.js.SDK.git#7c3741eba94d809791d664dfedd934f6afcf12b4"
resolved "git+https://github.com/WideChat/Rocket.Chat.js.SDK.git#2800f584ca769e6d931f2cce072cd57d24f05adf"
dependencies:
js-sha256 "^0.9.0"
lru-cache "^4.1.1"
Expand Down