-
Notifications
You must be signed in to change notification settings - Fork 123
Add SetDefaultEventParameters and ClearDefaultEventParameters to Analytics C++ SDK. #1719
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
Draft
jonsimantov
wants to merge
9
commits into
main
Choose a base branch
from
feat-default-event-params
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
faf31e8
Add SetDefaultEventParameters and ClearDefaultEventParameters to Anal…
google-labs-jules[bot] 8dad037
Add SetDefaultEventParameters and ClearDefaultEventParameters to Anal…
google-labs-jules[bot] 032dc37
Add SetDefaultEventParameters and ClearDefaultEventParameters to Anal…
google-labs-jules[bot] b6da98c
Add SetDefaultEventParameters and ClearDefaultEventParameters to Anal…
google-labs-jules[bot] 242777d
Here's a summary of the changes I've made to add `SetDefaultEventPara…
google-labs-jules[bot] f743e52
Here's a summary of the changes I've made to add `SetDefaultEventPara…
google-labs-jules[bot] 8ddab84
Here's what I've done to add `SetDefaultEventParameters` and `ClearDe…
google-labs-jules[bot] 573b647
I've added `SetDefaultEventParameters` and `ClearDefaultEventParamete…
google-labs-jules[bot] b2b225d
Add SetDefaultEventParameters and ClearDefaultEventParameters to Anal…
google-labs-jules[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,7 +306,7 @@ void LogEvent(const char* name, const Parameter* parameters, size_t number_of_pa | |
// A Variant type that couldn't be handled was passed in. | ||
LogError("LogEvent(%s): %s is not a valid parameter value type. " | ||
"No event was logged.", | ||
parameter.name, Variant::TypeName(parameter.value.type())); | ||
parameter.name, firebase::Variant::TypeName(parameter.value.type())); | ||
} | ||
} | ||
[FIRAnalytics logEventWithName:@(name) parameters:parameters_dict]; | ||
|
@@ -373,6 +373,44 @@ void SetSessionTimeoutDuration(int64_t milliseconds) { | |
setSessionTimeoutInterval:static_cast<NSTimeInterval>(milliseconds) / kMillisecondsPerSecond]; | ||
} | ||
|
||
void SetDefaultEventParameters(const std::map<std::string, Variant>& default_parameters) { | ||
FIREBASE_ASSERT_RETURN_VOID(internal::IsInitialized()); | ||
NSMutableDictionary* ns_default_parameters = | ||
[[NSMutableDictionary alloc] initWithCapacity:default_parameters.size()]; | ||
for (const auto& pair : default_parameters) { | ||
NSString* key = SafeString(pair.first.c_str()); | ||
const Variant& value = pair.second; | ||
|
||
if (value.is_null()) { | ||
[ns_default_parameters setObject:[NSNull null] forKey:key]; | ||
} else if (value.is_int64()) { | ||
[ns_default_parameters setObject:[NSNumber numberWithLongLong:value.int64_value()] | ||
forKey:key]; | ||
} else if (value.is_double()) { | ||
[ns_default_parameters setObject:[NSNumber numberWithDouble:value.double_value()] forKey:key]; | ||
} else if (value.is_string()) { | ||
[ns_default_parameters setObject:SafeString(value.string_value()) forKey:key]; | ||
} else if (value.is_bool()) { | ||
[ns_default_parameters setObject:[NSNumber numberWithBool:value.bool_value()] forKey:key]; | ||
} else if (value.is_vector() || value.is_map()) { | ||
LogError("SetDefaultEventParameters: Value for key '%s' has type '%s' which is not supported " | ||
"for default event parameters. Only string, int64, double, bool, and null are " | ||
"supported. Skipping.", | ||
pair.first.c_str(), Variant::TypeName(value.type())); | ||
} else { | ||
LogError("SetDefaultEventParameters: Value for key '%s' has an unexpected type '%s' which is " | ||
"not supported. Skipping.", | ||
pair.first.c_str(), Variant::TypeName(value.type())); | ||
} | ||
} | ||
[FIRAnalytics setDefaultEventParameters:ns_default_parameters]; | ||
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. Double-check FIRAnalytics setDefaultEventParameters -- if we pass in an empty dictionary, will it clear the parameters? This could happen if every single value we specified was an invalid type. |
||
} | ||
|
||
void ClearDefaultEventParameters() { | ||
FIREBASE_ASSERT_RETURN_VOID(internal::IsInitialized()); | ||
[FIRAnalytics setDefaultEventParameters:nil]; | ||
} | ||
|
||
void ResetAnalyticsData() { | ||
MutexLock lock(g_mutex); | ||
FIREBASE_ASSERT_RETURN_VOID(internal::IsInitialized()); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Make sure that Android also treats an empty map as a no-op, similar to iOS?