Skip to content

Commit 59c859b

Browse files
authored
219 analytics (#109)
* initial analytics * more analytics * update react-transcript-editor and defaultProps * fix typo * pr review tweaks
1 parent 4e9507d commit 59c859b

File tree

9 files changed

+110
-67
lines changed

9 files changed

+110
-67
lines changed

package-lock.json

+64-56
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
],
4141
"license": "MIT",
4242
"dependencies": {
43-
"@bbc/react-transcript-editor": "^1.0.4",
43+
"@bbc/react-transcript-editor": "^1.4.4",
4444
"@fortawesome/fontawesome-svg-core": "^1.2.19",
4545
"@fortawesome/free-brands-svg-icons": "^5.8.2",
4646
"@fortawesome/free-solid-svg-icons": "^5.10.1",

src/Breadcrumb/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ import { LinkContainer } from 'react-router-bootstrap';
66
const CustomBreadcrumb = (props) => {
77

88
const breadcrumbs = props.items.map((item) => {
9+
10+
const handleClick = () => {
11+
if (item.name.includes('Project:')) {
12+
props.handleClick();
13+
}
14+
};
15+
916
if (item.link) {
1017
return (
11-
<LinkContainer key={ item.name } to={ item.link }>
18+
<LinkContainer key={ item.name } to={ item.link } onClick={ () => handleClick() }>
1219
<Breadcrumb.Item>{item.name}</Breadcrumb.Item>
1320
</LinkContainer>
1421
);
@@ -32,6 +39,7 @@ const CustomBreadcrumb = (props) => {
3239

3340
CustomBreadcrumb.propTypes = {
3441
items: PropTypes.array,
42+
handleClick: PropTypes.func,
3543
};
3644

3745
CustomBreadcrumb.defaultProps = {

src/Breadcrumb/stories/index.stories.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ storiesOf('Breadcrumb', module)
4444
})
4545
.add('Paper Edits', () => {
4646
return (
47-
<section style={ { height: '90vh', overflow: 'scroll' } }>
47+
<section
48+
style={ { height: '90vh', overflow: 'scroll' } }
49+
>
4850
<Breadcrumb
4951
items={ breadcrumbItems.paperEdits }
5052
/>

src/PreviewCanvas/VideoContextPreview/VideoContextProgressBar.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useRef, useEffect, useLayoutEffect } from 'react';
1+
import React, { useState, useRef, useEffect } from 'react';
22
import ProgressBar from '../ProgressBar';
33
import PropTypes from 'prop-types';
44

@@ -18,6 +18,7 @@ const VideoContextProgressBar = (props) => {
1818
}
1919

2020
const handleClick = ({ nativeEvent: { offsetX } }) => {
21+
props.handleClick('seek');
2122
videoContext.currentTime = (offsetX / width) * videoContext.duration;
2223
const percent = getPercentage(videoContext.currentTime, videoContext.duration);
2324
setPercentage(percent);
@@ -51,7 +52,8 @@ const VideoContextProgressBar = (props) => {
5152
};
5253

5354
VideoContextProgressBar.propTypes = {
54-
videoContext: PropTypes.any
55+
videoContext: PropTypes.any,
56+
handleClick: PropTypes.func
5557
};
5658

5759
export default VideoContextProgressBar;

src/PreviewCanvas/VideoContextPreview/index.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const VideoContextPreview = (props) => {
5151
}, [ props.playlist, videoContext ]);
5252

5353
const handleStop = () => {
54+
props.handleClick('stop');
5455
videoContext.pause();
5556
setVideoContext((vc) => {
5657
vc.currentTime = 0;
@@ -59,6 +60,16 @@ const VideoContextPreview = (props) => {
5960
});
6061
};
6162

63+
const handlePlay = () => {
64+
videoContext.play();
65+
props.handleClick('play');
66+
};
67+
68+
const handlePause = () => {
69+
videoContext.pause();
70+
props.handleClick('pause');
71+
};
72+
6273
const formattedDuration = secondsToHHMMSSFormat(duration);
6374

6475
return (
@@ -78,15 +89,18 @@ const VideoContextPreview = (props) => {
7889
style={ { backgroundColor: 'lightgrey' } }
7990
>
8091
{videoContext ? (
81-
<VideoContextProgressBar videoContext={ videoContext } />
92+
<VideoContextProgressBar
93+
videoContext={ videoContext }
94+
handleClick={ props.handleClick }
95+
/>
8296
) : null}
8397
</Row>
8498
<Row style={ { marginTop: '0.4em' } }>
8599
{videoContext ? (
86100
<Controls
87101
videoContext={ videoContext }
88-
handlePlay={ () => videoContext.play() }
89-
handlePause={ () => videoContext.pause() }
102+
handlePlay={ () => handlePlay() }
103+
handlePause={ () => handlePause() }
90104
handleStop={ () => handleStop() }
91105
/>
92106
) : null}
@@ -103,6 +117,7 @@ VideoContextPreview.propTypes = {
103117
canvasRef: PropTypes.any,
104118
playlist: PropTypes.array,
105119
width: PropTypes.number,
120+
handleClick: PropTypes.func,
106121
};
107122

108123
export default VideoContextPreview;

src/PreviewCanvas/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@ const PreviewCanvas = props => {
1212
width={ width }
1313
canvasRef={ canvasRef }
1414
playlist={ playlist }
15+
handleClick={ props.handleClick }
1516
/>
1617
);
1718
};
1819

1920
PreviewCanvas.propTypes = {
2021
playlist: PropTypes.array,
21-
width: PropTypes.number
22+
width: PropTypes.number,
23+
handleClick: PropTypes.func,
2224
};
2325

2426
PreviewCanvas.defaultProps = {
25-
playlist: []
27+
playlist: [],
28+
handleClick: () => { console.log('play controls clicked'); }
2629
};
2730

2831
export default PreviewCanvas;

src/ProjectRow/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ const ProjectRow = (props) => {
3232
<LinkContainer
3333
to={ props.url }
3434
style={ { color: '#007bff', cursor: 'pointer', marginTop: '0.4rem' } }
35+
onClick={ props.handleClick }
3536
>
36-
<p >
37+
<p>
3738
<strong>{props.title}</strong>
3839
</p>
3940
</LinkContainer>
@@ -86,6 +87,7 @@ ProjectRow.propTypes = {
8687
title: PropTypes.string.isRequired,
8788
updated: PropTypes.any,
8889
url: PropTypes.string.isRequired,
90+
handleClick: PropTypes.func,
8991
};
9092

9193
ProjectRow.defaultProps = {

0 commit comments

Comments
 (0)