Skip to content

Commit e7cec78

Browse files
committed
Added AnalyticsResponse examples
1 parent 4837a9d commit e7cec78

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use primitives::sentry::AnalyticsResponse;
2+
use serde_json::{from_value, json};
3+
4+
fn main() {
5+
let json = json!({
6+
"analytics": [{
7+
"time": 1659592800,
8+
"value": "3",
9+
"segment": null
10+
},
11+
{
12+
"time": 1659592800,
13+
"value": "10000000000",
14+
"segment": null
15+
},
16+
{
17+
"time": 1659592800,
18+
"value": "100000000",
19+
"segment": "country"
20+
}],
21+
"totalPages": 1,
22+
"page": 0
23+
});
24+
25+
assert!(from_value::<AnalyticsResponse>(json).is_ok());
26+
}

primitives/src/sentry.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ pub struct FetchedAnalytics {
319319
pub segment: Option<String>,
320320
}
321321

322+
// Response returned when getting Analytics - an array of FetchedAnalytics
323+
//
324+
/// # Examples:
325+
/// ```
326+
#[doc = include_str!("../examples/analytics_response.rs")]
327+
/// ```
322328
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
323329
#[serde(rename_all = "camelCase")]
324330
pub struct AnalyticsResponse {

0 commit comments

Comments
 (0)