Skip to content

Commit 40eebf0

Browse files
committed
Add more metrics
1 parent e843dd9 commit 40eebf0

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

packages/app/src/app/pages/common/Modals/ShareModal/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ModeIcons from 'app/components/ModeIcons';
55
import { getModulePath } from 'common/sandbox/modules';
66
import QRCode from 'qrcode.react';
77
import Button from 'app/components/Button';
8+
import track from 'app/utils/analytics';
89

910
import {
1011
optionsToParameterizedUrl,
@@ -45,6 +46,10 @@ class ShareView extends React.Component {
4546
showQRCode: false,
4647
};
4748

49+
componentDidMount() {
50+
track('share-opened', {});
51+
}
52+
4853
handleChange = e => this.setState({ message: e.target.value });
4954

5055
handleSend = () => {

packages/app/src/app/store/factories.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { sequence, parallel } from 'cerebral';
22
import { set, when } from 'cerebral/operators';
33
import { state, props } from 'cerebral/tags';
4+
import { track as trackAnalytics } from 'app/utils/analytics';
45
import * as actions from './actions';
56

67
export function addTabById(id) {
@@ -34,6 +35,22 @@ export function addTabById(id) {
3435
};
3536
}
3637

38+
const trackedEvents = {};
39+
40+
export function track(e, args, { trackOnce } = { trackOnce: false }) {
41+
return () => {
42+
if (!trackOnce || !trackedEvents[e]) {
43+
trackAnalytics(e, args);
44+
45+
if (trackOnce) {
46+
trackedEvents[e] = true;
47+
}
48+
}
49+
50+
return {};
51+
};
52+
}
53+
3754
export function setCurrentModuleById(id) {
3855
// eslint-disable-next-line
3956
return function setCurrentModuleById({ state, resolve }) {

packages/app/src/app/store/modules/editor/sequences.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
closeModal,
1919
} from '../../sequences';
2020

21-
import { setCurrentModule, addNotification } from '../../factories';
21+
import { setCurrentModule, addNotification, track } from '../../factories';
2222

2323
export const openQuickActions = set(state`editor.quickActionsOpen`, true);
2424

@@ -116,6 +116,7 @@ export const forceForkSandbox = [
116116
];
117117

118118
export const changeCode = [
119+
track('change-code', {}, { trackOnce: true }),
119120
actions.setCode,
120121
actions.addChangedModule,
121122
actions.unsetDirtyTab,
@@ -140,6 +141,7 @@ export const saveChangedModules = [
140141
];
141142

142143
export const saveCode = [
144+
track('save-code', {}),
143145
ensureOwnedSandbox,
144146
when(props`code`),
145147
{

packages/app/src/app/store/modules/live/sequences.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ export const sendSelection = [
361361
];
362362

363363
export const createLive = [
364+
factories.track('create-live', {}),
364365
set(state`live.isOwner`, true),
365366
actions.createRoom,
366367
initializeLive,
@@ -413,6 +414,7 @@ export const removeEditor = [
413414
export const sendChat = [actions.sendChat];
414415

415416
export const setChatEnabled = [
417+
factories.track('live-chat-enabled', {}),
416418
equals(state`live.isOwner`),
417419
{
418420
true: [
@@ -424,6 +426,7 @@ export const setChatEnabled = [
424426
];
425427

426428
export const setFollowing = [
429+
factories.track('live-follow-user', {}),
427430
set(state`live.followingUserId`, props`userId`),
428431
actions.getCurrentModuleIdOfUser,
429432
when(props`moduleShortid`),

packages/app/src/app/store/sequences.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export const fetchGitChanges = [
135135

136136
export const signIn = [
137137
set(state`isAuthenticating`, true),
138+
factories.track('sign-in', {}),
138139
actions.signInGithub,
139140
{
140141
success: [

0 commit comments

Comments
 (0)