Commit 6096cba
authored
fix(issue): conditionally collapse lifetime to preserve count/userCount/firstSeen/lastSeen (#985)
## Summary
Fixes #969 — `sentry issue list --json --fields
count,firstSeen,lastSeen,userCount` was silently omitting those fields
because `collapse=lifetime` was always sent to the Sentry API.
## Root Cause
`buildIssueListCollapse()` always included `"lifetime"` in the collapse
array. Despite the JSDoc claiming top-level
`count`/`userCount`/`firstSeen`/`lastSeen` are unaffected by collapsing,
`collapse=lifetime` actually strips these fields from the list endpoint
response. This caused:
- `EVENTS: ?` in human output (`count` undefined)
- `SEEN: —` / `AGE: —` (`lastSeen`/`firstSeen` undefined)
- `USERS: 0` (`userCount` undefined)
- Empty values in `--json --fields` output
## Fix
Makes the `lifetime` collapse conditional via a new
`shouldCollapseLifetime` parameter on `buildIssueListCollapse()`
(defaults to `false`).
**Lifetime is NOT collapsed (fields available) when:**
- Human output — always needs these for EVENTS, USERS, SEEN, AGE columns
- JSON mode without `--fields` — all fields returned
- JSON mode with `--fields` that include any of: `count`, `userCount`,
`firstSeen`, `lastSeen`
**Lifetime IS collapsed (perf optimization) when:**
- JSON mode with explicit `--fields` that don't include any
lifetime-dependent field
## Changes
- `src/lib/api/issues.ts` — Added `shouldCollapseLifetime` option to
`buildIssueListCollapse()`, fixed misleading JSDoc comments
- `src/commands/issue/list.ts` — Added `LIFETIME_FIELDS` set, updated
`buildListApiOptions()` to compute lifetime collapse condition from
`flags.fields`
- `test/lib/issue-collapse.property.test.ts` — Updated property tests
for new parameter (11 tests, 407 expect calls)
- `test/commands/issue/list.test.ts` — Added 4 integration tests
covering all lifetime collapse scenarios1 parent 472f381 commit 6096cba
4 files changed
Lines changed: 263 additions & 47 deletions
File tree
- src
- commands/issue
- lib/api
- test
- commands/issue
- lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
178 | 189 | | |
179 | 190 | | |
180 | 191 | | |
181 | 192 | | |
182 | 193 | | |
183 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
184 | 200 | | |
185 | | - | |
| 201 | + | |
186 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
187 | 212 | | |
188 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
189 | 217 | | |
190 | 218 | | |
191 | 219 | | |
| |||
870 | 898 | | |
871 | 899 | | |
872 | 900 | | |
873 | | - | |
| 901 | + | |
874 | 902 | | |
875 | 903 | | |
876 | 904 | | |
877 | 905 | | |
878 | 906 | | |
879 | 907 | | |
880 | | - | |
| 908 | + | |
881 | 909 | | |
882 | 910 | | |
883 | 911 | | |
| |||
1257 | 1285 | | |
1258 | 1286 | | |
1259 | 1287 | | |
1260 | | - | |
| 1288 | + | |
1261 | 1289 | | |
1262 | 1290 | | |
1263 | 1291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
| |||
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
76 | 88 | | |
| 89 | + | |
77 | 90 | | |
78 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| |||
90 | 106 | | |
91 | 107 | | |
92 | 108 | | |
93 | | - | |
94 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
95 | 113 | | |
96 | 114 | | |
97 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
1110 | 1113 | | |
1111 | 1114 | | |
1112 | 1115 | | |
1113 | | - | |
| 1116 | + | |
1114 | 1117 | | |
1115 | 1118 | | |
1116 | 1119 | | |
| |||
1134 | 1137 | | |
1135 | 1138 | | |
1136 | 1139 | | |
1137 | | - | |
1138 | 1140 | | |
1139 | 1141 | | |
1140 | 1142 | | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
1141 | 1259 | | |
1142 | 1260 | | |
1143 | 1261 | | |
| |||
0 commit comments