⏱ Estimated Time To Completion: 2 minutes

Overview of Tags

Tags in Decipher allow you to add custom metadata to your sessions, making it easier to filter, search, and organize session replays. By using the setExtras method from the Sentry SDK, you can attach key-value pairs to your sessions that will be available for filtering within Decipher.

These key-values can be arbitrary and you will be able to filter replays by these tags in Decipher.

Why Tags?

  • Targeted Analysis: Focus on specific user segments or feature implementations
  • Issue Prioritization: Quickly identify which segments are most affected by issues
  • Customer Support: Filter sessions by company to assist specific customers
  • Feature Adoption: Track which segments are using new features

Adding Tags to Your Sessions

To add custom tags to your sessions, use the setExtras method from the Sentry SDK. This method accepts an object containing key-value pairs that will be attached to the current session.

import * as Sentry from "@sentry/browser";

// Add custom tags to this session (example tags)
Sentry.setExtras({
  feature_enabled: true,
  customer_tier: "premium",
  experiment_group: "A",
});

Integrating with Segment

If you’re using Segment for analytics, you can easily integrate it with Decipher to enrich your session data:

import * as Sentry from "@sentry/browser";
import { analytics } from "@segment/analytics-next";

// Initialize Segment
analytics.load("YOUR_SEGMENT_WRITE_KEY");

// Track an event with Segment and add the same properties to Sentry
function trackWithSegmentAndSentry(eventName, properties) {
  // Track with Segment
  analytics.track(eventName, properties);

  // Add the same properties as tags in Sentry
  // Include the event name as `segment_event_name`
  // to ensure it's available in Decipher
  Sentry.setExtras({
    segment_event_name: eventName,
    ...properties,
  });
}

// Example usage
trackWithSegmentAndSentry("Feature Used", {
  featureName: "dashboard",
  userType: "admin",
  companySize: "enterprise",
});

Best Practices

  • Avoid sensitive data: Don’t include PII or sensitive information in tags
  • Combine with user identification: Use tags alongside setUser for the most comprehensive session data

That’s it! With just a few lines of code, you can add powerful filtering capabilities to your use of Decipher.