GithubHelp home page GithubHelp logo

opteo / google-ads-node Goto Github PK

View Code? Open in Web Editor NEW
66.0 8.0 35.0 37.01 MB

Google Ads API client library for Node.js

Home Page: https://opteo.com

Makefile 0.01% JavaScript 52.66% TypeScript 47.34% Dockerfile 0.01% Shell 0.01%
google-ads nodejs grpc typescript adwords

google-ads-node's People

Contributors

avermeil avatar chloeroseanne avatar chunkai1312 avatar dependabot[bot] avatar joel-valentine avatar kritzware avatar loicadolphe avatar mateuszjanusz avatar mledwards avatar mortiy avatar rosslavery avatar veritymissed avatar wcoots avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-ads-node's Issues

Setting ad.url_custom_parameters

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

Setting a url_custom_parameters throws error:
Error: Field 'ad.url_custom_parameters' cannot be modified by 'UPDATE' operation.

await customer.adGroupAds.update({
    resource_name: 'customers/00000000/adGroupAds/00000000~00000000',
    ad : {
    url_custom_parameters: [
        { key:'test',  value: 'test_value' },
    ],
    }
});

Other information

Is this possibly related to Repeated types?
Working with Protobuf Types - Repeated types

Compilation issues with M1 chips

Several of us on newer M1 laptops were unable to perform several upgrade steps:

  • Running yarn, which in turn runs compileProtos from google-gax, fails
  • Running make protos at the Bazel build step

Everything worked fine when using an older chip. Perhaps some dependency in google-gax and Bazel is incompatible on M1 for the time being?

Project structure question

Hi,
I've some time to invest in order to optimize this lib so it will be more suitable for production use (#83 #87 #84)

But I'm not getting the structure of it.
I did understood that it gets generated from googles protobuf defs.

  1. What is the relation between build/src folder and the build/protos/protos.js file?
  2. Do we need build/src on production usage? (is google-ads-api uses it?)

Any help will be really appreciated.

Receiving RESOURCE_EXHAUSTED: received trailing metadata size exceeds limit

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

Large sets of mutations cause a RESOURCE_EXHAUSTED error with the following details:

"failure":{
      "code": 8,
      "details": "received trailing metadata size exceeds limit"
   }

Other information

This seems to be a problem with gRPC response size being capped as part of this library. When a response size is too large, a generic received trailing metadata size exceeds limit error is sent back, which obfuscates the actual cause of the error.

Spoke to Google support about this (provided them a request id) and they said the following (note I linked them to a similar issue from their officially-supported Python API Wrapper):

The Python issue you referenced has since been resolved, as we increased the grpc metadata size in September. However, since the error message from nodejs appears to be the same grpc error, there is a good chance that either the metadata size increase was not large enough for this particular response, or that the response size limit that's set in the nodejs library here is actually separate from the metadata size limit. I will follow up with the team about this issue to see what we can do, and will respond here as soon as I have updates for you.

and

I have investigated more deeply into the issue and confirmed that the longest response metadata for your requests (~42kb) is still shorter than what we have bumped the metadata size limit to (64kb). Since the equivalent issue has been resolved for Google-owned client libraries, even for response metadata longer that what is causing problems for you, the most likely case is that this error is manifesting due an Opteo-specific gRPC setup. Our recommendation is to file a Github Issue with the NodeJS client library open sourced by Opteo to have them look into the issue, and hopefully then you will have a resolution soon.

I see that you increase the message here but according to the email from Google above, my response payload for the problematic request was only ~42kb which is obviously well under the 1gb being set in the gRPC client for this library.

This has been a frequent issue for us in specific parts of our application, and would love to help get it fixed!

NPM webpage is broken

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

image

Other information

Tested just now and a couple days ago. It is downloadable via npm tho.

Label missing fields in resources.ts

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

This is a follow-up to this issue. After investigating, I found out that Label's interface in resources.ts is missing fields specified in the API. As a result, the fields are also missing from the compiled version of the resources. I tried adding the fields on my fork here.

However, I could not compile the resources and investigate further because I don't have the Docker permissions. I was wondering if someone could please provide an ETA on this issue. Also, is there an option of relaxing the permissions so that I could investigate further myself and open up a PR?

