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
Added metadata to NavigationPerformanceEvent #1820
Conversation
1b41a89
to
29e4f74
Compare
Codecov Report
@@ Coverage Diff @@
## master #1820 +/- ##
============================================
- Coverage 31.96% 31.82% -0.14%
+ Complexity 949 947 -2
============================================
Files 242 244 +2
Lines 8506 8533 +27
Branches 647 646 -1
============================================
- Hits 2719 2716 -3
- Misses 5540 5570 +30
Partials 247 247 |
29e4f74
to
d285dfa
Compare
@@ -10,8 +11,9 @@ | |||
private static final String IS_PLUGGED_IN_KEY = "is_plugged_in"; | |||
private static final String BATTERY_EVENT_NAME = "battery_event"; | |||
|
|||
BatteryEvent(String sessionId, float batteryPercentage, boolean isPluggedIn) { | |||
super(sessionId, BATTERY_EVENT_NAME); | |||
BatteryEvent(Context context, String sessionId, float batteryPercentage, boolean isPluggedIn, |
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.
Is the Context
necessary here?
|
||
NavigationPerformanceEvent(String sessionId, String eventName) { | ||
NavigationPerformanceEvent(String sessionId, String eventName, |
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.
There are now two constructors for the NavigationPerformanceEvent, one for creating an event with metadata, and one for creating an event without metadata.
Is this necessary? Wondering if we always want to capture the metadata 🤔 I guess so, right?
} | ||
|
||
NavigationPerformanceEvent(@Nullable Context context, String sessionId, String eventName, | ||
NavigationPerformanceMetadata metadata) { |
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.
Is this necessary? Wondering if we always want to capture the metadata 🤔 I guess so, right?
Actually, the metadata is a parameter in both constructors.
attributes.add(new Attribute(EVENT_NAME, eventName)); | ||
if (context != null) { |
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.
Is this necessary? Wondering if we always want to capture the screen density 🤔 I guess so, right?
attributes.add(new Attribute(EVENT_NAME, eventName)); | ||
if (context != null) { | ||
attributes.add(new Attribute(SCREEN_DENSITY, getScreenDensity(context))); |
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.
Is the
Context
necessary here?
What about passing in the screen density through the constructor so the Context
wouldn't be necessary?
|
||
NavigationPerformanceMetadata(Context context) { | ||
this.version = VERSION; | ||
this.screenSize = getScreenSize(context); |
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.
Is the
Context
necessary here?
What about passing in the screen size through the constructor so the Context
wouldn't be necessary?
NavigationPerformanceMetadata(Context context) { | ||
this.version = VERSION; | ||
this.screenSize = getScreenSize(context); | ||
this.country = getCountry(context); |
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.
Is the
Context
necessary here?
What about passing in the country through the constructor so the Context
wouldn't be necessary?
this.device = DEVICE; | ||
this.abi = ABI; | ||
this.brand = BRAND; | ||
this.ram = getTotalMemory(context); |
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.
Is the
Context
necessary here?
What about passing in the total memory through the constructor so the Context
wouldn't be necessary?
private final String gpu; | ||
private final String manufacturer; | ||
|
||
NavigationPerformanceMetadata(Context context) { |
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.
Is the
Context
necessary here?
Shouldn't NavigationPerformanceMetadata
be a DTO / POJO?
ac8e505
to
2916f28
Compare
Ready for re-review @Guardiola31337 |
@@ -10,7 +10,7 @@ | |||
private static final String INITIAL_GPS_EVENT_NAME = "initial_gps_event"; | |||
|
|||
InitialGpsEvent(double elapsedTime, String sessionId) { | |||
super(sessionId, INITIAL_GPS_EVENT_NAME); | |||
super(sessionId, INITIAL_GPS_EVENT_NAME, null); |
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.
Wondering why we aren't capturing the metadata for InitialGpsEvent
🤔 Is there any limitation?
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.
Yes @Guardiola31337 there is a race condition with the InitialGpsEventFactory
where it's initialized before NavigationTelemetry
is initialized. I tried initializing it later but got an error, I don't remember what it was.
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.
Could we add a quick TODO
comment so we don't forget to include the metadata in InitialGpsEvent
s eventually?
import android.os.Build; | ||
import android.util.DisplayMetrics; | ||
|
||
public class MetadataBuilder { |
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.
Could MetadaBuilder
be package-private?
...tion/src/main/java/com/mapbox/services/android/navigation/v5/navigation/MetadataBuilder.java
Show resolved
Hide resolved
attributes.add(new Attribute(EVENT_NAME, eventName)); | ||
} | ||
|
||
private String getScreenDensity(Context context) { |
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.
Noticed that we're not adding the screen density as attribute anymore, was that on purpose? If so, we should remove this method, 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.
Yes it was on purpose, I don't think it's a good idea to add added complexity for an attribute we're not sure we'll even need.
2916f28
to
d4489ce
Compare
… without metadata
…en density attribute
31e14d8
to
5a946de
Compare
Title
Added metadata to NavigationPerformanceEvent
What's the goal?
Goal is to add metadata to NavigationPerformanceEvent
How is it being implemented?
There are now two constructors for the NavigationPerformanceEvent, one for creating an event with metadata, and one for creating an event without metadata.
How has this been tested?
Checklist