Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

AnalyticsEvents.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. /**
  2. * The constant for the event type 'track'.
  3. * TODO: keep these constants in a single place. Can we import them from
  4. * lib-jitsi-meet's AnalyticsEvents somehow?
  5. * @type {string}
  6. */
  7. const TYPE_TRACK = 'track';
  8. /**
  9. * The constant for the event type 'UI' (User Interaction).
  10. * TODO: keep these constants in a single place. Can we import them from
  11. * lib-jitsi-meet's AnalyticsEvents somehow?
  12. * @type {string}
  13. */
  14. const TYPE_UI = 'ui';
  15. /**
  16. * The identifier for the "pinned" action. The local participant has pinned a
  17. * participant to remain on large video.
  18. *
  19. * @type {String}
  20. */
  21. export const ACTION_PINNED = 'pinned';
  22. /**
  23. * The identifier for the "unpinned" action. The local participant has unpinned
  24. * a participant so the participant doesn't remain permanently on local large
  25. * video.
  26. *
  27. * @type {String}
  28. */
  29. export const ACTION_UNPINNED = 'unpinned';
  30. /**
  31. * The identifier for the "pressed" action for shortcut events. This action
  32. * means that a button was pressed (and not yet released).
  33. *
  34. * @type {String}
  35. */
  36. export const ACTION_SHORTCUT_PRESSED = 'pressed';
  37. /**
  38. * The identifier for the "released" action for shortcut events. This action
  39. * means that a button which was previously pressed was released.
  40. *
  41. * @type {String}
  42. */
  43. export const ACTION_SHORTCUT_RELEASED = 'released';
  44. /**
  45. * The identifier for the "triggered" action for shortcut events. This action
  46. * means that a button was pressed, and we don't care about whether it was
  47. * released or will be released in the future.
  48. *
  49. * @type {String}
  50. */
  51. export const ACTION_SHORTCUT_TRIGGERED = 'triggered';
  52. /**
  53. * The name of the keyboard shortcut or toolbar button for muting audio.
  54. */
  55. export const AUDIO_MUTE = 'audio.mute';
  56. /**
  57. * The name of the keyboard shortcut or toolbar button for muting video.
  58. */
  59. export const VIDEO_MUTE = 'video.mute';
  60. /**
  61. * Creates an event which indicates that a certain action was requested through
  62. * the jitsi-meet API.
  63. *
  64. * @param {Object} action - The action which was requested through the
  65. * jitsi-meet API.
  66. * @param {Object} attributes - Attributes to attach to the event.
  67. * @returns {Object} The event in a format suitable for sending via
  68. * sendAnalytics.
  69. */
  70. export function createApiEvent(action, attributes = {}) {
  71. return {
  72. action,
  73. attributes,
  74. source: 'jitsi-meet-api'
  75. };
  76. }
  77. /**
  78. * Creates an event which indicates that the audio-only mode has been changed.
  79. *
  80. * @param {boolean} enabled - True if audio-only is enabled, false otherwise.
  81. * @returns {Object} The event in a format suitable for sending via
  82. * sendAnalytics.
  83. */
  84. export function createAudioOnlyChangedEvent(enabled) {
  85. return {
  86. action: `audio.only.${enabled ? 'enabled' : 'disabled'}`
  87. };
  88. }
  89. /**
  90. * Creates an event for about the JitsiConnection.
  91. *
  92. * @param {string} action - The action that the event represents.
  93. * @param {boolean} attributes - Additional attributes to attach to the event.
  94. * @returns {Object} The event in a format suitable for sending via
  95. * sendAnalytics.
  96. */
  97. export function createConnectionEvent(action, attributes = {}) {
  98. return {
  99. action,
  100. actionSubject: 'connection',
  101. attributes
  102. };
  103. }
  104. /**
  105. * Creates an event which indicates an action occurred in the calendar
  106. * integration UI.
  107. *
  108. * @param {string} eventName - The name of the calendar UI event.
  109. * @param {Object} attributes - Attributes to attach to the event.
  110. * @returns {Object} The event in a format suitable for sending via
  111. * sendAnalytics.
  112. */
  113. export function createCalendarClickedEvent(eventName, attributes = {}) {
  114. return {
  115. action: 'clicked',
  116. actionSubject: eventName,
  117. attributes,
  118. source: 'calendar',
  119. type: TYPE_UI
  120. };
  121. }
  122. /**
  123. * Creates an event which indicates that the calendar container is shown and
  124. * selected.
  125. *
  126. * @param {Object} attributes - Attributes to attach to the event.
  127. * @returns {Object} The event in a format suitable for sending via
  128. * sendAnalytics.
  129. */
  130. export function createCalendarSelectedEvent(attributes = {}) {
  131. return {
  132. action: 'selected',
  133. actionSubject: 'calendar.selected',
  134. attributes,
  135. source: 'calendar',
  136. type: TYPE_UI
  137. };
  138. }
  139. /**
  140. * Creates an event indicating that a calendar has been connected.
  141. *
  142. * @param {boolean} attributes - Additional attributes to attach to the event.
  143. * @returns {Object} The event in a format suitable for sending via
  144. * sendAnalytics.
  145. */
  146. export function createCalendarConnectedEvent(attributes = {}) {
  147. return {
  148. action: 'calendar.connected',
  149. actionSubject: 'calendar.connected',
  150. attributes
  151. };
  152. }
  153. /**
  154. * Creates an event which indicates an action occurred in the recent list
  155. * integration UI.
  156. *
  157. * @param {string} eventName - The name of the recent list UI event.
  158. * @param {Object} attributes - Attributes to attach to the event.
  159. * @returns {Object} The event in a format suitable for sending via
  160. * sendAnalytics.
  161. */
  162. export function createRecentClickedEvent(eventName, attributes = {}) {
  163. return {
  164. action: 'clicked',
  165. actionSubject: eventName,
  166. attributes,
  167. source: 'recent.list',
  168. type: TYPE_UI
  169. };
  170. }
  171. /**
  172. * Creates an event which indicate an action occured in the chrome extension banner.
  173. *
  174. * @param {boolean} installPressed - Whether the user pressed install or `x` - cancel.
  175. * @param {Object} attributes - Attributes to attach to the event.
  176. * @returns {Object} The event in a format suitable for sending via
  177. * sendAnalytics.
  178. */
  179. export function createChromeExtensionBannerEvent(installPressed, attributes = {}) {
  180. return {
  181. action: installPressed ? 'install' : 'cancel',
  182. attributes,
  183. source: 'chrome.extension.banner',
  184. type: TYPE_UI
  185. };
  186. }
  187. /**
  188. * Creates an event which indicates that the recent list container is shown and
  189. * selected.
  190. *
  191. * @param {Object} attributes - Attributes to attach to the event.
  192. * @returns {Object} The event in a format suitable for sending via
  193. * sendAnalytics.
  194. */
  195. export function createRecentSelectedEvent(attributes = {}) {
  196. return {
  197. action: 'selected',
  198. actionSubject: 'recent.list.selected',
  199. attributes,
  200. source: 'recent.list',
  201. type: TYPE_UI
  202. };
  203. }
  204. /**
  205. * Creates an event for an action on the deep linking page.
  206. *
  207. * @param {string} action - The action that the event represents.
  208. * @param {string} actionSubject - The subject that was acted upon.
  209. * @param {boolean} attributes - Additional attributes to attach to the event.
  210. * @returns {Object} The event in a format suitable for sending via
  211. * sendAnalytics.
  212. */
  213. export function createDeepLinkingPageEvent(
  214. action, actionSubject, attributes = {}) {
  215. return {
  216. action,
  217. actionSubject,
  218. source: 'deepLinkingPage',
  219. attributes
  220. };
  221. }
  222. /**
  223. * Creates an event which indicates that a device was changed.
  224. *
  225. * @param {string} mediaType - The media type of the device ('audio' or
  226. * 'video').
  227. * @param {string} deviceType - The type of the device ('input' or 'output').
  228. * @returns {Object} The event in a format suitable for sending via
  229. * sendAnalytics.
  230. */
  231. export function createDeviceChangedEvent(mediaType, deviceType) {
  232. return {
  233. action: 'device.changed',
  234. attributes: {
  235. 'device_type': deviceType,
  236. 'media_type': mediaType
  237. }
  238. };
  239. }
  240. /**
  241. * Creates an event indicating that an action related to E2EE occurred.
  242. *
  243. * @param {string} action - The action which occurred.
  244. * @returns {Object} The event in a format suitable for sending via
  245. * sendAnalytics.
  246. */
  247. export function createE2EEEvent(action) {
  248. return {
  249. action,
  250. actionSubject: 'e2ee'
  251. };
  252. }
  253. /**
  254. * Creates an event which specifies that the feedback dialog has been opened.
  255. *
  256. * @returns {Object} The event in a format suitable for sending via
  257. * sendAnalytics.
  258. */
  259. export function createFeedbackOpenEvent() {
  260. return {
  261. action: 'feedback.opened'
  262. };
  263. }
  264. /**
  265. * Creates an event for an action regarding the AddPeopleDialog (invites).
  266. *
  267. * @param {string} action - The action that the event represents.
  268. * @param {string} actionSubject - The subject that was acted upon.
  269. * @param {boolean} attributes - Additional attributes to attach to the event.
  270. * @returns {Object} The event in a format suitable for sending via
  271. * sendAnalytics.
  272. */
  273. export function createInviteDialogEvent(
  274. action, actionSubject, attributes = {}) {
  275. return {
  276. action,
  277. actionSubject,
  278. attributes,
  279. source: 'inviteDialog'
  280. };
  281. }
  282. /**
  283. * Creates an event which reports about the current network information reported by the operating system.
  284. *
  285. * @param {boolean} isOnline - Tells whether or not the internet is reachable.
  286. * @param {string} [networkType] - Network type, see {@code NetworkInfo} type defined by the 'base/net-info' feature.
  287. * @param {Object} [details] - Extra info, see {@code NetworkInfo} type defined by the 'base/net-info' feature.
  288. * @returns {Object}
  289. */
  290. export function createNetworkInfoEvent({ isOnline, networkType, details }) {
  291. const attributes = { isOnline };
  292. // Do no include optional stuff or Amplitude handler will log warnings.
  293. networkType && (attributes.networkType = networkType);
  294. details && (attributes.details = details);
  295. return {
  296. action: 'network.info',
  297. attributes
  298. };
  299. }
  300. /**
  301. * Creates an "offer/answer failure" event.
  302. *
  303. * @returns {Object} The event in a format suitable for sending via
  304. * sendAnalytics.
  305. */
  306. export function createOfferAnswerFailedEvent() {
  307. return {
  308. action: 'offer.answer.failure'
  309. };
  310. }
  311. /**
  312. * Creates a "page reload" event.
  313. *
  314. * @param {string} reason - The reason for the reload.
  315. * @param {number} timeout - The timeout in seconds after which the page is
  316. * scheduled to reload.
  317. * @param {Object} details - The details for the error.
  318. * @returns {Object} The event in a format suitable for sending via
  319. * sendAnalytics.
  320. */
  321. export function createPageReloadScheduledEvent(reason, timeout, details) {
  322. return {
  323. action: 'page.reload.scheduled',
  324. attributes: {
  325. reason,
  326. timeout,
  327. ...details
  328. }
  329. };
  330. }
  331. /**
  332. * Creates a "pinned" or "unpinned" event.
  333. *
  334. * @param {string} action - The action ("pinned" or "unpinned").
  335. * @param {string} participantId - The ID of the participant which was pinned.
  336. * @param {Object} attributes - Attributes to attach to the event.
  337. * @returns {Object} The event in a format suitable for sending via
  338. * sendAnalytics.
  339. */
  340. export function createPinnedEvent(action, participantId, attributes) {
  341. return {
  342. type: TYPE_TRACK,
  343. action,
  344. actionSubject: 'participant',
  345. objectType: 'participant',
  346. objectId: participantId,
  347. attributes
  348. };
  349. }
  350. /**
  351. * Creates an event which indicates that a button in the profile panel was
  352. * clicked.
  353. *
  354. * @param {string} buttonName - The name of the button.
  355. * @param {Object} attributes - Attributes to attach to the event.
  356. * @returns {Object} The event in a format suitable for sending via
  357. * sendAnalytics.
  358. */
  359. export function createProfilePanelButtonEvent(buttonName, attributes = {}) {
  360. return {
  361. action: 'clicked',
  362. actionSubject: buttonName,
  363. attributes,
  364. source: 'profile.panel',
  365. type: TYPE_UI
  366. };
  367. }
  368. /**
  369. * Creates an event which indicates that a specific button on one of the
  370. * recording-related dialogs was clicked.
  371. *
  372. * @param {string} dialogName - The name of the dialog (e.g. 'start' or 'stop').
  373. * @param {string} buttonName - The name of the button (e.g. 'confirm' or
  374. * 'cancel').
  375. * @param {Object} attributes - Attributes to attach to the event.
  376. * @returns {Object} The event in a format suitable for sending via
  377. * sendAnalytics.
  378. */
  379. export function createRecordingDialogEvent(
  380. dialogName, buttonName, attributes = {}) {
  381. return {
  382. action: 'clicked',
  383. actionSubject: buttonName,
  384. attributes,
  385. source: `${dialogName}.recording.dialog`,
  386. type: TYPE_UI
  387. };
  388. }
  389. /**
  390. * Creates an event which indicates that a specific button on one of the
  391. * liveStreaming-related dialogs was clicked.
  392. *
  393. * @param {string} dialogName - The name of the dialog (e.g. 'start' or 'stop').
  394. * @param {string} buttonName - The name of the button (e.g. 'confirm' or
  395. * 'cancel').
  396. * @returns {Object} The event in a format suitable for sending via
  397. * sendAnalytics.
  398. */
  399. export function createLiveStreamingDialogEvent(dialogName, buttonName) {
  400. return {
  401. action: 'clicked',
  402. actionSubject: buttonName,
  403. source: `${dialogName}.liveStreaming.dialog`,
  404. type: TYPE_UI
  405. };
  406. }
  407. /**
  408. * Creates an event with the local tracks duration.
  409. *
  410. * @param {Object} duration - The object with the duration of the local tracks.
  411. * @returns {Object} The event in a format suitable for sending via
  412. * sendAnalytics.
  413. */
  414. export function createLocalTracksDurationEvent(duration) {
  415. const { audio, video, conference } = duration;
  416. const { camera, desktop } = video;
  417. return {
  418. action: 'local.tracks.durations',
  419. attributes: {
  420. audio: audio.value,
  421. camera: camera.value,
  422. conference: conference.value,
  423. desktop: desktop.value
  424. }
  425. };
  426. }
  427. /**
  428. * Creates an event which indicates that an action related to recording has
  429. * occured.
  430. *
  431. * @param {string} action - The action (e.g. 'start' or 'stop').
  432. * @param {string} type - The recording type (e.g. 'file' or 'live').
  433. * @param {number} value - The duration of the recording in seconds (for stop
  434. * action).
  435. * @returns {Object} The event in a format suitable for sending via
  436. * sendAnalytics.
  437. */
  438. export function createRecordingEvent(action, type, value) {
  439. return {
  440. action,
  441. actionSubject: `recording.${type}`,
  442. attributes: {
  443. value
  444. }
  445. };
  446. }
  447. /**
  448. * Creates an event which indicates that the same conference has been rejoined.
  449. *
  450. * @param {string} url - The full conference URL.
  451. * @param {number} lastConferenceDuration - How many seconds user stayed in the previous conference.
  452. * @param {number} timeSinceLeft - How many seconds since the last conference was left.
  453. * @returns {Object} The event in a format suitable for sending via sendAnalytics.
  454. */
  455. export function createRejoinedEvent({ url, lastConferenceDuration, timeSinceLeft }) {
  456. return {
  457. action: 'rejoined',
  458. attributes: {
  459. lastConferenceDuration,
  460. timeSinceLeft,
  461. url
  462. }
  463. };
  464. }
  465. /**
  466. * Creates an event which specifies that the "confirm" button on the remote
  467. * mute dialog has been clicked.
  468. *
  469. * @param {string} participantId - The ID of the participant that was remotely
  470. * muted.
  471. * @param {string} mediaType - The media type of the channel to mute.
  472. * @returns {Object} The event in a format suitable for sending via
  473. * sendAnalytics.
  474. */
  475. export function createRemoteMuteConfirmedEvent(participantId, mediaType) {
  476. return {
  477. action: 'clicked',
  478. actionSubject: 'remote.mute.dialog.confirm.button',
  479. attributes: {
  480. 'participant_id': participantId,
  481. 'media_type': mediaType
  482. },
  483. source: 'remote.mute.dialog',
  484. type: TYPE_UI
  485. };
  486. }
  487. /**
  488. * Creates an event which indicates that one of the buttons in the "remote
  489. * video menu" was clicked.
  490. *
  491. * @param {string} buttonName - The name of the button.
  492. * @param {Object} attributes - Attributes to attach to the event.
  493. * @returns {Object} The event in a format suitable for sending via
  494. * sendAnalytics.
  495. */
  496. export function createRemoteVideoMenuButtonEvent(buttonName, attributes) {
  497. return {
  498. action: 'clicked',
  499. actionSubject: buttonName,
  500. attributes,
  501. source: 'remote.video.menu',
  502. type: TYPE_UI
  503. };
  504. }
  505. /**
  506. * The rtcstats websocket onclose event. We send this to amplitude in order
  507. * to detect trace ws prematurely closing.
  508. *
  509. * @param {Object} closeEvent - The event with which the websocket closed.
  510. * @returns {Object} The event in a format suitable for sending via
  511. * sendAnalytics.
  512. */
  513. export function createRTCStatsTraceCloseEvent(closeEvent) {
  514. const event = {
  515. action: 'trace.onclose',
  516. source: 'rtcstats'
  517. };
  518. event.code = closeEvent.code;
  519. event.reason = closeEvent.reason;
  520. return event;
  521. }
  522. /**
  523. * Creates an event indicating that an action related to video blur
  524. * occurred (e.g. It was started or stopped).
  525. *
  526. * @param {string} action - The action which occurred.
  527. * @returns {Object} The event in a format suitable for sending via
  528. * sendAnalytics.
  529. */
  530. export function createVideoBlurEvent(action) {
  531. return {
  532. action,
  533. actionSubject: 'video.blur'
  534. };
  535. }
  536. /**
  537. * Creates an event indicating that an action related to screen sharing
  538. * occurred (e.g. It was started or stopped).
  539. *
  540. * @param {string} action - The action which occurred.
  541. * @returns {Object} The event in a format suitable for sending via
  542. * sendAnalytics.
  543. */
  544. export function createScreenSharingEvent(action) {
  545. return {
  546. action,
  547. actionSubject: 'screen.sharing'
  548. };
  549. }
  550. /**
  551. * Creates an event which indicates the screen sharing video is not displayed when it needs to be displayed.
  552. *
  553. * @param {Object} attributes - Additional information that describes the issue.
  554. * @returns {Object} The event in a format suitable for sending via sendAnalytics.
  555. */
  556. export function createScreenSharingIssueEvent(attributes) {
  557. return {
  558. action: 'screen.sharing.issue',
  559. attributes
  560. };
  561. }
  562. /**
  563. * The local participant failed to send a "selected endpoint" message to the
  564. * bridge.
  565. *
  566. * @param {Error} error - The error which caused the failure.
  567. * @returns {Object} The event in a format suitable for sending via
  568. * sendAnalytics.
  569. */
  570. export function createSelectParticipantFailedEvent(error) {
  571. const event = {
  572. action: 'select.participant.failed'
  573. };
  574. if (error) {
  575. event.error = error.toString();
  576. }
  577. return event;
  578. }
  579. /**
  580. * Creates an event associated with the "shared video" feature.
  581. *
  582. * @param {string} action - The action that the event represents.
  583. * @param {Object} attributes - Attributes to attach to the event.
  584. * @returns {Object} The event in a format suitable for sending via
  585. * sendAnalytics.
  586. */
  587. export function createSharedVideoEvent(action, attributes = {}) {
  588. return {
  589. action,
  590. attributes,
  591. actionSubject: 'shared.video'
  592. };
  593. }
  594. /**
  595. * Creates an event associated with a shortcut being pressed, released or
  596. * triggered. By convention, where appropriate an attribute named 'enable'
  597. * should be used to indicate the action which resulted by the shortcut being
  598. * pressed (e.g. Whether screen sharing was enabled or disabled).
  599. *
  600. * @param {string} shortcut - The identifier of the shortcut which produced
  601. * an action.
  602. * @param {string} action - The action that the event represents (one
  603. * of ACTION_SHORTCUT_PRESSED, ACTION_SHORTCUT_RELEASED
  604. * or ACTION_SHORTCUT_TRIGGERED).
  605. * @param {Object} attributes - Attributes to attach to the event.
  606. * @returns {Object} The event in a format suitable for sending via
  607. * sendAnalytics.
  608. */
  609. export function createShortcutEvent(
  610. shortcut,
  611. action = ACTION_SHORTCUT_TRIGGERED,
  612. attributes = {}) {
  613. return {
  614. action,
  615. actionSubject: 'keyboard.shortcut',
  616. actionSubjectId: shortcut,
  617. attributes,
  618. source: 'keyboard.shortcut',
  619. type: TYPE_UI
  620. };
  621. }
  622. /**
  623. * Creates an event which indicates the "start audio only" configuration.
  624. *
  625. * @param {boolean} audioOnly - Whether "start audio only" is enabled or not.
  626. * @returns {Object} The event in a format suitable for sending via
  627. * sendAnalytics.
  628. */
  629. export function createStartAudioOnlyEvent(audioOnly) {
  630. return {
  631. action: 'start.audio.only',
  632. attributes: {
  633. enabled: audioOnly
  634. }
  635. };
  636. }
  637. /**
  638. * Creates an event which indicates the "start silent" configuration.
  639. *
  640. * @returns {Object} The event in a format suitable for sending via
  641. * sendAnalytics.
  642. */
  643. export function createStartSilentEvent() {
  644. return {
  645. action: 'start.silent'
  646. };
  647. }
  648. /**
  649. * Creates an event which indicates the "start muted" configuration.
  650. *
  651. * @param {string} source - The source of the configuration, 'local' or
  652. * 'remote' depending on whether it comes from the static configuration (i.e.
  653. * {@code config.js}) or comes dynamically from Jicofo.
  654. * @param {boolean} audioMute - Whether the configuration requests that audio
  655. * is muted.
  656. * @param {boolean} videoMute - Whether the configuration requests that video
  657. * is muted.
  658. * @returns {Object} The event in a format suitable for sending via
  659. * sendAnalytics.
  660. */
  661. export function createStartMutedConfigurationEvent(
  662. source,
  663. audioMute,
  664. videoMute) {
  665. return {
  666. action: 'start.muted.configuration',
  667. attributes: {
  668. source,
  669. 'audio_mute': audioMute,
  670. 'video_mute': videoMute
  671. }
  672. };
  673. }
  674. /**
  675. * Automatically changing the mute state of a media track in order to match
  676. * the current stored state in redux.
  677. *
  678. * @param {string} mediaType - The track's media type ('audio' or 'video').
  679. * @param {boolean} muted - Whether the track is being muted or unmuted as
  680. * as result of the sync operation.
  681. * @returns {Object} The event in a format suitable for sending via
  682. * sendAnalytics.
  683. */
  684. export function createSyncTrackStateEvent(mediaType, muted) {
  685. return {
  686. action: 'sync.track.state',
  687. attributes: {
  688. 'media_type': mediaType,
  689. muted
  690. }
  691. };
  692. }
  693. /**
  694. * Creates an event associated with a toolbar button being clicked/pressed. By
  695. * convention, where appropriate an attribute named 'enable' should be used to
  696. * indicate the action which resulted by the shortcut being pressed (e.g.
  697. * Whether screen sharing was enabled or disabled).
  698. *
  699. * @param {string} buttonName - The identifier of the toolbar button which was
  700. * clicked/pressed.
  701. * @param {Object} attributes - Attributes to attach to the event.
  702. * @returns {Object} The event in a format suitable for sending via
  703. * sendAnalytics.
  704. */
  705. export function createToolbarEvent(buttonName, attributes = {}) {
  706. return {
  707. action: 'clicked',
  708. actionSubject: buttonName,
  709. attributes,
  710. source: 'toolbar.button',
  711. type: TYPE_UI
  712. };
  713. }
  714. /**
  715. * Creates an event which indicates that a local track was muted.
  716. *
  717. * @param {string} mediaType - The track's media type ('audio' or 'video').
  718. * @param {string} reason - The reason the track was muted (e.g. It was
  719. * triggered by the "initial mute" option, or a previously muted track was
  720. * replaced (e.g. When a new device was used)).
  721. * @param {boolean} muted - Whether the track was muted or unmuted.
  722. * @returns {Object} The event in a format suitable for sending via
  723. * sendAnalytics.
  724. */
  725. export function createTrackMutedEvent(mediaType, reason, muted = true) {
  726. return {
  727. action: 'track.muted',
  728. attributes: {
  729. 'media_type': mediaType,
  730. muted,
  731. reason
  732. }
  733. };
  734. }
  735. /**
  736. * Creates an event for joining a vpaas conference.
  737. *
  738. * @param {string} tenant - The conference tenant.
  739. * @returns {Object} The event in a format suitable for sending via
  740. * sendAnalytics.
  741. */
  742. export function createVpaasConferenceJoinedEvent(tenant) {
  743. return {
  744. action: 'vpaas.conference.joined',
  745. attributes: {
  746. tenant
  747. }
  748. };
  749. }
  750. /**
  751. * Creates an event for an action on the welcome page.
  752. *
  753. * @param {string} action - The action that the event represents.
  754. * @param {string} actionSubject - The subject that was acted upon.
  755. * @param {boolean} attributes - Additional attributes to attach to the event.
  756. * @returns {Object} The event in a format suitable for sending via
  757. * sendAnalytics.
  758. */
  759. export function createWelcomePageEvent(action, actionSubject, attributes = {}) {
  760. return {
  761. action,
  762. actionSubject,
  763. attributes,
  764. source: 'welcomePage'
  765. };
  766. }