Skip to content

Commit

Permalink
Track customElement and full screen and autoplay usage (#39735) (#40016)
Browse files Browse the repository at this point in the history
* Track customElement and full screen and autoplay usage

* Rename action
  • Loading branch information
Corey Robertson authored Jul 1, 2019
1 parent f7c0982 commit ebea663
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import { notify } from '../../lib/notify';
import { selectToplevelNodes } from '../../state/actions/transient';
import { insertNodes, addElement } from '../../state/actions/elements';
import { getSelectedPage } from '../../state/selectors/workpad';
import { trackCanvasUiMetric } from '../../lib/ui_metric';
import { ElementTypes as Component } from './element_types';

const customElementAdded = 'elements-custom-added';

const mapStateToProps = state => ({ pageId: getSelectedPage(state) });

const mapDispatchToProps = dispatch => ({
Expand Down Expand Up @@ -48,6 +51,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
selectToplevelNodes(clonedNodes); // then select the cloned node(s)
}
onClose();
trackCanvasUiMetric(customElementAdded);
},
// custom element search
findCustomElements: async text => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import { setFullscreen, selectToplevelNodes } from '../../../state/actions/trans
import { enableAutoplay } from '../../../state/actions/workpad';
import { getFullscreen } from '../../../state/selectors/app';
import { getAutoplay } from '../../../state/selectors/workpad';
import { trackCanvasUiMetric } from '../../../lib/ui_metric';
import { FullscreenControl as Component } from './fullscreen_control';

const LaunchedFullScreen = 'workpad-full-screen-launch';
const LaunchedFullScreenAutoplay = 'workpad-full-screen-launch-with-autoplay';

const mapStateToProps = state => ({
isFullscreen: getFullscreen(state),
autoplayEnabled: getAutoplay(state).enabled,
Expand All @@ -24,7 +28,27 @@ const mapDispatchToProps = dispatch => ({
enableAutoplay: enabled => dispatch(enableAutoplay(enabled)),
});

const mergeProps = (stateProps, dispatchProps, ownProps) => {
return {
...ownProps,
...stateProps,
...dispatchProps,
setFullscreen: value => {
dispatchProps.setFullscreen(value);

if (value === true) {
trackCanvasUiMetric(
stateProps.autoplayEnabled
? [LaunchedFullScreen, LaunchedFullScreenAutoplay]
: LaunchedFullScreen
);
}
},
};
};

export const FullscreenControl = connect(
mapStateToProps,
mapDispatchToProps
mapDispatchToProps,
mergeProps
)(Component);

0 comments on commit ebea663

Please sign in to comment.