Skip to content

Commit

Permalink
release: 2.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Repro Bot committed Feb 11, 2018
1 parent 3d87cbf commit 5e0caba
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 18 deletions.
6 changes: 4 additions & 2 deletions Repro.embeddedframework/Repro.framework/Headers/Repro.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ typedef NS_ENUM(NSInteger, RPRLogLevel) {
+ (void)setUserID:(NSString *)userID;
+ (NSString *)getUserID;
+ (NSString *)getDeviceID;
+ (void)setUserProfile:(NSString *)value forKey:(NSString *)key;
+ (void)setUserProfile:(NSDictionary *)profile;
+ (void)setStringUserProfile:(NSString*)value forKey:(NSString*)key;
+ (void)setIntUserProfile:(int)value forKey:(NSString*)key;
+ (void)setDoubleUserProfile:(double)value forKey:(NSString*)key;
+ (void)setDateUserProfile:(NSDate*)value forKey:(NSString*)key;

// Event tracking
+ (void)track:(NSString*)name properties:(NSDictionary*)properties;
Expand Down
Binary file modified Repro.embeddedframework/Repro.framework/Info.plist
Binary file not shown.
Binary file modified Repro.embeddedframework/Repro.framework/Repro
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 7 additions & 5 deletions cpp/ReproCpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

#include <string>
#include <map>

using std::string;
using std::map;
#include <ctime>

class ReproCpp {

Expand All @@ -36,8 +34,12 @@ class ReproCpp {

// User Profile
static void setUserID(const char* userId);
static void setUserProfile(const char* key, const char* value);
static void setUserProfile(const std::map<std::string, std::string> &profile);
static const char* getUserID();
static const char* getDeviceID();
static void setStringUserProfile(const char* key, const char* value);
static void setIntUserProfile(const char* key, int value);
static void setDoubleUserProfile(const char* key, double value);
static void setDateUserProfile(const char* key, std::time_t value);

// Event Tracking
static void track(const char*eventName);
Expand Down
42 changes: 31 additions & 11 deletions cpp/ReproCpp.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
}
}

static const char* convertNSStringToCString(NSString* string) {
if (string) {
const char* src = [string UTF8String];
char* dst = (char*)malloc(strlen(src) + 1);
strcpy(dst, src);
return dst;
} else {
return "";
}
}

static NSDictionary* convertCStringJSONToNSDictionary(const char* string) {
if (string) {
NSString* json = convertCStringToNSString(string);
Expand Down Expand Up @@ -72,19 +83,28 @@
[Repro setUserID:convertCStringToNSString(userId)];
}

void ReproCpp::setUserProfile(const char* key, const char* value) {
[Repro setUserProfile:convertCStringToNSString(value) forKey:convertCStringToNSString(key)];
const char* ReproCpp::getUserID() {
return convertNSStringToCString([Repro getUserID]);
}

void ReproCpp::setUserProfile(const std::map<std::string, std::string> &profile) {
std::map<std::string, std::string>::const_iterator iter;
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
for (iter = profile.begin(); iter != profile.end(); iter++) {
NSString *key = [NSString stringWithUTF8String:iter->first.c_str()];
NSString *value = [NSString stringWithUTF8String:iter->second.c_str()];
dict[key] = value;
}
[Repro setUserProfile:[NSDictionary dictionaryWithDictionary:dict]];
const char* ReproCpp::getDeviceID() {
return convertNSStringToCString([Repro getDeviceID]);
}

void ReproCpp::setStringUserProfile(const char* key, const char* value) {
[Repro setStringUserProfile:convertCStringToNSString(value) forKey:convertCStringToNSString(key)];
}

void ReproCpp::setIntUserProfile(const char* key, int value) {
[Repro setIntUserProfile:value forKey:convertCStringToNSString(key)];
}

void ReproCpp::setDoubleUserProfile(const char* key, double value) {
[Repro setDoubleUserProfile:value forKey:convertCStringToNSString(key)];
}

void ReproCpp::setDateUserProfile(const char* key, std::time_t value) {
[Repro setDateUserProfile:[NSDate dateWithTimeIntervalSince1970:value] forKey:convertCStringToNSString(key)];
}

void ReproCpp::track(const char* eventName) {
Expand Down

0 comments on commit 5e0caba

Please sign in to comment.