This is blocking me significantly. Any info would be very much appreciated. I can provide more details if needed.
Thanks a lot!

How to authorize UserDataServiceClient

Hi,
Thank you for building these libraries!

I've successfully been using the companion google-ads-api library but I can't see how to add developerToken / authorize the services in this library. Specifically I need to run UserDataServiceClient.

Here is my code sample & I think/hope it should work if I can just authorize it correctly. (The google-ads-api constructor takes clientId, clientSecret, and developerToken & then Customer adds a refreshToken - I can't work out how to specify the developer_token).

const client = new UserDataServiceClient(
{
clientOptions: {
clientId: ADS_CLIENT,
clientSecret: ADS_SECRET,
refreshToken
}
}
)
const result = await client.uploadUserData({
customer_id: googleAdAccount,
operations: [
{
create: new common.UserData({
user_identifiers
}),
}
],
customer_match_user_list_metadata: {
user_list: googleAudience,
}
})

Hope this makes sense.

Again - thank you for making this awesome library.

Regards
Sam

Problem with authorization

Hey guys!
Currently i am started to working with this library, because I needs some things from google API v10, and library google-ads-api currently supports only v9.

And my question is:
How to authorize with my Google Ads Account?
In the case of working with google-ads-api, everything works, so it is not the fault of bad data.

My current code looks like this:

import { CustomerServiceClient } from "google-ads-node";
 async function makeCall() {
   const client = new CustomerServiceClient({
     clientOptions: {
       clientId: "myClientId",
       clientSecret: "myClientSecret",
       refreshToken: "myRefreshToken"
     },
   });
   const response = await client.listAccessibleCustomers();
   return response;
}

I receive: Error: 7 PERMISSION_DENIED: Request had insufficient authentication scopes.
I am more then sure that is because I didn't pass developer token.

And question is: how to pass it/and and is the rest okay (I mean clientOptions)?

Upgrade google-auth-library-nodejs

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

Forge fixed a potential prototype pollution security issue when used with unsafe inputs (see changelog). This library is used by google-auth-library which got patched already and thus an upgrade here would be very appreciated:

"google-auth-library": "^3.1.0",

Other information

$ npm audit --audit-level=high
                                                                                
                       === npm audit security report ===                        
                                                                                
                                                                                
                                 Manual Review                                  
             Some vulnerabilities require your attention to resolve             
                                                                                
          Visit https://go.npm.me/audit-guide for additional guidance           
                                                                                
                                                                                
  High            Prototype Pollution in node-forge                             
                                                                                
  Package         node-forge                                                    
                                                                                
  Patched in      >= 0.10.0                                                     
                                                                                
  Dependency of   google-ads-api                                                
                                                                                
  Path            google-ads-api > google-ads-node > google-auth-library >      
                  gtoken > google-p12-pem > node-forge                          
                                                                                
  More info       https://npmjs.com/advisories/1561            

Optimize package for lambda

I'm submitting a ...

  • bug report
  • [] feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

We are using the module for our lambda functions and the size of the package when deployed is over 42Mb. Are there some dependencies that could be move to dev depends and minimized code?

Other information

Running node 10.10 in AWS Lambda

Update Bidding Strategy for Campaign

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

This is the code that I am using to create a Campaign

// assuming all required properties
const campaign = {};
campaign.target_spend = {
    cpc_bid_ceiling_micros: 1000000
};

const response = await customer.campaigns.create(campaign);

It creates the campaign and in response I do have a campaign whose bidding strategy is target_spend

{
  "resource_name": "customers/9999999999/campaigns/1111111111",
  "bidding_strategy_type": 9,
  "id": 9999999999,
  "name": "Campaign Name",
  "status": 3
} 

Now, I want to change this bidding strategy to Maximize Conversions. As per API Docs, I just have to specify maximize_conversions property of type MaximizeConversions.

But MaximizeConversions type has no property. I am not sure what value I have to set it in update object.

I have tried it like below, that did not work.

const campaign = {
     "resource_name": "customers/9999999999/campaigns/1111111111",
    "maximize_conversions": ""
};
const response = await customer.campaigns.update(campaign);

How to set the maximize_conversions property in update object ?

Compiling protos on change of googleapis submodule version

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

I want to use the latest version of google's definitions. I checked out an updated commit on the submodule and then tried to compile (make protos), without success. Any clarification on the procedure to compile the protos from the submodule to the google-ads-node package would be appreciated. Thanks :)

gRPC streamed responses

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

In some cases, large Google Ads requests will fail as they exceed the gRPC response limit (roughly ~4mb). This can be solved by adding streamed responses. We'll need to add an experiment branch for this feature, and do some research on how they've been implemented in grpc-node.

Other information

Ref: Opteo/google-ads-api#46

[error code 13] Internal server error on authentication

I'm submitting a ...

  • bug report ?
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

While following the example code given, I tried to make my first request. (Used a python project to get set up with my tokens through a Google login dialog and copied the refreshtoken)

However I'm getting the error Error: 13 INTERNAL: Internal error encountered, see more below:

I used a invalid login_customer_id aswell and that returns as expected. Granted API-keys to a bigger project I have binded with Google Analytics as well, which permisions works well.

Other information

Code used

const {
    GoogleAdsClient,
    SearchGoogleAdsRequest,
    KeywordMatchTypeEnum,
  } = require("google-ads-node");
// // 1. Create a new client with valid authentication

const client = new GoogleAdsClient({
    client_id:'my-client-id',
    client_secret:'my-secret',
    refresh_token:'my-refresh-token',
    developer_token:'my-dev-token',
    login_customer_id:'123-456-7890',
});

async function example() {
    // 2. Load a Google Ads service
    const service = client.getService("GoogleAdsService");
    // 3. Create a request
    const request = new SearchGoogleAdsRequest();
    const result = await service.search(request)
        .then((data) => {
            return data.data
        })
        .catch((err) => {
        console.log("--- Error in search ---");
        console.log(err);
    })
}
example();

Error

Error: 13 INTERNAL: Internal error encountered.
    at Object.exports.createStatusError (/home/the-hive/node-reporter/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:1209:28)
    at InterceptingListener._callNext (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:618:8)
    at Object.onReceiveStatus (/home/the-hive/node-reporter/node_modules/google-ads-node/build/lib/interceptor.js:108:17)
    at InterceptingListener._callNext (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/home/the-hive/node-reporter/node_modules/grpc/src/client_interceptors.js:847:24) {
  code: 13,
  metadata: Metadata { _internal_repr: {}, flags: 0 },
  details: 'Internal error encountered.'
}

module growing in size, making use in a AWS function impossible

hi, when i updated my lambda function to the very latest version of google-ads-node i could no longer update my lambda function that doesn't use any other dependency because the max size for a lambda function was exceeded

so, i had no choice but to use an older version that will be deprecated before the end of the summer

currently my node_modules take 327mb, when i use the most recent version i go over 400mb,

80 megabytes more for a library that calls web services ?

it would be nice to be able to include just the required functions, or at least group them, campaigns, reporting etc
or, minimise the code in some way ?

is there another way to call the API ? should i make the calls to the webservices using axios instead ?

Is there an option to Upload Offline Conversion

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

Google docs:
https://developers.google.com/google-ads/api/docs/samples/upload-offline-conversion#java

I need to be able to report offline conversion to Google Ad account. I couldn't find this method in "conversion_upload_service_pb.d.ts", Is there a way to do it?, or is it just a regular UploadClickConversionsRequest?
Much appreciated ahead of time!

TypeError: Cannot read property 'googleads' of undefined

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

I am getting an error when creating a campaign with google-ads-node and I am not sure what the problem is here. I've been following the callstack up to compiled-resources where the error seems to be.

Does anybody know what the issue might be? Is there a bug or might I be doing something wrong?

This is what the code looks like:

const client = new GoogleAdsApi({
    client_id: process.env.ADWORDS_CLIENT_ID,
    client_secret: process.env.ADWORDS_SECRET,
    developer_token: process.env.ADWORDS_DEVELOPER_TOKEN
  });

  const customer = client.Customer({
    customer_account_id: clientAccountId,
    login_customer_id: process.env.ADWORDS_CUSTOMER_ID,
    refresh_token: process.env.ADWORDS_REFRESH_TOKEN
  });

 const { results  } = await customer.campaigns.create(
    campaignData
  );

Other information

TypeError: Cannot read property 'googleads' of undefined
    at Function.Campaign.fromObject (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-node/build/protos/compiled-resources.js:1:2603399)
    at GoogleAdsClient.buildResource (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-node/build/lib/client.js:95:30)
    at GrpcClient.buildResource (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/grpc.js:121:28)
    at CampaignService.buildResource (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:228:32)
    at CampaignService.<anonymous> (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:110:33)
    at Generator.next (<anonymous>)
    at /Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:4:12)
    at CampaignService.serviceCreate (/Users/alexanderlotvall/GoogleAdsService/node_modules/google-ads-api/build/services/service.js:93:16)

