2023-01-27 03:22:44 -08:00
import type { INodeProperties } from 'n8n-workflow' ;
2021-01-05 10:16:25 -08:00
2021-12-03 00:44:16 -08:00
export const reportOperations : INodeProperties [ ] = [
2021-01-05 10:16:25 -08:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-01-05 10:16:25 -08:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'report' ] ,
2021-01-05 10:16:25 -08:00
} ,
} ,
options : [
{
name : 'Get' ,
value : 'get' ,
description : 'Return the analytics data' ,
2022-07-10 13:50:51 -07:00
action : 'Get a report' ,
2021-01-05 10:16:25 -08:00
} ,
] ,
default : 'get' ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2021-01-05 10:16:25 -08:00
2021-12-03 00:44:16 -08:00
export const reportFields : INodeProperties [ ] = [
2021-01-05 10:16:25 -08:00
{
2022-06-03 10:23:49 -07:00
displayName : 'View Name or ID' ,
2021-01-05 10:16:25 -08:00
name : 'viewId' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getViews' ,
} ,
default : '' ,
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'report' ] ,
operation : [ 'get' ] ,
2021-01-05 10:16:25 -08:00
} ,
} ,
placeholder : '123456' ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'The View ID of Google Analytics. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.' ,
2021-01-05 10:16:25 -08:00
} ,
2021-05-08 13:26:06 -07:00
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'get' ] ,
resource : [ 'report' ] ,
2021-05-08 13:26:06 -07:00
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-05-08 13:26:06 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'get' ] ,
resource : [ 'report' ] ,
returnAll : [ false ] ,
2021-05-08 13:26:06 -07:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 1000 ,
} ,
default : 1000 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-05-08 13:26:06 -07:00
} ,
2021-01-05 10:16:25 -08:00
{
2022-05-20 14:47:24 -07:00
displayName : 'Simplify' ,
2021-01-05 10:16:25 -08:00
name : 'simple' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'get' ] ,
resource : [ 'report' ] ,
2021-01-05 10:16:25 -08:00
} ,
} ,
default : true ,
2022-05-20 14:47:24 -07:00
description : 'Whether to return a simplified version of the response instead of the raw data' ,
2021-01-05 10:16:25 -08:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'report' ] ,
operation : [ 'get' ] ,
2021-01-05 10:16:25 -08:00
} ,
} ,
options : [
{
displayName : 'Date Ranges' ,
name : 'dateRangesUi' ,
placeholder : 'Add Date Range' ,
type : 'fixedCollection' ,
default : { } ,
description : 'Date ranges in the request' ,
options : [
{
displayName : 'Date Range' ,
name : 'dateRanges' ,
values : [
{
displayName : 'Start Date' ,
name : 'startDate' ,
type : 'dateTime' ,
default : '' ,
} ,
{
displayName : 'End Date' ,
name : 'endDate' ,
type : 'dateTime' ,
default : '' ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Dimensions' ,
name : 'dimensionUi' ,
type : 'fixedCollection' ,
default : { } ,
typeOptions : {
multipleValues : true ,
} ,
placeholder : 'Add Dimension' ,
2022-08-17 08:50:24 -07:00
description :
'Dimensions are attributes of your data. For example, the dimension ga:city indicates the city, for example, "Paris" or "New York", from which a session originates.' ,
2021-01-05 10:16:25 -08:00
options : [
{
displayName : 'Dimension' ,
name : 'dimensionValues' ,
values : [
{
2022-06-03 10:23:49 -07:00
displayName : 'Name or ID' ,
2021-01-05 10:16:25 -08:00
name : 'name' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getDimensions' ,
} ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'Name of the dimension to fetch, for example ga:browser. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.' ,
2021-01-05 10:16:25 -08:00
} ,
] ,
} ,
] ,
} ,
2021-06-25 06:51:02 -07:00
{
displayName : 'Dimension Filters' ,
name : 'dimensionFiltersUi' ,
type : 'fixedCollection' ,
default : { } ,
typeOptions : {
multipleValues : true ,
} ,
placeholder : 'Add Dimension Filter' ,
description : 'Dimension Filters in the request' ,
options : [
{
displayName : 'Filters' ,
name : 'filterValues' ,
values : [
{
2022-06-03 10:23:49 -07:00
displayName : 'Dimension Name or ID' ,
2021-06-25 06:51:02 -07:00
name : 'dimensionName' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getDimensions' ,
} ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'Name of the dimension to filter by. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.' ,
2021-06-25 06:51:02 -07:00
} ,
// https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet#Operator
{
displayName : 'Operator' ,
name : 'operator' ,
type : 'options' ,
default : 'EXACT' ,
2022-05-06 14:01:25 -07:00
description : 'Operator to use in combination with value' ,
2021-06-25 06:51:02 -07:00
options : [
{
name : 'Begins With' ,
value : 'BEGINS_WITH' ,
} ,
{
name : 'Ends With' ,
value : 'ENDS_WITH' ,
} ,
2022-06-03 10:23:49 -07:00
{
name : 'Equal (Number)' ,
value : 'NUMERIC_EQUAL' ,
} ,
2021-06-25 06:51:02 -07:00
{
name : 'Exact' ,
value : 'EXACT' ,
} ,
{
2022-06-03 10:23:49 -07:00
name : 'Greater Than (Number)' ,
2021-06-25 06:51:02 -07:00
value : 'NUMERIC_GREATER_THAN' ,
} ,
2022-06-03 10:23:49 -07:00
{
name : 'Less Than (Number)' ,
value : 'NUMERIC_LESS_THAN' ,
} ,
2021-06-25 06:51:02 -07:00
{
name : 'Partial' ,
value : 'PARTIAL' ,
} ,
{
name : 'Regular Expression' ,
value : 'REGEXP' ,
} ,
] ,
} ,
{
displayName : 'Value' ,
name : 'expressions' ,
type : 'string' ,
default : '' ,
placeholder : 'ga:newUsers' ,
2022-08-17 08:50:24 -07:00
description :
'String or <a href="https://support.google.com/analytics/answer/1034324?hl=en">regular expression</a> to match against' ,
2021-06-25 06:51:02 -07:00
} ,
] ,
} ,
] ,
} ,
2021-01-05 10:16:25 -08:00
{
displayName : 'Hide Totals' ,
name : 'hideTotals' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
'Whether to hide the total of all metrics for all the matching rows, for every date range' ,
2021-01-05 10:16:25 -08:00
} ,
{
displayName : 'Hide Value Ranges' ,
name : 'hideValueRanges' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to hide the minimum and maximum across all matching rows' ,
2021-01-05 10:16:25 -08:00
} ,
{
displayName : 'Include Empty Rows' ,
name : 'includeEmptyRows' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
'Whether the response exclude rows if all the retrieved metrics are equal to zero' ,
2021-01-05 10:16:25 -08:00
} ,
{
displayName : 'Metrics' ,
name : 'metricsUi' ,
type : 'fixedCollection' ,
default : { } ,
typeOptions : {
multipleValues : true ,
} ,
placeholder : 'Add Metrics' ,
description : 'Metrics in the request' ,
options : [
{
displayName : 'Metric' ,
name : 'metricValues' ,
values : [
{
displayName : 'Alias' ,
name : 'alias' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'An alias for the metric expression is an alternate name for the expression. The alias can be used for filtering and sorting.' ,
2021-01-05 10:16:25 -08:00
} ,
{
displayName : 'Expression' ,
name : 'expression' ,
type : 'string' ,
default : 'ga:newUsers' ,
2022-08-17 08:50:24 -07:00
description :
'<p>A metric expression in the request. An expression is constructed from one or more metrics and numbers.</p><p>Accepted operators include: Plus (+), Minus (-), Negation (Unary -), Divided by (/), Multiplied by (*), Parenthesis, Positive cardinal numbers (0-9), can include decimals and is limited to 1024 characters.</p><p>Example ga:totalRefunds/ga:users, in most cases the metric expression is just a single metric name like ga:users.</p><p>Adding mixed MetricType (E.g., CURRENCY + PERCENTAGE) metrics will result in unexpected results.</p>.' ,
2021-01-05 10:16:25 -08:00
} ,
{
displayName : 'Formatting Type' ,
name : 'formattingType' ,
type : 'options' ,
default : 'INTEGER' ,
2022-05-06 14:01:25 -07:00
description : 'Specifies how the metric expression should be formatted' ,
2021-01-05 10:16:25 -08:00
options : [
{
name : 'Currency' ,
value : 'CURRENCY' ,
} ,
{
name : 'Float' ,
value : 'FLOAT' ,
} ,
{
name : 'Integer' ,
value : 'INTEGER' ,
} ,
{
name : 'Percent' ,
value : 'PERCENT' ,
} ,
{
name : 'Time' ,
value : 'TIME' ,
} ,
] ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Use Resource Quotas' ,
name : 'useResourceQuotas' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to enable resource based quotas' ,
2021-01-05 10:16:25 -08:00
} ,
] ,
} ,
2021-12-03 00:44:16 -08:00
] ;