Skip to content
Open
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
33 changes: 33 additions & 0 deletions javascript/sentry-conventions/src/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,26 @@ export const DEVICE_SIMULATOR = 'device.simulator';
*/
export type DEVICE_SIMULATOR_TYPE = boolean;

// Path: model/attributes/device/device__low_power_mode.json

/**
* Whether the device is in Low Power Mode. `device.low_power_mode`
*
* Attribute Value Type: `boolean` {@link DEVICE_LOW_POWER_MODE_TYPE}
*
* Contains PII: false
*
* Attribute defined in OTEL: No
*
* @example true
*/
export const DEVICE_LOW_POWER_MODE = 'device.low_power_mode';

/**
* Type for {@link DEVICE_LOW_POWER_MODE} device.low_power_mode
*/
export type DEVICE_LOW_POWER_MODE_TYPE = boolean;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New attribute placed in wrong alphabetical position

Low Severity

DEVICE_LOW_POWER_MODE is appended after DEVICE_SIMULATOR in every section (constant definitions, ATTRIBUTE_TYPE, AttributeName, ATTRIBUTE_METADATA, and Python ATTRIBUTE_NAMES), but the rest of the file maintains strict alphabetical order by constant name. Since L sorts before M, P, and S, it belongs between DEVICE_FREE_MEMORY and DEVICE_MEMORY_ESTIMATED_CAPACITY. These are auto-generated files, so the next regeneration will move the entry and produce a noisy diff.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f95b230. Configure here.


// Path: model/attributes/effectiveConnectionType.json

/**
Expand Down Expand Up @@ -10333,6 +10353,7 @@ export const ATTRIBUTE_TYPE: Record<string, AttributeType> = {
[DEVICE_MODEL_ID]: 'string',
[DEVICE_PROCESSOR_COUNT]: 'integer',
[DEVICE_SIMULATOR]: 'boolean',
[DEVICE_LOW_POWER_MODE]: 'boolean',
[EFFECTIVECONNECTIONTYPE]: 'string',
[ENVIRONMENT]: 'string',
[ERROR_TYPE]: 'string',
Expand Down Expand Up @@ -10821,6 +10842,7 @@ export type AttributeName =
| typeof DEVICE_MODEL_ID
| typeof DEVICE_PROCESSOR_COUNT
| typeof DEVICE_SIMULATOR
| typeof DEVICE_LOW_POWER_MODE
| typeof EFFECTIVECONNECTIONTYPE
| typeof ENVIRONMENT
| typeof ERROR_TYPE
Expand Down Expand Up @@ -12703,6 +12725,17 @@ export const ATTRIBUTE_METADATA: Record<AttributeName, AttributeMetadata> = {
example: false,
changelog: [{ version: 'next', prs: [300], description: 'Added device.simulator attribute' }],
},
[DEVICE_LOW_POWER_MODE]: {
brief: 'Whether the device is in Low Power Mode.',
type: 'boolean',
pii: {
isPii: 'false',
},
isInOtel: false,
sdks: ['sentry.cocoa'],
example: true,
changelog: [{ version: 'next', description: 'Added device.low_power_mode attribute' }],
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

TypeScript Attributes type missing new attribute entry

Medium Severity

DEVICE_LOW_POWER_MODE is added to the constant, ATTRIBUTE_TYPE map, AttributeName union, and ATTRIBUTE_METADATA, but the Attributes mapped type near line 17247 is missing [DEVICE_LOW_POWER_MODE]?: DEVICE_LOW_POWER_MODE_TYPE;. The entry jumps from DEVICE_SIMULATOR directly to EFFECTIVECONNECTIONTYPE. TypeScript consumers using the Attributes type won't get type-safe access to this new attribute.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f95b230. Configure here.

[EFFECTIVECONNECTIONTYPE]: {
brief: 'Specifies the estimated effective type of the current connection (e.g. slow-2g, 2g, 3g, 4g).',
type: 'string',
Expand Down
17 changes: 17 additions & 0 deletions model/attributes/device/device__low_power_mode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"key": "device.low_power_mode",
"brief": "Whether the device is in Low Power Mode.",
"type": "boolean",
"pii": {
"key": "false"
},
"is_in_otel": false,
"sdks": ["sentry.cocoa"],
"example": true,
"changelog": [
{
"version": "next",
"description": "Added device.low_power_mode attribute"
}
]
}
10 changes: 10 additions & 0 deletions python/src/sentry_conventions/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,16 @@ class ATTRIBUTE_NAMES(metaclass=_AttributeNamesMeta):
Example: false
"""

# Path: model/attributes/device/device__low_power_mode.json
DEVICE_LOW_POWER_MODE: Literal["device.low_power_mode"] = "device.low_power_mode"
"""Whether the device is in Low Power Mode.

Type: bool
Contains PII: false
Defined in OTEL: No
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The new attribute DEVICE_LOW_POWER_MODE was added to ATTRIBUTE_NAMES but is missing its corresponding entry in the ATTRIBUTE_METADATA dictionary in the Python file.
Severity: HIGH

Suggested Fix

Add the missing AttributeMetadata entry for "device.low_power_mode" to the ATTRIBUTE_METADATA dictionary in python/src/sentry_conventions/attributes.py. This will align the Python implementation with the TypeScript version and prevent runtime KeyError exceptions.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: python/src/sentry_conventions/attributes.py#L1535

Potential issue: The Python bindings file was updated to include the new
`DEVICE_LOW_POWER_MODE` constant in the `ATTRIBUTE_NAMES` class. However, the
corresponding entry for this attribute was not added to the `ATTRIBUTE_METADATA`
dictionary. As a result, any Python code that attempts to look up the metadata for this
new attribute, for example by calling `ATTRIBUTE_METADATA["device.low_power_mode"]`,
will encounter a `KeyError` at runtime. This creates an inconsistency where the
attribute constant exists but its metadata is inaccessible.

Did we get this right? 👍 / 👎 to inform future reviews.

Example: true
"""
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Python bindings missing metadata and TypedDict entries

High Severity

The device.low_power_mode attribute's Python bindings are incomplete. While the constant name exists, entries are missing from the ATTRIBUTE_METADATA dictionary and the Attributes TypedDict. This prevents Python consumers from accessing its metadata and type checkers from validating it, making the attribute effectively unusable.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f95b230. Configure here.


# Path: model/attributes/deviceMemory.json
DEVICEMEMORY: Literal["deviceMemory"] = "deviceMemory"
"""The estimated total memory capacity of the device, only a rough estimation in gigabytes.
Expand Down
Loading