Coder Social home page Coder Social logo

jakobbouchard / umami-api-client Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 2.0 1005 KB

πŸ™ Simple, tiny API client for Umami analytics.

Home Page: https://npm.im/umami-api

License: MIT License

TypeScript 97.16% JavaScript 2.84%
analytics api umami umami-analytics npm-module npm-package hacktoberfest

umami-api-client's Introduction

Umami API Client

GitHub Workflow Status npm npm bundle size npm downloads

πŸ™ Simple, tiny API client for Umami analytics.

Installation

npm install umami-api

Usage

import UmamiAPIClient from "umami-api";

Setting default options

Default options can be set with the following environment variables:

  • UMAMI_CLIENT_TIMEOUT_MS: Axios timeout in milliseconds. Default: 2000.
  • UMAMI_CLIENT_USER_AGENT: User agent to use for requests. Default: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0.
  • UMAMI_CLIENT_TIME_PERIOD: Default time period for pageviews, events, etc. Default: 24h.
  • UMAMI_CLIENT_TIME_UNIT: Default time unit for pageviews, events, etc. Default: hour.
  • UMAMI_CLIENT_TIMEZONE: Default timezone for pageviews, events, etc. Default: America/Toronto.
  • UMAMI_CLIENT_METRIC_TYPE: Default metric type to get. Default: url.

Example

import UmamiAPIClient from "umami-api";

const umami = new UmamiAPIClient("stats.example.com", "username", "password");

const newWebsite = await umami.createWebsite({
	domain: "test.com",
	name: "test.com",
	enableShareUrl: false,
});

const pageviews = await newWebsite.getPageviews();
const metrics = await newWebsite.getMetrics();

umami-api-client's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

umami-api-client's Issues

make this api-client compatible with umami 2.9.0

hi, the goal is to make this api-client compatible with umami 2.9.0

there is an helper with the following ticket
boly38/umami-api-client#15

Bonus: it could be over-mega-great to add a "CONTRIBUTE.md" helper in order to help (this) api-client users to install/build current source. I miss how to install requirement to play unit tests for example an confirm my hypothesis.

(anyway it seems that /api/websites data level in 2.x umami responses are not undertaken here.)

Nb: notice this related issue on umami doc side: umami-software/website#150

thanks πŸ‘

period?: TimePeriod:Add option for "All Time" or custom start date in TimePeriod selection

Currently, the TimePeriod selection in the author's period only allows a maximum duration of one month. It would be useful to have an option for "All Time" so that users can view the data for the entire available period. Alternatively, it would be great to be able to input a specific start date using Date.now() as the current time and subtracting the date the user inputs. This would provide more flexibility in analyzing the data over longer or customized periods.

Could you please consider adding these features to improve the usability of the author's period selection? Thank you!

Incompatible with umami version 1.39.0 and above

This client is incompatible with umami versions 1.39.0 and above.

v1.39.0 introduced UUID based queries, replacing the previous integer based queries for security reasons.

I noticed this was not working while using umami-action-report. Since it uses this client to interact with umami API, I have opened the issue here.

richError cause empty

Hi
from time to time I got error on action-umami-report.

result is

Run boly38/action-umami-report@main
ERROR: Error: Could not get websites
Options: {}
Stacktrace:
Error: Error: Could not get websites
Options: {}
Stacktrace:

I expect to see the root cause of the error.

I think that for Could not get websites : the richError method doesn't work well in all cases.

We may try to JSONify it or simply remove toString ?

If I reproduce the way to get this error, then I will amend this issue.

thanks πŸ™

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/main.yml
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
npm
package.json
  • axios ^1.3.4
  • @changesets/changelog-github 0.5.0
  • @changesets/cli 2.27.1
  • @types/node 18.19.31
  • @typescript-eslint/eslint-plugin 7.8.0
  • @typescript-eslint/parser 7.8.0
  • @vitest/coverage-c8 0.33.0
  • axios-mock-adapter 1.22.0
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • husky 9.0.11
  • lint-staged 15.2.2
  • prettier 3.2.5
  • tsup 8.0.2
  • typescript 5.4.5
  • vitest 1.5.3
  • vitest-github-actions-reporter 0.11.1
  • node >=16.0.0
  • pnpm 9.0.6

  • Check this box to trigger a request for Renovate to run again on this repository

npm audit found vulnerabilities

# npm audit report

loader-utils  3.0.0 - 3.2.0
Severity: high
loader-utils is vulnerable to Regular Expression Denial of Service (ReDoS) via url variable - https://github.com/advisories/GHSA-3rfm-jhwj-7488
loader-utils is vulnerable to Regular Expression Denial of Service (ReDoS)  - https://github.com/advisories/GHSA-hhq3-ff78-jv3g
fix available via `npm audit fix`
node_modules/loader-utils

1 high severity vulnerability

To address all issues, run:
  npm audit fix

npm audit found vulnerabilities

# npm audit report

json5  <2.2.2
Severity: high
Prototype Pollution in JSON5 via Parse Method - https://github.com/advisories/GHSA-9c47-m6qq-7p4h
fix available via `npm audit fix`
node_modules/json5

1 high severity vulnerability

To address all issues, run:
  npm audit fix

Axios timeout default value is 1 sec

Following #1 fix, I now have the root cause of the action report flaky failure.

Here is an example:

Run boly38/action-umami-report@main
ERROR: Error: Could not get websites
Options: {}
Stacktrace:Error: Login failed
Options: {"server":"umami.example.fr","username":"***"}
Stacktrace:AxiosError: timeout of 1000ms exceeded


Error: Error: Could not get websites
Options: {}
Stacktrace:Error: Login failed
Options: {"server":"umami.example.fr","username":"***"}
Stacktrace:AxiosError: timeout of 1000ms exceeded

The default timeout set with axios library is only 1 sec. source coce

When the server takes some time to wake up this could be insuficent.

expected

As umami-api-client user, I would like some setup options (either UmamiAPIClient constructor additional arg, else new setter) : example fetchTimeoutMs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.