您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AnalyticsEvents.js 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  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 occurred 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 a poll event.
  352. * The following events will be created:
  353. * - poll.created
  354. * - poll.vote.checked
  355. * - poll.vote.sent
  356. * - poll.vote.skipped
  357. * - poll.vote.detailsViewed
  358. * - poll.vote.changed
  359. * - poll.option.added
  360. * - poll.option.moved
  361. * - poll.option.removed.
  362. *
  363. * @param {string} action - The action.
  364. * @returns {Object}
  365. */
  366. export function createPollEvent(action) {
  367. return {
  368. action: `poll.${action}`
  369. };
  370. }
  371. /**
  372. * Creates an event which indicates that a button in the profile panel was
  373. * clicked.
  374. *
  375. * @param {string} buttonName - The name of the button.
  376. * @param {Object} attributes - Attributes to attach to the event.
  377. * @returns {Object} The event in a format suitable for sending via
  378. * sendAnalytics.
  379. */
  380. export function createProfilePanelButtonEvent(buttonName, attributes = {}) {
  381. return {
  382. action: 'clicked',
  383. actionSubject: buttonName,
  384. attributes,
  385. source: 'profile.panel',
  386. type: TYPE_UI
  387. };
  388. }
  389. /**
  390. * Creates an event which indicates that a specific button on one of the
  391. * recording-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. * @param {Object} attributes - Attributes to attach to the event.
  397. * @returns {Object} The event in a format suitable for sending via
  398. * sendAnalytics.
  399. */
  400. export function createRecordingDialogEvent(
  401. dialogName, buttonName, attributes = {}) {
  402. return {
  403. action: 'clicked',
  404. actionSubject: buttonName,
  405. attributes,
  406. source: `${dialogName}.recording.dialog`,
  407. type: TYPE_UI
  408. };
  409. }
  410. /**
  411. * Creates an event which indicates that a specific button on one of the
  412. * liveStreaming-related dialogs was clicked.
  413. *
  414. * @param {string} dialogName - The name of the dialog (e.g. 'start' or 'stop').
  415. * @param {string} buttonName - The name of the button (e.g. 'confirm' or
  416. * 'cancel').
  417. * @returns {Object} The event in a format suitable for sending via
  418. * sendAnalytics.
  419. */
  420. export function createLiveStreamingDialogEvent(dialogName, buttonName) {
  421. return {
  422. action: 'clicked',
  423. actionSubject: buttonName,
  424. source: `${dialogName}.liveStreaming.dialog`,
  425. type: TYPE_UI
  426. };
  427. }
  428. /**
  429. * Creates an event with the local tracks duration.
  430. *
  431. * @param {Object} duration - The object with the duration of the local tracks.
  432. * @returns {Object} The event in a format suitable for sending via
  433. * sendAnalytics.
  434. */
  435. export function createLocalTracksDurationEvent(duration) {
  436. const { audio, video, conference } = duration;
  437. const { camera, desktop } = video;
  438. return {
  439. action: 'local.tracks.durations',
  440. attributes: {
  441. audio: audio.value,
  442. camera: camera.value,
  443. conference: conference.value,
  444. desktop: desktop.value
  445. }
  446. };
  447. }
  448. /**
  449. * Creates an event which indicates that an action related to recording has
  450. * occurred.
  451. *
  452. * @param {string} action - The action (e.g. 'start' or 'stop').
  453. * @param {string} type - The recording type (e.g. 'file' or 'live').
  454. * @param {number} value - The duration of the recording in seconds (for stop
  455. * action).
  456. * @returns {Object} The event in a format suitable for sending via
  457. * sendAnalytics.
  458. */
  459. export function createRecordingEvent(action, type, value) {
  460. return {
  461. action,
  462. actionSubject: `recording.${type}`,
  463. attributes: {
  464. value
  465. }
  466. };
  467. }
  468. /**
  469. * Creates an event which indicates that the same conference has been rejoined.
  470. *
  471. * @param {string} url - The full conference URL.
  472. * @param {number} lastConferenceDuration - How many seconds user stayed in the previous conference.
  473. * @param {number} timeSinceLeft - How many seconds since the last conference was left.
  474. * @returns {Object} The event in a format suitable for sending via sendAnalytics.
  475. */
  476. export function createRejoinedEvent({ url, lastConferenceDuration, timeSinceLeft }) {
  477. return {
  478. action: 'rejoined',
  479. attributes: {
  480. lastConferenceDuration,
  481. timeSinceLeft,
  482. url
  483. }
  484. };
  485. }
  486. /**
  487. * Creates an event which specifies that the "confirm" button on the remote
  488. * mute dialog has been clicked.
  489. *
  490. * @param {string} participantId - The ID of the participant that was remotely
  491. * muted.
  492. * @param {string} mediaType - The media type of the channel to mute.
  493. * @returns {Object} The event in a format suitable for sending via
  494. * sendAnalytics.
  495. */
  496. export function createRemoteMuteConfirmedEvent(participantId, mediaType) {
  497. return {
  498. action: 'clicked',
  499. actionSubject: 'remote.mute.dialog.confirm.button',
  500. attributes: {
  501. 'participant_id': participantId,
  502. 'media_type': mediaType
  503. },
  504. source: 'remote.mute.dialog',
  505. type: TYPE_UI
  506. };
  507. }
  508. /**
  509. * Creates an event which indicates that one of the buttons in the "remote
  510. * video menu" was clicked.
  511. *
  512. * @param {string} buttonName - The name of the button.
  513. * @param {Object} attributes - Attributes to attach to the event.
  514. * @returns {Object} The event in a format suitable for sending via
  515. * sendAnalytics.
  516. */
  517. export function createRemoteVideoMenuButtonEvent(buttonName, attributes) {
  518. return {
  519. action: 'clicked',
  520. actionSubject: buttonName,
  521. attributes,
  522. source: 'remote.video.menu',
  523. type: TYPE_UI
  524. };
  525. }
  526. /**
  527. * The rtcstats websocket onclose event. We send this to amplitude in order
  528. * to detect trace ws prematurely closing.
  529. *
  530. * @param {Object} closeEvent - The event with which the websocket closed.
  531. * @returns {Object} The event in a format suitable for sending via
  532. * sendAnalytics.
  533. */
  534. export function createRTCStatsTraceCloseEvent(closeEvent) {
  535. const event = {
  536. action: 'trace.onclose',
  537. source: 'rtcstats'
  538. };
  539. event.code = closeEvent.code;
  540. event.reason = closeEvent.reason;
  541. return event;
  542. }
  543. /**
  544. * Creates an event indicating that an action related to video blur
  545. * occurred (e.g. It was started or stopped).
  546. *
  547. * @param {string} action - The action which occurred.
  548. * @returns {Object} The event in a format suitable for sending via
  549. * sendAnalytics.
  550. */
  551. export function createVideoBlurEvent(action) {
  552. return {
  553. action,
  554. actionSubject: 'video.blur'
  555. };
  556. }
  557. /**
  558. * Creates an event indicating that an action related to screen sharing
  559. * occurred (e.g. It was started or stopped).
  560. *
  561. * @param {string} action - The action which occurred.
  562. * @param {number?} value - The screenshare duration in seconds.
  563. * @returns {Object} The event in a format suitable for sending via
  564. * sendAnalytics.
  565. */
  566. export function createScreenSharingEvent(action, value = null) {
  567. return {
  568. action,
  569. actionSubject: 'screen.sharing',
  570. attributes: {
  571. value
  572. }
  573. };
  574. }
  575. /**
  576. * Creates an event which indicates the screen sharing video is not displayed when it needs to be displayed.
  577. *
  578. * @param {Object} attributes - Additional information that describes the issue.
  579. * @returns {Object} The event in a format suitable for sending via sendAnalytics.
  580. */
  581. export function createScreenSharingIssueEvent(attributes) {
  582. return {
  583. action: 'screen.sharing.issue',
  584. attributes
  585. };
  586. }
  587. /**
  588. * The local participant failed to send a "selected endpoint" message to the
  589. * bridge.
  590. *
  591. * @param {Error} error - The error which caused the failure.
  592. * @returns {Object} The event in a format suitable for sending via
  593. * sendAnalytics.
  594. */
  595. export function createSelectParticipantFailedEvent(error) {
  596. const event = {
  597. action: 'select.participant.failed'
  598. };
  599. if (error) {
  600. event.error = error.toString();
  601. }
  602. return event;
  603. }
  604. /**
  605. * Creates an event associated with the "shared video" feature.
  606. *
  607. * @param {string} action - The action that the event represents.
  608. * @param {Object} attributes - Attributes to attach to the event.
  609. * @returns {Object} The event in a format suitable for sending via
  610. * sendAnalytics.
  611. */
  612. export function createSharedVideoEvent(action, attributes = {}) {
  613. return {
  614. action,
  615. attributes,
  616. actionSubject: 'shared.video'
  617. };
  618. }
  619. /**
  620. * Creates an event associated with a shortcut being pressed, released or
  621. * triggered. By convention, where appropriate an attribute named 'enable'
  622. * should be used to indicate the action which resulted by the shortcut being
  623. * pressed (e.g. Whether screen sharing was enabled or disabled).
  624. *
  625. * @param {string} shortcut - The identifier of the shortcut which produced
  626. * an action.
  627. * @param {string} action - The action that the event represents (one
  628. * of ACTION_SHORTCUT_PRESSED, ACTION_SHORTCUT_RELEASED
  629. * or ACTION_SHORTCUT_TRIGGERED).
  630. * @param {Object} attributes - Attributes to attach to the event.
  631. * @returns {Object} The event in a format suitable for sending via
  632. * sendAnalytics.
  633. */
  634. export function createShortcutEvent(
  635. shortcut,
  636. action = ACTION_SHORTCUT_TRIGGERED,
  637. attributes = {}) {
  638. return {
  639. action,
  640. actionSubject: 'keyboard.shortcut',
  641. actionSubjectId: shortcut,
  642. attributes,
  643. source: 'keyboard.shortcut',
  644. type: TYPE_UI
  645. };
  646. }
  647. /**
  648. * Creates an event which indicates the "start audio only" configuration.
  649. *
  650. * @param {boolean} audioOnly - Whether "start audio only" is enabled or not.
  651. * @returns {Object} The event in a format suitable for sending via
  652. * sendAnalytics.
  653. */
  654. export function createStartAudioOnlyEvent(audioOnly) {
  655. return {
  656. action: 'start.audio.only',
  657. attributes: {
  658. enabled: audioOnly
  659. }
  660. };
  661. }
  662. /**
  663. * Creates an event which indicates the "start silent" configuration.
  664. *
  665. * @returns {Object} The event in a format suitable for sending via
  666. * sendAnalytics.
  667. */
  668. export function createStartSilentEvent() {
  669. return {
  670. action: 'start.silent'
  671. };
  672. }
  673. /**
  674. * Creates an event which indicates that HTMLAudioElement.play has failed.
  675. *
  676. * @param {sting} elementID - The ID of the HTMLAudioElement.
  677. * @returns {Object} The event in a format suitable for sending via sendAnalytics.
  678. */
  679. export function createAudioPlayErrorEvent(elementID) {
  680. return {
  681. action: 'audio.play.error',
  682. attributes: {
  683. elementID
  684. }
  685. };
  686. }
  687. /**
  688. * Creates an event which indicates that HTMLAudioElement.play has succeded after a prior failure.
  689. *
  690. * @param {sting} elementID - The ID of the HTMLAudioElement.
  691. * @returns {Object} The event in a format suitable for sending via sendAnalytics.
  692. */
  693. export function createAudioPlaySuccessEvent(elementID) {
  694. return {
  695. action: 'audio.play.success',
  696. attributes: {
  697. elementID
  698. }
  699. };
  700. }
  701. /**
  702. * Creates an event which indicates the "start muted" configuration.
  703. *
  704. * @param {string} source - The source of the configuration, 'local' or
  705. * 'remote' depending on whether it comes from the static configuration (i.e.
  706. * {@code config.js}) or comes dynamically from Jicofo.
  707. * @param {boolean} audioMute - Whether the configuration requests that audio
  708. * is muted.
  709. * @param {boolean} videoMute - Whether the configuration requests that video
  710. * is muted.
  711. * @returns {Object} The event in a format suitable for sending via
  712. * sendAnalytics.
  713. */
  714. export function createStartMutedConfigurationEvent(
  715. source,
  716. audioMute,
  717. videoMute) {
  718. return {
  719. action: 'start.muted.configuration',
  720. attributes: {
  721. source,
  722. 'audio_mute': audioMute,
  723. 'video_mute': videoMute
  724. }
  725. };
  726. }
  727. /**
  728. * Automatically changing the mute state of a media track in order to match
  729. * the current stored state in redux.
  730. *
  731. * @param {string} mediaType - The track's media type ('audio' or 'video').
  732. * @param {boolean} muted - Whether the track is being muted or unmuted as
  733. * as result of the sync operation.
  734. * @returns {Object} The event in a format suitable for sending via
  735. * sendAnalytics.
  736. */
  737. export function createSyncTrackStateEvent(mediaType, muted) {
  738. return {
  739. action: 'sync.track.state',
  740. attributes: {
  741. 'media_type': mediaType,
  742. muted
  743. }
  744. };
  745. }
  746. /**
  747. * Creates an event associated with a toolbar button being clicked/pressed. By
  748. * convention, where appropriate an attribute named 'enable' should be used to
  749. * indicate the action which resulted by the shortcut being pressed (e.g.
  750. * Whether screen sharing was enabled or disabled).
  751. *
  752. * @param {string} buttonName - The identifier of the toolbar button which was
  753. * clicked/pressed.
  754. * @param {Object} attributes - Attributes to attach to the event.
  755. * @returns {Object} The event in a format suitable for sending via
  756. * sendAnalytics.
  757. */
  758. export function createToolbarEvent(buttonName, attributes = {}) {
  759. return {
  760. action: 'clicked',
  761. actionSubject: buttonName,
  762. attributes,
  763. source: 'toolbar.button',
  764. type: TYPE_UI
  765. };
  766. }
  767. /**
  768. * Creates an event associated with a reaction button being clicked/pressed.
  769. *
  770. * @param {string} buttonName - The identifier of the reaction button which was
  771. * clicked/pressed.
  772. * @returns {Object} The event in a format suitable for sending via
  773. * sendAnalytics.
  774. */
  775. export function createReactionMenuEvent(buttonName) {
  776. return {
  777. action: 'clicked',
  778. actionSubject: buttonName,
  779. source: 'reaction.button',
  780. type: TYPE_UI
  781. };
  782. }
  783. /**
  784. * Creates an event which indicates that a local track was muted.
  785. *
  786. * @param {string} mediaType - The track's media type ('audio' or 'video').
  787. * @param {string} reason - The reason the track was muted (e.g. It was
  788. * triggered by the "initial mute" option, or a previously muted track was
  789. * replaced (e.g. When a new device was used)).
  790. * @param {boolean} muted - Whether the track was muted or unmuted.
  791. * @returns {Object} The event in a format suitable for sending via
  792. * sendAnalytics.
  793. */
  794. export function createTrackMutedEvent(mediaType, reason, muted = true) {
  795. return {
  796. action: 'track.muted',
  797. attributes: {
  798. 'media_type': mediaType,
  799. muted,
  800. reason
  801. }
  802. };
  803. }
  804. /**
  805. * Creates an event for joining a vpaas conference.
  806. *
  807. * @param {string} tenant - The conference tenant.
  808. * @returns {Object} The event in a format suitable for sending via
  809. * sendAnalytics.
  810. */
  811. export function createVpaasConferenceJoinedEvent(tenant) {
  812. return {
  813. action: 'vpaas.conference.joined',
  814. attributes: {
  815. tenant
  816. }
  817. };
  818. }
  819. /**
  820. * Creates an event for an action on the welcome page.
  821. *
  822. * @param {string} action - The action that the event represents.
  823. * @param {string} actionSubject - The subject that was acted upon.
  824. * @param {boolean} attributes - Additional attributes to attach to the event.
  825. * @returns {Object} The event in a format suitable for sending via
  826. * sendAnalytics.
  827. */
  828. export function createWelcomePageEvent(action, actionSubject, attributes = {}) {
  829. return {
  830. action,
  831. actionSubject,
  832. attributes,
  833. source: 'welcomePage'
  834. };
  835. }
  836. /**
  837. * Creates an event which indicates a screenshot of the screensharing has been taken.
  838. *
  839. * @returns {Object} The event in a format suitable for sending via
  840. * sendAnalytics.
  841. */
  842. export function createScreensharingCaptureTakenEvent() {
  843. return {
  844. action: 'screen.sharing.capture'
  845. };
  846. }