Skip to content

Commit

Permalink
fix: add cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
mhayashi committed Apr 29, 2015
1 parent 6663491 commit b0dc11a
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
50 changes: 50 additions & 0 deletions cpp/ReproCpp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// ReproCpp.h
//
// Created by jollyjoester_pro on 10/31/14.
// Copyright (c) 2014 Repro Inc. All rights reserved.
//

#ifndef __REPRO_CPP_H__
#define __REPRO_CPP_H__

class ReproCpp {

public:

// Setup
static void setup(const char* token);

// Log Level
static void setLogLevel(const char* logLevel);

// Screen Recording
static void startRecording();
static void stopRecording();
static void pauseRecording();
static void resumeRecording();

// UIView Masking
static void maskWithRect(float x, float y, float width, float height, const char* key);
static void unmaskWithRect(const char* key);

// User ID
static void setUserID(const char* userId);

// Track Events
static void track(const char*eventName);
static void trackWithProperties(const char* eventName, const char* jsonDictionary);

// Crash Reporting
static void enableCrashReporting();

// Survey
static void survey();

// Usablity Testing
static void enableUsabilityTesting();

};

#endif

96 changes: 96 additions & 0 deletions cpp/ReproCpp.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//
// ReproCpp.mm
//
// Created by jollyjoester_pro on 10/31/14.
// Copyright (c) 2014 Repro Inc. All rights reserved.
//

#include "ReproCpp.h"
#import <Repro/Repro.h>

static NSString* convertCStringToNSString(const char* string) {
if (string) {
return [NSString stringWithUTF8String:string];
} else {
return @"";
}
}

static NSDictionary* convertCStringJSONToNSDictionary(const char* string) {
if (string) {
NSString* json = convertCStringToNSString(string);
NSData* data = [json dataUsingEncoding:NSUTF8StringEncoding];
return [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
} else {
return nil;
}
}

void ReproCpp::setup(const char* token) {
[Repro setup:convertCStringToNSString(token)];
}

void ReproCpp::setLogLevel(const char* logLevel) {
if ([convertCStringToNSString(logLevel) isEqualToString:@"Debug"]) {
[Repro setLogLevel:RPRLogLevelDebug];
} else if ([convertCStringToNSString(logLevel) isEqualToString:@"Info"]) {
[Repro setLogLevel:RPRLogLevelInfo];
} else if ([convertCStringToNSString(logLevel) isEqualToString:@"Warn"]) {
[Repro setLogLevel:RPRLogLevelWarn];
} else if ([convertCStringToNSString(logLevel) isEqualToString:@"Error"]) {
[Repro setLogLevel:RPRLogLevelError];
} else if ([convertCStringToNSString(logLevel) isEqualToString:@"None"]) {
[Repro setLogLevel:RPRLogLevelNone];
}
}

void ReproCpp::startRecording() {
[Repro startRecording];
}

void ReproCpp::stopRecording() {
[Repro stopRecording];
}

void ReproCpp::pauseRecording() {
[Repro pauseRecording];
}

void ReproCpp::resumeRecording() {
[Repro resumeRecording];
}

void ReproCpp::maskWithRect(float x, float y, float width, float height, const char* key) {
[Repro maskWithRect:CGRectMake(x,y,width,height) key:convertCStringToNSString(key)];
}

void ReproCpp::unmaskWithRect(const char* key) {
[Repro unmaskForKey:convertCStringToNSString(key)];
}

void ReproCpp::setUserID(const char* userId) {
[Repro setUserID:convertCStringToNSString(userId)];
}

void ReproCpp::track(const char* eventName) {
[Repro track:convertCStringToNSString(eventName) properties:nil];
}

void ReproCpp::trackWithProperties(const char* eventName, const char* jsonDictionary) {
[Repro track:convertCStringToNSString(eventName) properties:convertCStringJSONToNSDictionary(jsonDictionary)];
}

void ReproCpp::enableCrashReporting() {
[Repro enableCrashReporting];
}

// Survey
void ReproCpp::survey() {
NSError *error = nil;
[Repro survey:&error];
}

// Usablity Testing
void ReproCpp::enableUsabilityTesting() {
[Repro enableUsabilityTesting];
}

0 comments on commit b0dc11a

Please sign in to comment.