-
Notifications
You must be signed in to change notification settings - Fork 20
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
bot filtering #79
bot filtering #79
Conversation
build |
1 similar comment
build |
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.
Mostly looks good. Some changes needed.
@@ -1,3 +1,19 @@ | |||
/* | |||
* Copyright 2017-2018, Optimizely |
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.
Thanks for adding this.
@@ -16,7 +32,7 @@ public class EventBuilderTest | |||
private string TestUserId = string.Empty; | |||
private ProjectConfig Config; | |||
private EventBuilder EventBuilder; | |||
|
|||
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.
nit. Seems unnecessary spaces got put in there. Lets undo.
OptimizelySDK/Logger/ILogger.cs
Outdated
@@ -20,6 +20,7 @@ public enum LogLevel | |||
DEBUG, | |||
INFO, | |||
ERROR, | |||
WARN, |
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.
WARN should go above ERROR IMO
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.
Also, update year
/// </summary> | ||
/// <param name="attributeKey">Key of the Attribute</param> | ||
/// <returns>Attribute ID corresponding to the provided attribute key. Attribute key if it is a reserved attribute</returns> | ||
public string GetAttributeId(string attributeKey) |
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.
Please add unit tests for this new module
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.
Already covered here:
public void TestGetAttributeIdWithReservedPrefix() |
public void TestGetAttributeIdWithInvalidAttributeKey() |
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.
Oh, good. GitHub does not render large files by default and hence missed it.
OptimizelySDK.Tests/TestData.json
Outdated
@@ -634,5 +634,6 @@ | |||
"key": "purchase" | |||
}], | |||
"revision": "15", | |||
"anonymizeIP": "false" | |||
"anonymizeIP": "false", |
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.
This will always be a boolean value
OptimizelySDK.Tests/TestData.json
Outdated
@@ -634,5 +634,6 @@ | |||
"key": "purchase" | |||
}], | |||
"revision": "15", | |||
"anonymizeIP": "false" | |||
"anonymizeIP": "false", | |||
"botFiltering": "true" |
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.
This will always be a boolean value.
{"account_id", "1592310167" }, | ||
{"client_name", "csharp-sdk" }, | ||
{"client_version", Optimizely.SDK_VERSION }, | ||
{"revision", 15 }, |
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.
Can you point me to where revision is set? It should be what it is in the datafile i.e. it should be string.
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.
https://github.com/optimizely/csharp-sdk/blob/master/OptimizelySDK/ProjectConfig.cs#L31
https://github.com/optimizely/csharp-sdk/blob/master/OptimizelySDK/ProjectConfig.cs#L266
We are deserializing it and it is set automatically.
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.
Bot revision and version need to be string and not int. Can you please fix that as well.
Thanks.
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.
Almost there. Last set of small changes needed.
public const string RESERVED_ATTRIBUTE_KEY_BUCKETING_ID_EVENT_PARAM_KEY = "optimizely_bucketing_id"; | ||
public const string BOT_FILTERING_ATTRIBUTE = "$opt_bot_filtering"; | ||
|
||
public const string USER_AGENT_ATTRIBUTE = "$opt_user_agent"; |
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.
nit. Like in other SDKs, lets consolidate all of the "special" attributes i.e. bucketing ID, bot filtering and user agent attributes.
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.
Done.
/// </summary> | ||
/// <param name="attributeKey">Key of the Attribute</param> | ||
/// <returns>Attribute ID corresponding to the provided attribute key. Attribute key if it is a reserved attribute</returns> | ||
public string GetAttributeId(string attributeKey) |
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.
Oh, good. GitHub does not render large files by default and hence missed it.
Assert.AreEqual(Config.GetAttributeId(EventBuilder.USER_AGENT_ATTRIBUTE), EventBuilder.USER_AGENT_ATTRIBUTE); | ||
|
||
// Verify that attribute Id is returned for attribute key with reserved prefix that does not exist in datafile. | ||
Assert.AreEqual(Config.GetAttributeId(EventBuilder.USER_AGENT_ATTRIBUTE), EventBuilder.USER_AGENT_ATTRIBUTE); |
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.
nit. This test is no different from the previous test. Let's have a separate example. Like lets test for $opt_reserved_prefix_attribute
OptimizelySDK.Tests/TestData.json
Outdated
@@ -634,5 +634,6 @@ | |||
"key": "purchase" | |||
}], | |||
"revision": "15", | |||
"anonymizeIP": "false" | |||
"anonymizeIP": false, | |||
"botFiltering": true | |||
} |
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.
nit. Add new line at end of file.
return attributeKey; | ||
} | ||
|
||
Logger.Log(LogLevel.ERROR, $@"Attribute key ""{attributeKey}"" is not in datafile."); |
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.
nit. Just single pair of double quotes should be good right?
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.
In verbatim strings, 2 double-quotes are used as an escape character like double backslashes in normal strings. The final string will contain attribute key in single double-quotes.
|
||
namespace OptimizelySDK.Utils | ||
{ | ||
public class ReservedAttribute |
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.
nit. Call this ControlAttribute
like in other SDKs
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.
Small changes needed. LGTM.
{ | ||
public class ReservedAttribute | ||
{ | ||
public const string BOT_FILTERING_ATTRIBUTE = "$opt_bot_filtering"; |
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.
nit. Alphabetize.
No description provided.