Skip to content

Customers

The Customer section in Treblle provides a comprehensive view of your API’s usage by individual customers.

It helps you understand how different customers interact with your API, identify trends in their usage patterns, and pinpoint potential issues or areas for improvement.

Steps to View the Customer Section

Click on “Customers” in the left navigation bar.

Overview of the Customer Section

The Customer Dashboard provides a comprehensive overview of all your customers and their API usage.

Here’s what you’ll find:

  • Customer Profiles: A list of all your customers, identified by their name or Customer ID.

  • Request Count: The total number of API requests each customer makes.

  • Overall Percentage: The percentage of total API requests attributed to each customer, giving you a sense of their impact on your API traffic.

  • Last Active: A timestamp indicating when each customer made their last API request.

Sorting Options

To help you find the information you need, you can sort the customer list by:

  • Customer ID: Organize customers alphabetically by their ID.

  • Request Count: See your most active customers first.

  • Most Recent Request: Identify the customers who recently interacted with your API.

Customer Profile

Click on a customer’s profile to access a detailed breakdown of their API usage.

The Customer Profile includes:

  • Request History: A complete list of all API requests made by that customer.

  • Request Graph: A visual representation of the customer’s API request activity over time. This graph helps you identify peak usage periods, trends, and potential anomalies.

Adding Customer/User Information to Requests

Treblle provides two important headers that you can use to enhance your API monitoring with customer information:

  • treblle-user-id: Used to identify your customers. You can pass any value here such as ID, UUID, email, username, or company name.
  • treblle-tag-id: Used if you want to pass a trace ID across multiple microservices or use it as an additional parameter to pass more user data.

These headers can be included in either Request or Response Headers - Treblle will pick them up from both.

Steps to add the Customer Information in Treblle’s Express SDK

Here’s how you can modify your Express middleware to add these headers:

// Custom middleware to add Customer information
app.use((req, res, next) => {
if (req.user) { // Ensure the user is authenticated
req.headers['treblle-user-id'] = req.user.id; // Attach Customer ID
req.headers['treblle-tag-id'] = req.user.traceId; // Optional: Attach trace ID
}
next();
});
// Treblle Middleware
app.use(treblle({
apiKey: process.env.TREBLLE_API_KEY,
projectId: process.env.TREBLLE_PROJECT_ID
}));

Treblle Dashboard View of Customer Information

The image below shows how the customer information will appear on the Treblle dashboard once you add it to the request.

Implementing Customer ID Tracking in Other SDKs

For other SDKs, the approach is similar. Here’s how you can implement it:

  1. First, check the user authentication, and then you can retrieve the Customer ID from the authentication system.

    Terminal window
    if (isAuthenticated) {
    customerId = getCustomerIdFromSession() // Fetch Customer ID from session or token
    }
  2. After authentication, you can add the Customer ID to the request headers (typically as “treblle-user-id”).

    Terminal window
    request.headers.set('treblle-user-id', customerId)
  3. Apply middleware to track customer data in API requests.

    Terminal window
    applyMiddleware('customerTrackingMiddleware', routes)

For specific integration details for other SDKs, please refer to the Integration page.

The Customer section in Treblle gives valuable insights into how your customers use your API. It provides a clear view of each customer’s interactions, helping you spot patterns, monitor usage, and address performance or support issues early on.