hyperlab / TiMixpanel

Mixpanel integration for Titanium Mobile
22 stars 12 forks source link

Willing to help out here #1

Closed wienke closed 10 years ago

wienke commented 10 years ago

What would be the first thing I can help you with? I just started making this module as well.

Cheers, Wienke

jonatansberg commented 10 years ago

Cool! There are plenty of things to do:

Where do you want to start? (:

On 10 apr 2014, at 15:43, Wienke notifications@github.com wrote:

What would be the first thing I can help you with? I just started making this module as well.

Cheers, Wienke

— Reply to this email directly or view it on GitHub.

wienke commented 10 years ago

Cool, I will start with the push notifications and setting the flush interval.

Could you setup the Android module environment with all the right settings?

jonatansberg commented 10 years ago

I'll take a look at that later tonight

wienke commented 10 years ago

Cool, will sent you the pull request when I have tested it.

wienke commented 10 years ago

Adding this to the module should make it possible to set the device token and the flush interval. My experience with making modules is to small to fix this. The setFlushInterval is not excepting integers. The addPushDeviceToken is not excepting strings either.

Will try to have a look at the Android version this weekend.

// add the device token to receive pushnotifications

// set the flush interval

2014-04-10 17:40 GMT+02:00 Jonatan Lundin notifications@github.com:

I'll take a look at that later tonight

Reply to this email directly or view it on GitHubhttps://github.com/hyperlab/TiMixpanel/issues/1#issuecomment-40101003 .

jonatansberg commented 10 years ago

I can understand that the push-part does not work since I think it requires data to be in another format.. Not sure about the flushing though.

jonatansberg commented 10 years ago

Added a delegate (9f1b756d337a5c7d5526681d70c7cbc8bdd185cc) to at least log when data gets flushed since I cant get the Mixpanel logging to work..

But do you need to set the interval manually? Flushing on background seems to work just fine.

wienke commented 10 years ago

The type of the push notification is NSData but in Titanium it is a string. Is this something that could help us?

http://stackoverflow.com/questions/1587407/iphone-device-token-nsdata-or-nsstring

Mean while I am trying to get MixPanel and Appcelerator to help out. For them this is yet another good PR moment.

2014-04-11 19:36 GMT+02:00 Jonatan Lundin notifications@github.com:

I can understand that the push-part does not work since I think it requires data to be in another format.. Not sure about the flushing though.

Reply to this email directly or view it on GitHubhttps://github.com/hyperlab/TiMixpanel/issues/1#issuecomment-40229341 .

jonatansberg commented 10 years ago

This is the code that handles push notification registration on iOS: https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiApp.m#L826

As far as I can tell there is really not any good way for us to access that raw data from within this module.

Internally the Mixpanel API converts that data into a hexadecimal string, then comes the interesting part, the token is added to the profile like any other property!

NSArray *tokens = @[[NSString stringWithString:hex]];
NSDictionary *properties = @{@"$ios_devices": tokens};
[self addPeopleRecordToQueueWithAction:@"$union" andProperties:properties];

This means that we probably can take the token provided through Titanium (as an NSString) and add it to the people data the same way:

- (void)profileAddDevice:(id)token
{
    ENSURE_STRING(token);
    NSArray *tokens = @[[NSString stringWithString:token]];
    NSDictionary *properties = @{@"$ios_devices": tokens};
    [[Mixpanel sharedInstance].people union:properties];
}

This conversation should really be turned into its own issue (and accompanying branch) though.