Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google analytics new goals source #2131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

andrewjschuang
Copy link
Collaborator

Google Analytics

New Goals | Triggers when a new goal is added.

@vercel
Copy link

vercel bot commented Jan 26, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

pipedream-docs-redirect-do-not-edit – ./docs

🔍 Inspect: https://vercel.com/pipedreamers/pipedream-docs-redirect-do-not-edit/9iQCwHYigR2c1FsepBFg1YdbChoM
✅ Preview: https://pipedream-docs-redirect-do-not-edit-git-for-a0120e-pipedreamers.vercel.app

pipedream-docs – ./docs

🔍 Inspect: https://vercel.com/pipedreamers/pipedream-docs/39k7pYqQ9c28hJGR48ndqgqcKcwf
✅ Preview: https://pipedream-docs-git-fork-andrewjschuang-goog-4030e8-pipedreamers.vercel.app

@andrewjschuang
Copy link
Collaborator Author

The OAuth authentication is missing some Analytics scopes

@dylburger
Copy link
Contributor

@andrewjschuang andrewjschuang linked an issue Jan 26, 2022 that may be closed by this pull request
@michelle0927 michelle0927 self-requested a review February 22, 2022 19:14
export default {
key: "google_analytics-list-goals",
name: "List Goals",
description: "Lists goals to which the user has access",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include a link to the docs for actions:

Suggested change
description: "Lists goals to which the user has access",
description: "Lists goals to which the user has access. [See the docs here](https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/goals/list)",

Comment on lines +11 to +16
token: {
propDefinition: [
analytics,
"token",
],
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think token is necessary since we have this.$auth.oauth_access_token.

Suggested change
token: {
propDefinition: [
analytics,
"token",
],
},

Comment on lines +17 to +40
accountId: {
propDefinition: [
analytics,
"accountId",
],
description: `${analytics.propDefinitions.accountId.description}
Can either be a specific account ID or \`~all\`, which refers to all the accounts that user has access to`,
},
webPropertyId: {
propDefinition: [
analytics,
"webPropertyId",
],
description: `${analytics.propDefinitions.webPropertyId.description}
Can either be a specific web property ID or \`~all\`, which refers to all the web properties that user has access to`,
},
profileId: {
propDefinition: [
analytics,
"profileId",
],
description: `${analytics.propDefinitions.profileId.description}
Can either be a specific view (profile) ID or \`~all\`, which refers to all the views (profiles) that user has access to`,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accountId, webPropertyId, and profileId should all have async options that list the accounts, web properties, and profiles that the user has access to. You could have them default to "~all".

Comment on lines +47 to +53
startIndex: {
type: "integer",
label: "Start Index",
description: `An index of the first goal to retrieve
Use this parameter as a pagination mechanism along with the max-results parameter`,
optional: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave in maxResults, but take out startIndex and handle pagination in the component.

Suggested change
startIndex: {
type: "integer",
label: "Start Index",
description: `An index of the first goal to retrieve
Use this parameter as a pagination mechanism along with the max-results parameter`,
optional: true,
},

},
},
async run({ $ }) {
let params = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should declare variables as constants whenever we can.

Suggested change
let params = {
const params = {

Comment on lines +46 to +48
_getGoalsInstance(token) {
return this._getAnalyticsInstance(token).management.goals;
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_getGoalsInstance(token) {
return this._getAnalyticsInstance(token).management.goals;
},
_getGoalsInstance() {
return this._getAnalyticsInstance().management.goals;
},

Comment on lines +49 to +50
async listGoals(token, params) {
return (await this._getGoalsInstance(token).list(params)).data;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async listGoals(token, params) {
return (await this._getGoalsInstance(token).list(params)).data;
async listGoals(params) {
return (await this._getGoalsInstance().list(params)).data;

},
async run() {
const startIndex = this._getLastGoalId();
let params = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let params = {
const params = {

Comment on lines +33 to +35
"accountId": "~all",
"webPropertyId": "~all",
"profileId": "~all",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have accountId, webPropertyId, and profileId as props in this component? Then the user can select which ones to watch.

"start-index": startIndex,
};

let response = await this.analytics.listGoals(null, params);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let response = await this.analytics.listGoals(null, params);
const response = await this.analytics.listGoals(null, params);

@andrewjschuang
Copy link
Collaborator Author

Thanks @michelle0927 for the review!
I will proceed to make the changes requested after the authentication scopes are added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SOURCE] Google Analytics: New Goals
3 participants