Fathom Analytics
Fathom Analytics provides simple, useful websites stats without tracking or storing personal data of your users.
- labels:
analytics
,web-analytics
,privacy
- authentication:
apiKey
Usage
ts
import { fathomanalytics } from 'https://deno.land/x/netzo/apis/fathomanalytics/mod.ts'
const { api } = fathomanalytics({
apiKey: Deno.env.get('FATHOMANALYTICS_API_KEY')
})
import { fathomanalytics } from 'https://deno.land/x/netzo/apis/fathomanalytics/mod.ts'
const { api } = fathomanalytics({
apiKey: Deno.env.get('FATHOMANALYTICS_API_KEY')
})
Configuration
The fathomanalytics
factory function expects an object with the following, and returns an object with an HTTP client api
.
Param | Type | Default | Description |
---|---|---|---|
apiKey | string | Deno.env.get('FATHOMANALYTICS_API_KEY') | the api key to use for authentication |
Refer to the API documentation to get the required information.
Examples
The following examples assume you have created an api client instance. Refer to the type definitions for all exported types to pass to the api
client for typed responses.
Find sites
Find all sites the API key owns.
ts
import type { QuerySites, Sites } from 'netzo/apis/fathomanalytics/types.ts'
const query: QuerySites = {}
const result = await api.sites.get<Sites>(query)
const resultData = result.resultData
import type { QuerySites, Sites } from 'netzo/apis/fathomanalytics/types.ts'
const query: QuerySites = {}
const result = await api.sites.get<Sites>(query)
const resultData = result.resultData
Get site
Get a site by id.
ts
import type { Site } from 'netzo/apis/fathomanalytics/types.ts'
const resultData = await api.sites[SITE_ID].get<Site>()
import type { Site } from 'netzo/apis/fathomanalytics/types.ts'
const resultData = await api.sites[SITE_ID].get<Site>()
Add site
Add a new site
ts
import type { DataAddSite, Site } from 'netzo/apis/fathomanalytics/types.ts'
const data: DataAddSite = { name: 'New website' }
const resultData = await api.sites.post<Site>(data)
import type { DataAddSite, Site } from 'netzo/apis/fathomanalytics/types.ts'
const data: DataAddSite = { name: 'New website' }
const resultData = await api.sites.post<Site>(data)
Update site
Update a site by id
ts
import type { DataUpdateSite, Site } from 'netzo/apis/fathomanalytics/types.ts'
const data: DataUpdateSite = { name: 'Updated website' }
const resultData = await api.sites[SITE_ID].post<Site>(data)
import type { DataUpdateSite, Site } from 'netzo/apis/fathomanalytics/types.ts'
const data: DataUpdateSite = { name: 'Updated website' }
const resultData = await api.sites[SITE_ID].post<Site>(data)
Wipe site
Wipe all pageviews & event completions from a website to reset statistics.
ts
import type { Site } from 'netzo/apis/fathomanalytics/types.ts'
const resultData = await api.sites[SITE_ID].data.delete<Site>()
import type { Site } from 'netzo/apis/fathomanalytics/types.ts'
const resultData = await api.sites[SITE_ID].data.delete<Site>()