Incorrect definition for bid_modifier at campaign criterion

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

The bid_modifier field in the campaign_crtierion struct has an incorrect definition.
Current definition is { value: number }. The definition should be just number.
At the moment if you try to perform any operation with campaign_criterion with bid modifier usage - it fails with assertion error.

Other information

{ AssertionError: Assertion failed
at new goog.asserts.AssertionError (/app/node_modules/google-protobuf/google-protobuf.js:81:876)
at Object.goog.asserts.doAssertFailure_ (/app/node_modules/google-protobuf/google-protobuf.js:82:257)
at Object.goog.asserts.assert (/app/node_modules/google-protobuf/google-protobuf.js:83:83)
at jspb.BinaryEncoder.writeFloat (/app/node_modules/google-protobuf/google-protobuf.js:466:384)
at jspb.BinaryWriter.writeFloat (/app/node_modules/google-protobuf/google-protobuf.js:489:142)
at proto.google.protobuf.FloatValue.serializeBinaryToWriter (/app/node_modules/google-protobuf/google/protobuf/wrappers_pb.js:447:12)
at jspb.BinaryWriter.writeMessage (/app/node_modules/google-protobuf/google-protobuf.js:491:336)
at proto.google.ads.googleads.v2.resources.CampaignCriterion.serializeBinaryToWriter (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/resources/campaign_criterion_pb.js:1:14157)
at jspb.BinaryWriter.writeMessage (/app/node_modules/google-protobuf/google-protobuf.js:491:336)
at proto.google.ads.googleads.v2.services.CampaignCriterionOperation.serializeBinaryToWriter (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/services/campaign_criterion_service_pb.js:1:12066)
at jspb.BinaryWriter.writeRepeatedMessage (/app/node_modules/google-protobuf/google-protobuf.js:504:385)
at Function.proto.google.ads.googleads.v2.services.MutateCampaignCriteriaRequest.serializeBinaryToWriter (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/services/campaign_criterion_service_pb.js:1:6297)
at proto.google.ads.googleads.v2.services.MutateCampaignCriteriaRequest.serializeBinary (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/services/campaign_criterion_service_pb.js:1:5992)
at serialize_google_ads_googleads_v2_services_MutateCampaignCriteriaRequest (/app/node_modules/google-ads-node/build/protos/google/ads/googleads/v2/services/campaign_criterion_service_grpc_pb.js:1:2147)
at Object.final_requester.sendMessage (/app/node_modules/grpc/src/client_interceptors.js:807:37)
at InterceptingCall._callNext (/app/node_modules/grpc/src/client_interceptors.js:419:43)
 message: 'Assertion failed',
 reportErrorToServer: true,
 messagePattern: 'Assertion failed'}

