orta / ARAnalytics

Simplify your iOS/Mac analytics
MIT License
1.84k stars 217 forks source link

Unable to remove a user property #71

Open kylef opened 10 years ago

kylef commented 10 years ago

The current API doesn't allow for removing of a user property, there is no remove method and setUserProperty:toValue: doesn't support this.

+ (void)setUserProperty:(NSString *)property toValue:(NSString *)value {
    if (value == nil) {
        NSLog(@"ARAnalytics: Value cannot be nil ( %@ ) ", property);
        return;
    }

    [_sharedAnalytics iterateThroughProviders:^(ARAnalyticalProvider *provider) {
        [provider setUserProperty:property toValue:value];
    }];
}

Is this down to certain providers not letting these be removed?

Daniel1of1 commented 10 years ago

haven't seen them all but I imagine, will look into it. for reference, do you have an example of which provider allows you to remove?

kylef commented 10 years ago

This depends on the provider, and some providers might need to map nil to another method or value.

I'd suggest we remove the early return inside [ARAnalytics setUserProperty:toValue:] and move this into each provider that doesn't support unsetting.

/cc @briomusic

ssuchanowski commented 8 years ago

+1

I'd be good to add to that 'analytics reset' which would clear and reinit all stack - eg. after logout.

Currently I am manually checking if currentProviders is 0 to init them from scrach and do this to stop all:

NSSet *providers = [[ARAnalytics currentProviders] copy];
for (ARAnalyticalProvider *provider in providers) {
  [ARAnalytics removeProvider:provider];
}