still-code/laravel-umami 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

still-code/laravel-umami

Composer 安装命令:

composer require still-code/laravel-umami

包简介

Umami API wrapper for laravel

README 文档

README

Umami API wrapper for laravel

API wrapper for umami website analytics. get your statistics in the laravel app.

check out Umami, own your website analytics

Features

  • Manage websites
  • Manage users
  • query statistics stats, page views, events and metrics

Installation

You can install the package via composer:

composer require still-code/laravel-umami

Umami version:

  • for umami v1 use v4
  • for umami v2 use v5

Config

to publish the configuration file:

php artisan vendor:publish --provider="Umami\UmamiServiceProvider"

and then add these to your .env file:

UMAMI_URL=https://stats-site-com/api
UMAMI_USERNAME=username
UMAMI_PASSWORD="password"
UMAMI_WEBSITE_ID=d131d2ae-5d21-4a54-80ba-16719afedf7b

Usage

Query Stats

\Umami\Umami::query('example-site-id', 'metrics', [
    'start_at'=>today()->subDays(7),
    'end_at'=>today(),
    'type'=>'referrer',
]);

short usage for PHP 8 to get default stats for the last 7 days and without cache:

\Umami\Umami::query(siteID: 1, force: true)

Parameters

Site id

required: site id from umami server

\Umami\Umami::query('example-site-id');

Part

required: the stats part you want to get from umami,

available options : active, stats, pageviews, events, metrics

default: stats

\Umami\Umami::query('example-site-id','pageviews');

Options for Query Stats

Dates (start_at,end_at)

optional: Timestamp of starting and end date,

default: last 7 days

you can pass carbon object or timestamp in milliseconds

\Umami\Umami::query('example-site-id','metrics',[
    'start_at'=>today()->subDays(7),
    'end_at'=>now(),
]);
unit

only available on pageviews and events

optional: Time unit, available options: year, month, hour, day,

default: day

\Umami\Umami::query('example-site-id','metrics',[
    'unit'=>'year',
]);
Timezone (tz)

optional: Timezone,

only available on pageviews and events

default: config('app.timezone')

\Umami\Umami::query('example-site-id','metrics',[
    'tz'=>'America/Los_Angeles',
]);
type (for metrics only)

optional: Gets metrics for a given time range,

available options: url, referrer, browser, os, device, country, event,

default: url

\Umami\Umami::query('example-site-id','metrics',[
    'tz'=>'America/Los_Angeles',
]);

Websites

Get All websites

\Umami\Umami::websites();

Create a website

\Umami\Umami::createWebsite([
    'domain'=>'domain.ltd',
    'name'=>'user name',
]);

create a website for a diffrent user

If you want to create a website for different user then the admin user defined in the config, you need to provide the authentication for that user. this is helpful when creating a new user with a website

\Umami\Umami::createWebsite([
    'domain' => 'domain.ltd',
    'name' => 'user name',
],[
    'username' => 'otherUserName',
    'password' => 'otherPassword',
]);

Update a website

\Umami\Umami::updateWebsites('example-site-id',[
    'name'=>'user name',
]);

Delete a website

\Umami\Umami::deleteWebsite('example-site-id');

Event data

Get website event and field key record counts within a given time range

See the API documentation for details: https://umami.is/docs/api/event-data#get-/api/event-data/events

\Umami\Umami::events('example-site-id', [
    'start_at'=>today()->subDays(7),
    'end_at'=>now(),
    'event' => 'custom_event',
]);

Get website field key and value record counts within a given time range

See the API documentation for details: https://umami.is/docs/api/event-data#get-/api/event-data/fields

\Umami\Umami::event_fields('example-site-id', [
    'start_at'=>today()->subDays(7),
    'end_at'=>now(),
]);

Users

Get all users

\Umami\Umami::users();

Create a user

\Umami\Umami::createUser('username','password');

Update a user

\Umami\Umami::updateUser(1,[
    'username'=>'username',
    'password'=>'password',
]);

Delete a user

\Umami\Umami::deleteUser(2);

More details

Please check out Umami website for more information.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

still-code/laravel-umami 适用场景与选型建议

still-code/laravel-umami 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.37k 次下载、GitHub Stars 达 35, 最近一次更新时间为 2023 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「analytics」 「stats」 「laravel」 「website」 「umami」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 still-code/laravel-umami 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 still-code/laravel-umami 我们能提供哪些服务?
定制开发 / 二次开发

基于 still-code/laravel-umami 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.37k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 35
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 35
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-14