@@ -3136,7 +3136,8 @@ def setUp(self):
3136
3136
"message" : "poof" ,
3137
3137
"timestamp" : (self .day_ago + timedelta (minutes = 2 )).isoformat (),
3138
3138
"user" : {"email" : self .user .email },
3139
- "tags" : {"shared-tag" : "yup" },
3139
+ "tags" : {"shared-tag" : "yup" , "env" : "prod" },
3140
+ "exception" : {"values" : [{"type" : "NameError" }, {"type" : "FooError" }]},
3140
3141
"fingerprint" : ["group1" ],
3141
3142
},
3142
3143
"project" : self .project2 ,
@@ -3148,7 +3149,8 @@ def setUp(self):
3148
3149
"timestamp" : (self .day_ago + timedelta (hours = 1 , minutes = 2 )).isoformat (),
3149
3150
"fingerprint" : ["group2" ],
3150
3151
"user" : {"email" : self .user2 .email },
3151
- "tags" : {"shared-tag" : "yup" },
3152
+ "tags" : {"shared-tag" : "yup" , "env" : "prod" },
3153
+ "exception" : {"values" : [{"type" : "NameError" }, {"type" : "FooError" }]},
3152
3154
},
3153
3155
"project" : self .project2 ,
3154
3156
"count" : 6 ,
@@ -3159,7 +3161,8 @@ def setUp(self):
3159
3161
"timestamp" : (self .day_ago + timedelta (minutes = 2 )).isoformat (),
3160
3162
"fingerprint" : ["group3" ],
3161
3163
"user" : {
"email" :
"[email protected] " },
3162
- "tags" : {"shared-tag" : "yup" },
3164
+ "tags" : {"shared-tag" : "yup" , "env" : "prod" },
3165
+ "exception" : {"values" : [{"type" : "NameError" }, {"type" : "FooError" }]},
3163
3166
},
3164
3167
"project" : self .project ,
3165
3168
"count" : 5 ,
@@ -3170,7 +3173,8 @@ def setUp(self):
3170
3173
"timestamp" : (self .day_ago + timedelta (minutes = 2 )).isoformat (),
3171
3174
"fingerprint" : ["group4" ],
3172
3175
"user" : {
"email" :
"[email protected] " },
3173
- "tags" : {"shared-tag" : "yup" },
3176
+ "tags" : {"shared-tag" : "yup" , "env" : "prod" },
3177
+ "exception" : {"values" : [{"type" : "ValueError" }]},
3174
3178
},
3175
3179
"project" : self .project ,
3176
3180
"count" : 4 ,
@@ -3180,7 +3184,8 @@ def setUp(self):
3180
3184
"message" : "kinda bad" ,
3181
3185
"timestamp" : (self .day_ago + timedelta (minutes = 2 )).isoformat (),
3182
3186
"user" : {"email" : self .user .email },
3183
- "tags" : {"shared-tag" : "yup" },
3187
+ "tags" : {"shared-tag" : "yup" , "env" : "staging" },
3188
+ "exception" : {"values" : [{"type" : "NameError" }, {"type" : "FooError" }]},
3184
3189
"fingerprint" : ["group7" ],
3185
3190
},
3186
3191
"project" : self .project ,
@@ -3193,7 +3198,8 @@ def setUp(self):
3193
3198
"timestamp" : (self .day_ago + timedelta (minutes = 2 )).isoformat (),
3194
3199
"fingerprint" : ["group5" ],
3195
3200
"user" : {
"email" :
"[email protected] " },
3196
- "tags" : {"shared-tag" : "yup" },
3201
+ "tags" : {"shared-tag" : "yup" , "env" : "dev" },
3202
+ "exception" : {"values" : [{"type" : "ValueError" }]},
3197
3203
},
3198
3204
"project" : self .project ,
3199
3205
"count" : 2 ,
@@ -3204,7 +3210,8 @@ def setUp(self):
3204
3210
"timestamp" : (self .day_ago + timedelta (minutes = 2 )).isoformat (),
3205
3211
"fingerprint" : ["group6" ],
3206
3212
"user" : {
"email" :
"[email protected] " },
3207
- "tags" : {"shared-tag" : "yup" },
3213
+ "tags" : {"shared-tag" : "yup" , "env" : "dev" },
3214
+ "exception" : {"values" : [{"type" : "ValueError" }]},
3208
3215
},
3209
3216
"project" : self .project ,
3210
3217
"count" : 1 ,
@@ -3250,8 +3257,14 @@ def test_simple_top_events(self):
3250
3257
3251
3258
for index , event in enumerate (self .events [:5 ]):
3252
3259
message = event .message or event .transaction
3260
+ exception = event .get_event_metadata ()["type" ]
3253
3261
results = data [
3254
- "," .join ([message , self .event_data [index ]["data" ]["user" ].get ("email" , "None" )])
3262
+ "," .join (
3263
+ [
3264
+ f"{ message } { exception } " ,
3265
+ self .event_data [index ]["data" ]["user" ].get ("email" , "None" ),
3266
+ ]
3267
+ )
3255
3268
]
3256
3269
assert results ["order" ] == index
3257
3270
assert [{"count" : self .event_data [index ]["count" ]}] in [
@@ -3262,6 +3275,38 @@ def test_simple_top_events(self):
3262
3275
assert other ["order" ] == 5
3263
3276
assert [{"count" : 3 }] in [attrs for _ , attrs in other ["data" ]]
3264
3277
3278
+ def test_top_events_with_array_field (self ):
3279
+ """
3280
+ Test that when doing a qurey on top events with an array field that its handled correctly
3281
+ """
3282
+
3283
+ with self .feature (self .enabled_features ):
3284
+ response = self .client .get (
3285
+ self .url ,
3286
+ data = {
3287
+ "start" : self .day_ago .isoformat (),
3288
+ "end" : (self .day_ago + timedelta (hours = 2 )).isoformat (),
3289
+ "interval" : "1h" ,
3290
+ "project" : self .project .id ,
3291
+ "query" : "!error.type:*Exception*" ,
3292
+ "yAxis" : "count_unique(user)" ,
3293
+ "orderby" : ["-count_unique(user)" ],
3294
+ "field" : ["error.type" , "count_unique(user)" ],
3295
+ "topEvents" : "2" ,
3296
+ "dataset" : "errors" ,
3297
+ },
3298
+ format = "json" ,
3299
+ )
3300
+
3301
+ assert response .status_code == 200 , response .content
3302
+
3303
+ data = response .data
3304
+ assert len (data ) == 2
3305
+ assert "[NameError,FooError]" in data
3306
+ assert "[ValueError]" in data
3307
+ assert [attrs [0 ]["count" ] for _ , attrs in data ["[NameError,FooError]" ]["data" ]] == [2 , 0 ]
3308
+ assert [attrs [0 ]["count" ] for _ , attrs in data ["[ValueError]" ]["data" ]] == [1 , 0 ]
3309
+
3265
3310
def test_top_events_with_projects_other (self ):
3266
3311
with self .feature (self .enabled_features ):
3267
3312
response = self .client .get (
@@ -3318,13 +3363,14 @@ def test_top_events_with_issue(self):
3318
3363
3319
3364
for index , event in enumerate (self .events [:4 ]):
3320
3365
message = event .message
3366
+ exception = event .get_event_metadata ()["type" ]
3321
3367
# Because we deleted the group for event 0
3322
3368
if index == 0 or event .group is None :
3323
3369
issue = "unknown"
3324
3370
else :
3325
3371
issue = event .group .qualified_short_id
3326
3372
3327
- results = data ["," .join ([issue , message ])]
3373
+ results = data ["," .join ([issue , f" { message } { exception } " ])]
3328
3374
assert results ["order" ] == index
3329
3375
assert [{"count" : self .event_data [index ]["count" ]}] in [
3330
3376
attrs for time , attrs in results ["data" ]
0 commit comments