-
Notifications
You must be signed in to change notification settings - Fork 32
refact(audience-logs): Added and refactored audience evaluation logs. #336
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
Changes from all commits
8c5cb8a
2de57f0
1c79eca
dba9c96
6f4f2e7
fca7b01
ddd16c8
6b09583
aaae35f
6189ef2
a9ca059
27ea03a
8b3e711
4322a83
a7e7ece
ed1315c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/**************************************************************************** | ||
* Copyright 2019, Optimizely, Inc. and contributors * | ||
* Copyright 2019-2020, Optimizely, Inc. and contributors * | ||
* * | ||
* Licensed under the Apache License, Version 2.0 (the "License"); * | ||
* you may not use this file except in compliance with the License. * | ||
|
@@ -42,6 +42,24 @@ struct Project: Codable, Equatable { | |
var typedAudiences: [Audience]? | ||
var featureFlags: [FeatureFlag] | ||
var botFiltering: Bool? | ||
|
||
let logger = OPTLoggerFactory.getLogger() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a space above to make it clear from the other JSON fields? |
||
|
||
// Required since logger in not decodable | ||
enum CodingKeys: String, CodingKey { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where it's needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding |
||
// V2 | ||
case version, projectId, experiments, audiences, groups, attributes, accountId, events, revision | ||
// V3 | ||
case anonymizeIP | ||
// V4 | ||
case rollouts, typedAudiences, featureFlags, botFiltering | ||
} | ||
|
||
// Required since logger in not equatable | ||
static func ==(lhs: Project, rhs: Project) -> Bool { | ||
return lhs.version == rhs.version && lhs.projectId == rhs.projectId && lhs.experiments == rhs.experiments && | ||
lhs.audiences == rhs.audiences && lhs.groups == rhs.groups && lhs.attributes == rhs.attributes && lhs.accountId == rhs.accountId && lhs.events == rhs.events && lhs.revision == rhs.revision && lhs.anonymizeIP == rhs.anonymizeIP && lhs.rollouts == rhs.rollouts && lhs.typedAudiences == rhs.typedAudiences && lhs.featureFlags == rhs.featureFlags && lhs.botFiltering == rhs.botFiltering | ||
} | ||
} | ||
|
||
extension Project: ProjectProtocol { | ||
|
@@ -50,8 +68,13 @@ extension Project: ProjectProtocol { | |
guard let audience = getAudience(id: audienceId) else { | ||
throw OptimizelyError.conditionNoMatchingAudience(audienceId) | ||
} | ||
logger.d { () -> String in | ||
return LogMessage.audienceEvaluationStarted(audienceId, Utils.getConditionString(conditions: audience.conditions)).description | ||
} | ||
|
||
return try audience.evaluate(project: self, attributes: attributes) | ||
let result = try audience.evaluate(project: self, attributes: attributes) | ||
logger.d(.audienceEvaluationResult(audienceId, result.description)) | ||
return result | ||
} | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removed
prettySrc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated it as per python since it also doesn't log the source of the error.