Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Usage/Metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ class Metric extends ArrayObject
'service', 'resourceType', 'resourceId', 'resourceInternalId',
'teamId', 'teamInternalId',
'country', 'region', 'hostname', 'ip',
// request attributes (firewall rule matching)
'protocol', 'accept', 'acceptLanguage', 'cookie', 'queryKeys',
// premium geo
'city', 'continentCode', 'subdivisions',
Comment on lines +58 to 60

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Event-column contract test breaks

When the test suite runs, testEventColumnsConstant compares Metric::EVENT_COLUMNS with a hard-coded list that omits all ten newly added fields, causing the exact assertSame assertion and CI to fail.

Knowledge Base Used: Usage domain model

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Usage/Metric.php
Line: 58-60

Comment:
**Event-column contract test breaks**

When the test suite runs, `testEventColumnsConstant` compares `Metric::EVENT_COLUMNS` with a hard-coded list that omits all ten newly added fields, causing the exact `assertSame` assertion and CI to fail.

**Knowledge Base Used:** [Usage domain model](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/utopia-php/usage/-/docs/usage-domain-model.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

'postalCode', 'latitude', 'longitude', 'timeZone', 'weatherCode',
'isp', 'autonomousSystemNumber', 'autonomousSystemOrganization',
'connectionType', 'connectionUsageType', 'connectionOrganization',
'osCode', 'osName', 'osVersion',
Expand Down Expand Up @@ -88,7 +91,9 @@ class Metric extends ArrayObject
* - resourceType / resourceId / resourceInternalId: resource identity
* - teamId / teamInternalId: owning team identity
* - country / region / hostname / ip: geographic + caller origin
* - protocol / accept / acceptLanguage / cookie / queryKeys: request attributes (firewall rule matching)
* - city / continentCode / subdivisions: premium geo location fields
* - postalCode / latitude / longitude / timeZone / weatherCode: premium geo location fields
* - isp / autonomousSystemNumber / autonomousSystemOrganization: premium network origin
* - connectionType / connectionUsageType / connectionOrganization: premium connection intelligence
* - osCode / osName / osVersion: parsed user-agent OS fields
Expand Down Expand Up @@ -648,10 +653,24 @@ public static function getEventSchema(): array
$stringColumn('region', 64),
$stringColumn('hostname', 255),
$stringColumn('ip', 45),
// request attributes (firewall rule matching)
$stringColumn('protocol', 16),
$stringColumn('accept', 1024),
$stringColumn('acceptLanguage', 256),
// Cookie headers are large; size > maxVarchar (16381) makes this a
// TEXT column, stored off-page so it costs ~20 bytes toward the
// MariaDB 65535 row-size limit instead of size*4.
$stringColumn('cookie', 65535),
$stringColumn('queryKeys', 1024),
// premium geo
$stringColumn('city', 256),
$stringColumn('continentCode', 2),
$stringColumn('subdivisions', 256),
$stringColumn('postalCode', 32),
$stringColumn('latitude', 32),
$stringColumn('longitude', 32),
$stringColumn('timeZone', 64),
$stringColumn('weatherCode', 16),
$stringColumn('isp', 256),
$stringColumn('autonomousSystemNumber', 255),
$stringColumn('autonomousSystemOrganization', 256),
Expand Down
4 changes: 3 additions & 1 deletion tests/Usage/MetricTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testGetEventSchemaReturnsAttributeDefinitions(): void
{
$schema = Metric::getEventSchema();

// 3 core (metric, value, time) + 24 dimension columns from EVENT_COLUMNS.
// 3 core (metric, value, time) + one column per EVENT_COLUMNS entry.
$this->assertCount(3 + count(Metric::EVENT_COLUMNS), $schema);

$metricAttr = $schema[0];
Expand Down Expand Up @@ -609,7 +609,9 @@ public function testEventColumnsConstant(): void
'service', 'resourceType', 'resourceId', 'resourceInternalId',
'teamId', 'teamInternalId',
'country', 'region', 'hostname', 'ip',
'protocol', 'accept', 'acceptLanguage', 'cookie', 'queryKeys',
'city', 'continentCode', 'subdivisions',
'postalCode', 'latitude', 'longitude', 'timeZone', 'weatherCode',
'isp', 'autonomousSystemNumber', 'autonomousSystemOrganization',
'connectionType', 'connectionUsageType', 'connectionOrganization',
'osCode', 'osName', 'osVersion',
Expand Down
Loading