Skip to content

Commit

Permalink
Do not trace when in debug
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Jul 22, 2021
1 parent 2b80149 commit 4c76071
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 8 additions & 2 deletions android/app/src/main/java/com/expensify/chat/StartupTimer.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.expensify.chat;
import android.util.Log;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
Expand Down Expand Up @@ -27,7 +29,11 @@ public void stop() {
}

public static void start() {
trace = FirebasePerformance.getInstance().newTrace("js_loaded");
trace.start();
if (BuildConfig.DEBUG) {
Log.d("StartupTimer", "Metric tracing disabled in DEBUG");
} else {
trace = FirebasePerformance.getInstance().newTrace("js_loaded");
trace.start();
}
}
}
4 changes: 4 additions & 0 deletions ios/ExpensifyCash/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
center.delegate = self;

[RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView]; // <- initialization using the storyboard file name

// Start the "js_load" custom performance tracing metric. This timer is stopped by a native
// module in the JS so we can measure total time starting in the native layer and ending in
// the JS layer.
[RCTStartupTimer start];
return YES;
}
Expand Down
9 changes: 8 additions & 1 deletion ios/ExpensifyCash/RCTStartupTimer.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ @implementation RCTStartupTimer
static FIRTrace *trace = nil;

+ (void)start {
#if DEBUG
// We don't want to record this on debug since it will skew the metrics we collect
NSLog(@"[StartupTimer] Metric tracing disabled in DEBUG");
#else
trace = [FIRPerformance startTraceWithName:@"js_loaded"];
#endif
}

RCT_EXPORT_METHOD(stop)
{
[trace stop];
if (trace) {
[trace stop];
}
}

// To export a module named StartupTimer
Expand Down

0 comments on commit 4c76071

Please sign in to comment.