CRFilter

By default, Apteligent reports networks statistics for all URLs that are accessed by your app. Before being reported to Apteligent, each URL is stripped of any query parameters (http://foo.com?name=critter becomes http://foo.com); this helps ensure personal information is not transmitted to Apteligent.

It is also possible to customise filter blacklists that will completely discard matching URLs. They will not be reported to Apteligent.

Use the [CRFilter filterWithString:] to modify the default filtering behavior:

// Add filters at initialization
CrittercismConfig *config = [CrittercismConfig defaultConfig];
config.urlFilters = @[[CRFilter filterWithString:@"sensitiveURL"],
                      [CRFilter filterWithString:@"additionalURL"]];
[Crittercism enableWithAppID:@"MYAPPID" andConfig:config];

// Add filters later on
[Crittercism addFilter:[CRFilter filterWithString:@"anotherURL"]];
// Swift 2.X

// Add filters at initialization
let config = CrittercismConfig.defaultConfig();
config.urlFilters = [CRFilter(string: "sensitiveURL"), CRFilter(string: "additionalURL")]
Crittercism.enableWithAppID("MYAPPID", andConfig: config)

// Add filters later on
Crittercism.addFilter(CRFilter(string: "sensitiveURL"))

// Swift 3.x

// Add filters at initialization
let config : CrittercismConfig = CrittercismConfig.default()
config.urlFilters = [CRFilter(string: "sensitiveURL"), CRFilter(string: "additionalURL")]
Crittercism.enable(withAppID: appID, and config: config)

// Add filters later on
Crittercism.add(filter: CRFilter)

Note

  • Filters match URLs via case sensitive substring matching
  • Older versions of the agent did not scrub query parameters by default, and so a `queryOnlyFilter` existed. To avoid compile time errors for existing Crittercism users, this filter type can still be created, but it will be ignored by the library. This filter type is deprecated, and will be removed in a future version of the agent.

Creating a Filter

+ filterWithString:
Convenience method to create a blacklisting filter.
+ (CRFilter *)filterWithString:(NSString *)matchToken;
// Swift 2.X
class func filterWithString(matchToken: String)

// Swift 3.x
class func filter(withString: matchToken)
matchToken An NSString of the url to filter
A CRFilter object for matchToken.
+ queryPreservingFilterWithString:
Convenience method to create a filter which preserves the query portion of.
+ (CRFilter *)queryPreservingFilterWithString:(NSString *)matchToken
// Swift 2.X
class func queryPreservingFilterWithString(matchToken: String)
matchToken An NSString of the url to filter
- initWithString:
Initialize a filter that blacklists all URLs that match the specified token.
- (id)initWithString:(NSString *)matchToken;
// Swift 2.X and 3.x
init?(string matchToken: String)
matchToken An NSString of the url to filter
A CRFilter object of type CRFilterTypeBlacklist
- initWithString:andFilterType:
Initialize a filter that blacklists all URLs that match the specified token.
- (id)initWithString:(NSString *)matchToken
       andFilterType:(CRFilterType)filterType;
// Swift 2.X and 3.x
init?(string matchToken: String,
  filterType filterType: CRFilterType)
matchToken An NSString of the url to filter
filterType Indicates filter type
A CRFilter object with the indicated filter type.

Other Methods

+ applyFilter:ToURL:
Filter a URL, specifying which type of filter to use.
+ (NSString *)applyFilter:(CRFilterType)filterType
                    ToURL:(NSString *)url;
// Swift 2.X and 3.x
class func applyFilter(filterType: CRFilterType,
                        ToURL url: String)
filterType Specifies the filter type
url Specifies the url
Returns nil when a blacklist filter is specified.

Constants

CRFilterType
The filter type of CRFilter
typedef enum : NSInteger {
   CRFilterTypeScrubQuery,
   CRFilterTypeBlacklist,
   CRFilterTypePreserveQuery
} UIApplicationState;
// Swift 2.X and 3.x
enum CRFilterType : Int {
    case ScrubQuery
    case Blacklist
    case PreserveQuery
}
CRFilterTypeScrubQuery Remove all query parameters before being reported to Apteligent server
CRFilterTypeBlacklist Blacklist certain endpoints so requests sent to these URLs are not reported
CRFilterTypePreserveQuery Prevent URL query parameters from being stripped out