Cannot create Label due to failiure in utils.ts:202

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

Hello!

Here's the error I am getting:

Error: Attempted to set value "001" on invalid path "name" in resource
    at toProtoValueFormat (c:\Users\ackht\projects\add3-be\node_modules\google-ads-node\src\lib\utils.ts:202:11)
    at unroll (c:\Users\ackht\projects\add3-be\node_modules\google-ads-node\src\lib\utils.ts:192:11)
    at Object.convertToProtoFormat (c:\Users\ackht\projects\add3-be\node_modules\google-ads-node\src\lib\utils.ts:187:22)
    at GoogleAdsClient.buildResource (c:\Users\ackht\projects\add3-be\node_modules\google-ads-node\src\lib\client.ts:138:29)
    at GrpcClient.buildResource (c:\Users\ackht\projects\add3-be\node_modules\google-ads-api\build\grpc.js:134:28)
    at LabelService.buildResource (c:\Users\ackht\projects\add3-be\node_modules\google-ads-api\build\services\service.js:212:32)
    at LabelService.<anonymous> (c:\Users\ackht\projects\add3-be\node_modules\google-ads-api\build\services\service.js:103:33)
    at Generator.next (<anonymous>)
    at c:\Users\ackht\projects\add3-be\node_modules\google-ads-api\build\services\service.js:8:71
    at new Promise (<anonymous>) {stack: 'Error: Attempted to set value "001" on invaliโ€ฆvice.js:8:71
    at new Promise (<anonymous>)', message: 'Attempted to set value "001" on invalid path "name" in resource'}

Here's what I am doing:

                const label = {
                    name: `00${result.label}`,
                    text_label: { 
                        background_color: '#e993eb', 
                        description: `Label ${result.label}`
                    },
                }
                const genLabelResult = await customer.labels.create(label);

The name seems to be a part of the labels API as per https://opteo.com/dev/google-ads-api/#label

So I was wondering if this is a bug?
Thank you!

Proper handling of unknown enums

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

Today, when google releases new enums under a minor version update, and these enums are not in the protos of this library, things break. We should automatically assign any unknown enums to the UNKNOWN enum, which is the expected behavior.

[v3] Argument mismatch in "makeUnaryRequest" on ListAccessibleCustomersRequest

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

There seems to be an issue with the ListAccessibleCustomersRequest API call on latest Google Ads v3.
This piece of code throws an Argument mismatch error and doens't work as expected:

import { GoogleAdsClient, ListAccessibleCustomersRequest } from 'google-ads-node'

const client = new GoogleAdsClient({
    client_id: CLIENT_ID,
    client_secret: CLIENT_SECRET,
    developer_token: DEVELOPER_TOKEN,
    refresh_token: REFRESH_TOKEN
})

const service = client.getService('CustomerService')

const request = new ListAccessibleCustomersRequest()
const response = await service.listAccessibleCustomers(request) // throws the error

The same exact code works fine on API v2, and on latest version this API has not been changed.

Other information

The error thrown is: Argument mismatch in "makeUnaryRequest" (from grpc dependency)

Migration from grpc to grpc-js

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Question

Hi there,
did you consider moving from grpc to grpc-js dependency? I think it is quite stable now to be used instead of the native dependency.

Next.js: Module not found: Can't resolve 'child_process'

Hello,

I don't think this is an issue with this module and more likely my implementation but I've tried searching the docs and the issues tab here for any understanding and have not been able to make any progress to get things to work.

I'm using Next.js to build a web app that would show google ads related data for accounts I manage and so I installed this module as a dependency using npm, however, when I import it into my Next.js app and instantiate a new client I get this error:

error - ./node_modules/google-auth-library/build/src/auth/googleauth.js:17:0
Module not found: Can't resolve 'child_process'
null
Could not find files for / in .next/build-manifest.json
Could not find files for / in .next/build-manifest.json

I did some digging around and thought I might be instantiating this module on the client side when it is maybe a server side only module? In order to work around that, I tried to instantiate it through Next.js's API routes and then called the endpoint using a hook on the front end but it gave me the same error.

I also tried to implement a separate node application running just express and tried to import this module and it gave me the Must use import to load ES Module: error since node applications don't accept import/export functions from what I remember.

I feel entirely lost and would love if someone could help.

Thanks!

Argument mismatch in makeUnaryRequest

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

Thank you for this library.
I am trying to use the KeywordPlanIdeaService. The sample example call given in the reposiotry works fine for me. So connection and credentials are fine. But using below code, I am getting the Argument mismatch in makeUnaryRequest error that I assume occurs during the request building process. On a side note, is this the right way to set request params ? Initializing each class and calling setters looks too much for a simple request.

const oGoogleAdsClient = new GoogleAdsClient({
  client_id: GOOGLE_CLIENT_ID,
  client_secret: GOOGLE_CLIENT_SECRET,
  developer_token: GOOGLE_ADS_DEVELOPER_KEY,
  login_customer_id: GOOGLE_ADS_ACCOUNT_ID, // my manager account id
  refresh_token: GOOGLE_ADS_ACCOUNT_REFRESH_TOKEN,
  parseResults: true,
});
const customerId = CUSTOMER_ID; // client inside my Manager account

const service = oGoogleAdsClient.getService("KeywordPlanIdeaService");

const request = new GenerateKeywordIdeasRequest();

const language = new StringValue();
language.setValue("EN");
request.setLanguage(language);

const urlValue = new StringValue();
urlValue.setValue("https://example.com/");
const url = new UrlSeed();
url.setUrl(urlValue);
request.setUrlSeed(url);
request.setCustomerId(customerId);

const response: GenerateKeywordIdeaResponse = await service.generateKeywordIdeas(
  request
);

console.log(response);

Other information

[Node] Error: Argument mismatch in makeUnaryRequest
[Node]     at ServiceClient.Client.makeUnaryRequest (/home/xxxx/dev/xxxx/node_modules/grpc/src/client.js:530:11)
[Node]     at ServiceClient.method_func [as generateKeywordIdeas] (/home/xxxx/dev/xxxx/node_modules/grpc/src/client.js:1000:43)
[Node]     at /home/xxxx/dev/adconnector-api/dist/controllers/googleAds/search.js:270:36
[Node]     at Generator.next (<anonymous>)
[Node]     at fulfilled (/home/xxxx/dev/xxxx/dist/controllers/googleAds/search.js:5:58)
[Node]     at processTicksAndRejections (internal/process/task_queues.js:97:5)

Add examples directory

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

We should add a variety of detailed examples

Other information

Base examples on the official client libraries, e.g. google-ads-python

๐Ÿ˜” Cannot use ConversionActionServiceClient and really would appreciate some help

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

No matter what I do I can't get a conversion_action object accepted by conversionActions.create(). (These are built on top of ConversionActionServiceClient)

This is for a client and I would really appreciate some help, am willing to pay for some mentorship if need be, thanks!

I am trying to use this code:
customer.conversionActions.create(conversion_action);

I get this issue:
Error: The required field was not present.

Here is a photo of the conversion_action object I'm trying to use:
https://i.gyazo.com/2d987777c1a091339801114bb69ca30b.jpg

Here are the docs for the ConversionAction Object structure:

Here are the docs for this create ConversionAction API:

I have tried every combination I could think of but even with all fields uncommented it shows this issue.

Examples:
With all fields uncommented, I get this same error.
With all fields uncommented except Immutable ones, I get this same error.
With all fields uncommented except Immutable and id, I get this same error.
With all fields uncommented except Immutable and owner_customer, I get this same error.
With all fields uncommented except Immutable and owner_customer, I get this same error.
and many more combos...

Other information

//google-apis-test.js

const { GoogleAdsApi } = require('google-ads-api');

const client = new GoogleAdsApi({
    client_id: 'client_id',
    client_secret: 'client_secret',
    developer_token: 'developer_token',
});

const customer = client.Customer({
    customer_account_id: 'ADWORDS-ACCOUNT-ID',
    login_customer_id: 'MANAGER-ACCOUNT-ID', // Optionally provide a login-customer-id
    refresh_token: 'TOKEN',
});

// Error: The required field was not present.
const conversion_action = {
    //resource_name: '', //Immutable
    //id: 420420420, //Output only
    attribution_model_settings: {
        attribution_model: 101//,
        //data_driven_model_status: 5 //Output only
    },
    category: 4,
    click_through_lookback_window_days: 30,
    counting_type: 3,
    include_in_conversions_metric: true,
    name: 'My API Created conversion action',
    //owner_customer: 'customers/9105817791', //Output only
    phone_call_duration_seconds: 60,
    status: 2,
    //type: 0, //Immutable
    value_settings: {
        always_use_default_value: false,
        default_currency_code: 'USD',
        default_value: 1
    },
    view_through_lookback_window_days: 1,
    //tag_snippets: [], //Output only
    app_id: ''
  };
  
// Passing in a single entity to create
const conversionActionResult = customer.conversionActions.create(conversion_action);

setTimeout(async () => {
    console.log(await conversionActionResult);
}, 5000);
Sotacan-MBP:google-api-tests sotacan$ node google-apis-test.js
(node:40797) UnhandledPromiseRejectionWarning: Error: The required field was not present.
    at ConversionActionService.<anonymous> (/Users/sotacan/Documents/Projects/contract-work/Google-Tracker-Shopify-App/google-api-tests/node_modules/google-ads-api/build/services/service.js:199:23)
    at Generator.throw (<anonymous>)
    at rejected (/Users/sotacan/Documents/Projects/contract-work/Google-Tracker-Shopify-App/google-api-tests/node_modules/google-ads-api/build/services/service.js:6:65)
(node:40797) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:40797) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:40797) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(node:40797) UnhandledPromiseRejectionWarning: Error: The required field was not present.
    at ConversionActionService.<anonymous> (/Users/sotacan/Documents/Projects/contract-work/Google-Tracker-Shopify-App/google-api-tests/node_modules/google-ads-api/build/services/service.js:199:23)
    at Generator.throw (<anonymous>)
    at rejected (/Users/sotacan/Documents/Projects/contract-work/Google-Tracker-Shopify-App/google-api-tests/node_modules/google-ads-api/build/services/service.js:6:65)
