This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android]added generic performance event
- Loading branch information
osana
committed
Jan 28, 2019
1 parent
b53ea9b
commit 366f43b
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
68 changes: 68 additions & 0 deletions
68
...boxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/PerformanceEvent.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.mapbox.mapboxsdk.module.telemetry; | ||
|
||
import com.mapbox.android.telemetry.Event; | ||
|
||
import android.os.Bundle; | ||
import android.os.Parcel; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
|
||
/** | ||
* Generic Performance Event that can be used for performance measurements. | ||
* Customer measurements can be added to the bundle. | ||
*/ | ||
public class PerformanceEvent extends Event { | ||
private static final String PERFORMANCE_TRACE = "performance.trace"; | ||
|
||
private final String event; | ||
|
||
private final String created; | ||
|
||
private final String sessionId; | ||
|
||
private final Bundle data; | ||
|
||
private static final SimpleDateFormat DATE_FORMAT = | ||
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US); | ||
|
||
PerformanceEvent(String sessionId, Bundle data) { | ||
this.event = PERFORMANCE_TRACE; | ||
this.created = DATE_FORMAT.format(new Date()); | ||
this.sessionId = sessionId; | ||
this.data = data; | ||
} | ||
|
||
private PerformanceEvent(Parcel in) { | ||
this.event = in.readString(); | ||
this.created = in.readString(); | ||
this.sessionId = in.readString(); | ||
this.data = in.readBundle(); | ||
} | ||
|
||
@Override | ||
public int describeContents() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void writeToParcel(Parcel parcel, int i) { | ||
parcel.writeString(event); | ||
parcel.writeString(created); | ||
parcel.writeString(sessionId); | ||
parcel.writeBundle(data); | ||
} | ||
|
||
public static final Creator<PerformanceEvent> CREATOR = new Creator<PerformanceEvent>() { | ||
@Override | ||
public PerformanceEvent createFromParcel(Parcel in) { | ||
return new PerformanceEvent(in); | ||
} | ||
|
||
@Override | ||
public PerformanceEvent[] newArray(int size) { | ||
return new PerformanceEvent[size]; | ||
} | ||
}; | ||
} |
This file contains 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