<commit_before>package it.near.sdk.operation;

import java.util.HashMap;

public class NearItUserProfiler implements NearItUserDataAPI.UserDataSendListener {

    private static final String TAG = "NearItUserProfiler";

    private final UserDataCacheManager userDataCacheManager;
    private final NearItUserDataAPI userDataAPI;
    private final UserDataTimer timer;

    private HashMap<String, String> userData;
    private boolean hasTimer = false;
    private boolean isBusy = false;

    NearItUserProfiler(UserDataCacheManager userDataCacheManager, NearItUserDataAPI userDataAPI, UserDataTimer timer) {
        this.userDataCacheManager = userDataCacheManager;
        this.userDataAPI = userDataAPI;
        this.timer = timer;
    }

    public void setUserData(String key, String value) {
        if (!hasTimer) {
            hasTimer = true;
            timer.start(new UserDataTimer.TimerListener() {
                @Override
                public void sendNow() {
                    startSend();
                }
            });
        }
        userDataCacheManager.setUserData(key, value);
    }

    public void sendDataPoints() {
        userData = userDataCacheManager.getUserData();
        isBusy = true;
        userDataAPI.sendDataPoints(userData, this);
    }

    public void clearUserData() {
        userDataCacheManager.removeAllData();
    }

    private void startSend() {
        shouldSendDataPoints();
        hasTimer = false;
    }

    private void shouldSendDataPoints() {
        if (userDataCacheManager.hasData()) {
            userData = userDataCacheManager.getUserData();
            isBusy = true;
            userDataAPI.sendDataPoints(userData, this);
        }
    }

    @Override
    public void onSendingSuccess(HashMap<String, String> sentData) {
        isBusy = false;
        userDataCacheManager.removeSentData(sentData);
    }

    @Override
    public void onSendingFailure() {
        isBusy = false;
    }
}<commit_msg>implement timer listener + remove hasTimer<commit_after>package it.near.sdk.operation;

import java.util.HashMap;

public class NearItUserProfiler implements NearItUserDataAPI.UserDataSendListener, UserDataTimer.TimerListener {

    private static final String TAG = "NearItUserProfiler";

    private final UserDataCacheManager userDataCacheManager;
    private final NearItUserDataAPI userDataAPI;
    private final UserDataTimer timer;

    private HashMap<String, String> userData;
    private boolean isBusy = false;

    NearItUserProfiler(UserDataCacheManager userDataCacheManager, NearItUserDataAPI userDataAPI, UserDataTimer timer) {
        this.userDataCacheManager = userDataCacheManager;
        this.userDataAPI = userDataAPI;
        this.timer = timer;
    }

    public void setUserData(String key, String value) {
        timer.start(this);
        userDataCacheManager.setUserData(key, value);
    }

    public void sendDataPoints() {
        userData = userDataCacheManager.getUserData();
        isBusy = true;
        userDataAPI.sendDataPoints(userData, this);
    }

    public void clearUserData() {
        userDataCacheManager.removeAllData();
    }

    private void startSend() {
        shouldSendDataPoints();
    }

    private void shouldSendDataPoints() {
        if (userDataCacheManager.hasData()) {
            userData = userDataCacheManager.getUserData();
            isBusy = true;
            userDataAPI.sendDataPoints(userData, this);
        }
    }

    @Override
    public void onSendingSuccess(HashMap<String, String> sentData) {
        isBusy = false;
        userDataCacheManager.removeSentData(sentData);
    }

    @Override
    public void onSendingFailure() {
        isBusy = false;
    }

    @Override
    public void sendNow() {
        startSend();
    }
}
{'fraction_non_alphanumeric': 0.07763157894736843, 'fraction_numerical': 0.0, 'mean_word_length': 2.763366336633663, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5277882', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1027, 'n_words': 224}