(node:40797) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
Sotacan-MBP:google-api-tests sotacan$ 

Missing fields when using any type of simulations

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

When querying any type of simulations (i.e. ad_group_simulation or campaign_criterion_simulation) with the report() method any fields ending in list are not shown.

This is the list of all the missing fields :

  • campaign_criterion_simulation.bid_modifier_point_list
  • ad_group_simulation.cpc_bid_point_list
  • ad_group_simulation.target_cpa_point_list
  • ad_group_criterion_simulation.cpc_bid_point_list

Using with Google service account and JWT

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

I am trying to understand how to use this module with JWT authentication. I have a simple Lambda that will run every few hours, get reports from Google Ads and store it in one of our DBs. The Ads account is internal (and server-to-server) so as I understand I don't need OAuth. I setup a Google service account and download the JSON file but I didn't understnad how to use it with this module. I also have a developer token I got from Google Ads.

Other information

This is the information I have in the JSON:

{
  "type": "service_account",
  "project_id": "XXX",
  "private_key_id": "XXX",
  "private_key": "-----BEGIN PRIVATE KEY-----XXXXXXXXX-----END PRIVATE KEY-----\n",
  "client_email": "[email protected]",
  "client_id": "XXX",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "XXXXXXXXX"
}

keywordPlanIdeas.generateKeywordIdeas() is returning dumb fileds

