mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
✨ Add Dimension Filters to Google Analyics Node
This commit is contained in:
parent
6c7e1ec3c9
commit
876cf7323d
|
@ -212,6 +212,14 @@ export class GoogleAnalytics implements INodeType {
|
||||||
body.dimensions = dimensions;
|
body.dimensions = dimensions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (additionalFields.dimensionFiltersUi) {
|
||||||
|
const dimensionFilters = (additionalFields.dimensionFiltersUi as IDataObject).filterValues as IDataObject[];
|
||||||
|
if (dimensionFilters) {
|
||||||
|
dimensionFilters.forEach(filter => filter.expressions = [filter.expressions]);
|
||||||
|
body.dimensionFilterClauses = { filters: dimensionFilters };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (additionalFields.includeEmptyRows) {
|
if (additionalFields.includeEmptyRows) {
|
||||||
Object.assign(body, { includeEmptyRows: additionalFields.includeEmptyRows });
|
Object.assign(body, { includeEmptyRows: additionalFields.includeEmptyRows });
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
export interface IData {
|
export interface IData {
|
||||||
viewId: string;
|
viewId: string;
|
||||||
dimensions?: IDimension[];
|
dimensions?: IDimension[];
|
||||||
|
dimensionFilterClauses?: {
|
||||||
|
filters: IDimensionFilter[];
|
||||||
|
};
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
metrics?: IMetric[];
|
metrics?: IMetric[];
|
||||||
}
|
}
|
||||||
|
@ -10,6 +13,11 @@ export interface IDimension {
|
||||||
histogramBuckets?: string[];
|
histogramBuckets?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IDimensionFilter {
|
||||||
|
dimensionName?: string;
|
||||||
|
operator?: string;
|
||||||
|
expressions?: string[];
|
||||||
|
}
|
||||||
export interface IMetric {
|
export interface IMetric {
|
||||||
expression?: string;
|
expression?: string;
|
||||||
alias?: string;
|
alias?: string;
|
||||||
|
|
|
@ -183,6 +183,85 @@ export const reportFields = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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: [
|
||||||
|
{
|
||||||
|
displayName: 'Dimension Name',
|
||||||
|
name: 'dimensionName',
|
||||||
|
type: 'options',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getDimensions',
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Name of the dimension to filter by.',
|
||||||
|
},
|
||||||
|
// https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet#Operator
|
||||||
|
{
|
||||||
|
displayName: 'Operator',
|
||||||
|
name: 'operator',
|
||||||
|
type: 'options',
|
||||||
|
default: 'EXACT',
|
||||||
|
description: 'Operator to use in combination with value.',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Begins With',
|
||||||
|
value: 'BEGINS_WITH',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Ends With',
|
||||||
|
value: 'ENDS_WITH',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Exact',
|
||||||
|
value: 'EXACT',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Greater Than (number)',
|
||||||
|
value: 'NUMERIC_GREATER_THAN',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Partial',
|
||||||
|
value: 'PARTIAL',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Regular Expression',
|
||||||
|
value: 'REGEXP',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Equal (number)',
|
||||||
|
value: 'NUMERIC_EQUAL',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Less Than (number)',
|
||||||
|
value: 'NUMERIC_LESS_THAN',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Value',
|
||||||
|
name: 'expressions',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
placeholder: 'ga:newUsers',
|
||||||
|
description: `String or <a href="https://support.google.com/analytics/answer/1034324?hl=en" target="_blank">regular expression</a> to match against.`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Hide Totals',
|
displayName: 'Hide Totals',
|
||||||
name: 'hideTotals',
|
name: 'hideTotals',
|
||||||
|
|
Loading…
Reference in a new issue