Skip to content

Commit

Permalink
feat(WebexCreateSpace): emit operational metrics in create space comp…
Browse files Browse the repository at this point in the history
…onent
  • Loading branch information
sumit12690 authored and kishorepmr committed Sep 7, 2022
1 parent 74549d4 commit ca2d8b4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/components/WebexCreateSpace/WebexCreateSpace.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {InputField, Button} from '../generic';
import webexComponentClasses from '../helpers';
import WebexSearchPeople from '../WebexSearchPeople/WebexSearchPeople';
import {AdapterContext} from '../hooks/contexts';
import {useMetrics} from '../hooks';

/**
* Webex Create Space Component
Expand Down Expand Up @@ -36,6 +37,8 @@ export default function WebexCreateSpace({
const [alertMsg, setAlertMsg] = useState('');
const adapter = useContext(AdapterContext);
const addCollaboratorsRef = useRef();
const [emitMetrics] = useMetrics();
let startTime = window.performance.now();

const handleCancel = () => {
setSpaceTitle('');
Expand Down Expand Up @@ -64,17 +67,53 @@ export default function WebexCreateSpace({
};

const onError = (error) => {
const endTime = window.performance.now();

emitMetrics({
fields: {
startTime,
endTime,
totalTime: endTime - startTime,
},
metricName: 'createSpaceError',
tag: 'webex_widgets',
type: 'operational',
}, 'loginId');
showBanner(true, error.message);
isCreateSpaceResponse({error: error.message});
};

const addMembersSuccess = () => {
const endTime = window.performance.now();

emitMetrics({
fields: {
startTime,
endTime,
totalTime: endTime - startTime,
},
metricName: 'addMembersSuccess',
tag: 'webex_widgets',
type: 'operational',
}, 'loginId');
showBanner(false, 'space created successfully');
isCreateSpaceResponse(null, {data: {spaceTitle, addedSpaceMembers}, msg: 'space created successfully'});
};

const createRoomSuccess = (data) => {
const membership = [];
const endTime = window.performance.now();

emitMetrics({
fields: {
startTime,
endTime,
totalTime: endTime - startTime,
},
metricName: 'createSpaceSuccess',
tag: 'webex_widgets',
type: 'operational',
}, 'loginId');

addedSpaceMembers.forEach((personId) => {
membership.push(adapter.membershipsAdapter.addRoomMember(personId, data.ID));
Expand All @@ -85,6 +124,7 @@ export default function WebexCreateSpace({
};

const handleCreateSpace = () => {
startTime = window.performance.now();
if (createSpace) {
if (spaceTitle) {
adapter.roomsAdapter.createRoom({title: spaceTitle}).subscribe(createRoomSuccess, onError);
Expand Down

0 comments on commit ca2d8b4

Please sign in to comment.