@google-analytics/data 4.5.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Google LLC
1
+ // Copyright 2024 Google LLC
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -119,6 +119,43 @@ message DimensionExpression {
119
119
  }
120
120
  }
121
121
 
122
+ // The quantitative measurements of a report. For example, the metric
123
+ // `eventCount` is the total number of events. Requests are allowed up to 10
124
+ // metrics.
125
+ message Metric {
126
+ // The name of the metric. See the [API
127
+ // Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema#metrics)
128
+ // for the list of metric names supported by core reporting methods such
129
+ // as `runReport` and `batchRunReports`. See
130
+ // [Realtime
131
+ // Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-api-schema#metrics)
132
+ // for the list of metric names supported by the `runRealtimeReport`
133
+ // method. See
134
+ // [Funnel
135
+ // Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/exploration-api-schema#metrics)
136
+ // for the list of metric names supported by the `runFunnelReport`
137
+ // method.
138
+ //
139
+ // If `expression` is specified, `name` can be any string that you would like
140
+ // within the allowed character set. For example if `expression` is
141
+ // `screenPageViews/sessions`, you could call that metric's name =
142
+ // `viewsPerSession`. Metric names that you choose must match the regular
143
+ // expression `^[a-zA-Z0-9_]$`.
144
+ //
145
+ // Metrics are referenced by `name` in `metricFilter`, `orderBys`, and metric
146
+ // `expression`.
147
+ string name = 1;
148
+
149
+ // A mathematical expression for derived metrics. For example, the metric
150
+ // Event count per user is `eventCount/totalUsers`.
151
+ string expression = 2;
152
+
153
+ // Indicates if a metric is invisible in the report response. If a metric is
154
+ // invisible, the metric will not produce a column in the response, but can be
155
+ // used in `metricFilter`, `orderBys`, or a metric `expression`.
156
+ bool invisible = 3;
157
+ }
158
+
122
159
  // To express dimension or metric filters. The fields in the same
123
160
  // FilterExpression need to be either all dimensions or all metrics.
