Skip to content

Methods

Marco provides several methods to help you track custom events, reset all logs at any point, and retrieve performance logs for analysis.

track

Custom performance markers can be sent at any point in app to measure specific events or actions.

For example:

// Without metadata
PerformanceTracker.track('start_event', Date.now());
// With metadata
PerformanceTracker.track('start_event', Date.now(), { data: 'meta_data' });

getLogs

You can retrieve all performance logs asynchronously using the getLogs method. This allows you to analyze performance data after it has been collected.

For example:

const logs = await PerformanceTracker.getLogs();

Logs are structured in a JSON format, and can be analyzed as needed.

resetLogs

You can clear all performance logs at any time. This can be done through the resetLogs method.

For example:

// This will clear in memory logs.
PerformanceTracker.resetLogs();
// This will clear in memory logs and also clear the persisted log files if `persistToFile` is true.
PerformanceTracker.resetLogs({ clearFiles: true });

This will reset the logs and optionally clear the persisted log files.