Skip to content

Commit e50bf92

Browse files
committed
Add some more actions
1 parent a4f0bc2 commit e50bf92

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const stopResizing = set(state`editor.isResizing`, false);
5353
export const createZip = actions.createZip;
5454

5555
export const changeCurrentModule = [
56+
track('change-current-module', {}),
5657
setReceivingStatus,
5758
setCurrentModule(props`id`),
5859
equals(state`live.isLive`),
@@ -123,6 +124,7 @@ export const changeCode = [
123124
];
124125

125126
export const saveChangedModules = [
127+
track('save-all', {}),
126128
ensureOwnedSandbox,
127129
actions.outputChangedModules,
128130
actions.saveChangedModules,
@@ -176,6 +178,7 @@ export const saveCode = [
176178
];
177179

178180
export const addNpmDependency = [
181+
track('add-dependency', {}),
179182
closeModal,
180183
ensureOwnedSandbox,
181184
when(props`version`),
@@ -193,6 +196,7 @@ export const addNpmDependency = [
193196
];
194197

195198
export const removeNpmDependency = [
199+
track('remove-dependency', {}),
196200
ensureOwnedSandbox,
197201
actions.removeNpmDependencyFromPackage,
198202
equals(state`live.isLive`),
@@ -244,6 +248,7 @@ export const setPreviewContent = [
244248
];
245249

246250
export const prettifyCode = [
251+
track('prettify', {}),
247252
actions.prettifyCode,
248253
{
249254
success: [changeCode],

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { set } from 'cerebral/operators';
22
import { state, props } from 'cerebral/tags';
33
import * as actions from './actions';
4-
import { addNotification, withLoadApp } from '../../factories';
4+
import { addNotification, withLoadApp, track } from '../../factories';
55

66
export const changePrice = set(state`patron.price`, props`price`);
77

@@ -15,6 +15,7 @@ export const clearError = set(state`patron.error`, null);
1515
export const loadPatron = withLoadApp([]);
1616

1717
export const createSubscription = [
18+
track('create-subscription', {}),
1819
clearError,
1920
set(state`patron.isUpdatingSubscription`, true),
2021
actions.subscribe,
@@ -24,6 +25,7 @@ export const createSubscription = [
2425
];
2526

2627
export const updateSubscription = [
28+
track('update-subscription', {}),
2729
clearError,
2830
set(state`patron.isUpdatingSubscription`, true),
2931
actions.updateSubscription,
@@ -33,6 +35,7 @@ export const updateSubscription = [
3335
];
3436

3537
export const cancelSubscription = [
38+
track('cancel-subscription', {}),
3639
actions.whenConfirmedCancelSubscription,
3740
{
3841
true: [

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export const addNotification = factories.addNotification(
107107
);
108108

109109
export const forkSandbox = sequence('forkSandbox', [
110+
factories.track('fork', {}),
110111
set(state`editor.isForkingSandbox`, true),
111112
actions.forkSandbox,
112113
actions.moveModuleContent,
@@ -159,6 +160,7 @@ export const signIn = [
159160
];
160161

161162
export const signOut = [
163+
factories.track('sign-out', {}),
162164
set(state`workspace.openedWorkspaceItem`, 'files'),
163165
when(state`live.isLive`),
164166
{

packages/common/utils/analytics.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1+
import VERSION from 'common/version';
2+
13
export const DNT = !!(
24
window.doNotTrack ||
35
window.navigator.doNotTrack ||
46
window.navigator.msDoNotTrack
57
);
68

7-
export default function track(eventName, secondArg: any) {
8-
if (window.ga && !DNT) {
9-
window.ga('send', secondArg);
9+
export default function track(eventName, secondArg: Object = {}) {
10+
try {
11+
if (window.ga && !DNT) {
12+
const data = {
13+
...secondArg,
14+
version: VERSION,
15+
};
16+
17+
window.ga('send', data);
1018

11-
if (typeof window.amplitude !== 'undefined') {
12-
window.amplitude.logEvent(eventName, secondArg);
19+
if (typeof window.amplitude !== 'undefined') {
20+
window.amplitude.logEvent(eventName, data);
21+
}
1322
}
23+
} catch (e) {
24+
/* empty */
1425
}
1526
}

0 commit comments

Comments
 (0)