Skip to content

Commit c33a384

Browse files
committed
Make idType a standard prop in the base props, so the default case
(where the `ids` prop is not needed) works without calling reloadProps
1 parent ece4738 commit c33a384

File tree

5 files changed

+63
-90
lines changed

5 files changed

+63
-90
lines changed

components/youtube_analytics_api/actions/common/reports-query.mjs

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,85 +6,61 @@ import propsFragments from "../../common/props-fragments.mjs";
66
export default {
77
props: {
88
app,
9-
reloader: {
10-
type: "boolean",
11-
label: "Hidden Reloader",
12-
description: "This prop is used to reload the props when the step gets created.",
13-
hidden: true,
14-
reloadProps: true,
15-
},
169
startDate: {
17-
propDefinition: [
18-
app,
19-
"startDate",
20-
],
10+
propDefinition: [app, "startDate"],
2111
},
2212
endDate: {
23-
propDefinition: [
24-
app,
25-
"endDate",
26-
],
13+
propDefinition: [app, "endDate"],
2714
},
2815
dimensions: {
29-
propDefinition: [
30-
app,
31-
"dimensions",
32-
],
16+
propDefinition: [app, "dimensions"],
3317
},
3418
sort: {
35-
propDefinition: [
36-
app,
37-
"sort",
38-
],
19+
propDefinition: [app, "sort"],
3920
},
4021
maxResults: {
41-
propDefinition: [
42-
app,
43-
"maxResults",
44-
],
22+
propDefinition: [app, "maxResults"],
23+
},
24+
idType: {
25+
type: "string",
26+
label: "ID Type",
27+
description:
28+
"The type of ID to use for the query. This can be either `My Channel`, `Channel ID`, or `Content Owner`.",
29+
options: Object.values(constants.ID_TYPE),
30+
default: constants.ID_TYPE.CHANNEL.value,
31+
reloadProps: true,
4532
},
4633
},
4734
methods: {
4835
getIdsProps() {
4936
const { idType } = this;
5037

51-
if (idType === constants.ID_TYPE.CHANNEL.value) {
52-
return {
53-
idType: propsFragments.idType,
54-
};
55-
}
56-
5738
if (idType === constants.ID_TYPE.CONTENT_OWNER.value) {
5839
return {
59-
idType: propsFragments.idType,
6040
ids: {
6141
type: "string",
6242
label: "Content Owner Name",
63-
description: "The content owner name for the user. Eg. `MyContentOwnerName`.",
43+
description:
44+
"The content owner name for the user. Eg. `MyContentOwnerName`.",
6445
},
6546
};
6647
}
6748

6849
if (idType === constants.ID_TYPE.CHANNEL_ID.value) {
6950
return {
70-
idType: propsFragments.idType,
7151
ids: {
7252
type: "string",
7353
label: "Channel ID",
74-
description: "The channel ID for the user. Eg. `UC_x5XG1OV2P6uZZ5FSM9Ttw`. You can find the ID using the [YouTube Data API](https://developers.google.com/youtube/v3/docs/channels/list).",
54+
description:
55+
"The channel ID for the user. Eg. `UC_x5XG1OV2P6uZZ5FSM9Ttw`. You can find the ID using the [YouTube Data API](https://developers.google.com/youtube/v3/docs/channels/list).",
7556
},
7657
};
7758
}
7859

79-
return {
80-
idType: propsFragments.idType,
81-
};
60+
return {};
8261
},
8362
getIdsParam() {
84-
const {
85-
idType,
86-
ids,
87-
} = this;
63+
const { idType, ids } = this;
8864
if (idType === constants.ID_TYPE.CHANNEL.value) {
8965
return "channel==MINE";
9066
}
@@ -104,14 +80,10 @@ export default {
10480
}
10581

10682
return utils.arrayToCommaSeparatedList(
107-
Object.entries(filtersObj)
108-
.reduce((acc, [
109-
key,
110-
val,
111-
]) => [
112-
...acc,
113-
`${key}==${val}`,
114-
], []),
83+
Object.entries(filtersObj).reduce(
84+
(acc, [key, val]) => [...acc, `${key}==${val}`],
85+
[],
86+
),
11587
";",
11688
);
11789
},

components/youtube_analytics_api/actions/get-video-metrics/get-video-metrics.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ export default {
66
...common,
77
key: "youtube_analytics_api-get-video-metrics",
88
name: "Get Video Metrics",
9-
description: "Retrieve detailed analytics for a specific video. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
10-
version: "0.0.1",
9+
description:
10+
"Retrieve detailed analytics for a specific video. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
11+
version: "0.0.2",
1112
type: "action",
1213
props: {
1314
...common.props,
1415
videoId: {
1516
type: "string",
1617
label: "Video ID",
17-
description: "The ID of the video for which you want to retrieve metrics. Eg. `pd1FJh59zxQ`.",
18+
description:
19+
"The ID of the video for which you want to retrieve metrics. Eg. `pd1FJh59zxQ`.",
1820
},
1921
metrics: propsFragments.metrics,
2022
},

components/youtube_analytics_api/actions/list-channel-reports/list-channel-reports.mjs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ export default {
77
...common,
88
key: "youtube_analytics_api-list-channel-reports",
99
name: "List Channel Reports",
10-
description: "Fetch summary analytics reports for a specified youtube channel. Optional filters include date range and report type. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
11-
version: "0.0.1",
10+
description:
11+
"Fetch summary analytics reports for a specified youtube channel. Optional filters include date range and report type. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
12+
version: "0.0.2",
1213
type: "action",
1314
additionalProps() {
14-
const {
15-
getIdsProps,
16-
getReportTypeProps,
17-
} = this;
15+
const { getIdsProps, getReportTypeProps } = this;
1816

1917
return {
2018
...getIdsProps(),
@@ -25,17 +23,18 @@ export default {
2523
...common.methods,
2624
getReportTypeProps() {
2725
const { channelReportType } = this;
28-
const {
29-
VIDEO_BASIC_USER_ACTIVITY_STATS,
30-
PLAYLIST_BASIC_STATS,
31-
} = constants.CHANNEL_REPORT_TYPE;
26+
const { VIDEO_BASIC_USER_ACTIVITY_STATS, PLAYLIST_BASIC_STATS } =
27+
constants.CHANNEL_REPORT_TYPE;
3228

3329
if (channelReportType === VIDEO_BASIC_USER_ACTIVITY_STATS.value) {
34-
const supportedFilters = VIDEO_BASIC_USER_ACTIVITY_STATS.metadata.filters
35-
.reduce((acc, filter) => ({
36-
...acc,
37-
[filter]: "",
38-
}), {});
30+
const supportedFilters =
31+
VIDEO_BASIC_USER_ACTIVITY_STATS.metadata.filters.reduce(
32+
(acc, filter) => ({
33+
...acc,
34+
[filter]: "",
35+
}),
36+
{},
37+
);
3938

4039
return {
4140
channelReportType: propsFragments.channelReportType,
@@ -51,11 +50,13 @@ export default {
5150
}
5251

5352
if (channelReportType === PLAYLIST_BASIC_STATS.value) {
54-
const supportedFilters = PLAYLIST_BASIC_STATS.metadata.filters
55-
.reduce((acc, filter) => ({
53+
const supportedFilters = PLAYLIST_BASIC_STATS.metadata.filters.reduce(
54+
(acc, filter) => ({
5655
...acc,
5756
[filter]: "",
58-
}), {});
57+
}),
58+
{},
59+
);
5960

6061
return {
6162
channelReportType: propsFragments.channelReportType,

components/youtube_analytics_api/actions/query-custom-analytics/query-custom-analytics.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ export default {
66
...common,
77
key: "youtube_analytics_api-query-custom-analytics",
88
name: "Query Custom Analytics",
9-
description: "Execute a custom analytics query using specified metrics, dimensions, filters, and date ranges. Requires query parameters to configure. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query).",
10-
version: "0.0.1",
9+
description:
10+
"Execute a custom analytics query using specified metrics, dimensions, filters, and date ranges. Requires query parameters to configure. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query).",
11+
version: "0.0.2",
1112
type: "action",
1213
props: {
1314
...common.props,
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
import constants from "./constants.mjs";
22

33
export default {
4-
idType: {
5-
type: "string",
6-
label: "ID Type",
7-
description: "The type of ID to use for the query. This can be either `My Channel`, `Channel ID`, or `Content Owner`.",
8-
options: Object.values(constants.ID_TYPE),
9-
default: constants.ID_TYPE.CHANNEL.value,
10-
reloadProps: true,
11-
},
124
channelReportType: {
135
type: "string",
146
label: "Channel Report Type",
15-
description: "The type of report to fetch for the specified YouTube Channel. This selects default dimensions, metrics and filters.",
16-
options: Object.values(constants.CHANNEL_REPORT_TYPE)
17-
.map(({
7+
description:
8+
"The type of report to fetch for the specified YouTube Channel. This selects default dimensions, metrics and filters.",
9+
options: Object.values(constants.CHANNEL_REPORT_TYPE).map(
10+
({
1811
// eslint-disable-next-line no-unused-vars
1912
metadata,
2013
...rest
21-
}) => rest),
22-
default: constants.CHANNEL_REPORT_TYPE.VIDEO_BASIC_USER_ACTIVITY_STATS.value,
14+
}) => rest,
15+
),
16+
default:
17+
constants.CHANNEL_REPORT_TYPE.VIDEO_BASIC_USER_ACTIVITY_STATS.value,
2318
reloadProps: true,
2419
},
2520
metrics: {
2621
type: "string[]",
2722
label: "Metrics",
28-
description: "Metrics, such as `views` or `likes`, `dislikes`. See the documentation for [channel reports](https://developers.google.com/youtube/analytics/channel_reports) or [content owner reports](https://developers.google.com/youtube/analytics/content_owner_reports) for a list of the reports that you can retrieve and the metrics available in each report. (The [Metrics](https://developers.google.com/youtube/reporting#metrics) document contains definitions for all of the metrics.).",
23+
description:
24+
"Metrics, such as `views` or `likes`, `dislikes`. See the documentation for [channel reports](https://developers.google.com/youtube/analytics/channel_reports) or [content owner reports](https://developers.google.com/youtube/analytics/content_owner_reports) for a list of the reports that you can retrieve and the metrics available in each report. (The [Metrics](https://developers.google.com/youtube/reporting#metrics) document contains definitions for all of the metrics.).",
2925
options: Object.values(constants.METRIC),
3026
},
3127
filters: {
3228
type: "object",
3329
label: "Filters",
34-
description: "A list of filters that should be applied when retrieving YouTube Analytics data. The documentation for [channel reports](https://developers.google.com/youtube/analytics/channel_reports) and [content owner reports](https://developers.google.com/youtube/analytics/content_owner_reports) identifies the dimensions that can be used to filter each report, and the [Dimensions](https://developers.google.com/youtube/analytics/dimsmets/dims) document defines those dimensions.\n\nIf a request uses multiple filters the returned result table will satisfy both filters. For example, a filters parameter value of `{\"video\":\"dMH0bHeiRNg\",\"country\":\"IT\"}` restricts the result set to include data for the given video in Italy.\n\nSpecifying multiple values for a filter\nThe API supports the ability to specify multiple values for the [video](https://developers.google.com/youtube/reporting#supported-reports), [playlist](https://developers.google.com/youtube/reporting#supported-reports), and [channel](https://developers.google.com/youtube/reporting#supported-reports) filters. To do so, specify a separated list of the video, playlist, or channel IDs for which the API response should be filtered. For example, a filters parameter value of `{\"video\":\"pd1FJh59zxQ,Zhawgd0REhA\",\"country\":\"IT\"}` restricts the result set to include data for the given videos in Italy. The parameter value can specify up to 500 IDs. For more details on the filters parameter, see the filters parameter in [Parameters](https://developers.google.com/youtube/analytics/reference/reports/query#Parameters) section.",
30+
description:
31+
'A list of filters that should be applied when retrieving YouTube Analytics data. The documentation for [channel reports](https://developers.google.com/youtube/analytics/channel_reports) and [content owner reports](https://developers.google.com/youtube/analytics/content_owner_reports) identifies the dimensions that can be used to filter each report, and the [Dimensions](https://developers.google.com/youtube/analytics/dimsmets/dims) document defines those dimensions.\n\nIf a request uses multiple filters the returned result table will satisfy both filters. For example, a filters parameter value of `{"video":"dMH0bHeiRNg","country":"IT"}` restricts the result set to include data for the given video in Italy.\n\nSpecifying multiple values for a filter\nThe API supports the ability to specify multiple values for the [video](https://developers.google.com/youtube/reporting#supported-reports), [playlist](https://developers.google.com/youtube/reporting#supported-reports), and [channel](https://developers.google.com/youtube/reporting#supported-reports) filters. To do so, specify a separated list of the video, playlist, or channel IDs for which the API response should be filtered. For example, a filters parameter value of `{"video":"pd1FJh59zxQ,Zhawgd0REhA","country":"IT"}` restricts the result set to include data for the given videos in Italy. The parameter value can specify up to 500 IDs. For more details on the filters parameter, see the filters parameter in [Parameters](https://developers.google.com/youtube/analytics/reference/reports/query#Parameters) section.',
3532
optional: true,
3633
},
3734
};

0 commit comments

Comments
 (0)