UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

39 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.searchProperties = searchProperties; exports.searchViews = searchViews; const utils_1 = require("../helpers/utils"); const transport_1 = require("../transport"); async function searchProperties() { const returnData = []; const { accounts } = await transport_1.googleApiRequest.call(this, 'GET', '', {}, {}, 'https://analyticsadmin.googleapis.com/v1alpha/accounts'); for (const acount of accounts || []) { const { properties } = await transport_1.googleApiRequest.call(this, 'GET', '', {}, { filter: `parent:${acount.name}` }, 'https://analyticsadmin.googleapis.com/v1alpha/properties'); if (properties && properties.length > 0) { for (const property of properties) { const name = property.displayName; const value = property.name.split('/')[1] || property.name; const url = `https://analytics.google.com/analytics/web/#/p${value}/`; returnData.push({ name, value, url }); } } } return { results: (0, utils_1.sortLoadOptions)(returnData), }; } async function searchViews() { const returnData = []; const { items } = await transport_1.googleApiRequest.call(this, 'GET', '', {}, {}, 'https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles'); for (const item of items) { returnData.push({ name: `${item.name} [${item.websiteUrl}]`, value: item.id, url: `https://analytics.google.com/analytics/web/#/report-home/a${item.accountId}w${item.internalWebPropertyId}p${item.id}`, }); } return { results: (0, utils_1.sortLoadOptions)(returnData), }; } //# sourceMappingURL=listSearch.js.map