Skip to content

Commit 6b49122

Browse files
committed
GA4-test
1 parent 4e0d4af commit 6b49122

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/GameStatusView.jsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import GtagHelper from './GtagHelper';
43

54
const GameStatusView = props => {
6-
const handleRestartClick = () => {
7-
GtagHelper.sendEvent('restart_game', {
8-
event_category: 'game',
9-
event_label: 'User clicked restart',
10-
});
11-
props.onShowNumCardsSelection();
12-
};
135

146
if (props.gameComplete) {
157
return <>
@@ -22,7 +14,7 @@ const GameStatusView = props => {
2214
<div>
2315
Turn: {props.turnNo} Pairs found: {props.pairsFound}
2416
</div>
25-
<div><button className='game-button' onClick={handleRestartClick}>Play again?</button></div>
17+
<button className='game-button' onClick={props.onShowNumCardsSelection}>Restart game</button>
2618
</>;
2719
}
2820
}

src/GameView.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { connect } from 'react-redux'
66
import { flipUpCard, checkUnmatchedPair, checkMatchedPair, initGame, showNumCardsSelection } from './actions';
77
import NumCardsSelectionView from './NumCardsSelectionView';
88
import GameStatusView from './GameStatusView';
9+
import GtagHelper from './GtagHelper';
910

1011
let timeOut = null;
1112

@@ -71,6 +72,10 @@ const mapStateToProps = state => {
7172
const mapDispatchToProps = dispatch => {
7273
return {
7374
onCardClicked: id => {
75+
GtagHelper.sendEvent('card_clicked', {
76+
event_category: 'game',
77+
event_label: 'User clicked card',
78+
});
7479
clearInterval(timeOut);
7580
dispatch(flipUpCard(id));
7681
dispatch(checkMatchedPair());
@@ -79,6 +84,10 @@ const mapDispatchToProps = dispatch => {
7984
}, 4000);
8085
},
8186
onShowNumCardsSelection: () => {
87+
GtagHelper.sendEvent('game_restarted', {
88+
event_category: 'game',
89+
event_label: 'User has initiated game restart',
90+
});
8291
dispatch(showNumCardsSelection());
8392
},
8493
onInitGame: numPairs => {

0 commit comments

Comments
 (0)