Skip to content

Commit

Permalink
chore(analytics): Track play event inside library
Browse files Browse the repository at this point in the history
  • Loading branch information
yadPe committed Apr 10, 2021
1 parent 26838c3 commit e3271f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/App/Providers/AudioPlayer/useBeatmapSong.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { useSelector } from 'react-redux';
import { remote } from 'electron';
import { getOsuSongPath } from '../../modules/Settings/reducer/selectors';
import { useDownloadHistory } from '../HistoryProvider';
import { getAudioFilePath, makePlaylist } from './audioPlayer.helpers';
import { useAudioPlayer } from './AudioPlayerProvider.bs';

const { trackEvent } = remote.getGlobal('tracking');

const useBeatmapSong = ({ id, title, artist, collectionName }, mode = '', items = []) => {
const isLibraryMode = mode === 'library';

Expand All @@ -28,6 +31,7 @@ const useBeatmapSong = ({ id, title, artist, collectionName }, mode = '', items
audioPlayer.setAudio({ id, title, artist }, audioPath || undefined);
audioPlayer.setPlaylist(makePlaylist(items, osuSongPath, history.history), collectionName);
} else audioPlayer.setAudio({ id, title, artist }, audioPath || undefined, previewTime || undefined);
trackEvent('beatmapPreview', 'play', mode);
};

return {
Expand Down
4 changes: 4 additions & 0 deletions src/App/modules/MyLibrary/components/Collection.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-continue */
import React, { useCallback, useEffect, useState } from 'react';
import { remote } from 'electron';
import { createUseStyles } from 'react-jss';
import { useSelector } from 'react-redux';
import { getListCoverUrl } from '../../../../shared/PpyHelpers.bs';
Expand All @@ -9,6 +10,8 @@ import { useDownloadHistory } from '../../../Providers/HistoryProvider';
import { getOsuSongPath } from '../../Settings/reducer/selectors';
import CollectionCover from './CollectionCover';

const { trackEvent } = remote.getGlobal('tracking');

const useStyle = createUseStyles({
collectionWrapper: {
padding: '1rem',
Expand Down Expand Up @@ -89,6 +92,7 @@ const Collection = ({ name, beatmapsHash, select }) => {
getAudioFilePath(osuSongPath, beatmaps[0].audioPath) || undefined,
);
audioPlayer.setPlaylist(makePlaylist(beatmaps, osuSongPath), name);
trackEvent('collectionPlay', 'start');
};

const handleClick = () => {
Expand Down

0 comments on commit e3271f7

Please sign in to comment.