@@ -19,6 +19,7 @@ Reports::Reports(
19
19
AdsImpl* ads)
20
20
: is_first_run_(true ),
21
21
ads_ (ads) {
22
+ DCHECK (ads_);
22
23
}
23
24
24
25
Reports::~Reports () = default ;
@@ -29,37 +30,33 @@ std::string Reports::GenerateAdNotificationEventReport(
29
30
rapidjson::StringBuffer buffer;
30
31
rapidjson::Writer<rapidjson::StringBuffer> writer (buffer);
31
32
33
+ const std::string timestamp = Time::Timestamp ();
34
+
35
+ writer.StartObject ();
36
+
32
37
if (is_first_run_) {
33
38
is_first_run_ = false ;
34
39
35
- writer.StartObject ();
36
-
37
40
writer.String (" data" );
38
41
writer.StartObject ();
39
42
40
43
writer.String (" type" );
41
44
writer.String (" restart" );
42
45
43
46
writer.String (" timestamp" );
44
- auto time_stamp = Time::Timestamp ();
45
- writer.String (time_stamp.c_str ());
46
-
47
- writer.EndObject ();
47
+ writer.String (timestamp.c_str ());
48
48
49
49
writer.EndObject ();
50
50
}
51
51
52
- writer.StartObject ();
53
-
54
52
writer.String (" data" );
55
53
writer.StartObject ();
56
54
57
55
writer.String (" type" );
58
56
writer.String (" notify" );
59
57
60
58
writer.String (" timestamp" );
61
- auto time_stamp = Time::Timestamp ();
62
- writer.String (time_stamp.c_str ());
59
+ writer.String (timestamp.c_str ());
63
60
64
61
writer.String (" eventType" );
65
62
switch (event_type) {
@@ -125,8 +122,8 @@ std::string Reports::GenerateConfirmationEventReport(
125
122
writer.String (" confirmation" );
126
123
127
124
writer.String (" timestamp" );
128
- auto time_stamp = Time::Timestamp ();
129
- writer.String (time_stamp .c_str ());
125
+ const std::string timestamp = Time::Timestamp ();
126
+ writer.String (timestamp .c_str ());
130
127
131
128
writer.String (" creativeInstanceId" );
132
129
writer.String (creative_instance_id.c_str ());
@@ -155,8 +152,8 @@ std::string Reports::GenerateLoadEventReport(
155
152
writer.String (" load" );
156
153
157
154
writer.String (" timestamp" );
158
- auto time_stamp = Time::Timestamp ();
159
- writer.String (time_stamp .c_str ());
155
+ const std::string timestamp = Time::Timestamp ();
156
+ writer.String (timestamp .c_str ());
160
157
161
158
writer.String (" tabId" );
162
159
writer.Int (info.tab_id );
@@ -211,8 +208,8 @@ std::string Reports::GenerateBackgroundEventReport() const {
211
208
writer.String (" background" );
212
209
213
210
writer.String (" timestamp" );
214
- auto time_stamp = Time::Timestamp ();
215
- writer.String (time_stamp .c_str ());
211
+ const std::string timestamp = Time::Timestamp ();
212
+ writer.String (timestamp .c_str ());
216
213
217
214
writer.EndObject ();
218
215
@@ -234,8 +231,8 @@ std::string Reports::GenerateForegroundEventReport() const {
234
231
writer.String (" foreground" );
235
232
236
233
writer.String (" timestamp" );
237
- auto time_stamp = Time::Timestamp ();
238
- writer.String (time_stamp .c_str ());
234
+ const std::string timestamp = Time::Timestamp ();
235
+ writer.String (timestamp .c_str ());
239
236
240
237
writer.EndObject ();
241
238
@@ -258,8 +255,8 @@ std::string Reports::GenerateBlurEventReport(
258
255
writer.String (" blur" );
259
256
260
257
writer.String (" timestamp" );
261
- auto time_stamp = Time::Timestamp ();
262
- writer.String (time_stamp .c_str ());
258
+ const std::string timestamp = Time::Timestamp ();
259
+ writer.String (timestamp .c_str ());
263
260
264
261
writer.String (" tabId" );
265
262
writer.Int (info.tab_id );
@@ -285,8 +282,8 @@ std::string Reports::GenerateDestroyEventReport(
285
282
writer.String (" destroy" );
286
283
287
284
writer.String (" timestamp" );
288
- auto time_stamp = Time::Timestamp ();
289
- writer.String (time_stamp .c_str ());
285
+ const std::string timestamp = Time::Timestamp ();
286
+ writer.String (timestamp .c_str ());
290
287
291
288
writer.String (" tabId" );
292
289
writer.Int (info.tab_id );
@@ -312,8 +309,8 @@ std::string Reports::GenerateFocusEventReport(
312
309
writer.String (" focus" );
313
310
314
311
writer.String (" timestamp" );
315
- auto time_stamp = Time::Timestamp ();
316
- writer.String (time_stamp .c_str ());
312
+ const std::string timestamp = Time::Timestamp ();
313
+ writer.String (timestamp .c_str ());
317
314
318
315
writer.String (" tabId" );
319
316
writer.Int (info.tab_id );
@@ -326,11 +323,6 @@ std::string Reports::GenerateFocusEventReport(
326
323
}
327
324
328
325
std::string Reports::GenerateSettingsEventReport () const {
329
- DCHECK (ads_);
330
- if (!ads_) {
331
- return " Failed to generate settings event report" ;
332
- }
333
-
334
326
rapidjson::StringBuffer buffer;
335
327
rapidjson::Writer<rapidjson::StringBuffer> writer (buffer);
336
328
@@ -343,8 +335,8 @@ std::string Reports::GenerateSettingsEventReport() const {
343
335
writer.String (" settings" );
344
336
345
337
writer.String (" timestamp" );
346
- auto time_stamp = Time::Timestamp ();
347
- writer.String (time_stamp .c_str ());
338
+ const std::string timestamp = Time::Timestamp ();
339
+ writer.String (timestamp .c_str ());
348
340
349
341
writer.String (" settings" );
350
342
writer.StartObject ();
0 commit comments