3030/** Details of a session including a unique Id and related information. */
3131public class PerfSession implements Parcelable {
3232
33- private final String internalSessionId ;
33+ private static final String SESSION_ID_PREFIX = "fireperf-session" ;
34+ private final String sessionId ;
3435 private final Timer creationTime ;
3536
3637 private boolean isGaugeAndEventCollectionEnabled = false ;
@@ -39,42 +40,39 @@ public class PerfSession implements Parcelable {
3940 * Creates a PerfSession object and decides what metrics to collect.
4041 */
4142 public static PerfSession createNewSession () {
42- String prunedSessionId = UUID .randomUUID ().toString ().replace ("-" , "" );
43+ String prunedSessionId = SESSION_ID_PREFIX + UUID .randomUUID ().toString ().replace ("-" , "" );
4344 PerfSession session = new PerfSession (prunedSessionId , new Clock ());
4445 session .setGaugeAndEventCollectionEnabled (shouldCollectGaugesAndEvents ());
45-
46- // Every time a PerfSession is created, it sets the AQS to null. Once an AQS is received,
47- // SessionManagerKt verifies if this is an active session, and sets the AQS session ID.
48- // The assumption is that new PerfSessions *should* be limited to either App Start, or through
49- // AQS.
50- FirebasePerformanceSessionSubscriber .Companion .getInstance ().reportPerfSession (prunedSessionId );
51-
5246 return session ;
5347 }
5448
5549 /** Creates a PerfSession with the provided {@code sessionId} and {@code clock}. */
5650 @ VisibleForTesting (otherwise = VisibleForTesting .PACKAGE_PRIVATE )
57- public PerfSession (String internalSessionId , Clock clock ) {
58- this .internalSessionId = internalSessionId ;
51+ public PerfSession (String sessionId , Clock clock ) {
52+ this .sessionId = sessionId ;
5953 creationTime = clock .getTime ();
54+ // Every time a PerfSession is created, it sets the AQS to null. Once an AQS is received,
55+ // SessionManagerKt verifies if this is an active session, and sets the AQS session ID.
56+ // The assumption is that new PerfSessions *should* be limited to either App Start, or through
57+ // AQS.
58+ FirebasePerformanceSessionSubscriber .Companion .getInstance ().reportPerfSession (sessionId );
6059 }
6160
6261 private PerfSession (@ NonNull Parcel in ) {
6362 super ();
64- internalSessionId = in .readString ();
63+ sessionId = in .readString ();
6564 isGaugeAndEventCollectionEnabled = in .readByte () != 0 ;
6665 creationTime = in .readParcelable (Timer .class .getClassLoader ());
6766 }
6867
6968 /** Returns the sessionId of the object. */
7069 public String sessionId () {
71- return FirebasePerformanceSessionSubscriber .Companion .getInstance ()
72- .getAqsMappedToPerfSession (this .internalSessionId );
70+ return this .sessionId ;
7371 }
7472
75- @ VisibleForTesting ( otherwise = VisibleForTesting . PACKAGE_PRIVATE )
76- public String getInternalSessionId () {
77- return internalSessionId ;
73+ private String aqsSessionId () {
74+ return FirebasePerformanceSessionSubscriber . Companion . getInstance ()
75+ . getAqsMappedToPerfSession ( this . sessionId ) ;
7876 }
7977
8078 /**
@@ -127,7 +125,7 @@ public boolean isSessionRunningTooLong() {
127125 /** Creates and returns the proto object for PerfSession object. */
128126 public com .google .firebase .perf .v1 .PerfSession build () {
129127 com .google .firebase .perf .v1 .PerfSession .Builder sessionMetric =
130- com .google .firebase .perf .v1 .PerfSession .newBuilder ().setSessionId (sessionId ());
128+ com .google .firebase .perf .v1 .PerfSession .newBuilder ().setSessionId (aqsSessionId ());
131129
132130 // If gauge collection is enabled, enable gauge collection verbosity.
133131 if (isGaugeAndEventCollectionEnabled ) {
@@ -202,7 +200,7 @@ public int describeContents() {
202200 * @param flags Additional flags about how the object should be written.
203201 */
204202 public void writeToParcel (@ NonNull Parcel out , int flags ) {
205- out .writeString (internalSessionId );
203+ out .writeString (sessionId );
206204 out .writeByte ((byte ) (isGaugeAndEventCollectionEnabled ? 1 : 0 ));
207205 out .writeParcelable (creationTime , 0 );
208206 }
0 commit comments