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

AnalyticsEvents.js 13KB

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