C++ Server-Side SDK
LaunchDarkly SDK
Public Member Functions | List of all members
launchdarkly::server_side::hooks::TrackSeriesContext Class Reference

#include <hook.hpp>

Public Member Functions

 TrackSeriesContext (Context const &context, std::string key, std::optional< double > metric_value, std::optional< std::reference_wrapper< Value const >> data, HookContext const &hook_context, std::optional< std::string > environment_id)
 
Context const & TrackContext () const
 
std::string_view Key () const
 
std::optional< double > MetricValue () const
 
std::optional< std::reference_wrapper< Value const > > Data () const
 
std::optional< std::string_view > EnvironmentId () const
 
HookContext const & HookCtx () const
 

Detailed Description

Context for track series handlers. Provides readonly information about the track call being performed.

Lifetime: Objects of this type are valid only during the execution of a hook stage. Do not store references, pointers, or string_views from this context. If you need any data beyond the stage execution, copy it to owned types (e.g., std::string, Value).

Constructor & Destructor Documentation

◆ TrackSeriesContext()

launchdarkly::server_side::hooks::TrackSeriesContext::TrackSeriesContext ( Context const &  context,
std::string  key,
std::optional< double >  metric_value,
std::optional< std::reference_wrapper< Value const >>  data,
HookContext const &  hook_context,
std::optional< std::string >  environment_id 
)

Constructs a track series context.

Parameters
contextThe context associated with the track call.
keyThe event key.
metric_valueOptional metric value.
dataOptional reference to application-specified data.
hook_contextAdditional context data provided by the caller.
environment_idOptional environment ID.

Member Function Documentation

◆ Data()

std::optional< std::reference_wrapper< Value const > > launchdarkly::server_side::hooks::TrackSeriesContext::Data ( ) const

Returns the application-specified data associated with the track call.

Lifetime: The returned reference (if present) is valid only during the execution of the current hook stage. If you need the value beyond this call, make a copy.

Returns
Reference to the data, or std::nullopt if not provided.

◆ EnvironmentId()

std::optional< std::string_view > launchdarkly::server_side::hooks::TrackSeriesContext::EnvironmentId ( ) const

Returns the environment ID if available. Only available once initialization has completed.

Lifetime: If present, the returned string_view is valid only during the execution of the current hook stage. If you need the environment ID beyond this call, copy it to a std::string.

Returns
The environment ID as optional string_view, or std::nullopt if not available.

◆ HookCtx()

HookContext const & launchdarkly::server_side::hooks::TrackSeriesContext::HookCtx ( ) const

Returns the hook context provided by the caller.

This contains arbitrary data that the caller wants to pass through to hooks, such as OpenTelemetry span parents.

Lifetime: The returned reference is valid only during the execution of the current hook stage.

Returns
Reference to the hook context.

◆ Key()

std::string_view launchdarkly::server_side::hooks::TrackSeriesContext::Key ( ) const

Returns the key associated with the track call.

Lifetime: The returned string_view is valid only during the execution of the current hook stage. If you need the key beyond this call, copy it to a std::string.

Returns
The event key as a string_view (immutable).

◆ MetricValue()

std::optional< double > launchdarkly::server_side::hooks::TrackSeriesContext::MetricValue ( ) const

Returns the optional metric value associated with the track call.

Returns
The metric value, or std::nullopt if not provided.

◆ TrackContext()

Context const & launchdarkly::server_side::hooks::TrackSeriesContext::TrackContext ( ) const

Returns the context associated with the track call.

Lifetime: The returned Context reference is valid only during the execution of the current hook stage. If you need context data beyond this call, copy the necessary fields.

Returns
The context.

The documentation for this class was generated from the following files: