選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

AnalyticsEvents.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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 const createApiEvent = function(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 turned
  79. * off.
  80. *
  81. * @returns {Object} The event in a format suitable for sending via
  82. * sendAnalytics.
  83. */
  84. export const createAudioOnlyDisableEvent = function() {
  85. return {
  86. action: 'audio.only.disabled'
  87. };
  88. };
  89. /**
  90. * Creates an event which indicates that a device was changed.
  91. *
  92. * @param {string} mediaType - The media type of the device ('audio' or
  93. * 'video').
  94. * @param {string} deviceType - The type of the device ('input' or 'output').
  95. * @returns {Object} The event in a format suitable for sending via
  96. * sendAnalytics.
  97. */
  98. export const createDeviceChangedEvent = function(mediaType, deviceType) {
  99. return {
  100. action: 'device.changed',
  101. attributes: {
  102. 'device_type': deviceType,
  103. 'media_type': mediaType
  104. }
  105. };
  106. };
  107. /**
  108. * Creates an event which specifies that the feedback dialog has been opened.
  109. *
  110. * @returns {Object} The event in a format suitable for sending via
  111. * sendAnalytics.
  112. */
  113. export const createFeedbackOpenEvent = function() {
  114. return {
  115. action: 'feedback.opened'
  116. };
  117. };
  118. /**
  119. * Creates an event which indicates that the invite dialog was closed. This is
  120. * not a TYPE_UI event, since it is not necessarily the result of a user
  121. * interaction.
  122. *
  123. * @returns {Object} The event in a format suitable for sending via
  124. * sendAnalytics.
  125. */
  126. export const createInviteDialogClosedEvent = function() {
  127. return {
  128. action: 'invite.dialog.closed'
  129. };
  130. };
  131. /**
  132. * Creates a "page reload" event.
  133. *
  134. * @param {string} reason - The reason for the reload.
  135. * @param {number} timeout - The timeout in seconds after which the page is
  136. * scheduled to reload.
  137. * @param {Object} details - The details for the error.
  138. * @returns {Object} The event in a format suitable for sending via
  139. * sendAnalytics.
  140. */
  141. export const createPageReloadScheduledEvent
  142. = function(reason, timeout, details) {
  143. return {
  144. action: 'page.reload.scheduled',
  145. attributes: {
  146. reason,
  147. timeout,
  148. ...details
  149. }
  150. };
  151. };
  152. /**
  153. * Creates a "pinned" or "unpinned" event.
  154. *
  155. * @param {string} action - The action ("pinned" or "unpinned").
  156. * @param {string} participantId - The ID of the participant which was pinned.
  157. * @param {Object} attributes - Attributes to attach to the event.
  158. * @returns {Object} The event in a format suitable for sending via
  159. * sendAnalytics.
  160. */
  161. export const createPinnedEvent
  162. = function(action, participantId, attributes) {
  163. return {
  164. type: TYPE_TRACK,
  165. action,
  166. actionSubject: 'participant',
  167. objectType: 'participant',
  168. objectId: participantId,
  169. attributes
  170. };
  171. };
  172. /**
  173. * Creates an event which indicates that a button in the profile panel was
  174. * clicked.
  175. *
  176. * @param {string} buttonName - The name of the button.
  177. * @param {Object} attributes - Attributes to attach to the event.
  178. * @returns {Object} The event in a format suitable for sending via
  179. * sendAnalytics.
  180. */
  181. export const createProfilePanelButtonEvent
  182. = function(buttonName, attributes = {}) {
  183. return {
  184. action: 'clicked',
  185. actionSubject: buttonName,
  186. attributes,
  187. source: 'profile.panel',
  188. type: TYPE_UI
  189. };
  190. };
  191. /**
  192. * Creates an event which indicates that a specific button on one of the
  193. * recording-related dialogs was clicked.
  194. *
  195. * @param {string} dialogName - The name of the dialog (e.g. 'start' or 'stop').
  196. * @param {string} buttonName - The name of the button (e.g. 'confirm' or
  197. * 'cancel').
  198. * @returns {Object} The event in a format suitable for sending via
  199. * sendAnalytics.
  200. */
  201. export const createRecordingDialogEvent = function(dialogName, buttonName) {
  202. return {
  203. action: 'clicked',
  204. actionSubject: buttonName,
  205. source: `${dialogName}.recording.dialog`,
  206. type: TYPE_UI
  207. };
  208. };
  209. /**
  210. * Creates an event which specifies that the "confirm" button on the remote
  211. * mute dialog has been clicked.
  212. *
  213. * @param {string} participantId - The ID of the participant that was remotely
  214. * muted.
  215. * @returns {Object} The event in a format suitable for sending via
  216. * sendAnalytics.
  217. */
  218. export const createRemoteMuteConfirmedEvent = function(participantId) {
  219. return {
  220. action: 'clicked',
  221. actionSubject: 'remote.mute.dialog.confirm.button',
  222. attributes: {
  223. 'participant_id': participantId
  224. },
  225. source: 'remote.mute.dialog',
  226. type: TYPE_UI
  227. };
  228. };
  229. /**
  230. * Creates an event which indicates that one of the buttons in the "remote
  231. * video menu" was clicked.
  232. *
  233. * @param {string} buttonName - The name of the button.
  234. * @param {Object} attributes - Attributes to attach to the event.
  235. * @returns {Object} The event in a format suitable for sending via
  236. * sendAnalytics.
  237. */
  238. export const createRemoteVideoMenuButtonEvent
  239. = function(buttonName, attributes) {
  240. return {
  241. action: 'clicked',
  242. actionSubject: buttonName,
  243. attributes,
  244. source: 'remote.video.menu',
  245. type: TYPE_UI
  246. };
  247. };
  248. /**
  249. * Creates an event indicating that an action related to screen sharing
  250. * occurred (e.g. it was started or stopped).
  251. *
  252. * @param {string} action - The action which occurred.
  253. * @returns {Object} The event in a format suitable for sending via
  254. * sendAnalytics.
  255. */
  256. export const createScreenSharingEvent = function(action) {
  257. return {
  258. action,
  259. actionSubject: 'screen.sharing'
  260. };
  261. };
  262. /**
  263. * The local participant failed to send a "selected endpoint" message to the
  264. * bridge.
  265. *
  266. * @param {Error} error - The error which caused the failure.
  267. * @returns {Object} The event in a format suitable for sending via
  268. * sendAnalytics.
  269. */
  270. export const createSelectParticipantFailedEvent = function(error) {
  271. const event = {
  272. action: 'select.participant.failed'
  273. };
  274. if (error) {
  275. event.error = error.toString();
  276. }
  277. return event;
  278. };
  279. /**
  280. * Creates an event associated with the "shared video" feature.
  281. *
  282. * @param {string} action - The action that the event represents.
  283. * @param {Object} attributes - Attributes to attach to the event.
  284. * @returns {Object} The event in a format suitable for sending via
  285. * sendAnalytics.
  286. */
  287. export const createSharedVideoEvent = function(action, attributes = {}) {
  288. return {
  289. action,
  290. attributes,
  291. actionSubject: 'shared.video'
  292. };
  293. };
  294. /**
  295. * Creates an event associated with a shortcut being pressed, released or
  296. * triggered. By convention, where appropriate an attribute named 'enable'
  297. * should be used to indicate the action which resulted by the shortcut being
  298. * pressed (e.g. whether screen sharing was enabled or disabled).
  299. *
  300. * @param {string} shortcut - The identifier of the shortcut which produced
  301. * an action.
  302. * @param {string} action - The action that the event represents (one
  303. * of ACTION_SHORTCUT_PRESSED, ACTION_SHORTCUT_RELEASED
  304. * or ACTION_SHORTCUT_TRIGGERED).
  305. * @param {Object} attributes - Attributes to attach to the event.
  306. * @returns {Object} The event in a format suitable for sending via
  307. * sendAnalytics.
  308. */
  309. export const createShortcutEvent
  310. = function(shortcut, action = ACTION_SHORTCUT_TRIGGERED, attributes = {}) {
  311. return {
  312. action,
  313. actionSubject: 'keyboard.shortcut',
  314. actionSubjectId: shortcut,
  315. attributes,
  316. source: 'keyboard.shortcut',
  317. type: TYPE_UI
  318. };
  319. };
  320. /**
  321. * Creates an event which indicates the "start audio only" configuration.
  322. *
  323. * @param {boolean} audioOnly - Whether "start audio only" is enabled or not.
  324. * @returns {Object} The event in a format suitable for sending via
  325. * sendAnalytics.
  326. */
  327. export const createStartAudioOnlyEvent = function(audioOnly) {
  328. return {
  329. action: 'start.audio.only',
  330. attributes: {
  331. enabled: audioOnly
  332. }
  333. };
  334. };
  335. /**
  336. * Creates an event which indicates the "start muted" configuration.
  337. *
  338. * @param {string} source - The source of the configuration, 'local' or
  339. * 'remote' depending on whether it comes from the static configuration (i.e.
  340. * config.js) or comes dynamically from Jicofo.
  341. * @param {boolean} audioMute - Whether the configuration requests that audio
  342. * is muted.
  343. * @param {boolean} videoMute - Whether the configuration requests that video
  344. * is muted.
  345. * @returns {Object} The event in a format suitable for sending via
  346. * sendAnalytics.
  347. */
  348. export const createStartMutedConfigurationEvent
  349. = function(source, audioMute, videoMute) {
  350. return {
  351. action: 'start.muted.configuration',
  352. attributes: {
  353. source,
  354. 'audio_mute': audioMute,
  355. 'video_mute': videoMute
  356. }
  357. };
  358. };
  359. /**
  360. * Creates an event which indicates the delay for switching between simulcast
  361. * streams.
  362. *
  363. * @param {Object} attributes - Attributes to attach to the event.
  364. * @returns {Object} The event in a format suitable for sending via
  365. * sendAnalytics.
  366. */
  367. export const createStreamSwitchDelayEvent = function(attributes) {
  368. return {
  369. action: 'stream.switch.delay',
  370. attributes
  371. };
  372. };
  373. /**
  374. * Automatically changing the mute state of a media track in order to match
  375. * the current stored state in redux.
  376. *
  377. * @param {string} mediaType - The track's media type ('audio' or 'video').
  378. * @param {boolean} muted - Whether the track is being muted or unmuted as
  379. * as result of the sync operation.
  380. * @returns {Object} The event in a format suitable for sending via
  381. * sendAnalytics.
  382. */
  383. export const createSyncTrackStateEvent = function(mediaType, muted) {
  384. return {
  385. action: 'sync.track.state',
  386. attributes: {
  387. 'media_type': mediaType,
  388. muted
  389. }
  390. };
  391. };
  392. /**
  393. * Creates an event associated with a toolbar button being clicked/pressed. By
  394. * convention, where appropriate an attribute named 'enable' should be used to
  395. * indicate the action which resulted by the shortcut being pressed (e.g.
  396. * whether screen sharing was enabled or disabled).
  397. *
  398. * @param {string} buttonName - The identifier of the toolbar button which was
  399. * clicked/pressed.
  400. * @param {Object} attributes - Attributes to attach to the event.
  401. * @returns {Object} The event in a format suitable for sending via
  402. * sendAnalytics.
  403. */
  404. export const createToolbarEvent = function(buttonName, attributes = {}) {
  405. return {
  406. action: 'clicked',
  407. actionSubject: buttonName,
  408. attributes,
  409. source: 'toolbar.button',
  410. type: TYPE_UI
  411. };
  412. };
  413. /**
  414. * Creates an event which indicates that a local track was muted.
  415. *
  416. * @param {string} mediaType - The track's media type ('audio' or 'video').
  417. * @param {string} reason - The reason the track was muted (e.g. it was
  418. * triggered by the "initial mute" option, or a previously muted track was
  419. * replaced (e.g. when a new device was used)).
  420. * @param {boolean} muted - Whether the track was muted or unmuted.
  421. * @returns {Object} The event in a format suitable for sending via
  422. * sendAnalytics.
  423. */
  424. export const createTrackMutedEvent = function(mediaType, reason, muted = true) {
  425. return {
  426. action: 'track.muted',
  427. attributes: {
  428. 'media_type': mediaType,
  429. muted,
  430. reason
  431. }
  432. };
  433. };