124
161
  message FilterExpression {
@@ -243,6 +280,58 @@ message NumericFilter {
243
280
  NumericValue value = 2;
244
281
  }
245
282
 
283
+ // Order bys define how rows will be sorted in the response. For example,
284
+ // ordering rows by descending event count is one ordering, and ordering rows by
285
+ // the event name string is a different ordering.
286
+ message OrderBy {
287
+ // Sorts by metric values.
288
+ message MetricOrderBy {
289
+ // A metric name in the request to order by.
290
+ string metric_name = 1;
291
+ }
292
+
293
+ // Sorts by dimension values.
294
+ message DimensionOrderBy {
295
+ // Rule to order the string dimension values by.
296
+ enum OrderType {
297
+ // Unspecified.
298
+ ORDER_TYPE_UNSPECIFIED = 0;
299
+
300
+ // Alphanumeric sort by Unicode code point. For example, "2" < "A" < "X" <
301
+ // "b" < "z".
302
+ ALPHANUMERIC = 1;
303
+
304
+ // Case insensitive alphanumeric sort by lower case Unicode code point.
305
+ // For example, "2" < "A" < "b" < "X" < "z".
306
+ CASE_INSENSITIVE_ALPHANUMERIC = 2;
307
+
308
+ // Dimension values are converted to numbers before sorting. For example
309
+ // in NUMERIC sort, "25" < "100", and in `ALPHANUMERIC` sort, "100" <
310
+ // "25". Non-numeric dimension values all have equal ordering value below
311
+ // all numeric values.
312
+ NUMERIC = 3;
313
+ }
314
+
315
+ // A dimension name in the request to order by.
316
+ string dimension_name = 1;
317
+
318
+ // Controls the rule for dimension value ordering.
319
+ OrderType order_type = 2;
320
+ }
321
+
322
+ // Specify one type of order by for `OrderBy`.
323
+ oneof one_order_by {
324
+ // Sorts results by a metric's values.
325
+ MetricOrderBy metric = 1;
326
+
327
+ // Sorts results by a dimension's values.
328
+ DimensionOrderBy dimension = 2;
329
+ }
330
+
331
+ // If true, sorts by descending order.
332
+ bool desc = 4;
333
+ }
334
+
246
335
  // To express that the result needs to be between two numbers (inclusive).
247
336
  message BetweenFilter {
248
337
  // Begins with this number.
@@ -264,6 +353,209 @@ message NumericValue {
264
353
  }
265
354
  }
266
355
 
356
+ // The specification of cohorts for a cohort report.
357
+ //
358
+ // Cohort reports create a time series of user retention for the cohort. For
359
+ // example, you could select the cohort of users that were acquired in the first
360
+ // week of September and follow that cohort for the next six weeks. Selecting
361
+ // the users acquired in the first week of September cohort is specified in the
362
+ // `cohort` object. Following that cohort for the next six weeks is specified in
363
+ // the `cohortsRange` object.
364
+ //
365
+ // For examples, see [Cohort Report
366
+ // Examples](https://developers.google.com/analytics/devguides/reporting/data/v1/advanced#cohort_report_examples).
367
+ //
368
+ // The report response could show a weekly time series where say your app has
369
+ // retained 60% of this cohort after three weeks and 25% of this cohort after
370
+ // six weeks. These two percentages can be calculated by the metric
371
+ // `cohortActiveUsers/cohortTotalUsers` and will be separate rows in the report.
372
+ message CohortSpec {
373
+ // Defines the selection criteria to group users into cohorts.
374
+ //
375
+ // Most cohort reports define only a single cohort. If multiple cohorts are
376
+ // specified, each cohort can be recognized in the report by their name.
377
+ repeated Cohort cohorts = 1;
378
+
379
+ // Cohort reports follow cohorts over an extended reporting date range. This
380
+ // range specifies an offset duration to follow the cohorts over.
381
+ CohortsRange cohorts_range = 2;
382
+
383
+ // Optional settings for a cohort report.
384
+ CohortReportSettings cohort_report_settings = 3;
385
+ }
386
+
387
+ // Defines a cohort selection criteria. A cohort is a group of users who share
388
+ // a common characteristic. For example, users with the same `firstSessionDate`
389
+ // belong to the same cohort.
390
+ message Cohort {
391
+ // Assigns a name to this cohort. The dimension `cohort` is valued to this
392
+ // name in a report response. If set, cannot begin with `cohort_` or
393
+ // `RESERVED_`. If not set, cohorts are named by their zero based index
394
+ // `cohort_0`, `cohort_1`, etc.
395
+ string name = 1;
396
+
397
+ // Dimension used by the cohort. Required and only supports
398
+ // `firstSessionDate`.
399
+ string dimension = 2;
400
+
401
+ // The cohort selects users whose first touch date is between start date and
402
+ // end date defined in the `dateRange`. This `dateRange` does not specify the
403
+ // full date range of event data that is present in a cohort report. In a
404
+ // cohort report, this `dateRange` is extended by the granularity and offset
405
+ // present in the `cohortsRange`; event data for the extended reporting date
406
+ // range is present in a cohort report.
407
+ //
408
+ // In a cohort request, this `dateRange` is required and the `dateRanges` in
409
+ // the `RunReportRequest` or `RunPivotReportRequest` must be unspecified.
410
+ //
411
+ // This `dateRange` should generally be aligned with the cohort's granularity.
412
+ // If `CohortsRange` uses daily granularity, this `dateRange` can be a single
413
+ // day. If `CohortsRange` uses weekly granularity, this `dateRange` can be
414
+ // aligned to a week boundary, starting at Sunday and ending Saturday. If
415
+ // `CohortsRange` uses monthly granularity, this `dateRange` can be aligned to
416
+ // a month, starting at the first and ending on the last day of the month.
417
+ DateRange date_range = 3;
418
+ }
419
+
420
+ // Configures the extended reporting date range for a cohort report. Specifies
421
+ // an offset duration to follow the cohorts over.
422
+ message CohortsRange {
423
+ // The granularity used to interpret the `startOffset` and `endOffset` for the
424
+ // extended reporting date range for a cohort report.
425
+ enum Granularity {
426
+ // Should never be specified.
427
+ GRANULARITY_UNSPECIFIED = 0;
428
+
429
+ // Daily granularity. Commonly used if the cohort's `dateRange` is a single
430
+ // day and the request contains `cohortNthDay`.
431
+ DAILY = 1;
432
+
433
+ // Weekly granularity. Commonly used if the cohort's `dateRange` is a week
434
+ // in duration (starting on Sunday and ending on Saturday) and the request
435
+ // contains `cohortNthWeek`.
436
+ WEEKLY = 2;
437
+
438
+ // Monthly granularity. Commonly used if the cohort's `dateRange` is a month
439
+ // in duration and the request contains `cohortNthMonth`.
440
+ MONTHLY = 3;
441
+ }
442
+
443
+ // Required. The granularity used to interpret the `startOffset` and
444
+ // `endOffset` for the extended reporting date range for a cohort report.
445
+ Granularity granularity = 1;
446
+
447
+ // `startOffset` specifies the start date of the extended reporting date range
448
+ // for a cohort report. `startOffset` is commonly set to 0 so that reports
449
+ // contain data from the acquisition of the cohort forward.
450
+ //
451
+ // If `granularity` is `DAILY`, the `startDate` of the extended reporting date
452
+ // range is `startDate` of the cohort plus `startOffset` days.
453
+ //
454
+ // If `granularity` is `WEEKLY`, the `startDate` of the extended reporting
455
+ // date range is `startDate` of the cohort plus `startOffset * 7` days.
456
+ //
457
+ // If `granularity` is `MONTHLY`, the `startDate` of the extended reporting
458
+ // date range is `startDate` of the cohort plus `startOffset * 30` days.
459
+ int32 start_offset = 2;
460
+
461
+ // Required. `endOffset` specifies the end date of the extended reporting date
462
+ // range for a cohort report. `endOffset` can be any positive integer but is
463
+ // commonly set to 5 to 10 so that reports contain data on the cohort for the
464
+ // next several granularity time periods.
465
+ //
466
+ // If `granularity` is `DAILY`, the `endDate` of the extended reporting date
467
+ // range is `endDate` of the cohort plus `endOffset` days.
468
+ //
469
+ // If `granularity` is `WEEKLY`, the `endDate` of the extended reporting date
470
+ // range is `endDate` of the cohort plus `endOffset * 7` days.
471
+ //
472
+ // If `granularity` is `MONTHLY`, the `endDate` of the extended reporting date
473
+ // range is `endDate` of the cohort plus `endOffset * 30` days.
474
+ int32 end_offset = 3;
475
+ }
476
+
477
+ // Optional settings of a cohort report.
478
+ message CohortReportSettings {
479
+ // If true, accumulates the result from first touch day to the end day. Not
480
+ // supported in `RunReportRequest`.
481
+ bool accumulate = 1;
482
+ }
483
+
484
+ // Response's metadata carrying additional information about the report content.
485
+ message ResponseMetaData {
486
+ // The schema restrictions actively enforced in creating this report. To learn
487
+ // more, see [Access and data-restriction
488
+ // management](https://support.google.com/analytics/answer/10851388).
489
+ message SchemaRestrictionResponse {
490
+ // A metric actively restricted in creating the report.
491
+ message ActiveMetricRestriction {
492
+ // The name of the restricted metric.
493
+ optional string metric_name = 1;
494
+
495
+ // The reason for this metric's restriction.
496
+ repeated RestrictedMetricType restricted_metric_types = 2;
497
+ }
498
+
499
+ // All restrictions actively enforced in creating the report. For example,
500
+ // `purchaseRevenue` always has the restriction type `REVENUE_DATA`.
501
+ // However, this active response restriction is only populated if the user's
502
+ // custom role disallows access to `REVENUE_DATA`.
503
+ repeated ActiveMetricRestriction active_metric_restrictions = 1;
504
+ }
505
+
506
+ // If true, indicates some buckets of dimension combinations are rolled into
507
+ // "(other)" row. This can happen for high cardinality reports.
508
+ //
509
+ // The metadata parameter dataLossFromOtherRow is populated based on the
510
+ // aggregated data table used in the report. The parameter will be accurately
511
+ // populated regardless of the filters and limits in the report.
512
+ //
513
+ // For example, the (other) row could be dropped from the report because the
514
+ // request contains a filter on sessionSource = google. This parameter will
515
+ // still be populated if data loss from other row was present in the input
516
+ // aggregate data used to generate this report.
517
+ //
518
+ // To learn more, see [About the (other) row and data
519
+ // sampling](https://support.google.com/analytics/answer/13208658#reports).
520
+ bool data_loss_from_other_row = 3;
521
+
522
+ // Describes the schema restrictions actively enforced in creating this
523
+ // report. To learn more, see [Access and data-restriction
524
+ // management](https://support.google.com/analytics/answer/10851388).
525
+ optional SchemaRestrictionResponse schema_restriction_response = 4;
526
+
527
+ // The currency code used in this report. Intended to be used in formatting
528
+ // currency metrics like `purchaseRevenue` for visualization. If currency_code
529
+ // was specified in the request, this response parameter will echo the request
530
+ // parameter; otherwise, this response parameter is the property's current
531
+ // currency_code.
532
+ //
533
+ // Currency codes are string encodings of currency types from the ISO 4217
534
+ // standard (https://en.wikipedia.org/wiki/ISO_4217); for example "USD",
535
+ // "EUR", "JPY". To learn more, see
536
+ // https://support.google.com/analytics/answer/9796179.
537
+ optional string currency_code = 5;
538
+
539
+ // The property's current timezone. Intended to be used to interpret
540
+ // time-based dimensions like `hour` and `minute`. Formatted as strings from
541
+ // the IANA Time Zone database (https://www.iana.org/time-zones); for example
542
+ // "America/New_York" or "Asia/Tokyo".
543
+ optional string time_zone = 6;
544
+
545
+ // If empty reason is specified, the report is empty for this reason.
546
+ optional string empty_reason = 7;
547
+
548
+ // If `subjectToThresholding` is true, this report is subject to thresholding
549
+ // and only returns data that meets the minimum aggregation thresholds. It is
550
+ // possible for a request to be subject to thresholding thresholding and no
551
+ // data is absent from the report, and this happens when all data is above the
552
+ // thresholds. To learn more, see [Data
553
+ // thresholds](https://support.google.com/analytics/answer/9383630) and [About
554
+ // Demographics and
555
+ // Interests](https://support.google.com/analytics/answer/2799357).
556
+ optional bool subject_to_thresholding = 8;
557
+ }
558
+
267
559
  // Describes a dimension column in the report. Dimensions requested in a report
268
560
  // produce column entries within rows and DimensionHeaders. However, dimensions
269
561
  // used exclusively within filters or expressions do not produce columns in a
@@ -1209,6 +1501,24 @@ message SamplingMetadata {
1209
1501
  int64 sampling_space_size = 2;
1210
1502
  }
1211
1503
 
1504
+ // Represents aggregation of metrics.
1505
+ enum MetricAggregation {
1506
+ // Unspecified operator.
1507
+ METRIC_AGGREGATION_UNSPECIFIED = 0;
1508
+
1509
+ // SUM operator.
1510
+ TOTAL = 1;
1511
+
1512
+ // Minimum operator.
1513
+ MINIMUM = 5;
1514
+
1515
+ // Maximum operator.
1516
+ MAXIMUM = 6;
1517
+
1518
+ // Count operator.
1519
+ COUNT = 4;
1520
+ }
1521
+
1212
1522
  // A metric's value type.
1213
1523
  enum MetricType {
1214
1524
  // Unspecified type.
@@ -1250,3 +1560,16 @@ enum MetricType {
1250
1560
  // A length in kilometers; a special floating point type.
1251
1561
  TYPE_KILOMETERS = 13;
1252
1562
  }
1563
+
1564
+ // Categories of data that you may be restricted from viewing on certain GA4
1565
+ // properties.
1566
+ enum RestrictedMetricType {
1567
+ // Unspecified type.
1568
+ RESTRICTED_METRIC_TYPE_UNSPECIFIED = 0;
1569
+
1570
+ // Cost metrics such as `adCost`.
1571
+ COST_DATA = 1;
1572
+
1573
+ // Revenue metrics such as `purchaseRevenue`.
1574
+ REVENUE_DATA = 2;
1575
+ }
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Google LLC
1
+ // Copyright 2024 Google LLC
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Google LLC
1
+ // Copyright 2024 Google LLC
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.