ARAnalytics icon indicating copy to clipboard operation
ARAnalytics copied to clipboard

Unable to remove a user property

Open kylef opened this issue 10 years ago • 3 comments

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?

kylef avatar Apr 24 '14 11:04 kylef

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?

Daniel1of1 avatar Apr 27 '14 19:04 Daniel1of1

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

  • Google Analytics accepts nil to clear a value: http://cocoadocs.org/docsets/GoogleAnalytics-iOS-SDK/3.0.7/Protocols/GAITracker.html#//api/name/set:value:
  • Localytics (nil == delete) - http://cocoadocs.org/docsets/Localytics-iOS-Client/2.23.0/Classes/LocalyticsSession.html#//api/name/setValueForIdentifier:value:
  • Mixpanel, I think NSNull maps to clear it, i'm not too clear on this behaviour. (http://cocoadocs.org/docsets/Mixpanel/2.4.0/Classes/MixpanelPeople.html#//api/name/set:to:)

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

kylef avatar Jun 27 '14 13:06 kylef

+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];
}

ssuchanowski avatar Oct 05 '15 18:10 ssuchanowski