Skip to content

Commit

Permalink
Send analytics to know how users display the game details
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreSi committed Nov 24, 2023
1 parent 1f610cf commit 00c80f9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions newIDE/app/src/GameDashboard/GameDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { GameAnalyticsPanel } from './GameAnalyticsPanel';
import GameFeedback from './Feedbacks/GameFeedback';
import { GameMonetization } from './Monetization/GameMonetization';
import RouterContext from '../MainFrame/RouterContext';
import { sendGameDetailsOpened } from '../Utils/Analytics/EventSender';

export type GameDetailsTab =
| 'details'
Expand Down Expand Up @@ -88,6 +89,7 @@ type Props = {|
onLoading: boolean => void,
currentTab: GameDetailsTab,
setCurrentTab: GameDetailsTab => void,
analyticsSource: 'profile' | 'homepage' | 'projectManager',
|};

const GameDetails = ({
Expand All @@ -98,6 +100,7 @@ const GameDetails = ({
onLoading,
currentTab,
setCurrentTab,
analyticsSource,
}: Props) => {
const { routeArguments, removeRouteArguments } = React.useContext(
RouterContext
Expand Down Expand Up @@ -157,6 +160,13 @@ const GameDetails = ({
[loadPublicGame]
);

React.useEffect(
() => {
sendGameDetailsOpened({ from: analyticsSource });
},
[analyticsSource]
);

const handleGameUpdated = React.useCallback(
(updatedGame: Game) => {
// Set Public Game to null to show the loader.
Expand Down
3 changes: 3 additions & 0 deletions newIDE/app/src/GameDashboard/GameDetailsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Props = {|
onClose: () => void,
onGameUpdated: (updatedGame: Game) => void,
onGameDeleted: () => void,
analyticsSource: 'profile' | 'homepage' | 'projectManager',
|};

export const GameDetailsDialog = ({
Expand All @@ -26,6 +27,7 @@ export const GameDetailsDialog = ({
onClose,
onGameUpdated,
onGameDeleted,
analyticsSource,
}: Props) => {
const [isLoading, setIsLoading] = React.useState<boolean>(false);
const [currentTab, setCurrentTab] = React.useState<GameDetailsTab>('details');
Expand Down Expand Up @@ -75,6 +77,7 @@ export const GameDetailsDialog = ({
onLoading={setIsLoading}
currentTab={currentTab}
setCurrentTab={setCurrentTab}
analyticsSource={analyticsSource}
/>
</Dialog>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const ManageSection = ({
onLoading={() => {}}
currentTab={currentTab}
setCurrentTab={setCurrentTab}
analyticsSource="homepage"
/>
</ColumnStackLayout>
</Paper>
Expand Down
1 change: 1 addition & 0 deletions newIDE/app/src/Profile/ProfileDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ const ProfileDialog = ({ currentProject, open, onClose }: Props) => {
setOpenedGame(null);
fetchGames();
}}
analyticsSource="profile"
/>
)}
</Dialog>
Expand Down
6 changes: 6 additions & 0 deletions newIDE/app/src/Utils/Analytics/EventSender.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ export const sendExportLaunched = (exportKind: string) => {
});
};

export const sendGameDetailsOpened = (options: {
from: 'profile' | 'homepage' | 'projectManager',
}) => {
recordEvent('game_details_opened', options);
};

export const sendExampleDetailsOpened = (slug: string) => {
recordEvent('example-details-opened', { slug });
};
Expand Down

0 comments on commit 00c80f9

Please sign in to comment.