You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AnalyticsEvents.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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 indicates that the recent list container is shown and
  173. * selected.
  174. *
  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 createRecentSelectedEvent(attributes = {}) {
  180. return {
  181. action: 'selected',
  182. actionSubject: 'recent.list.selected',
  183. attributes,
  184. source: 'recent.list',
  185. type: TYPE_UI
  186. };
  187. }
  188. /**
  189. * Creates an event for an action on the deep linking page.
  190. *
  191. * @param {string} action - The action that the event represents.
  192. * @param {string} actionSubject - The subject that was acted upon.
  193. * @param {boolean} attributes - Additional attributes to attach to the event.
  194. * @returns {Object} The event in a format suitable for sending via
  195. * sendAnalytics.
  196. */
  197. export function createDeepLinkingPageEvent(
  198. action, actionSubject, attributes = {}) {
  199. return {
  200. action,
  201. actionSubject,
  202. source: 'deepLinkingPage',
  203. attributes
  204. };
  205. }
  206. /**
  207. * Creates an event which indicates that a device was changed.
  208. *
  209. * @param {string} mediaType - The media type of the device ('audio' or
  210. * 'video').
  211. * @param {string} deviceType - The type of the device ('input' or 'output').
  212. * @returns {Object} The event in a format suitable for sending via
  213. * sendAnalytics.
  214. */
  215. export function createDeviceChangedEvent(mediaType, deviceType) {
  216. return {
  217. action: 'device.changed',
  218. attributes: {
  219. 'device_type': deviceType,
  220. 'media_type': mediaType
  221. }
  222. };
  223. }
  224. /**
  225. * Creates an event which specifies that the feedback dialog has been opened.
  226. *
  227. * @returns {Object} The event in a format suitable for sending via
  228. * sendAnalytics.
  229. */
  230. export function createFeedbackOpenEvent() {
  231. return {
  232. action: 'feedback.opened'
  233. };
  234. }
  235. /**
  236. * Creates an event for an action regarding the AddPeopleDialog (invites).
  237. *
  238. * @param {string} action - The action that the event represents.
  239. * @param {string} actionSubject - The subject that was acted upon.
  240. * @param {boolean} attributes - Additional attributes to attach to the event.
  241. * @returns {Object} The event in a format suitable for sending via
  242. * sendAnalytics.
  243. */
  244. export function createInviteDialogEvent(
  245. action, actionSubject, attributes = {}) {
  246. return {
  247. action,
  248. actionSubject,
  249. attributes,
  250. source: 'inviteDialog'
  251. };
  252. }
  253. /**
  254. * Creates an event which reports about the current network information reported by the operating system.
  255. *
  256. * @param {boolean} isOnline - Tells whether or not the internet is reachable.
  257. * @param {string} [networkType] - Network type, see {@code NetworkInfo} type defined by the 'base/net-info' feature.
  258. * @param {Object} [details] - Extra info, see {@code NetworkInfo} type defined by the 'base/net-info' feature.
  259. * @returns {Object}
  260. */
  261. export function createNetworkInfoEvent({ isOnline, networkType, details }) {
  262. const attributes = { isOnline };
  263. // Do no include optional stuff or Amplitude handler will log warnings.
  264. networkType && (attributes.networkType = networkType);
  265. details && (attributes.details = details);
  266. return {
  267. action: 'network.info',
  268. attributes
  269. };
  270. }
  271. /**
  272. * Creates an "offer/answer failure" event.
  273. *
  274. * @returns {Object} The event in a format suitable for sending via
  275. * sendAnalytics.
  276. */
  277. export function createOfferAnswerFailedEvent() {
  278. return {
  279. action: 'offer.answer.failure'
  280. };
  281. }
  282. /**
  283. * Creates a "page reload" event.
  284. *
  285. * @param {string} reason - The reason for the reload.
  286. * @param {number} timeout - The timeout in seconds after which the page is
  287. * scheduled to reload.
  288. * @param {Object} details - The details for the error.
  289. * @returns {Object} The event in a format suitable for sending via
  290. * sendAnalytics.
  291. */
  292. export function createPageReloadScheduledEvent(reason, timeout, details) {
  293. return {
  294. action: 'page.reload.scheduled',
  295. attributes: {
  296. reason,
  297. timeout,
  298. ...details
  299. }
  300. };
  301. }
  302. /**
  303. * Creates a "pinned" or "unpinned" event.
  304. *
  305. * @param {string} action - The action ("pinned" or "unpinned").
  306. * @param {string} participantId - The ID of the participant which was pinned.
  307. * @param {Object} attributes - Attributes to attach to the event.
  308. * @returns {Object} The event in a format suitable for sending via
  309. * sendAnalytics.
  310. */
  311. export function createPinnedEvent(action, participantId, attributes) {
  312. return {
  313. type: TYPE_TRACK,
  314. action,
  315. actionSubject: 'participant',
  316. objectType: 'participant',
  317. objectId: participantId,
  318. attributes
  319. };
  320. }
  321. /**
  322. * Creates an event which indicates that a button in the profile panel was
  323. * clicked.
  324. *
  325. * @param {string} buttonName - The name of the button.
  326. * @param {Object} attributes - Attributes to attach to the event.
  327. * @returns {Object} The event in a format suitable for sending via
  328. * sendAnalytics.
  329. */
  330. export function createProfilePanelButtonEvent(buttonName, attributes = {}) {
  331. return {
  332. action: 'clicked',
  333. actionSubject: buttonName,
  334. attributes,
  335. source: 'profile.panel',
  336. type: TYPE_UI
  337. };
  338. }
  339. /**
  340. * Creates an event which indicates that a specific button on one of the
  341. * recording-related dialogs was clicked.
  342. *
  343. * @param {string} dialogName - The name of the dialog (e.g. 'start' or 'stop').
  344. * @param {string} buttonName - The name of the button (e.g. 'confirm' or
  345. * 'cancel').
  346. * @param {Object} attributes - Attributes to attach to the event.
  347. * @returns {Object} The event in a format suitable for sending via
  348. * sendAnalytics.
  349. */
  350. export function createRecordingDialogEvent(
  351. dialogName, buttonName, attributes = {}) {
  352. return {
  353. action: 'clicked',
  354. actionSubject: buttonName,
  355. attributes,
  356. source: `${dialogName}.recording.dialog`,
  357. type: TYPE_UI
  358. };
  359. }
  360. /**
  361. * Creates an event which indicates that a specific button on one of the
  362. * liveStreaming-related dialogs was clicked.
  363. *
  364. * @param {string} dialogName - The name of the dialog (e.g. 'start' or 'stop').
  365. * @param {string} buttonName - The name of the button (e.g. 'confirm' or
  366. * 'cancel').
  367. * @returns {Object} The event in a format suitable for sending via
  368. * sendAnalytics.
  369. */
  370. export function createLiveStreamingDialogEvent(dialogName, buttonName) {
  371. return {
  372. action: 'clicked',
  373. actionSubject: buttonName,
  374. source: `${dialogName}.liveStreaming.dialog`,
  375. type: TYPE_UI
  376. };
  377. }
  378. /**
  379. * Creates an event with the local tracks duration.
  380. *
  381. * @param {Object} duration - The object with the duration of the local tracks.
  382. * @returns {Object} The event in a format suitable for sending via
  383. * sendAnalytics.
  384. */
  385. export function createLocalTracksDurationEvent(duration) {
  386. const { audio, video, conference } = duration;
  387. const { camera, desktop } = video;
  388. return {
  389. action: 'local.tracks.durations',
  390. attributes: {
  391. audio: audio.value,
  392. camera: camera.value,
  393. conference: conference.value,
  394. desktop: desktop.value
  395. }
  396. };
  397. }
  398. /**
  399. * Creates an event which indicates that an action related to recording has
  400. * occured.
  401. *
  402. * @param {string} action - The action (e.g. 'start' or 'stop').
  403. * @param {string} type - The recording type (e.g. 'file' or 'live').
  404. * @param {number} value - The duration of the recording in seconds (for stop
  405. * action).
  406. * @returns {Object} The event in a format suitable for sending via
  407. * sendAnalytics.
  408. */
  409. export function createRecordingEvent(action, type, value) {
  410. return {
  411. action,
  412. actionSubject: `recording.${type}`,
  413. attributes: {
  414. value
  415. }
  416. };
  417. }
  418. /**
  419. * Creates an event which indicates that the same conference has been rejoined.
  420. *
  421. * @param {string} url - The full conference URL.
  422. * @param {number} lastConferenceDuration - How many seconds user stayed in the previous conference.
  423. * @param {number} timeSinceLeft - How many seconds since the last conference was left.
  424. * @returns {Object} The event in a format suitable for sending via sendAnalytics.
  425. */
  426. export function createRejoinedEvent({ url, lastConferenceDuration, timeSinceLeft }) {
  427. return {
  428. action: 'rejoined',
  429. attributes: {
  430. lastConferenceDuration,
  431. timeSinceLeft,
  432. url
  433. }
  434. };
  435. }
  436. /**
  437. * Creates an event which specifies that the "confirm" button on the remote
  438. * mute dialog has been clicked.
  439. *
  440. * @param {string} participantId - The ID of the participant that was remotely
  441. * muted.
  442. * @returns {Object} The event in a format suitable for sending via
  443. * sendAnalytics.
  444. */
  445. export function createRemoteMuteConfirmedEvent(participantId) {
  446. return {
  447. action: 'clicked',
  448. actionSubject: 'remote.mute.dialog.confirm.button',
  449. attributes: {
  450. 'participant_id': participantId
  451. },
  452. source: 'remote.mute.dialog',
  453. type: TYPE_UI
  454. };
  455. }
  456. /**
  457. * Creates an event which indicates that one of the buttons in the "remote
  458. * video menu" was clicked.
  459. *
  460. * @param {string} buttonName - The name of the button.
  461. * @param {Object} attributes - Attributes to attach to the event.
  462. * @returns {Object} The event in a format suitable for sending via
  463. * sendAnalytics.
  464. */
  465. export function createRemoteVideoMenuButtonEvent(buttonName, attributes) {
  466. return {
  467. action: 'clicked',
  468. actionSubject: buttonName,
  469. attributes,
  470. source: 'remote.video.menu',
  471. type: TYPE_UI
  472. };
  473. }
  474. /**
  475. * Creates an event indicating that an action related to video blur
  476. * occurred (e.g. It was started or stopped).
  477. *
  478. * @param {string} action - The action which occurred.
  479. * @returns {Object} The event in a format suitable for sending via
  480. * sendAnalytics.
  481. */
  482. export function createVideoBlurEvent(action) {
  483. return {
  484. action,
  485. actionSubject: 'video.blur'
  486. };
  487. }
  488. /**
  489. * Creates an event indicating that an action related to screen sharing
  490. * occurred (e.g. It was started or stopped).
  491. *
  492. * @param {string} action - The action which occurred.
  493. * @returns {Object} The event in a format suitable for sending via
  494. * sendAnalytics.
  495. */
  496. export function createScreenSharingEvent(action) {
  497. return {
  498. action,
  499. actionSubject: 'screen.sharing'
  500. };
  501. }
  502. /**
  503. * The local participant failed to send a "selected endpoint" message to the
  504. * bridge.
  505. *
  506. * @param {Error} error - The error which caused the failure.
  507. * @returns {Object} The event in a format suitable for sending via
  508. * sendAnalytics.
  509. */
  510. export function createSelectParticipantFailedEvent(error) {
  511. const event = {
  512. action: 'select.participant.failed'
  513. };
  514. if (error) {
  515. event.error = error.toString();
  516. }
  517. return event;
  518. }
  519. /**
  520. * Creates an event associated with the "shared video" feature.
  521. *
  522. * @param {string} action - The action that the event represents.
  523. * @param {Object} attributes - Attributes to attach to the event.
  524. * @returns {Object} The event in a format suitable for sending via
  525. * sendAnalytics.
  526. */
  527. export function createSharedVideoEvent(action, attributes = {}) {
  528. return {
  529. action,
  530. attributes,
  531. actionSubject: 'shared.video'
  532. };
  533. }
  534. /**
  535. * Creates an event associated with a shortcut being pressed, released or
  536. * triggered. By convention, where appropriate an attribute named 'enable'
  537. * should be used to indicate the action which resulted by the shortcut being
  538. * pressed (e.g. Whether screen sharing was enabled or disabled).
  539. *
  540. * @param {string} shortcut - The identifier of the shortcut which produced
  541. * an action.
  542. * @param {string} action - The action that the event represents (one
  543. * of ACTION_SHORTCUT_PRESSED, ACTION_SHORTCUT_RELEASED
  544. * or ACTION_SHORTCUT_TRIGGERED).
  545. * @param {Object} attributes - Attributes to attach to the event.
  546. * @returns {Object} The event in a format suitable for sending via
  547. * sendAnalytics.
  548. */
  549. export function createShortcutEvent(
  550. shortcut,
  551. action = ACTION_SHORTCUT_TRIGGERED,
  552. attributes = {}) {
  553. return {
  554. action,
  555. actionSubject: 'keyboard.shortcut',
  556. actionSubjectId: shortcut,
  557. attributes,
  558. source: 'keyboard.shortcut',
  559. type: TYPE_UI
  560. };
  561. }
  562. /**
  563. * Creates an event which indicates the "start audio only" configuration.
  564. *
  565. * @param {boolean} audioOnly - Whether "start audio only" is enabled or not.
  566. * @returns {Object} The event in a format suitable for sending via
  567. * sendAnalytics.
  568. */
  569. export function createStartAudioOnlyEvent(audioOnly) {
  570. return {
  571. action: 'start.audio.only',
  572. attributes: {
  573. enabled: audioOnly
  574. }
  575. };
  576. }
  577. /**
  578. * Creates an event which indicates the "start silent" configuration.
  579. *
  580. * @returns {Object} The event in a format suitable for sending via
  581. * sendAnalytics.
  582. */
  583. export function createStartSilentEvent() {
  584. return {
  585. action: 'start.silent'
  586. };
  587. }
  588. /**
  589. * Creates an event which indicates the "start muted" configuration.
  590. *
  591. * @param {string} source - The source of the configuration, 'local' or
  592. * 'remote' depending on whether it comes from the static configuration (i.e.
  593. * {@code config.js}) or comes dynamically from Jicofo.
  594. * @param {boolean} audioMute - Whether the configuration requests that audio
  595. * is muted.
  596. * @param {boolean} videoMute - Whether the configuration requests that video
  597. * is muted.
  598. * @returns {Object} The event in a format suitable for sending via
  599. * sendAnalytics.
  600. */
  601. export function createStartMutedConfigurationEvent(
  602. source,
  603. audioMute,
  604. videoMute) {
  605. return {
  606. action: 'start.muted.configuration',
  607. attributes: {
  608. source,
  609. 'audio_mute': audioMute,
  610. 'video_mute': videoMute
  611. }
  612. };
  613. }
  614. /**
  615. * Creates an event which indicates the delay for switching between simulcast
  616. * streams.
  617. *
  618. * @param {Object} attributes - Attributes to attach to the event.
  619. * @returns {Object} The event in a format suitable for sending via
  620. * sendAnalytics.
  621. */
  622. export function createStreamSwitchDelayEvent(attributes) {
  623. return {
  624. action: 'stream.switch.delay',
  625. attributes
  626. };
  627. }
  628. /**
  629. * Automatically changing the mute state of a media track in order to match
  630. * the current stored state in redux.
  631. *
  632. * @param {string} mediaType - The track's media type ('audio' or 'video').
  633. * @param {boolean} muted - Whether the track is being muted or unmuted as
  634. * as result of the sync operation.
  635. * @returns {Object} The event in a format suitable for sending via
  636. * sendAnalytics.
  637. */
  638. export function createSyncTrackStateEvent(mediaType, muted) {
  639. return {
  640. action: 'sync.track.state',
  641. attributes: {
  642. 'media_type': mediaType,
  643. muted
  644. }
  645. };
  646. }
  647. /**
  648. * Creates an event associated with a toolbar button being clicked/pressed. By
  649. * convention, where appropriate an attribute named 'enable' should be used to
  650. * indicate the action which resulted by the shortcut being pressed (e.g.
  651. * Whether screen sharing was enabled or disabled).
  652. *
  653. * @param {string} buttonName - The identifier of the toolbar button which was
  654. * clicked/pressed.
  655. * @param {Object} attributes - Attributes to attach to the event.
  656. * @returns {Object} The event in a format suitable for sending via
  657. * sendAnalytics.
  658. */
  659. export function createToolbarEvent(buttonName, attributes = {}) {
  660. return {
  661. action: 'clicked',
  662. actionSubject: buttonName,
  663. attributes,
  664. source: 'toolbar.button',
  665. type: TYPE_UI
  666. };
  667. }
  668. /**
  669. * Creates an event which indicates that a local track was muted.
  670. *
  671. * @param {string} mediaType - The track's media type ('audio' or 'video').
  672. * @param {string} reason - The reason the track was muted (e.g. It was
  673. * triggered by the "initial mute" option, or a previously muted track was
  674. * replaced (e.g. When a new device was used)).
  675. * @param {boolean} muted - Whether the track was muted or unmuted.
  676. * @returns {Object} The event in a format suitable for sending via
  677. * sendAnalytics.
  678. */
  679. export function createTrackMutedEvent(mediaType, reason, muted = true) {
  680. return {
  681. action: 'track.muted',
  682. attributes: {
  683. 'media_type': mediaType,
  684. muted,
  685. reason
  686. }
  687. };
  688. }
  689. /**
  690. * Creates an event for an action on the welcome page.
  691. *
  692. * @param {string} action - The action that the event represents.
  693. * @param {string} actionSubject - The subject that was acted upon.
  694. * @param {boolean} attributes - Additional attributes to attach to the event.
  695. * @returns {Object} The event in a format suitable for sending via
  696. * sendAnalytics.
  697. */
  698. export function createWelcomePageEvent(action, actionSubject, attributes = {}) {
  699. return {
  700. action,
  701. actionSubject,
  702. attributes,
  703. source: 'welcomePage'
  704. };
  705. }