Skip to content

Commit 4cc580e

Browse files
authored
Google Analytics - add async options for properties (#17255)
* properties async options * pnpm-lock.yaml
1 parent 195dc39 commit 4cc580e

File tree

7 files changed

+38
-13
lines changed

7 files changed

+38
-13
lines changed

components/google_analytics/actions/create-ga4-property/create-ga4-property.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "google_analytics-create-ga4-property",
66
name: "Create GA4 Property",
77
description: "Creates a new GA4 property. [See the documentation](https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1beta/properties/create)",
8-
version: "0.1.0",
8+
version: "0.1.1",
99
type: "action",
1010
props: {
1111
googleAnalytics,

components/google_analytics/actions/create-key-event/create-key-event.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ export default {
44
key: "google_analytics-create-key-event",
55
name: "Create Key Event",
66
description: "Creates a new key event. [See the documentation](https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1beta/properties.keyEvents/create)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
app,
1111
parent: {
12-
type: "string",
13-
label: "Parent",
12+
propDefinition: [
13+
app,
14+
"property",
15+
],
1416
description: "The resource name of the parent property where this Key Event will be created. Format: `properties/123`",
1517
},
1618
eventName: {

components/google_analytics/actions/run-report-in-ga4/run-report-in-ga4.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import analytics from "../../google_analytics.app.mjs";
22

33
export default {
44
key: "google_analytics-run-report-in-ga4",
5-
version: "0.1.0",
5+
version: "0.1.1",
66
name: "Run Report in GA4",
7-
description: "Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the Google Analytics tracking code. [See the documentation here](https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport)",
7+
description: "Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the Google Analytics tracking code. [See the documentation](https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport)",
88
type: "action",
99
props: {
1010
analytics,
1111
property: {
12-
type: "string",
13-
label: "Property",
12+
propDefinition: [
13+
analytics,
14+
"property",
15+
],
1416
description: "A Google Analytics GA4 property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, [see where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Within a batch request, this property should either be unspecified or consistent with the batch-level property.",
1517
},
1618
startDate: {
@@ -64,8 +66,9 @@ export default {
6466
})),
6567
dimensionFilter: dimensionFilter,
6668
};
69+
const property = this.property.match(/\d+/)[0];
6770
const report = await this.analytics.queryReportsGA4({
68-
property: this.property,
71+
property,
6972
data,
7073
});
7174
$.export("$summary", `Successfully retrieved report for the property ${this.property}`);

components/google_analytics/actions/run-report/run-report.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import analytics from "../../google_analytics.app.mjs";
22

33
export default {
44
key: "google_analytics-run-report",
5-
version: "0.1.0",
5+
version: "0.1.1",
66
name: "Run Report",
7-
description: "Return report metrics based on a start and end date. [See the docs here](https://developers.google.com/analytics/devguides/reporting/core/v4/rest?hl=en)",
7+
description: "Return report metrics based on a start and end date. [See the documentation](https://developers.google.com/analytics/devguides/reporting/core/v4/rest?hl=en)",
88
type: "action",
99
props: {
1010
analytics,

components/google_analytics/google_analytics.app.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ export default {
2323
label: "View Id",
2424
description: "ID of the view to monitor. Can be found on your Google Analytics Dashboard -> Admin -> View Setting",
2525
},
26+
property: {
27+
type: "string",
28+
label: "Property",
29+
description: "A Google Analytics property ID",
30+
async options() {
31+
const response = await this.listProperties();
32+
return response?.map((property) => ({
33+
label: property.displayName,
34+
value: property.property,
35+
}));
36+
},
37+
},
2638
},
2739
methods: {
2840
_accessToken() {
@@ -79,6 +91,14 @@ export default {
7991
...args,
8092
});
8193
},
94+
async listProperties(args = {}) {
95+
const { accountSummaries } = await this.makeRequest({
96+
path: "/accountSummaries",
97+
...args,
98+
});
99+
return accountSummaries.map(({ propertySummaries }) => propertySummaries).flat()
100+
.filter((property) => property);
101+
},
82102
queryReportsGA4({
83103
property, ...args
84104
} = {}) {

components/google_analytics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/google_analytics",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Pipedream Google_analytics Components",
55
"main": "google_analytics.app.mjs",
66
"keywords": [

components/google_analytics/sources/page-opened/page-opened.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import utils from "../../common/utils.mjs";
44

55
export default {
66
key: "google_analytics-page-opened",
7-
version: "0.1.0",
7+
version: "0.1.1",
88
name: "New Page Opened",
99
description: "Emit new event when a page is viewed",
1010
type: "source",

0 commit comments

Comments
 (0)