定制 vdvcoder/laravel-dashboard-google-analytics-realtime-tile-v2 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

vdvcoder/laravel-dashboard-google-analytics-realtime-tile-v2

Composer 安装命令:

composer require vdvcoder/laravel-dashboard-google-analytics-realtime-tile-v2

包简介

A Google Analytics realtime tile for Laravel Dashboard v2

README 文档

README

Latest Version on Packagist Total Downloads

This tile can be used on the Laravel Dashboard to display Google Analytics realtime information.

Installation

You can install the package via composer:

composer require vdvcoder/laravel-dashboard-google-analytics-realtime-tile-v2

Google Analytics credentials

Before using this tile you need to ensure you have the correct credentials on your system. Follow the instructions on Real Time Reporting API Overview to sign up to access the API. When access is granted:

  1. Enable the Google Analytics API.
  2. Create a Service Account with appropriate permissions.
  3. Navigate to the Service Account and add a new JSON private key. A JSON file will be downloaded - rename this to 'analytics-credentials.json' and move it to your root Laravel directory.

Make note of the 'Service Account ID' that is generated. It will follow the format of "<service_account_name>@.iam.gserviceaccount.com".

Google Analytics view

Access Google Analytics and navigate to the required view (e.g. Account > Properties & Apps > View). Make note of the 'View ID' that is displayed underneath the view name. Click on 'View User Management' and add a new user. The email address is the Service Account ID that was used in the Google Analytics credentials step.

More information is available on the Real Time Reporting API Developer Guide. Also take into account your quotas and limits on API Requests.

Usage

In the dashboard config file, you must add this configuration in the tiles key.

  1. Enter the view ID that you wish to gather information for e.g. 123456789.
  2. If you changed the name and/or location of the analytics credentials JSON from suggested below, update the field.
  3. The number of URLs displayed on the URLs tile can be limited by amending the urls_displayed field, with a default value of 10.
  4. The active users tile can have the background changed depending upon a threshold of how many active users you set. If the active_users_warning_threshold field is not in the settings, there will be no threshold and no change to the background. Setting to a value of 0 would use the warning background when there are 0 active users. Setting to a value of 10 would use the warning background when there are 10 or fewer active users.
// in config/dashboard.php

return [
    // ...
    'tiles' => [
        'google_analytics_realtime' => [
            'view_id' => '123456789',
            'key_file_location' => __DIR__ . '/../analytics-credentials.json',
            'urls_displayed' => 4,
            'active_users_warning_threshold' => 0,
        ]
    ],
];

In app\Console\Kernel.php you should schedule the \vdvcoder\GoogleAnalyticsRealtimeTile\Commands\FetchGoogleAnalyticsRealtimeCommand to run every minute, pending your Google API quotas and limits.

// in app/console/Kernel.php

protected function schedule(Schedule $schedule)
{
    // ...
    $schedule->command(\vdvcoder\GoogleAnalyticsRealtimeTile\Commands\FetchGoogleAnalyticsRealtimeCommand::class)->everyMinute();
}

In your dashboard view you can use three separate tiles:

  • livewire:google-analytics-realtime-active-users-tile
  • livewire:google-analytics-realtime-devices-tile
  • livewire:google-analytics-realtime-urls-tile
<x-dashboard>
    <livewire:google-analytics-realtime-active-users-tile position="a1:a4" />
    <livewire:google-analytics-realtime-devices-tile position="b1:b4" />
    <livewire:google-analytics-realtime-urls-tile position="a5:b8" />
</x-dashboard>

The layout above will produce something similar to:

Dashboard tiles

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email instead of using the issue tracker.

Support Spatie

I have learnt a lot from Spatie's various packages, including Mailcoach, and would recommend you check them out if you want to know more.

Learn how to create a package like this one, by watching Spatie's premium video course:

Laravel Package training

Spatie invest a lot of resources into creating best in class open source packages. You can support them by buying one of their paid products.

Credits

License

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

vdvcoder/laravel-dashboard-google-analytics-realtime-tile-v2 适用场景与选型建议

vdvcoder/laravel-dashboard-google-analytics-realtime-tile-v2 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 69 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 10 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 vdvcoder/laravel-dashboard-google-analytics-realtime-tile-v2 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 69
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-20