我们可以增加GA批处理获取API的请求对象的最大数量吗

时间:2018-10-18 13:33:48

标签: google-analytics google-api google-api-v4

在Google Analytics(分析)中

        private gateway = `${environment.baseHref}/api/Authentication`;

        constructor(private router: Router,
                    private http: Http) { }

        public GetCurrentUser(): Observable<SystemUser> {
            let headers = new Headers();
            headers.append('Authorization', `Bearer ${this.getAccessToken()}`);
            return this.http.get(this.gateway, { headers: headers })
              .map(res => {
                  if (!res.json().IsSuccess)
                      console.log(res.json().ErrorMessage);

                  console.log('here now');
                  console.log(this.getAccessToken());

                  return res.json().Data;
              });
      }

        public Logout(): Promise<void> {
          sessionStorage.removeItem('accessToken');
          return this.http.post(`${this.gateway}/Logout`, []) 
              .toPromise()
              .then(() => this.redirectToLogin());
      }

      private redirectToLogin() {
        this.router.navigate(['/authentication/login']); 
      }


        public async login(username: string, password: string, rememberMe: boolean): 
          Promise<boolean> {
            return this.http.post(`${this.gateway}/Login`, { UserName: username, 
           Password: password, RememberMe: rememberMe })
                .toPromise()
                .then
                (
                  resolve => {
                      if (!resolve.json().IsSuccess)
                          console.log(resolve.json().ErrorMessage);

                      return resolve.json().IsSuccess;
                });
      }

        public async register(model: RegistrationModel): Promise<{ isSuccess: boolean, ErrorMessage: any }> {
            return this.http.put(`${this.gateway}/Register`,
                {
                    UserName: model.UserName,
                    Email: model.Email,
                    Password: model.Password,
                    ConfirmPassword: model.ConfirmPassword,
                    FullName: model.FullName
                }) 
              .toPromise()
              .then
              (
                resolve => {  
                  return { isSuccess: resolve.json().IsSuccess, ErrorMessage: 
                    resolve.json().ErrorMessage }
              });
      }

      public isAuthenticated(): boolean {
          if (this.getAccessToken()) { 
              return true;
          }
          else
          { 
              // The following code looks for a fragment in the URL to get the 
              access token which will be
              // used to call the protected Web API resource 
              var fragment = urlFragmenter.getFragment(); 

              if (fragment.access_token) {
                  console.log('setting');
                // returning with access token, restore old hash, or at least hide token
                window.location.hash = fragment.state || '';
                this.setAccessToken(fragment.access_token);
                return true;
              }
              else
              { 
                // no token - so bounce to Authorize endpoint in AccountController to sign in or register
                let url = `${environment.baseHref}/Account/Authorize?client_id=web&response_type=token&state=` + encodeURIComponent(window.location.hash);

                window.location.href = url;
                this.router.navigate([url]);
                return false;
              }
        }
      }


      private setAccessToken(accessToken: string): void {
        sessionStorage.setItem("accessToken", accessToken);
      };

      public getAccessToken(): string {
        return sessionStorage.getItem("accessToken");
      }; 
    }

    class urlFragmenter {
        public static getFragment(): any {
            console.log(window.location);
            console.log(window.location.hash);

            // NOT working on production !!!!
            if (window.location.hash.indexOf("#") === 0) {
                console.log('this is the index');
                console.log(window.location.hash.substr(1));
          return this.parseQueryString(window.location.hash.substr(1));
        } else {
          return {};
        }
      }

        private static parseQueryString(queryString) {
            console.log('parsing');
        var data = {},
          pairs, pair, separatorIndex, escapedKey, escapedValue, key, value;

        if (queryString === null) {
          return data;
        }

        pairs = queryString.split("&");

        for (var i = 0; i < pairs.length; i++) {
          pair = pairs[i];
          separatorIndex = pair.indexOf("=");

          if (separatorIndex === -1) {
            escapedKey = pair;
            escapedValue = null;
          } else {
            escapedKey = pair.substr(0, separatorIndex);
            escapedValue = pair.substr(separatorIndex + 1);
          }

          key = decodeURIComponent(escapedKey);
          value = decodeURIComponent(escapedValue);

          data[key] = value;
        }

        return data;
      }

在这里,我们最多可以传递5个reportRequest,如果我尝试给它提供大于5的值,则会收到我们不能使用大于5的错误消息。

  

因此,在升级帐户或   还有什么?

1 个答案:

答案 0 :(得分:0)