VOOZH about

URL: https://deepwiki.com/hypervel/sentry/6.3-version-and-sdk-identification

⇱ Version and SDK Identification | hypervel/sentry | DeepWiki


Loading...
Menu

Version and SDK Identification

Purpose and Scope

This document describes the Version class, which provides SDK identification metadata for the Hypervel Sentry integration. The class supplies a unique SDK identifier and version information that is transmitted with every request to Sentry, allowing the platform to recognize traffic from this specific integration. This metadata is primarily used by the HTTP client to populate User-Agent headers and SDK information in event payloads.

For information about the HTTP client that uses this version information, see Transport and HTTP Client. For broader utility components, see Utilities and Helpers.


Overview

The Version class serves as a central source of truth for SDK identification. It provides two key pieces of information:

  1. SDK Identifier: A unique string that identifies this integration as the Hypervel-specific Sentry PHP SDK
  2. SDK Version: The current version of the integration package, retrieved dynamically from Composer metadata

Sources: src/Version.php1-24


Class Structure

The Version class is implemented as a final class with static methods and constants. It has no instance state and cannot be extended.


Diagram: Version Class Architecture

Sources: src/Version.php9-24


SDK Identifier

The SDK identifier is a constant string that uniquely identifies the Hypervel Sentry integration among all Sentry SDKs.

ConstantValuePurpose
SDK_IDENTIFIER"sentry.php.hypervel"Unique identifier for the Hypervel integration

The identifier follows Sentry's naming convention of sentry.<language>.<framework>. This allows Sentry to:

  • Track which SDK versions are being used across their user base
  • Provide framework-specific debugging and support
  • Apply platform-specific processing rules to incoming events

The identifier is accessed via the static method getSdkIdentifier():


Sources: src/Version.php11-18


Version Retrieval

The SDK version is retrieved dynamically to ensure accuracy even when the package is installed via Composer with different version constraints.

Version Resolution Flow


Diagram: Version Resolution Flow

Implementation Details

The getSdkVersion() method implements a two-stage fallback mechanism:

  1. Primary Source: Queries Composer::getVersions() for the 'hypervel/sentry' package
  2. Fallback: Returns the SDK_VERSION constant ("3.1.0") if Composer data is unavailable

This approach ensures that:

  • The actual installed version is reported in production environments
  • The system remains functional even if Composer metadata is unavailable (e.g., in phar archives)
  • Development versions are correctly identified

Sources: src/Version.php13-23


Integration Points

The Version class is primarily consumed by the HTTP client factory to populate User-Agent headers for requests to Sentry.


Diagram: Version Usage in HTTP Communication

Usage in HttpClientFactory

The HttpClientFactory uses version information to construct User-Agent headers in the format:

sentry.php.hypervel/<version>

This header is included in all HTTP requests to the Sentry API, allowing Sentry to:

  • Track SDK usage statistics
  • Identify requests from specific SDK versions
  • Apply version-specific compatibility layers if needed

Sources: src/Version.php1-24


Constants Reference

ConstantTypeValueDescription
SDK_IDENTIFIERstring"sentry.php.hypervel"Unique identifier for the SDK in Sentry's ecosystem
SDK_VERSIONstring"3.1.0"Fallback version number used when Composer metadata is unavailable

Sources: src/Version.php11-13


Methods Reference

MethodReturn TypeDescription
getSdkIdentifier()stringReturns the SDK identifier constant
getSdkVersion()stringReturns the installed package version from Composer, or the SDK_VERSION constant as fallback

Method: getSdkIdentifier()

Signature: public static function getSdkIdentifier(): string

Returns the SDK_IDENTIFIER constant directly without any computation.

Returns: "sentry.php.hypervel"

Sources: src/Version.php15-18

Method: getSdkVersion()

Signature: public static function getSdkVersion(): string

Attempts to retrieve the actual installed version from Composer metadata. If the package version cannot be determined, falls back to the hardcoded SDK_VERSION constant.

Returns: The installed package version string, or "3.1.0" as fallback

Implementation Logic:

1. Call Composer::getVersions() to get package metadata
2. Look up 'hypervel/sentry' in the returned array
3. If found, return the version string
4. If not found, return SDK_VERSION constant

Sources: src/Version.php20-23


Design Rationale

Static Methods

The class uses static methods rather than dependency injection because:

  • Version information is truly global and immutable
  • No state needs to be maintained
  • Simplifies access throughout the codebase
  • Reduces overhead of creating unnecessary objects

Composer Integration

The integration with Composer::getVersions() ensures accurate version reporting because:

  • Users may install different versions via Composer constraints
  • Development versions (e.g., dev-main) are correctly identified
  • The actual deployed version is always reported, not the hardcoded fallback

Fallback Mechanism

The SDK_VERSION constant provides resilience when:

  • Composer autoloader is not available
  • Package is bundled in a phar archive
  • Metadata files are missing or corrupted
  • Testing environments mock Composer functionality

Sources: src/Version.php1-24


Complete API Example


Diagram: Typical Version API Usage Sequence

Sources: src/Version.php1-24