I am runing this code

const {
    GoogleAdsApi,
    services: { KeywordSeed },
} = require('google-ads-api'); // package v5.2.0 = Google Ads API to v7

(async () => {
    const client = new GoogleAdsApi({
        client_id: "107229fasdfasdf.apps.googleusercontent.com",
        client_secret: "GOCSPX-fasdfasdfasdfasdfa",
        developer_token: "fasdfadfasdfasdf",
    });
    const customer = client.Customer({
        customer_id: "1fasfasdfasdf9446",
        refresh_token: "1//0g-fasdfasdfaasdf-LfasdfasdfjbuMWel-fo",
    });

    const keywordSeed = new KeywordSeed({ keywords: ['content marketing'] });

    const generateKeywordIdeaResponse = await customer.keywordPlanIdeas.generateKeywordIdeas({
        customer_id: customer.credentials.customer_id,
        page_size: 10,
        keyword_seed: keywordSeed,
    }).catch((e) => console.error(e));

    console.log(JSON.stringify(generateKeywordIdeaResponse, null, 2));
})();

This console logs

[  
  {
    "keyword_idea_metrics": {
      "monthly_search_volumes": [
        {
          "month": "JANUARY",
          "year": "2021",
          "_year": "year",a
          "monthly_searches": "880",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "FEBRUARY",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1000",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "MARCH",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1000",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "APRIL",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1000",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "MAY",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1000",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "JUNE",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1600",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "JULY",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1600",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "AUGUST",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1900",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "SEPTEMBER",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "3600",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "OCTOBER",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1600",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "NOVEMBER",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "880",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "DECEMBER",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "880",
          "_monthly_searches": "monthly_searches"
        }
      ],
      "competition": "LOW",
      "avg_monthly_searches": "1600",
      "_avg_monthly_searches": "avg_monthly_searches",
      "competition_index": "10",
      "_competition_index": "competition_index",
      "low_top_of_page_bid_micros": "207450549",
      "_low_top_of_page_bid_micros": "low_top_of_page_bid_micros",
      "high_top_of_page_bid_micros": "1022202884",
      "_high_top_of_page_bid_micros": "high_top_of_page_bid_micros"
    },
    "keyword_annotations": {
      "concepts": []
    },
    "text": "content marketing world",
    "_text": "text"
  }
]

