npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@maxim_mazurok/gapi.client.analyticsadmin

v1.0.20220810

Published

TypeScript typings for Google Analytics Admin API v1alpha

Downloads

40

Readme

TypeScript typings for Google Analytics Admin API v1alpha

For detailed description please check documentation.

Installing

Install typings for Google Analytics Admin API:

npm install @types/gapi.client.analyticsadmin@v1alpha --save-dev

Usage

You need to initialize Google API client in your code:

gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:

gapi.client.load('analyticsadmin', 'v1alpha', () => {
  // now we can use gapi.client.analyticsadmin
  // ...
});

Don't forget to authenticate your client before sending any request to resources:

// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [ 
      // Edit Google Analytics management entities
      'https://www.googleapis.com/auth/analytics.edit',

      // Manage Google Analytics Account users by email address
      'https://www.googleapis.com/auth/analytics.manage.users',

      // View Google Analytics user permissions
      'https://www.googleapis.com/auth/analytics.manage.users.readonly',

      // See and download your Google Analytics data
      'https://www.googleapis.com/auth/analytics.readonly',
    ],
    immediate = true;
// ...

gapi.auth.authorize(
  { client_id: client_id, scope: scope, immediate: immediate },
  authResult => {
    if (authResult && !authResult.error) {
        /* handle successful authorization */
    } else {
        /* handle authorization error */
    }
});

After that you can use Google Analytics Admin API resources:


/*
Marks target Account as soft-deleted (ie: "trashed") and returns it. This API does not have a method to restore soft-deleted accounts. However, they can be restored using the Trash Can UI. If the accounts are not restored before the expiration time, the account and all child resources (eg: Properties, GoogleAdsLinks, Streams, UserLinks) will be permanently purged. https://support.google.com/analytics/answer/6154772 Returns an error if the target is not found.
*/
await gapi.client.analyticsadmin.accounts.delete({ name: "name",  });

/*
Lookup for a single Account.
*/
await gapi.client.analyticsadmin.accounts.get({ name: "name",  });

/*
Get data sharing settings on an account. Data sharing settings are singletons.
*/
await gapi.client.analyticsadmin.accounts.getDataSharingSettings({ name: "name",  });

/*
Returns all accounts accessible by the caller. Note that these accounts might not currently have GA4 properties. Soft-deleted (ie: "trashed") accounts are excluded by default. Returns an empty list if no relevant accounts are found.
*/
await gapi.client.analyticsadmin.accounts.list({  });

/*
Updates an account.
*/
await gapi.client.analyticsadmin.accounts.patch({ name: "name",  });

/*
Requests a ticket for creating an account.
*/
await gapi.client.analyticsadmin.accounts.provisionAccountTicket({  });

/*
Searches through all changes to an account or its children given the specified set of filters.
*/
await gapi.client.analyticsadmin.accounts.searchChangeHistoryEvents({ account: "account",  });

/*
Returns summaries of all accounts accessible by the caller.
*/
await gapi.client.analyticsadmin.accountSummaries.list({  });

/*
Acknowledges the terms of user data collection for the specified property. This acknowledgement must be completed (either in the Google Analytics UI or via this API) before MeasurementProtocolSecret resources may be created.
*/
await gapi.client.analyticsadmin.properties.acknowledgeUserDataCollection({ property: "property",  });

/*
Creates an "GA4" property with the specified location and attributes.
*/
await gapi.client.analyticsadmin.properties.create({  });

/*
Marks target Property as soft-deleted (ie: "trashed") and returns it. This API does not have a method to restore soft-deleted properties. However, they can be restored using the Trash Can UI. If the properties are not restored before the expiration time, the Property and all child resources (eg: GoogleAdsLinks, Streams, UserLinks) will be permanently purged. https://support.google.com/analytics/answer/6154772 Returns an error if the target is not found, or is not an GA4 Property.
*/
await gapi.client.analyticsadmin.properties.delete({ name: "name",  });

/*
Lookup for a single "GA4" Property.
*/
await gapi.client.analyticsadmin.properties.get({ name: "name",  });

/*
Lookup for a AttributionSettings singleton.
*/
await gapi.client.analyticsadmin.properties.getAttributionSettings({ name: "name",  });

/*
Returns the singleton data retention settings for this property.
*/
await gapi.client.analyticsadmin.properties.getDataRetentionSettings({ name: "name",  });

/*
Lookup for Google Signals settings for a property.
*/
await gapi.client.analyticsadmin.properties.getGoogleSignalsSettings({ name: "name",  });

/*
Returns child Properties under the specified parent Account. Only "GA4" properties will be returned. Properties will be excluded if the caller does not have access. Soft-deleted (ie: "trashed") properties are excluded by default. Returns an empty list if no relevant properties are found.
*/
await gapi.client.analyticsadmin.properties.list({  });

/*
Updates a property.
*/
await gapi.client.analyticsadmin.properties.patch({ name: "name",  });

/*
Returns a customized report of data access records. The report provides records of each time a user reads Google Analytics reporting data. Access records are retained for up to 2 years. Data Access Reports can be requested for a property. The property must be in Google Analytics 360. This method is only available to Administrators. These data access records include GA4 UI Reporting, GA4 UI Explorations, GA4 Data API, and other products like Firebase & Admob that can retrieve data from Google Analytics through a linkage. These records don't include property configuration changes like adding a stream or changing a property's time zone. For configuration change history, see [searchChangeHistoryEvents](https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/accounts/searchChangeHistoryEvents).
*/
await gapi.client.analyticsadmin.properties.runAccessReport({ entity: "entity",  });

/*
Updates attribution settings on a property.
*/
await gapi.client.analyticsadmin.properties.updateAttributionSettings({ name: "name",  });

/*
Updates the singleton data retention settings for this property.
*/
await gapi.client.analyticsadmin.properties.updateDataRetentionSettings({ name: "name",  });

/*
Updates Google Signals settings for a property.
*/
await gapi.client.analyticsadmin.properties.updateGoogleSignalsSettings({ name: "name",  });