2

Google アナリティクス アカウントで特定のタスクを実行する Web アプリを構築していますが、「userRateLimitExceeded」が原因でエラーが発生します。

私が現時点で持っているもの:

(1) 管理アカウント リストに対して通常の (バッチ処理されていない) クエリを実行します。

(2) 各アカウントのすべてのウェブ プロパティに対して、バッチ処理された 2 番目のクエリを実行します。

最初のクエリは期待どおりに実行され、2 番目のバッチ クエリは完了しますが、すべてのサブクエリに同じエラー 'Quota Error: User Rate Limit Exceeded.' が表示されます。

私の理解では、クライアント ライブラリは、これが起こらないことを保証するレート制限メカニズムを実装しています。この問題を解決するために何が起こっているのか、誰でも説明できますか? あなたが与えることができるどんな助けにも前もって感謝します.

    (function(window){

    "use strict";

    var dataStore = new GlobalDataStore();      


    function handleAccountProperties(AccountProperties){
        console.log(AccountProperties);
    }

    function getAccountProperties(){
        var batch = gapi.client.newBatch();

        for (var i = 0; i < dataStore.accounts.length; i++) {
            var account = dataStore.accounts[0];
            var request = gapi.client.analytics.management.webproperties.list({
                'accountId': account.details.id
            });           
            batch.add(request);
        }

        batch.then(function(response){
            handleAccountProperties(response.result);
        }, function(reason){
             console.log('Error: ' + reason.result.error.message);
        });
    };

    function getAndHandleAccounts(){
        var request = gapi.client.analytics.management.accounts.list();
        request.then(function(response) {
            if(response.result.items && response.result.items.length) {
                for (var i = 0; i < response.result.items.length; i++) {
                    var account = new GoogleAnalyticsAccount();
                    account.details = response.result.items[i];
                    dataStore.accounts.push(account);
                }
                getAccountProperties();
            }
        });
    };

    function authorise(){
        var authData = {
            client_id: dataStore.clientID,
            scope: dataStore.scopes,
            immediate: false
        };

        gapi.auth.authorize(authData, function(response) {
            if (response.error) {
                console.error('shit went wrong');
            } else {
                gapi.client.load('analytics', 'v3').then(getAndHandleAccounts);
            }
        });
    };

    window.onload = authorise;

})(window);
4

0 に答える 0