But if you notice there are lots of dumb fileds, look at the last two properties.

"text": "content marketing world",
 "_text": "text"

Why i am warry about this?
Because this behavior increases the size of data which increases the time to response from the server which leads us to slow APIs.

CriterionCategoryAvailability.locale should be .locale_list

Hello.
Here is current typing definition:

export interface CriterionCategoryAvailability {
channel?: CriterionCategoryChannelAvailability;
locale?: CriterionCategoryLocaleAvailability[];
}

Should be:

export interface CriterionCategoryAvailability {
channel?: CriterionCategoryChannelAvailability;
locale_list?: CriterionCategoryLocaleAvailability[];
}

BR, Vlad

Huge package size

Hi,

I'm trying to improve install size of my app, and looks like google_ads_node is the biggest package :|
image

lodash.snakecase

I'm submitting a ...

Error: Cannot find module 'lodash.snakecase'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/home/rohit/Hardik/api-marketing/node_modules/google-ads-node/build/lib/utils.js:17:44)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/home/rohit/Hardik/api-marketing/node_modules/google-ads-node/build/lib/interceptor.js:8:17)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)

Summary

i tried to install lodash module but no effect

Other information

Usage requires esModuleInterop, or results in compilation error

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

Simple TypeScript installation of the latest google-ads-api fails to compile due to the following error:

