OLD | NEW |
---|---|
(Empty) | |
1 # User Action Guidelines | |
2 | |
3 This document gives the best practices on how to use user actions in code and | |
4 how to document them for the dashboard. User actions come with only a name and | |
5 a timestamp. They are best used when you care about a sequence--which actions | |
6 happen in what order. If you don't care about the order, you should be using | |
7 histograms. | |
rkaplow
2016/10/06 22:03:07
nit, maybe say enumerated histograms here
Mark P
2016/10/06 22:21:12
Sure; done.
| |
8 | |
9 Often, you want both user actions and histogram logging in your code. They | |
10 enable different analyses. They're complementary. | |
11 | |
12 [TOC] | |
13 | |
14 ## Emitting to User Actions | |
15 | |
16 ### Emit Once Per Action | |
17 | |
18 A user action should be tied to an actual action taken by a user. Each | |
19 meaningful unit of action should cause one emit. | |
20 | |
21 ### Emit at a High-Level, not Deep in the Implementation | |
22 | |
23 Prefer to emit at the highest level reasonable, closest to the code that handles | |
24 the UI interaction. Emitting deep in implementation code can cause problems | |
25 because that code may get reused (and thus called more times in more places) or | |
26 may get called fewer times (due to caching for example). In cases like this, | |
27 the logged user action will not longer correspond with a meaningful action by | |
28 the user. | |
29 | |
30 ### Do Not Emit Redundantly | |
31 | |
32 Generally a meaningful user action should cause only one emit. For example, if | |
33 the browser already has a "Back" user action, it's poor practice to add a | |
34 "BackViaKeyboardShortcut" user action. This is mostly redundant. (If you're | |
35 trying to determine the breakdown of keyboard-shortcut backs versus all backs, | |
36 use a histogram.) | |
37 | |
38 ### Do Not Emit Excessively | |
39 | |
40 Again, choose an appropriately-sized meaningful unit. For example, emit | |
41 "DragScrolled" for a whole scroll action. Don't emit this action every time the | |
42 user pauses scrolling if the user remains in the process of scrolling (mouse | |
43 button still down). | |
44 | |
45 As another example, you may want to emit "FocusOmnibox" (upon focus), | |
46 "OmniboxEditInProgress" (upon first keystroke), and "OmniboxUse" (upon going | |
47 somwhere) but forswear "OmniboxKeystroke". That's probably more detailed than | |
48 you need. | |
49 | |
50 ### Generally, Do Not Emit Impressions | |
51 | |
52 It's okay to emit user actions such as "ShowTranslateInfobar" or | |
53 "DisplayedImageLinkContextMenu". However, more detailed impression information, | |
54 especially those not caused by the user (as in the second example) and not as | |
55 attention-grabbing (as in the first example), is often not useful for analyzing | |
56 sequences of user actions. For example, don't emit | |
57 "ShowedSecureIconNextToOmnibox". | |
58 | |
59 ### Testing | |
60 | |
61 Test your user actions using *chrome://user-actions*. Make sure they're being | |
62 emitted when you expect and not emitted at other times. | |
63 | |
64 If this is a general UI surface, please try to check every platform. In | |
65 particular, check Windows (Views-based platforms), Mac (non-Views), Android | |
66 phone (yet other UI wrapper code), Android tablet (often triggers lookalike but | |
67 different menus), and iOS (yet more different UI wrapper code). | |
68 | |
69 Also, check that your new user action is not mostly redundant with other user | |
70 actions (see [advice above](#Do-Not-Emit-Redundantly)) and not emitted | |
71 excessively (see [advice above](#Do-Not-Emit-Excessively)). | |
72 | |
73 ### Revising User Actions | |
74 | |
75 If you're changing the semantics of a user action (when it's emitted), make it | |
76 into a new user action with a new name. Otherwise the dashboard will be mixing | |
77 two different interpretations of the data and make no sense. | |
78 | |
79 ## Documenting User Actions | |
80 | |
81 ### Add User Actions and Documentation in the Same Changelist | |
82 | |
83 If possible, please add the actions.xml description in the same changelist in | |
84 which you add the user-action-emitting code. This has several benefits. One, | |
85 it sometimes happens that the actions.xml reviewer has questions or concerns | |
86 about the user action description that reveal problems with interpretation of | |
87 the data and call for a different recording strategy. Two, it allows the user | |
88 action reviewer to easily review the emission code to see if it comports with | |
89 these best practices, and to look for other errors. | |
90 | |
91 ### Understandable to Everyone | |
92 | |
93 User actions descriptions should be understandable to someone not familiar with | |
94 your feature. Please add a sentence or two of background if necessary. | |
95 | |
96 It is good practice to note caveats associated with your user actions in this | |
97 section, such as which platforms are supported (if the set of supported | |
98 platforms is surprising). E.g., a desktop feature that happens not to be logged | |
99 on Mac. | |
100 | |
101 ### State When It Is Emitted | |
102 | |
103 User action descriptions should clearly state when the action is emitted. | |
104 | |
105 ### Owners | |
106 | |
107 User actions need to be owned by a person or set of people. These indicate who | |
108 the current experts on it are. Being the owner means you are responsible for | |
109 answering questions about it, handling the maintenance if there are functional | |
110 changes. The owners should be added in the original user action description. | |
Mark P
2016/10/06 21:54:38
Added this section, basically a copy from the hist
| |
111 If you are using a user action heavily and understand it intimately, feel free | |
112 to add yourself as an owner. @chromium.org email addresses are preferred. | |
113 | |
114 ### Beware `not_user_action="true"` | |
115 | |
116 actions.xml allows you to annotate an action as `not_user_action="true"`. This | |
117 feature should be used rarely. If you think you want to annotate your action | |
118 thusly, please re-review the best practices above. | |
119 | |
120 ### Deleting User Action Entries | |
121 | |
122 Do not delete actions from actions.xml. Instead, mark unused user actions as | |
123 obsolete, annotating them with the associated date or milestone in the obsolete | |
124 tag entry. If your user action is being replaced by a new version, we suggest | |
125 noting that in the previous user action's description. | |
126 | |
127 Deleting user action entries would be bad if someone to accidentally reused your | |
rkaplow
2016/10/06 22:03:07
nit, remove 'to'
Mark P
2016/10/06 22:21:12
Done.
| |
128 old user action name and thereby corrupts new data with whatever old data is | |
rkaplow
2016/10/06 22:03:07
I think corrupted would be better here - or you ca
Mark P
2016/10/06 22:21:12
Done; chose the latter.
| |
129 still coming in. It's also useful to keep obsolete user action descriptions in | |
130 actions.xml--that way, if someone is searching for a user action to answer | |
131 a particular question, they can learn if there was a user action at some point | |
132 that did so even if it isn't active now. | |
OLD | NEW |