Skip to main content
Glama
client.ts1.57 kB
import { google, analyticsdata_v1beta, analyticsadmin_v1beta } from 'googleapis'; import { getAuthClient } from '../auth/auth.js'; export class AnalyticsClient { private dataClient: analyticsdata_v1beta.Analyticsdata; private adminClient: analyticsadmin_v1beta.Analyticsadmin; constructor(authClient: any) { this.dataClient = google.analyticsdata({ version: 'v1beta', auth: authClient }); this.adminClient = google.analyticsadmin({ version: 'v1beta', auth: authClient }); } static async create() { const authClient = await getAuthClient(); return new AnalyticsClient(authClient); } async listAccountSummaries() { const res = await this.adminClient.accountSummaries.list(); return res.data.accountSummaries || []; } async runReport( propertyId: string, dateRanges: { startDate: string; endDate: string }[], dimensions?: { name: string }[], metrics?: { name: string }[], limit?: number ) { const res = await this.dataClient.properties.runReport({ property: `properties/${propertyId}`, requestBody: { dateRanges, dimensions, metrics, limit: limit ? String(limit) : undefined, }, }); return res.data; } async getMetadata(propertyId: string) { const res = await this.dataClient.properties.getMetadata({ name: `properties/${propertyId}/metadata` }); return res.data; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ehukaimedia/google-webmaster-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server