@@ -1915,23 +1915,10 @@ + (void)trackInAppPurchase:(SKPaymentTransaction *)transaction
19151915 LP_END_TRY
19161916}
19171917
1918- + (void )track : (NSString *)event withValue : (double )value andInfo : (NSString *)info
1919- andArgs : (NSDictionary *)args andParameters : (NSDictionary *)params
1920- {
1921- RETURN_IF_NOOP;
1922- LP_TRY
1923-
1924- // Track should not be called in background.
1925- if (![NSThread isMainThread ]) {
1926- dispatch_sync (dispatch_get_main_queue (), ^{
1927- [self track: event withValue: value andInfo: info andArgs: args andParameters: params];
1928- });
1929- return ;
1930- }
1931-
1918+ + (NSMutableDictionary *)makeTrackArgs : (NSString *)event withValue : (double )value andInfo : (NSString *)info andArgs : (NSDictionary *)args andParameters : (NSDictionary *)params {
19321919 NSString *valueStr = [NSString stringWithFormat: @" %f " , value];
19331920 NSMutableDictionary *arguments = [NSMutableDictionary dictionaryWithObjectsAndKeys:
1934- valueStr, LP_PARAM_VALUE, nil ];
1921+ valueStr, LP_PARAM_VALUE, nil ];
19351922 if (args) {
19361923 [arguments addEntriesFromDictionary: args];
19371924 }
@@ -1948,7 +1935,25 @@ + (void)track:(NSString *)event withValue:(double)value andInfo:(NSString *)info
19481935 if ([[UIApplication sharedApplication ] applicationState ] != UIApplicationStateActive) {
19491936 arguments[@" allowOffline" ] = @YES ;
19501937 }
1938+ return arguments;
1939+ }
19511940
1941+ + (void )track : (NSString *)event withValue : (double )value andInfo : (NSString *)info
1942+ andArgs : (NSDictionary *)args andParameters : (NSDictionary *)params
1943+ {
1944+ RETURN_IF_NOOP;
1945+ LP_TRY
1946+
1947+ // Track should not be called in background.
1948+ if (![NSThread isMainThread ]) {
1949+ dispatch_sync (dispatch_get_main_queue (), ^{
1950+ [self track: event withValue: value andInfo: info andArgs: args andParameters: params];
1951+ });
1952+ return ;
1953+ }
1954+
1955+ NSMutableDictionary *arguments = [self makeTrackArgs: event withValue: value andInfo: info andArgs: args andParameters: params];
1956+
19521957 [self onStartIssued: ^{
19531958 [self trackInternal: event withArgs: arguments andParameters: params];
19541959 }];
@@ -1957,6 +1962,39 @@ + (void)track:(NSString *)event withValue:(double)value andInfo:(NSString *)info
19571962 [[LPCountAggregator sharedAggregator ] incrementCount: @" track" ];
19581963}
19591964
1965+ + (void )trackGeofence : (LPGeofenceEventType)event withInfo : (NSString *)info {
1966+ if ([[LPFeatureFlagManager sharedManager ] isFeatureFlagEnabled: @" track_geofence" ]) {
1967+ [self trackGeofence: event withValue: 0.0 andInfo: info andArgs: nil andParameters: nil ];
1968+ } else {
1969+ [[LPCountAggregator sharedAggregator ] incrementCount: @" track_geofence_disabled" ];
1970+ }
1971+ }
1972+
1973+ + (void )trackGeofence : (LPGeofenceEventType)event withValue : (double )value andInfo : (NSString *)info
1974+ andArgs : (NSDictionary *)args andParameters : (NSDictionary *)params
1975+ {
1976+ RETURN_IF_NOOP;
1977+ LP_TRY
1978+
1979+ // TrackGeofence should not be called in background.
1980+ if (![NSThread isMainThread ]) {
1981+ dispatch_sync (dispatch_get_main_queue (), ^{
1982+ [self trackGeofence: event withValue: value andInfo: info andArgs: args andParameters: params];
1983+ });
1984+ return ;
1985+ }
1986+
1987+ NSString *eventName = [LPEnumConstants getEventNameFromGeofenceType: event];
1988+
1989+ NSMutableDictionary *arguments = [self makeTrackArgs: eventName withValue: value andInfo: info andArgs: args andParameters: params];
1990+
1991+ LPRequestFactory *reqFactory = [[LPRequestFactory alloc ]
1992+ initWithFeatureFlagManager: [LPFeatureFlagManager sharedManager ]];
1993+ id <LPRequesting> request = [reqFactory trackGeofenceWithParams: arguments];
1994+ [[LPRequestSender sharedInstance ] sendIfConnected: request];
1995+ LP_END_TRY
1996+ }
1997+
19601998+ (void )trackInternal : (NSString *)event withArgs : (NSDictionary *)args
19611999 andParameters : (NSDictionary *)params
19622000{
0 commit comments