Skip to content

feat: Inline context for custom events #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 14, 2025
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # If you only need the current version keep this.

- name: Install PCRE development libraries
run: sudo apt-get update && sudo apt-get install -y libpcre3-dev

- uses: ./.github/actions/setup-cache
with:
Expand Down
2 changes: 1 addition & 1 deletion contract-tests/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ getAppStatus =
, "context-type"
, "secure-mode-hash"
, "tags"
, "inline-context"
, "inline-context-all"
, "anonymous-redaction"
, "omit-anonymous-contexts"
, "client-prereq-events"
Expand Down
4 changes: 2 additions & 2 deletions src/LaunchDarkly/Server/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import LaunchDarkly.Server.Config.ClientContext (ClientContext (..))
import LaunchDarkly.Server.Config.HttpConfiguration (HttpConfiguration (..))
import LaunchDarkly.Server.Config.Internal (ApplicationInfo, Config, getApplicationInfoHeader, shouldSendEvents)
import LaunchDarkly.Server.Context (getValue)
import LaunchDarkly.Server.Context.Internal (Context (Invalid), getCanonicalKey, getKey, getKeys, optionallyRedactAnonymous, redactContext)
import LaunchDarkly.Server.Context.Internal (Context (Invalid), getCanonicalKey, getKey, optionallyRedactAnonymous, redactContext, redactContextRedactAnonymous)
import LaunchDarkly.Server.DataSource.Internal (DataSource (..), DataSourceFactory, DataSourceUpdates (..), defaultDataSourceUpdates, nullDataSourceFactory)
import LaunchDarkly.Server.Details (EvalErrorKind (..), EvaluationDetail (..), EvaluationReason (..))
import LaunchDarkly.Server.Evaluate (evaluateDetail, evaluateTyped)
Expand Down Expand Up @@ -293,7 +293,7 @@ track client context key value metric = do
makeBaseEvent $
CustomEvent
{ key = key
, contextKeys = getKeys context
, context = redactContextRedactAnonymous (getField @"config" client) context
, metricValue = metric
, value = value
}
Expand Down
4 changes: 2 additions & 2 deletions src/LaunchDarkly/Server/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ makeFeatureEventWithContextPayload context includeReason event =

data CustomEvent = CustomEvent
{ key :: !Text
, contextKeys :: !(KeyMap Text)
, context :: !Value
, metricValue :: !(Maybe Double)
, value :: !(Maybe Value)
}
Expand All @@ -226,7 +226,7 @@ instance ToJSON CustomEvent where
filter
((/=) Null . snd)
[ ("key", toJSON $ getField @"key" ctx)
, ("contextKeys", toJSON $ getField @"contextKeys" ctx)
, ("context", toJSON $ getField @"context" ctx)
, ("metricValue", toJSON $ getField @"metricValue" ctx)
, ("data", toJSON $ getField @"value" ctx)
]
Expand Down
Loading