node_modules/google-ads-node/build/lib/utils.d.ts(1,8): error TS1192: Module '"/usr/app/node_modules/@types/google-protobuf/google/protobuf/field_mask_pb"' has no default export.

tsconfig.json in this repo has esModuleInterop: true, which is a non-default compiler option.

Projects that don't have this enabled are unable to use google-ads-api and google-ads-node as a result.

Other information

Enabling esModuleInterop on my project fixes the above error but created many more errors (unrelated to google-ads-node as a result.

Screen Shot 2019-08-23 at 3 00 37 PM

High memory usage

Hi, first of all thank you for this package ๐Ÿ™๐Ÿผ

I've noticed that my service at production env get's restarted due to high memory usage.

I've debugged it, and looks like proto.js is 17% of my entire app memory usage!
image

There is anything we can do in order to improve it?
Maybe it is better to split this file into separate "domain" based files?

Long initial init time

For the first usage of something from the lib, it takes ~10sec to load the proto.js file.
Simple report query like

await client.report({
    entity: 'campaign',
    attributes: [
      'campaign.id',
      'campaign.name',
      'campaign.labels',
      'campaign.advertising_channel_type',
      'campaign.advertising_channel_sub_type',
      'campaign.start_date',
      'campaign.end_date',
      'campaign.campaign_budget',
      'campaign.bidding_strategy',
      'campaign.bidding_strategy_type',
      'campaign.manual_cpc.enhanced_cpc_enabled',
      'campaign.network_settings.target_content_network',
      'campaign.network_settings.target_google_search',
      'campaign.network_settings.target_partner_search_network',
      'campaign.network_settings.target_search_network',
      'campaign.targeting_setting.target_restrictions',
    ],
    constraints: [{ key: 'campaign.id', op: 'IN', val: [].concat(campaignIds) }],
  })

image

Probably related to the fact that proto.js file is huge!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.