Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions components/youtube_analytics_api/actions/common/reports-query.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import app from "../../youtube_analytics_api.app.mjs";
import constants from "../../common/constants.mjs";
import utils from "../../common/utils.mjs";
import propsFragments from "../../common/props-fragments.mjs";

export default {
props: {
app,
reloader: {
type: "boolean",
label: "Hidden Reloader",
description: "This prop is used to reload the props when the step gets created.",
hidden: true,
reloadProps: true,
},
startDate: {
propDefinition: [
app,
Expand Down Expand Up @@ -43,47 +35,47 @@ export default {
"maxResults",
],
},
idType: {
type: "string",
label: "ID Type",
description:
"The type of ID to use for the query. This can be either `My Channel`, `Channel ID`, or `Content Owner`.",
options: Object.values(constants.ID_TYPE),
default: constants.ID_TYPE.CHANNEL.value,
reloadProps: true,
},
},
methods: {
getIdsProps() {
const { idType } = this;

if (idType === constants.ID_TYPE.CHANNEL.value) {
return {
idType: propsFragments.idType,
};
}

if (idType === constants.ID_TYPE.CONTENT_OWNER.value) {
return {
idType: propsFragments.idType,
ids: {
type: "string",
label: "Content Owner Name",
description: "The content owner name for the user. Eg. `MyContentOwnerName`.",
description:
"The content owner name for the user. Eg. `MyContentOwnerName`.",
},
};
}

if (idType === constants.ID_TYPE.CHANNEL_ID.value) {
return {
idType: propsFragments.idType,
ids: {
type: "string",
label: "Channel ID",
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).",
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).",
},
};
}

return {
idType: propsFragments.idType,
};
return {};
},
getIdsParam() {
const {
idType,
ids,
idType, ids,
} = this;
if (idType === constants.ID_TYPE.CHANNEL.value) {
return "channel==MINE";
Expand All @@ -104,14 +96,16 @@ export default {
}

return utils.arrayToCommaSeparatedList(
Object.entries(filtersObj)
.reduce((acc, [
Object.entries(filtersObj).reduce(
(acc, [
key,
val,
]) => [
...acc,
`${key}==${val}`,
], []),
],
[],
),
";",
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ export default {
...common,
key: "youtube_analytics_api-get-video-metrics",
name: "Get Video Metrics",
description: "Retrieve detailed analytics for a specific video. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
version: "0.0.1",
description:
"Retrieve detailed analytics for a specific video. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
version: "0.0.2",
type: "action",
props: {
...common.props,
videoId: {
type: "string",
label: "Video ID",
description: "The ID of the video for which you want to retrieve metrics. Eg. `pd1FJh59zxQ`.",
description:
"The ID of the video for which you want to retrieve metrics. Eg. `pd1FJh59zxQ`.",
},
metrics: propsFragments.metrics,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export default {
...common,
key: "youtube_analytics_api-list-channel-reports",
name: "List Channel Reports",
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)",
version: "0.0.1",
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)",
version: "0.0.2",
type: "action",
additionalProps() {
const {
getIdsProps,
getReportTypeProps,
getIdsProps, getReportTypeProps,
} = this;

return {
Expand All @@ -26,16 +26,19 @@ export default {
getReportTypeProps() {
const { channelReportType } = this;
const {
VIDEO_BASIC_USER_ACTIVITY_STATS,
PLAYLIST_BASIC_STATS,
} = constants.CHANNEL_REPORT_TYPE;
VIDEO_BASIC_USER_ACTIVITY_STATS, PLAYLIST_BASIC_STATS,
} =
constants.CHANNEL_REPORT_TYPE;

if (channelReportType === VIDEO_BASIC_USER_ACTIVITY_STATS.value) {
const supportedFilters = VIDEO_BASIC_USER_ACTIVITY_STATS.metadata.filters
.reduce((acc, filter) => ({
...acc,
[filter]: "",
}), {});
const supportedFilters =
VIDEO_BASIC_USER_ACTIVITY_STATS.metadata.filters.reduce(
(acc, filter) => ({
...acc,
[filter]: "",
}),
{},
);

return {
channelReportType: propsFragments.channelReportType,
Expand All @@ -51,11 +54,13 @@ export default {
}

if (channelReportType === PLAYLIST_BASIC_STATS.value) {
const supportedFilters = PLAYLIST_BASIC_STATS.metadata.filters
.reduce((acc, filter) => ({
const supportedFilters = PLAYLIST_BASIC_STATS.metadata.filters.reduce(
(acc, filter) => ({
...acc,
[filter]: "",
}), {});
}),
{},
);

return {
channelReportType: propsFragments.channelReportType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ export default {
...common,
key: "youtube_analytics_api-query-custom-analytics",
name: "Query Custom Analytics",
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).",
version: "0.0.1",
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).",
version: "0.0.2",
type: "action",
props: {
...common.props,
Expand Down
27 changes: 12 additions & 15 deletions components/youtube_analytics_api/common/props-fragments.mjs
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
import constants from "./constants.mjs";

export default {
idType: {
type: "string",
label: "ID Type",
description: "The type of ID to use for the query. This can be either `My Channel`, `Channel ID`, or `Content Owner`.",
options: Object.values(constants.ID_TYPE),
default: constants.ID_TYPE.CHANNEL.value,
reloadProps: true,
},
channelReportType: {
type: "string",
label: "Channel Report Type",
description: "The type of report to fetch for the specified YouTube Channel. This selects default dimensions, metrics and filters.",
options: Object.values(constants.CHANNEL_REPORT_TYPE)
.map(({
description:
"The type of report to fetch for the specified YouTube Channel. This selects default dimensions, metrics and filters.",
options: Object.values(constants.CHANNEL_REPORT_TYPE).map(
({
// eslint-disable-next-line no-unused-vars
metadata,
...rest
}) => rest),
default: constants.CHANNEL_REPORT_TYPE.VIDEO_BASIC_USER_ACTIVITY_STATS.value,
}) => rest,
),
default:
constants.CHANNEL_REPORT_TYPE.VIDEO_BASIC_USER_ACTIVITY_STATS.value,
reloadProps: true,
},
metrics: {
type: "string[]",
label: "Metrics",
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.).",
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.).",
options: Object.values(constants.METRIC),
},
filters: {
type: "object",
label: "Filters",
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.",
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.",
optional: true,
},
};
2 changes: 1 addition & 1 deletion components/youtube_analytics_api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/youtube_analytics_api",
"version": "0.0.1",
"version": "0.0.2",
"description": "Pipedream Youtube Analytics API Components",
"main": "youtube_analytics_api.app.mjs",
"keywords": [
Expand Down
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading