Dashboard\Classes\TrafficLogger
Overview
TrafficLogger logs pageviews for Internal Traffic Statistics.
Protected Properties
protected Dashboard\Models\DashboardSetting $settingModel
Public Methods
public __construct()
public __construct(): void
__construct this class
public getRetentionMonths()
public getRetentionMonths(): int|null
getRetentionMonths returns data retention, in months. Returns the number of months or null for indefinite retention.
public getTimezone()
public getTimezone(): string
getTimezone retrieves the timezone setting for the Internal Traffic Statistics feature. If no specific timezone is set for the feature, it defaults to the general CMS timezone. Returns the timezone identifier string.
public static instance()
public static instance(): static
instance creates a new instance of this singleton
public isEnabled()
public isEnabled(): bool
isEnabled checks if the Internal Traffic Statistics feature is enabled. Returns true if the feature is enabled, and false otherwise.
public logPageview()
public logPageview(): void
logPageview logs a pageview for the Internal Traffic Statistics. This method should be called whenever a page is viewed to keep the statistics up-to-date. Creates a client ID cookie if it doesn't exist.
Protected Methods
protected generateClientId()
protected generateClientId(): string
generateClientId generates a random client ID string.
protected getClientId()
protected getClientId(): void
getClientId retrieves the client ID from the cookie. The client ID must have a maximum length of 64, as enforced by the database.
protected ipMatchesCidr()
protected ipMatchesCidr($ip, $cidr): bool
ipMatchesCidr checks if an IP address falls within a CIDR range
protected isAdminRoleExcluded()
protected isAdminRoleExcluded(): bool
isAdminRoleExcluded determines if an administrator role is excluded
protected isIpExcluded()
protected isIpExcluded($ip): bool
isIpExcluded determines if a request IP address is excluded
protected isPathExcluded()
protected isPathExcluded($path): bool
isPathExcluded determines if a request path is excluded
protected isUserAuthenticated()
protected isUserAuthenticated(): bool
isUserAuthenticated checks if the user is currently authenticated. Returns true if the user is authenticated, and false otherwise.
protected makeEventDateTime()
protected makeEventDateTime(): Carbon\Carbon
makeEventDateTime returns the current event date and time in the configured timezone. Returns the event date and time string.
protected makePageview()
protected makePageview(): Dashboard\Models\TrafficStatisticsPageview|null
makePageview builds the pageview record for the current request, or returns null when the request should not be counted.