//
// Created by Nicky Romeijn on 23-06-16.
// Copyright (c) 2016 Adversitement. All rights reserved.
//

#import "ReactTagger.h"
#import "Tagger.h"

@implementation ReactTagger
static int taggerInit = NO;
@synthesize bridge = _bridge;

RCT_EXPORT_METHOD(start:(NSString *)appId :(NSString *)endpoint :(nonnull NSNumber *)dispatchInterval){
    //    if(!taggerInit){
    _tagger = [[Tagger alloc] init:appId :endpoint :dispatchInterval :true];
    taggerInit = YES;
    //    }
}

RCT_EXPORT_METHOD(trackLocation :(NSString*)location){
    [_tagger trackLocation:location];
}


RCT_EXPORT_METHOD(track:(NSString*)eventName){
    [_tagger track:eventName];
}

RCT_EXPORT_METHOD(trackWithProperties:(NSString*)eventName:(NSString*)propertiesAsJson){
    [_tagger trackWithProperties:eventName :propertiesAsJson];
}

RCT_EXPORT_METHOD(createAlias:(NSString*)alias){
    [_tagger createAlias:alias];
}

RCT_EXPORT_METHOD(identify:(NSString *)identity){
    [_tagger identify:identity];
}

RCT_EXPORT_METHOD(timeEventStartWithProperties:(NSString*)eventName:(NSString*)propertiesAsJson){
    [_tagger timeEventStartWithProperties:eventName :propertiesAsJson];
}

RCT_EXPORT_METHOD(timeEventStart:(NSString*)eventName){
    [_tagger timeEventStart:eventName];
}

RCT_EXPORT_METHOD(timeEventStop:(NSString*)eventName) {
    [_tagger timeEventStop:eventName];
}

RCT_EXPORT_MODULE(o2mcTracker);

@end
