Repository navigation
feat(telemetry): send the scale activity, game mix, permission shape, region and export signals - #1609
Merged
Conversation
… region and export signals sbpp/cf-analytics#7 appended these slots to schema-1 for sbpp/cf-analytics#6. Mirror them in the vendored JSON Schema and add the matching extractors so the parity test stays green: - scale.bans_30d / admins_active_30d: 30-day counts from :prefix_bans.created and :prefix_admins.lastvisit. - scale.ban_history_months: whole calendar months since the oldest ban (created = 0 legacy rows ignored); null without bans, so it is dropped from the wire body. - scale.web_bans_majority_30d: more than half of last-30d bans have sid = 0. - scale.games.*: tf / cstrike / csgo / garrysmod / left4dead2 / other over enabled servers' modfolders. Other folder names never leave the panel. - scale.perms.*: any web group (type 1), server group, override, or admin with immunity > 0. - panel.exported_30d: a Data Export success row in :prefix_log in the last 30 days. - panel.region: continent code via the new Sbpp\Telemetry\Region, from config.timezone when it holds a zone name, else PHP's default timezone. Fresh 2.0 installs have no config.timezone and pre-2.0 upgrades can hold a bare UTC offset there, so the fallback is what most installs will use. Never derived from the request. Operator docs and the Features help text list the new fields. Refs sbpp/cf-analytics#6 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XsiwAF3BzPy1aMBEuQcGZe
|
Thanks for the PR! This change touches To sign, comment exactly the following line on this PR:
You only need to sign once — your signature applies to every future See I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Paired panel change for sbpp/cf-analytics#6. sbpp/cf-analytics#7 added 16 new optional fields to the schema-1 Analytics Engine layout. This PR adds the same fields to the vendored JSON Schema (
web/includes/Telemetry/schema-1.lock.json) and the collectors that fill them.TelemetrySchemaParityTestneeds both: every schema field must have a collector, and every collector field must be in the schema.scale.bans_30d:prefix_bans.createdin the last 30 daysscale.admins_active_30d:prefix_admins.lastvisitin the last 30 daysscale.ban_history_monthsMIN(:prefix_bans.created), ignoringcreated = 0legacy rows.nullwith no bans, so it is left out of the requestscale.web_bans_majority_30dsid = 0scale.games.{tf,cstrike,csgo,garrysmod,left4dead2,other}modfolderof enabled servers (join on:prefix_mods). Folder names outside the five tracked games are never sentscale.perms.{web_groups,server_groups,overrides,immunity}:prefix_groupsrow withtype = 1, any:prefix_srvgroupsrow, any:prefix_overridesrow, any admin withimmunity > 0panel.exported_30dData Exportrow (LogType::Message) in:prefix_login the last 30 days.web/export.phplogs both ZIP and S3 successes this way; failures and denials log ase/wpanel.regionSbpp\Telemetry\Region(see below)Docs: the operator-facing payload list in
updating/1-8-to-2-0.mdx, the help text under Settings → Features (it now mentions the continent and the game mix), ARCHITECTURE.md and AGENTS.md.Note on
panel.regionThe issue says "from
config.timezone", but on 2.0 that setting is mostly empty. Fresh installs never write it, and installs upgraded from 1.x can hold a bare UTC offset like-8(left by updater150.php), which can't be turned into a continent.Region::resolve()therefore usesconfig.timezonewhen it holds an IANA zone name, and otherwise falls back to PHP's default timezone (date.timezone), which is the zone the panel actually shows dates in. Either way the value comes only from configuration, never from the request or the IP.UTC,Etc/*, Antarctica and unknown names givenull, so the field is left out.The mapping is a hardcoded table, not
DateTimeZone::getLocation(), because distro PHP builds that use the system tzdata don't always include the location data. On a host whose timezone is unset (UTC), the field will simply be absent. That will likely be common on shared hosts, where the timezone may also reflect the hosting provider rather than the community.Motivation and Context
Without this PR the new slots stay empty: every ping leaves the new doubles
nulland the new bits0, the same gap #1606 fixed for the env fingerprint.How Has This Been Tested?
phpstan analyse --configuration=phpstan.neon, with phpstan-dba connected (DBA_REQUIRE=1) to MariaDB 10.11 loaded fromstruc.sql. No errors.TelemetryCollectTest,TelemetrySchemaParityTestand the newTelemetryRegionTestthrough a minimal stand-in for PHPUnit's assertions, with the realtests/bootstrap.phpandFixtureagainst a local MariaDB 10.11: 40/40 passed. With the originalTelemetry.phprestored, the same run fails 12, so the tests do check the new collectors. CI'stest.yml(PHP 8.5) is the authoritative run.TelemetryCollectTest: the existing seeded universe now asserts every new field. A second dataset covers mixed games, mostly web bans, a 400-day-old ban (always exactly 13 calendar months), groups, overrides and a recent export. Further tests check thatban_history_monthsisnulland dropped from the request with no bans, and that failed or 31-day-old exports don't count.TelemetryRegionTest: the zone → continent table, the legacy-offset fallback, thegamesmapping andmonthsBetween.TelemetrySchemaParityTest: the expected field list is extended.Types of changes
Checklist:
Generated by Claude Code