### Configuration Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md This example shows the structure of the configuration file for Filament Google Analytics, allowing customization of widget visibility and icons. ```php // config/google-analytics.php - Custom configuration return [ 'dedicated_dashboard' => true, 'dashboard_icon' => 'heroicon-m-chart-bar', 'page_views' => ['filament_dashboard' => true, 'global' => true], 'visitors' => ['filament_dashboard' => true, 'global' => true], 'active_users_one_day' => ['filament_dashboard' => false, 'global' => true], 'active_users_seven_day' => ['filament_dashboard' => false, 'global' => true], 'active_users_twenty_eight_day' => ['filament_dashboard' => false, 'global' => false], 'sessions' => ['filament_dashboard' => true, 'global' => true], 'sessions_duration' => ['filament_dashboard' => false, 'global' => true], 'sessions_by_country' => ['filament_dashboard' => false, 'global' => true], 'sessions_by_device' => ['filament_dashboard' => false, 'global' => true], 'most_visited_pages' => ['filament_dashboard' => false, 'global' => true], 'top_referrers_list' => ['filament_dashboard' => false, 'global' => true], 'trending_up_icon' => 'heroicon-m-arrow-trending-up', 'trending_down_icon' => 'heroicon-m-arrow-trending-down', 'trending_steady_icon' => 'heroicon-m-minus', 'trending_up_color' => 'success', 'trending_down_color' => 'danger', 'trending_steady_color' => 'gray', ]; ``` -------------------------------- ### Using the Facade Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md Example of using the GoogleAnalytics facade to create metrics and format data. ```php use BezhanSalleh\GoogleAnalytics\Facades\GoogleAnalytics; // Create a metric with comparison $metric = GoogleAnalytics::for(1250) ->previous(1000) ->format('%'); // Get computed statistics echo $metric->compute(); // 25 (25% increase) echo $metric->trajectoryValue(); // '1.2k' echo $metric->trajectoryLabel(); // 'trending_up' echo $metric->trajectoryColor(); // 'success' echo $metric->trajectoryIcon(); // 'heroicon-o-arrow-trending-up' echo $metric->trajectoryDescription(); // '25% trending_up' // Format large numbers echo GoogleAnalytics::thousandsFormater(1500000); // '1.5m' ``` -------------------------------- ### Dashboard Icon Configuration Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example of how to configure the dashboard icon. ```php 'dashboard_icon' => 'heroicon-m-chart-bar', ``` ```php 'dashboard_icon' => 'heroicon-o-chart-bar', ``` ```php 'dashboard_icon' => 'heroicon-s-chart-bar', ``` -------------------------------- ### Custom Dashboard Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md This example shows how to create a custom dashboard page in Filament that combines multiple Google Analytics widgets. ```php // Create a custom dashboard combining multiple widgets use Filament\Pages\Page; use BezhanSalleh\GoogleAnalytics\Widgets; class AnalyticsOverview extends Page { protected static ?string $navigationIcon = 'heroicon-o-chart-bar'; protected static ?string $navigationLabel = 'Analytics Overview'; protected static string $view = 'filament.pages.analytics-overview'; protected static ?int $navigationSort = 2; protected function getHeaderWidgets(): array { return [ // Core metrics row Widgets\PageViewsWidget::class, Widgets\VisitorsWidget::class, Widgets\SessionsWidget::class, // Active users row Widgets\ActiveUsersOneDayWidget::class, Widgets\ActiveUsersSevenDayWidget::class, // Geographic and device row Widgets\SessionsByCountryWidget::class, Widgets\SessionsByDeviceWidget::class, // Detail tables row Widgets\MostVisitedPagesWidget::class, Widgets\TopReferrersListWidget::class, ]; } } ``` -------------------------------- ### WidgetManager Instance Method Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Example of how to boot the WidgetManager in a service provider. ```php // In service provider WidgetManager::make()->boot(); ``` -------------------------------- ### Dedicated Dashboard Configuration Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example of how to configure the dedicated dashboard setting. ```php 'dedicated_dashboard' => true, ``` -------------------------------- ### Set Up Google Analytics Credentials Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md Place the downloaded service account JSON credentials file in the specified storage path. ```text storage/app/analytics/service-account-credentials.json ``` -------------------------------- ### Creating a Custom Dashboard Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md Example of creating a custom Filament page to display analytics widgets. ```php use Filament\Pages\Page; use BezhanSalleh\GoogleAnalytics\Widgets; class AnalyticsDashboard extends Page { protected static ?string $navigationIcon = 'heroicon-o-chart-bar'; protected static ?string $navigationLabel = 'Analytics'; protected static string $view = 'filament.pages.analytics-dashboard'; protected function getHeaderWidgets(): array { return [ Widgets\PageViewsWidget::class, Widgets\VisitorsWidget::class, Widgets\ActiveUsersOneDayWidget::class, Widgets\SessionsWidget::class, Widgets\MostVisitedPagesWidget::class, Widgets\TopReferrersListWidget::class, ]; } } ``` -------------------------------- ### GoogleAnalyticsDashboard Configuration Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Example configuration for setting the dashboard icon. ```php // config/google-analytics.php 'dashboard_icon' => 'heroicon-m-chart-bar', ``` -------------------------------- ### Enable All Widgets Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Configuration to enable all widgets to show everywhere. ```php 'dedicated_dashboard' => true, 'dashboard_icon' => 'heroicon-m-chart-bar', 'page_views' => ['filament_dashboard' => true, 'global' => true], 'visitors' => ['filament_dashboard' => true, 'global' => true], 'active_users_one_day' => ['filament_dashboard' => true, 'global' => true], 'active_users_seven_day' => ['filament_dashboard' => true, 'global' => true], 'active_users_twenty_eight_day' => ['filament_dashboard' => true, 'global' => true], 'sessions' => ['filament_dashboard' => true, 'global' => true], 'sessions_duration' => ['filament_dashboard' => true, 'global' => true], 'sessions_by_country' => ['filament_dashboard' => true, 'global' => true], 'sessions_by_device' => ['filament_dashboard' => true, 'global' => true], 'most_visited_pages' => ['filament_dashboard' => true, 'global' => true], 'top_referrers_list' => ['filament_dashboard' => true, 'global' => true], ``` -------------------------------- ### Complete Configuration Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md This is a comprehensive example of the configuration array for the Filament Google Analytics package, showing all available options. ```php true, 'dashboard_icon' => 'heroicon-m-chart-bar', /** * Widgets */ 'page_views' => [ 'filament_dashboard' => false, 'global' => true, ], 'visitors' => [ 'filament_dashboard' => false, 'global' => true, ], 'active_users_one_day' => [ 'filament_dashboard' => false, 'global' => true, ], 'active_users_seven_day' => [ 'filament_dashboard' => false, 'global' => true, ], 'active_users_twenty_eight_day' => [ 'filament_dashboard' => false, 'global' => false, ], 'sessions' => [ 'filament_dashboard' => false, 'global' => true, ], 'sessions_duration' => [ 'filament_dashboard' => false, 'global' => true, ], 'sessions_by_country' => [ 'filament_dashboard' => false, 'global' => true, ], 'sessions_by_device' => [ 'filament_dashboard' => false, 'global' => true, ], 'most_visited_pages' => [ 'filament_dashboard' => false, 'global' => true, ], 'top_referrers_list' => [ 'filament_dashboard' => false, 'global' => true, ], /** * Trajectory Icons */ 'trending_up_icon' => 'heroicon-o-arrow-trending-up', 'trending_down_icon' => 'heroicon-o-arrow-trending-down', 'trending_steady_icon' => 'heroicon-o-arrows-right-left', /** * Trajectory Colors */ 'trending_up_color' => 'success', 'trending_down_color' => 'danger', 'trending_steady_color' => 'gray', ]; ``` -------------------------------- ### Configure Filament Panel Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md Register the Google Analytics plugin in your Filament panel configuration. ```php use BezhanSalleh\GoogleAnalytics\GoogleAnalyticsPlugin; return Panel::make() ->plugins([ GoogleAnalyticsPlugin::make(), ]); ``` -------------------------------- ### GoogleAnalyticsDashboard Configuration Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Example configuration for enabling the dedicated dashboard page. ```php // config/google-analytics.php 'dedicated_dashboard' => true, // Enable the dashboard page ``` -------------------------------- ### Page Views Widget Configuration Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example of configuring the 'page_views' widget to show on the main dashboard and globally. ```php 'page_views' => [ 'filament_dashboard' => true, 'global' => true, ], ``` -------------------------------- ### Installation via Composer Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/README.md Install the package using composer. ```bash composer require bezhansalleh/filament-google-analytics ``` -------------------------------- ### Configuring Widget Visibility Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md Configuration options in `config/google-analytics.php` to control widget visibility. ```php 'dedicated_dashboard' => true, // Enable dedicated dashboard // Show page views widget everywhere 'page_views' => [ 'filament_dashboard' => false, // Not on main dashboard 'global' => true, // On GA dashboard and other pages ], // Show sessions only on dedicated dashboard 'sessions' => [ 'filament_dashboard' => false, 'global' => true, ], // Hide this widget entirely 'active_users_twenty_eight_day' => [ 'filament_dashboard' => false, 'global' => false, ], ``` -------------------------------- ### Sessions Widget Configuration Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example of configuring the 'sessions' widget to show globally but not on the main dashboard. ```php 'sessions' => [ 'filament_dashboard' => false, 'global' => true, ], ``` -------------------------------- ### Sessions by Device Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example of Sessions by Device data. ```php [ 'Desktop (8000)' => 8000, 'Mobile (4500)' => 4500, 'Tablet (500)' => 500, 'total (13000)' => '13000', ] ``` -------------------------------- ### Show Widgets on Main Dashboard Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md Configuration to control the visibility of page views and visitors widgets on the main Filament dashboard. ```php // config/google-analytics.php 'page_views' => [ 'filament_dashboard' => true, // Add to main dashboard 'global' => true, ], 'visitors' => [ 'filament_dashboard' => true, 'global' => true, ] ``` -------------------------------- ### Minimal Setup Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Configuration to show only core metrics and disable others for a minimal dashboard view. ```php 'dedicated_dashboard' => true, 'page_views' => ['filament_dashboard' => false, 'global' => true], 'visitors' => ['filament_dashboard' => false, 'global' => true], 'sessions' => ['filament_dashboard' => false, 'global' => true], 'most_visited_pages' => ['filament_dashboard' => false, 'global' => true], // Disable others 'active_users_one_day' => ['filament_dashboard' => false, 'global' => false], 'active_users_seven_day' => ['filament_dashboard' => false, 'global' => false], 'active_users_twenty_eight_day' => ['filament_dashboard' => false, 'global' => false], 'sessions_duration' => ['filament_dashboard' => false, 'global' => false], 'sessions_by_country' => ['filament_dashboard' => false, 'global' => false], 'sessions_by_device' => ['filament_dashboard' => false, 'global' => false], 'top_referrers_list' => ['filament_dashboard' => false, 'global' => false], ``` -------------------------------- ### MetricDiff get method example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-traits.md Example of how to use the get method from the MetricDiff trait to query Google Analytics for a metric grouped by dimension across a time period, and then map the results. ```php use Spatie\Analytics\Period; $results = $this->get('screenPageViews', 'year', Period::days(7)); // Returns collection with one item per day showing page views $results->map(fn ($item) => [ 'date' => $item['date'], 'value' => $item['value'], ]); ``` -------------------------------- ### Main Dashboard Only Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Configuration to show widgets only on the main Filament dashboard. ```php 'dedicated_dashboard' => false, 'page_views' => ['filament_dashboard' => true, 'global' => false], 'visitors' => ['filament_dashboard' => true, 'global' => false], 'sessions' => ['filament_dashboard' => true, 'global' => false], // ... set other widgets similarly ``` -------------------------------- ### Example Configuration in Config File Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md An example of how widget configurations, specifically for 'page_views', are set within the 'config/google-analytics.php' file. ```php // config/google-analytics.php 'page_views' => [ 'filament_dashboard' => false, 'global' => true, ], ``` -------------------------------- ### Fetching All Page View Data Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-traits.md An example demonstrating how to fetch all page view data for various time periods using the `GADataLookups` facade. ```php use Facades\BezhanSalleh\GoogleAnalytics\Support\GADataLookups; // Get page views for all time periods $pageViewData = GADataLookups::pageViews(); // Returns: [ 'T' => ['result' => 1250, 'previous' => 1100], 'Y' => ['result' => 980, 'previous' => 1050], 'LW' => ['result' => 8500, 'previous' => 7800], 'LM' => ['result' => 35000, 'previous' => 32000], 'LSD' => ['result' => 9200, 'previous' => 8900], 'LTD' => ['result' => 38000, 'previous' => 36000], ] ``` -------------------------------- ### GAStats Instance Method Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Example of using the select method on GAStats to configure filter options. ```php use BezhanSalleh\GoogleAnalytics\Support\GAStats; $stat = GAStats::make('Page Views', 1250) ->select([ 'T' => 'Today', 'Y' => 'Yesterday', 'LW' => 'Last Week', ], 'T'); ``` -------------------------------- ### Widget Registration Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-widgets.md Example of registering widgets automatically and adding them to a custom dashboard. ```php GoogleAnalyticsPlugin::make() // Registers all 11 widgets ``` ```php use BezhanSalleh\GoogleAnalytics\Widgets; class MyAnalyticsDashboard extends Page { protected function getHeaderWidgets(): array { return [ Widgets\PageViewsWidget::class, Widgets\VisitorsWidget::class, Widgets\SessionsWidget::class, Widgets\MostVisitedPagesWidget::class, Widgets\TopReferrersListWidget::class, ]; } } ``` -------------------------------- ### Sessions by Country Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example of Sessions by Country data. ```php [ 'United States (5000)' => 5000, 'United Kingdom (2500)' => 2500, 'Canada (1200)' => 1200, 'Australia (800)' => 800, 'total (9500)' => '9500', ] ``` -------------------------------- ### Example: Make PageViewsWidget Visible Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-widgets.md Example code to make the PageViewsWidget visible on the main dashboard. ```php // Make PageViewsWidget visible on the main dashboard config('google-analytics.page_views.filament_dashboard', true); config('google-analytics.page_views.global', true); ``` -------------------------------- ### GAStatsBuilder Static Factory and Instance Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Example of creating a GAStatsBuilder instance and configuring it to resolve into a GAStats object. ```php use BezhanSalleh\GoogleAnalytics\Support\GAStatsBuilder; $builder = GAStatsBuilder::make('Page Views') ->usingResponse($analyticsData) ->withSelectFilter([ 'T' => 'Today', 'Y' => 'Yesterday', ], 'T') ->resolve(); ``` -------------------------------- ### Trending Up Icon Options Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example options for the `trending_up_icon` configuration. ```php 'trending_up_icon' => 'heroicon-o-arrow-trending-up', 'trending_up_icon' => 'heroicon-m-arrow-trending-up', 'trending_up_icon' => 'heroicon-s-arrow-trending-up', ``` -------------------------------- ### Customize Trending Color Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md Configuration options to customize the colors for trending up, down, and steady indicators. ```php // config/google-analytics.php 'trending_up_color' => 'success', // Green 'trending_down_color' => 'danger', // Red 'trending_steady_color' => 'gray', // Gray ``` -------------------------------- ### Metric Lookup Array Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example of a Metric Lookup Array. ```php [ 'T' => ['result' => 500, 'previous' => 450], 'Y' => ['result' => 480, 'previous' => 510], 'LW' => ['result' => 3200, 'previous' => 2950], 'LM' => ['result' => 12500, 'previous' => 11200], 'LSD' => ['result' => 3500, 'previous' => 3200], 'LTD' => ['result' => 14000, 'previous' => 13500], ] ``` -------------------------------- ### Using the Facade Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Example demonstrating how to use the GoogleAnalytics facade to create and configure an analytics instance and retrieve computed metrics. ```php use BezhanSalleh\GoogleAnalytics\Facades\GoogleAnalytics; // Create and configure analytics instance $metric = GoogleAnalytics::for(500) ->previous(450) ->format('%'); // Get computed metrics $percentChange = $metric->compute(); // 11 (percent) $display = $metric->trajectoryValue(); // '500' or '500' $label = $metric->trajectoryLabel(); // 'trending_up' $color = $metric->trajectoryColor(); // 'success' $icon = $metric->trajectoryIcon(); // 'heroicon-o-arrow-trending-up' $description = $metric->trajectoryDescription(); // '11% trending_up' // Format large numbers $formatted = GoogleAnalytics::thousandsFormater(1500); // '1.5k' ``` -------------------------------- ### Active Users Response Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example of an Active Users Response. ```php GAResponse::activeUsers( GADataLookups::activeUsers('active7DayUsers'), '10' ); // Returns: [ 'results' => [ 'Jan 08' => 145, 'Jan 09' => 167, 'Jan 10' => 192, // ... 7 more days ] ] ``` -------------------------------- ### Customize Trending Icon Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/quick-start.md Configuration options to customize the icons used for trending up, down, and steady indicators. ```php // config/google-analytics.php 'trending_up_icon' => 'heroicon-m-arrow-trending-up', 'trending_down_icon' => 'heroicon-m-arrow-trending-down', 'trending_steady_icon' => 'heroicon-m-minus', ``` -------------------------------- ### Trending Steady Icon Options Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example options for the `trending_steady_icon` configuration. ```php 'trending_steady_icon' => 'heroicon-o-arrows-right-left', 'trending_steady_icon' => 'heroicon-m-minus', 'trending_steady_icon' => 'heroicon-o-check-circle', ``` -------------------------------- ### GoogleAnalytics Facade thousandsFormater Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Example demonstrating the usage of the thousandsFormater method on the GoogleAnalytics facade. ```php GoogleAnalytics::thousandsFormater(1500); // '1.5k' GoogleAnalytics::thousandsFormater(1000000); // '1m' GoogleAnalytics::thousandsFormater(500); // 500 ``` -------------------------------- ### PageViewsWidget Example Usage Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-widgets.md Example of how to register the PageViewsWidget in a Filament page. ```php use BezhanSalleh\GoogleAnalytics\Widgets\PageViewsWidget; // In your Filament page protected function getHeaderWidgets(): array { return [ PageViewsWidget::class, ]; } ``` -------------------------------- ### GoogleAnalytics Facade Usage Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Example demonstrating the usage of the GoogleAnalytics facade for retrieving and formatting analytics data. ```php use BezhanSalleh\GoogleAnalytics\Facades\GoogleAnalytics; $stats = GoogleAnalytics::for(1250) ->previous(1000) ->format('%'); echo $stats->compute(); // 25 echo $stats->trajectoryValue(); // '1.2k' echo $stats->trajectoryDescription(); // '25% trending_up' echo $stats->trajectoryIcon(); // 'heroicon-o-arrow-trending-up' echo $stats->trajectoryColor(); // 'success' ``` -------------------------------- ### Period Lookup Array Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example of a Period Lookup Array. ```php use Spatie\Analytics\Period; use Carbon\Carbon; [ 'T' => Period::create(Carbon::yesterday(), Carbon::today()), 'LW' => Period::days(7), 'LM' => Period::months(1), ] ``` -------------------------------- ### Stat Value Array Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example of a Stat Value Array. ```php [ 'result' => 1250, 'previous' => 1000, ] ``` -------------------------------- ### Analytics Period Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Examples of creating Period objects for different timeframes. ```php use Spatie\Analytics\Period; $today = Period::days(1); $lastWeek = Period::days(7); $lastMonth = Period::months(1); $custom = Period::create(Carbon::now()->subMonth(), Carbon::now()); ``` -------------------------------- ### Sessions by Device Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Retrieves sessions grouped by device category with formatted labels. ```php $devices = GAResponse::sessionsByDevice('LW'); // Returns: // [ // 'Desktop (8000)' => 8000, // 'Mobile (4500)' => 4500, // 'Tablet (500)' => 500, // 'total (13000)' => '13000' // ] ``` -------------------------------- ### SessionsByCountryWidget Example Usage Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-widgets.md Example of how to register the SessionsByCountryWidget in a Filament page. ```php use BezhanSalleh\GoogleAnalytics\Widgets\SessionsByCountryWidget; protected function getHeaderWidgets(): array { return [ SessionsByCountryWidget::class, ]; } ``` -------------------------------- ### Dedicated Dashboard Only Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Configuration to show widgets only on the dedicated GA dashboard. ```php 'dedicated_dashboard' => true, 'page_views' => ['filament_dashboard' => false, 'global' => true], 'visitors' => ['filament_dashboard' => false, 'global' => true], 'sessions' => ['filament_dashboard' => false, 'global' => true], // ... set other widgets similarly ``` -------------------------------- ### Top Referrer Record Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md An example of a single referrer analytics record. ```php [ 'url' => 'https://google.com', 'pageViews' => 1500, ] ``` -------------------------------- ### Active Users Lookup Array Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example of an Active Users Lookup Array. ```php [ '5' => ['results' => ['Jan 11' => 120, 'Jan 12' => 135, ...]], '10' => ['results' => ['Jan 06' => 100, 'Jan 07' => 112, ...]], '15' => ['results' => ['Jan 01' => 85, 'Jan 02' => 95, ...]], ] ``` -------------------------------- ### GoogleAnalytics trajectoryDescription Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Example of trajectoryDescription output. ```php $stats = GoogleAnalytics::for(1250) ->previous(1000) ->format('%'); echo $stats->trajectoryDescription(); // "25% trending_up" ``` -------------------------------- ### GAStatsBuilder Resolve Example with GoogleAnalytics Instance Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Example demonstrating the resolve method of GAStatsBuilder when using a GoogleAnalytics instance for response data. ```php $stat = GAStatsBuilder::make('Visitors', null) ->usingResponse(GoogleAnalytics::for(500)->previous(450)->format('%')) ->withSelectFilter( ['T' => 'Today', 'Y' => 'Yesterday'], 'T' ) ->resolve(); ``` -------------------------------- ### SelectAction Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Renders a select action with options, suitable for filter dropdowns in widgets, featuring Livewire bindings and loading indicators. ```php use BezhanSalleh\GoogleAnalytics\Support\SelectAction; SelectAction::make('filter') ->options([ 'T' => 'Today', 'Y' => 'Yesterday', ]) // Renders with Livewire loading indicator and live updates ``` -------------------------------- ### Trending Down Icon Options Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example options for the `trending_down_icon` configuration. ```php 'trending_down_icon' => 'heroicon-o-arrow-trending-down', 'trending_down_icon' => 'heroicon-m-arrow-trending-down', 'trending_down_icon' => 'heroicon-s-arrow-trending-down', ``` -------------------------------- ### Trending Up Color Usage Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example usage for setting the `trending_up_color`. ```php 'trending_up_color' => 'success', // Default green 'trending_up_color' => 'primary', // Primary blue ``` -------------------------------- ### Most Visited Page Record Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md An example of a single page analytics record. ```php [ 'name' => 'About Us', 'hostname' => 'example.com', 'path' => '/about', 'visits' => 250, ] // Renders as link: https://example.com/about ``` -------------------------------- ### GoogleAnalytics trajectoryValueAsTimeString Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Example of trajectoryValueAsTimeString output. ```php GoogleAnalytics::for(1703001600)->trajectoryValueAsTimeString(); // "20:00:00" ``` -------------------------------- ### GoogleAnalytics trajectoryValue Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Examples of trajectoryValue output. ```php GoogleAnalytics::for(1250)->trajectoryValue(); // '1.2k' GoogleAnalytics::for(150)->trajectoryValue(); // 150 GoogleAnalytics::for(500)->trajectoryValue(); // 500 ``` -------------------------------- ### Trending Steady Color Usage Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example usage for setting the `trending_steady_color`. ```php 'trending_steady_color' => 'gray', // Default gray 'trending_steady_color' => 'info', // Light blue info ``` -------------------------------- ### Top Referrers Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Retrieves top 10 referrer URLs with visitor counts. ```php $referrers = GAResponse::topReferrers('TW'); // This Week foreach ($referrers as $ref) { echo $ref['url'] . ': ' . $ref['pageViews'] . ' referrals'; } ``` -------------------------------- ### GoogleAnalytics Example Usage Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Example of how to use the GoogleAnalytics class for tracking and displaying analytics data. ```php use BezhanSalleh\GoogleAnalytics\GoogleAnalytics; $stats = GoogleAnalytics::for(1250); $stats->previous(1000) ->format('%'); echo $stats->compute(); // 25 echo $stats->trajectoryValue(); // '1.2k' echo $stats->trajectoryDescription(); // '25% trending_up' ``` -------------------------------- ### GADataLookups Active Users Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Fetches active users data for 5, 10, and 15 day periods using the GADataLookups facade. ```php use Facades\BezhanSalleh\GoogleAnalytics\Support\GADataLookups; $oneDay = GADataLookups::activeUsers(); $sevenDay = GADataLookups::activeUsers('active7DayUsers'); $twentyEightDay = GADataLookups::activeUsers('active28DayUsers'); ``` -------------------------------- ### Sessions by Country Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Retrieves sessions grouped by country with formatted labels. ```php $countries = GAResponse::sessionsByCountry('T'); // Returns: // [ // 'United States (5000)' => 5000, // 'United Kingdom (2500)' => 2500, // 'Canada (1200)' => 1200, // 'total (8700)' => '8700' // ] ``` -------------------------------- ### Trending Down Color Usage Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example usage for setting the `trending_down_color`. ```php 'trending_down_color' => 'danger', // Default red 'trending_down_color' => 'warning', // Orange warning ``` -------------------------------- ### Enabling Specific Widgets Configuration Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Configuration example for enabling or disabling specific widgets on the Filament dashboard and globally. ```php // config/google-analytics.php return [ 'dedicated_dashboard' => true, 'page_views' => [ 'filament_dashboard' => true, // Show on main dashboard 'global' => true, ], 'sessions' => [ 'filament_dashboard' => false, 'global' => true, ], 'most_visited_pages' => [ 'filament_dashboard' => false, 'global' => true, ], ]; ``` -------------------------------- ### Common Metrics Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Processes common metrics (page views, visitors, sessions, session duration). ```php $data = GAResponse::common( GADataLookups::pageViews(), 'T' ); // Returns GoogleAnalytics with trajectory data for today vs yesterday ``` -------------------------------- ### Perform Active Users Query Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-traits.md Demonstrates how to query active users for specific metrics and time windows using the `performActiveUsersQuery` method. ```php $oneDay = $this->performActiveUsersQuery('active1DayUsers', 5); // Returns last 5 days of daily active users $sevenDay = $this->performActiveUsersQuery('active7DayUsers', 15); // Returns last 15 days of 7-day active users ``` -------------------------------- ### Creating Custom Dashboard Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Example of creating a custom Filament dashboard page that includes various Google Analytics widgets. ```php use Filament\Pages\Page; use BezhanSalleh\GoogleAnalytics\Widgets; class CustomAnalyticsDashboard extends Page { protected static ?string $navigationIcon = 'heroicon-o-chart-bar'; protected static ?string $navigationLabel = 'Custom Analytics'; protected static string $view = 'filament.pages.custom-analytics-dashboard'; protected static ?int $navigationSort = 2; protected function getHeaderWidgets(): array { return [ Widgets\PageViewsWidget::class, Widgets\VisitorsWidget::class, Widgets\ActiveUsersOneDayWidget::class, Widgets\SessionsWidget::class, Widgets\SessionsByCountryWidget::class, Widgets\MostVisitedPagesWidget::class, Widgets\TopReferrersListWidget::class, ]; } } ``` -------------------------------- ### Creating a Custom Analytics Dashboard Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Example of creating a custom analytics dashboard page in Filament. ```php use BezhanSalleh\GoogleAnalytics\Widgets; use Filament\Pages\Page; class MyAnalyticsDashboard extends Page { protected static ?string $navigationIcon = 'heroicon-o-chart-bar'; protected static ?string $navigationLabel = 'Analytics'; protected static ?string $title = 'Analytics Dashboard'; protected static ?int $navigationSort = 1; protected function getHeaderWidgets(): array { return [ Widgets\PageViewsWidget::class, Widgets\VisitorsWidget::class, Widgets\ActiveUsersOneDayWidget::class, Widgets\SessionsWidget::class, Widgets\MostVisitedPagesWidget::class, Widgets\TopReferrersListWidget::class, ]; } } ``` -------------------------------- ### Custom Widget Visibility Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-traits.md Shows how to implement the `canView` method in a custom widget to control its visibility based on configuration and route. ```php use BezhanSalleh\GoogleAnalytics\Traits\CanViewWidget; class CustomWidget extends Widget { use CanViewWidget; public static function canView(): bool { // Automatically checks config and current route } } ``` -------------------------------- ### Registering GoogleAnalyticsPlugin in Filament Panel Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Example of how to register the GoogleAnalyticsPlugin in a Filament panel configuration. ```php use Filament\Panel; use BezhanSalleh\GoogleAnalytics\GoogleAnalyticsPlugin; class AdminPanel extends Panel { public function panel(Panel $panel): Panel { return $panel ->plugins([ GoogleAnalyticsPlugin::make(), ]) // Other panel config... } } ``` -------------------------------- ### Active Users Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Processes active users data with multiple time period variants. ```php use BezhanSalleh\GoogleAnalytics\Support\GAResponse; use Facades\BezhanSalleh\GoogleAnalytics\Support\GADataLookups; $data = GAResponse::activeUsers( GADataLookups::activeUsers(), '10' // 10-day active users ); // Returns: ['results' => [100, 150, 200, 180, ...]] ``` -------------------------------- ### Environment Variable Usage Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Example of how to set and access the `ANALYTICS_PROPERTY_ID` environment variable. ```env ANALYTICS_PROPERTY_ID=123456789 ``` ```php $propertyId = env('ANALYTICS_PROPERTY_ID'); config('analytics.property_id'); ``` -------------------------------- ### GoogleAnalytics Facade Usage Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/README.md Example usage of the GoogleAnalytics facade. ```php use BezhanSalleh\GoogleAnalytics\Facades\GoogleAnalytics; GoogleAnalytics::for($value)->previous($prev)->compute(); GoogleAnalytics::thousandsFormater($number); ``` -------------------------------- ### Most Visited Pages Example Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Retrieves top 10 most visited pages with full URL reconstruction. ```php $pages = GAResponse::mostVisitedPages('TM'); // This Month foreach ($pages as $page) { echo $page['name'] . ': ' . $page['visits'] . ' visits'; // Full URL: https://example.com/about } ``` -------------------------------- ### Common Filters Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example filters for common time periods. ```php [ 'T' => 'Today', 'Y' => 'Yesterday', 'LW' => 'Last Week', 'LM' => 'Last Month', 'LSD' => 'Last Seven Days', 'LTD' => 'Last Thirty Days', ] ``` -------------------------------- ### Most Visited & Referrers Filters Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example filters for most visited pages and top referrers. ```php [ 'T' => 'This Day', 'TW' => 'This Week', 'TM' => 'This Month', 'TY' => 'This Year', ] ``` -------------------------------- ### Active Users Filters Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Example filters for active users over different day ranges. ```php [ '5' => 'Five Days', // Or localized: __('google-analytics::widgets.FD') '10' => 'Ten Days', // Or localized: __('google-analytics::widgets.TD') '15' => 'Fifteen Days', // Or localized: __('google-analytics::widgets.FFD') ] ``` -------------------------------- ### Create Custom Dashboard Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/README.md Example of creating a custom dashboard with specific widgets. ```php use BezhanSalleh\GoogleAnalytics\Widgets; use Filament\Pages\Page; class MyDashboard extends Page { protected function getHeaderWidgets(): array { return [ Widgets\PageViewsWidget::class, Widgets\SessionsWidget::class, ]; } } ``` -------------------------------- ### Publishing Views Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Command to publish the package's views. ```bash php artisan vendor:publish --tag=google-analytics-views ``` -------------------------------- ### boot Method Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Boots the plugin after registration (currently empty). ```php public function boot(Panel $panel): void ``` -------------------------------- ### packageBooted Method Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Called after the package boots. Initializes the WidgetManager. ```php public function packageBooted(): void ``` -------------------------------- ### Publishing Translations Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Command to publish the package's translation files. ```bash php artisan vendor:publish --tag=google-analytics-translations ``` -------------------------------- ### Widget Visibility Structure Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md The structure for configuring widget visibility. ```php 'widget_name' => [ 'filament_dashboard' => bool, 'global' => bool, ], ``` -------------------------------- ### configurePackage Method Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Configures the package name, config, views, and translations. ```php public function configurePackage(Package $package): void ``` -------------------------------- ### Publish Configuration Files Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/README.md Publish the configuration files to customize settings. ```bash php artisan vendor:publish --tag=google-analytics-config ``` -------------------------------- ### Livewire Component Registry Structure Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Illustrates the structure of the internal Livewire component registry, mapping widget aliases to their corresponding class names. ```php [ 'aliased.component.name' => 'BezhanSalleh\GoogleAnalytics\Widgets\WidgetClass', // ... ] ``` -------------------------------- ### GoogleAnalytics Constructor Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Creates a new GoogleAnalytics instance with an initial value. ```php public function __construct(public int | float $value = 0) ``` -------------------------------- ### Customize Trending Indicators Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/README.md Configuration example for customizing the icons and colors used for trending indicators in the analytics widgets. ```php // config/google-analytics.php 'trending_up_icon' => 'heroicon-m-arrow-trending-up', 'trending_up_color' => 'success', ``` -------------------------------- ### Clearing Cached Configurations Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/configuration.md Command to clear cached configurations after publishing the config file. ```bash php artisan config:clear ``` -------------------------------- ### GoogleAnalytics Instance Method: trajectoryDescription Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Returns a complete formatted description with percentage and label. ```php public function trajectoryDescription(): string ``` -------------------------------- ### Widget Visibility Logic Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-widgets.md Logic for controlling widget visibility based on configuration and route. ```php // Show on default Filament dashboard if (filament_dashboard_enabled && route == 'dashboard') { return true; } // Show on dedicated GA dashboard if (global_enabled && dedicated_dashboard_enabled && route == 'google-analytics-dashboard') { return true; } // Show globally on any other panel pages return global_enabled && !route == 'dashboard' && !route == 'google-analytics-dashboard'; ``` -------------------------------- ### Registered Widgets Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md An array listing all the widgets registered by the WidgetManager. ```php protected array $widgets = [ Widgets\PageViewsWidget::class, Widgets\VisitorsWidget::class, Widgets\ActiveUsersOneDayWidget::class, Widgets\ActiveUsersSevenDayWidget::class, Widgets\ActiveUsersTwentyEightDayWidget::class, Widgets\SessionsWidget::class, Widgets\SessionsByCountryWidget::class, Widgets\SessionsDurationWidget::class, Widgets\SessionsByDeviceWidget::class, Widgets\MostVisitedPagesWidget::class, Widgets\TopReferrersListWidget::class, ]; ``` -------------------------------- ### WidgetManager Static Factory Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-pages-facades.md Creates a new manager instance via service container. ```php public static function make(): static ``` -------------------------------- ### Use Facade in Custom Code Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/README.md Demonstrates how to use the GoogleAnalytics facade in custom PHP code to fetch and format analytics data. ```php use BezhanSalleh\GoogleAnalytics\Facades\GoogleAnalytics; $metric = GoogleAnalytics::for(500) ->previous(450) ->format('%'); echo $metric->trajectoryDescription(); ``` -------------------------------- ### Common Filter Options Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Provides filter options for common metrics like page views, visitors, and sessions. ```php use BezhanSalleh\GoogleAnalytics\Support\GAFilters; $options = GAFilters::common(); // Use in select: ['T' => 'Today', 'Y' => 'Yesterday', 'LW' => 'Last Week', 'LM' => 'Last Month', 'LSD' => 'Last Seven Days', 'LTD' => 'Last Thirty Days'] ``` -------------------------------- ### GoogleAnalytics Instance Method: format Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Sets the format suffix for trajectory description output. ```php public function format(string $format): static ``` -------------------------------- ### Most Visited and Top Referrers Filter Options Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Provides filter options for most visited pages and referrers. ```php use BezhanSalleh\GoogleAnalytics\Support\GAFilters; $options = GAFilters::mostVisitedAndTopReferrers(); // Use in select: ['T' => 'This Day', 'TW' => 'This Week', 'TM' => 'This Month', 'TY' => 'This Year'] ``` -------------------------------- ### GoogleAnalytics Static Factory Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Creates a new GoogleAnalytics instance via service container. ```php public static function for(int | float $value = 0): static ``` -------------------------------- ### GADataLookups Facade Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/README.md Facade-accessible data fetching. ```php GADataLookups::pageViews(); // → Multi-period array GADataLookups::visitors(); // → Multi-period array GADataLookups::sessions(); // → Multi-period array GADataLookups::activeUsers($variant); // → 5/10/15-day variants ``` -------------------------------- ### Active Users Filter Options Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-support.md Provides filter options for active users metrics (5, 10, 15 day variants). ```php use BezhanSalleh\GoogleAnalytics\Support\GAFilters; $options = GAFilters::activeUsers(); // Use in select: ['5' => 'FD', '10' => 'TD', '15' => 'FFD'] ``` -------------------------------- ### Register Plugin in Panel Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/README.md Register the GoogleAnalyticsPlugin in your Filament panel. ```php public function panel(Panel $panel): Panel { return $panel ->plugins([ ... \BezhanSalleh\GoogleAnalytics\GoogleAnalyticsPlugin::make() ]); } ``` -------------------------------- ### Sessions by Device Structure Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Array of device categories with session counts. ```php [ 'Device Category (count)' => count, // ... more devices 'total (count)' => total_as_string, ] ``` -------------------------------- ### Enable Widgets on Main Dashboard Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/README.md Configuration to enable widgets on the main Filament dashboard. ```php // config/google-analytics.php 'page_views' => [ 'filament_dashboard' => true, 'global' => true, ] ``` -------------------------------- ### register Method Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Registers the plugin's pages and widgets with the Filament panel. ```php public function register(Panel $panel): void ``` -------------------------------- ### Widget Visibility Method Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-widgets.md The canView method signature for controlling widget visibility. ```php public static function canView(): bool ``` -------------------------------- ### Using Traits with Widgets Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-traits.md Demonstrates how to fetch and process Google Analytics data within a custom Filament widget using the provided traits. ```php use BezhanSalleh\GoogleAnalytics\Support\GAResponse; use Facades\BezhanSalleh\GoogleAnalytics\Support\GADataLookups; class CustomWidget extends StatsOverviewWidget { public ?string $filter = 'T'; protected function getStats(): array { // Fetch data using traits through GADataLookups $data = GADataLookups::sessions(); // Process with GAResponse $response = GAResponse::common($data, $this->filter); // Build the stat return [ GAStatsBuilder::make('Sessions') ->usingResponse($response) ->resolve(), ]; } } ``` -------------------------------- ### Widget Visibility Configuration Keys Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-widgets.md Configuration keys in google-analytics.php for controlling widget visibility. ```php 'page_views' => [ 'filament_dashboard' => false, // Show on main dashboard 'global' => true, // Show elsewhere ], // ... same for all widgets ``` -------------------------------- ### Analytics Period Creation Methods Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/types.md Methods for creating Period objects for querying analytics data. ```php Period::days(int $days); Period::months(int $months); Period::years(int $years); Period::create(Carbon $start, Carbon $end); ``` -------------------------------- ### Composer Configuration for Local Development Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/README.md This JSON snippet shows how to configure composer to use a local path for the filament-google-analytics package, useful for contributing and testing. ```json { "require": { "bezhansalleh/filament-google-analytics": "dev-fix/error-message as main-dev" }, "repositories": [ { "type": "path", "url": "filament-analytics" } ] } ``` -------------------------------- ### GoogleAnalytics Instance Method: compute Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-core.md Calculates the percentage difference between current and previous values. ```php public function compute(): int | float ``` -------------------------------- ### Widget Visibility Configuration Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/README.md Configuration for widget visibility on different dashboard areas. ```php 'page_views' => [ 'filament_dashboard' => bool, 'global' => bool, ] ``` -------------------------------- ### SessionsByDeviceWidget Properties Source: https://github.com/bezhansalleh/filament-google-analytics/blob/main/_autodocs/api-reference-widgets.md Properties for the SessionsByDeviceWidget, including filter and sort order. ```php public ?string $filter = 'T'; // Default: Today protected static ?int $sort = 4; ```