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

AnalyticsEvents.js 22KB

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