HomeDocumentationAPI Reference
Getting StartedAPI ReferenceBug ReportingCrash ReportingAPMHelp Center
Documentation

Setting Custom Data for iOS

Discussed here is how to set user attributes and tags, as well as log user events, and their relevant APIs for your iOS app.

User Attributes

You can assign custom attributes to your users and they will show up on your Luciq dashboard with each report. These attributes can later be used to filter reports in your dashboard.

To add a new user attribute, use the following method.

Luciq.setUserAttribute("True", withKey: "Logged in")
Luciq.setUserAttribute("False", withKey: "Completed IAP")
[Luciq setUserAttribute:@"True" withKey:@"Logged in"];
[Luciq setUserAttribute:@"18" withKey:@"Age"];

You can also retrieve or remove the current value of a certain user attribute.

let loggedIn = Luciq.userAttribute(forKey: "Logged in")
Luciq.removeUserAttribute(forKey: "Logged in")
NSString *loggedIn = [Luciq userAttributeForKey:@"Logged in"];
[Luciq removeUserAttributeForKey:@"Logged in"];

Or retrieve all user attributes.

let allUserAttributes = Luciq.userAttributes()
NSDictionary *allUserAttributes = [Luciq userAttributes];

User Events

You can log custom user events throughout your application. Custom events are automatically included with each report.

Luciq.logUserEvent(withName: "Skipped Walkthrough")
[Luciq logUserEventWithName:@"Skipped Walkthrough"];

Tags

You can add custom tags to your bug and crash reports. These tags can later be used to filter reports or set custom rules from your dashboard.

The example below demonstrates how to add tags to a report.

Luciq.appendTags(["Design", "Flow"])
[Luciq appendTags:@[@"Design", @"Flow"]];

📘

Adding tags before sending reports

Sometimes it's useful to be able to add a tag to a bug report before it's been sent. In these cases, the perfect solution would be use the event handlers of the bug reporting class. You can find more details here.

You can also get all the currently set tags as follows.

let tags = Luciq.getTags()
NSString *tags = [Luciq getTags];

Last, you can reset all the tags.

Luciq.resetTags()
[Luciq resetTags];

Managing Tags

If you'd like to remove a particular tag from your dashboard to prevent it from appearing again when entering a new tag manually, you can do so by navigating to the tags page under the settings options and remove the tag. You can also edit and rename the tag.


Feature Flags

In certain scenarios, you might find that you're rolling out different experiments to different users, where your user base would see different features depending on what's enabled for them. In scenarios such as these, you'll want to keep track of the enabled experiments for each user and even filter by them.

Notes:

  1. Feature Flag Naming: Each feature flag name should not exceed 70 characters and each variant name should not exceed 70 characters. Otherwise, they will get ignored by the SDK. Note that feature flag names are case-insensitive.
  2. Feature Flag Persistence: Feature flag persist beyond individual sessions and are not automatically removed at the end of a session. Additionally, calling the logOut function does not impact the existence of the feature flag. The feature flag is only removed when you call the removing method or the clearing method.
  3. The amount of feature flags sent in a session is 200 with maximum of 1 variant per a multivariate feature flag. For example, a feature flag that has 3 variants sent within 1 session will only be sent to our backend as the last variant, and not all 3.

For more information on feature flags, visit Feature Flags.

Adding Feature Flags

Boolean Feature Flags - Example Usage

Below is an example of where in your code you would use feature flag. In this example, you are experimenting with feature logic that controls whether or not the user has a Dark Mode toggle available.

let flag = FeatureFlag(name: "flag")
Luciq.add(featureFlag: flag)
[Luciq addFeatureFlag: [[LCQFeatureFlag alloc] initWithName:@"boolFeatureFlag"]];

Multivariant Feature Flags - Example Usage

Below is an example of where in your code you would use feature flag with multiple variants. In this example, you are experimenting with feature logic that controls multiple versions of a specific feature.

let flagWithVariant = FeatureFlag(name: "flag", variant: "variant")
Luciq.add(featureFlag: flagWithVariant)
[Luciq addFeatureFlag: [[LCQFeatureFlag alloc] initWithName:@"stringFeatureFlag" variant:@"Value1"]];

Removing Feature Flags

If your feature flag is concluded or you would like to simply remove it, you can use this method:

Luciq.removeFeatureFlag("stringFeatureFlag")
[Luciq removeFeatureFlag:@"boolFeatureFlag"];
[Luciq removeFeatureFlags:@[flag1]];

Clearing Feature Flags

You can use the below method to clear all the Feature Flags from your reports:

Luciq.removeAllFeatureFlags()
[Luciq removeAllFeatureFlags];