← back to mixpanel__mixpanel-java

Function bodies 269 total

All specs Real LLM only Function bodies
delete method · java · L274-L276 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject delete(String distinctId) {
        return delete(distinctId, null);
    }
delete method · java · L294-L296 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject delete(String distinctId, JSONObject modifiers) {
        return peopleMessage(distinctId, "$delete", new JSONObject(), modifiers);
    }
increment method · java · L318-L320 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject increment(String distinctId, Map<String, Long> properties) {
        return increment(distinctId, properties, null);
    }
increment method · java · L345-L348 (4 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject increment(String distinctId, Map<String, Long> properties, JSONObject modifiers) {
        JSONObject jsonProperties = new JSONObject(properties);
        return peopleMessage(distinctId, "$add", jsonProperties, modifiers);
    }
append method · java · L359-L361 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject append(String distinctId, JSONObject properties) {
        return append(distinctId, properties, null);
    }
append method · java · L375-L377 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject append(String distinctId, JSONObject properties, JSONObject modifiers) {
        return peopleMessage(distinctId, "$append", properties, modifiers);
    }
remove method · java · L388-L390 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject remove(String distinctId, JSONObject properties) {
        return remove(distinctId, properties, null);
    }
Repobility — the code-quality scanner for AI-generated software · https://repobility.com
remove method · java · L404-L406 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject remove(String distinctId, JSONObject properties, JSONObject modifiers) {
        return peopleMessage(distinctId, "$remove", properties, modifiers);
    }
union method · java · L418-L420 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject union(String distinctId, Map<String, JSONArray> properties) {
        return union(distinctId, properties, null);
    }
union method · java · L435-L438 (4 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject union(String distinctId, Map<String, JSONArray> properties, JSONObject modifiers) {
        JSONObject jsonProperties = new JSONObject(properties);
        return peopleMessage(distinctId, "$union", jsonProperties, modifiers);
    }
unset method · java · L448-L450 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject unset(String distinctId, Collection<String> propertyNames) {
        return unset(distinctId, propertyNames, null);
    }
unset method · java · L463-L466 (4 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject unset(String distinctId, Collection<String> propertyNames, JSONObject modifiers) {
        JSONArray propNamesArray = new JSONArray(propertyNames);
        return peopleMessage(distinctId, "$unset", propNamesArray, modifiers);
    }
trackCharge method · java · L477-L479 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject trackCharge(String distinctId, double amount, JSONObject properties) {
        return trackCharge(distinctId, amount, properties, null);
    }
trackCharge method · java · L492-L515 (24 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject trackCharge(String distinctId, double amount, JSONObject properties, JSONObject modifiers) {
        JSONObject transactionValue = new JSONObject();
        JSONObject appendProperties = new JSONObject();
        try {
            transactionValue.put("$amount", amount);
            DateFormat dateFormat = new SimpleDateFormat(ENGAGE_DATE_FORMAT);
            dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
            transactionValue.put("$time", dateFormat.format(new Date()));

            if (null != properties) {
                for (Iterator<?> iter = properties.keys(); iter.hasNext();) {
                    String key = (String) iter.next();
                    transactionValue.put(key, properties.get(key));
                }
            }

            appendProperties.put("$transactions", transactionValue);

            return this.append(distinctId, appendProperties, modifiers);
        } catch (JSONException e) {
            e.printStackTrace();
    
peopleMessage method · java · L543-L576 (34 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject peopleMessage(String distinctId, String actionType, Object properties, JSONObject modifiers) {
        JSONObject dataObj = new JSONObject();
        if (null == properties) {
            throw new IllegalArgumentException("Cannot send null properties, use JSONObject.NULL instead");
        }

        try {
            dataObj.put(actionType, properties);
        } catch (JSONException e) {
            throw new IllegalArgumentException("Cannot interpret properties as a JSON payload", e);
        }

        // At this point, nothing should ever throw a JSONException
        try {
            dataObj.put("$token", mToken);
            dataObj.put("$distinct_id", distinctId);
            dataObj.put("$time", System.currentTimeMillis());
            if (null != modifiers) {
                final String[] keys = JSONObject.getNames(modifiers);
                if (keys != null) {
                  for(String key : keys) {
                      dataObj.put(key, modifier
Repobility · code-quality intelligence platform · https://repobility.com
groupSet method · java · L598-L600 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupSet(String groupKey, String groupId, JSONObject properties) {
        return groupSet(groupKey, groupId, properties, null);
    }
groupSet method · java · L625-L627 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupSet(String groupKey, String groupId, JSONObject properties, JSONObject modifiers) {
        return groupMessage(groupKey, groupId, "$set", properties, modifiers);
    }
groupSetOnce method · java · L647-L649 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupSetOnce(String groupKey, String groupId, JSONObject properties) {
        return groupSetOnce(groupKey, groupId, properties, null);
    }
groupSetOnce method · java · L672-L674 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupSetOnce(String groupKey, String groupId, JSONObject properties, JSONObject modifiers) {
        return groupMessage(groupKey, groupId, "$set_once", properties, modifiers);
    }
groupDelete method · java · L690-L692 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupDelete(String groupKey, String groupId) {
        return groupDelete(groupKey, groupId, null);
    }
groupDelete method · java · L711-L713 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupDelete(String groupKey, String groupId, JSONObject modifiers) {
        return groupMessage(groupKey, groupId, "$delete", new JSONObject(), modifiers);
    }
groupRemove method · java · L723-L725 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupRemove(String groupKey, String groupId, JSONObject properties) {
        return groupRemove(groupKey, groupId, properties, null);
    }
groupRemove method · java · L738-L740 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupRemove(String groupKey, String groupId, JSONObject properties, JSONObject modifiers) {
        return groupMessage(groupKey, groupId, "$remove", properties, modifiers);
    }
All rows scored by the Repobility analyzer (https://repobility.com)
groupUnion method · java · L751-L753 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupUnion(String groupKey, String groupId, Map<String, JSONArray> properties) {
        return groupUnion(groupKey, groupId, properties, null);
    }
groupUnion method · java · L767-L771 (5 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupUnion(String groupKey, String groupId, Map<String, JSONArray> properties,
                              JSONObject modifiers) {
        JSONObject jsonProperties = new JSONObject(properties);
        return groupMessage(groupKey, groupId, "$union", jsonProperties, modifiers);
    }
groupUnset method · java · L780-L782 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupUnset(String groupKey, String groupId, Collection<String> propertyNames) {
        return groupUnset(groupKey, groupId, propertyNames, null);
    }
groupUnset method · java · L794-L798 (5 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupUnset(String groupKey, String groupId, Collection<String> propertyNames,
                                 JSONObject modifiers) {
        JSONArray propNamesArray = new JSONArray(propertyNames);
        return groupMessage(groupKey, groupId, "$unset", propNamesArray, modifiers);
    }
groupMessage method · java · L826-L861 (36 LOC)
src/main/java/com/mixpanel/mixpanelapi/MessageBuilder.java
    public JSONObject groupMessage(String groupKey, String groupId, String actionType, Object properties,
                                   JSONObject modifiers) {
        JSONObject dataObj = new JSONObject();
        if (null == properties) {
            throw new IllegalArgumentException("Cannot send null properties, use JSONObject.NULL instead");
        }

        try {
            dataObj.put(actionType, properties);
        } catch (JSONException e) {
            throw new IllegalArgumentException("Cannot interpret properties as a JSON payload", e);
        }

        // At this point, nothing should ever throw a JSONException
        try {
            dataObj.put("$token", mToken);
            dataObj.put("$group_key", groupKey);
            dataObj.put("$group_id", groupId);
            dataObj.put("$time", System.currentTimeMillis());
            if (null != modifiers) {
                final String[] keys = JSONObject.getNames(modifiers);
                if (keys != null) {
MixpanelAPI method · java · L65-L67 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public MixpanelAPI() {
        this(false);
    }
MixpanelAPI method · java · L74-L76 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public MixpanelAPI(boolean useGzipCompression) {
        this(null, null, null, null, useGzipCompression, null, null, null, null, null, null);
    }
MixpanelAPI method · java · L83-L85 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public MixpanelAPI(LocalFlagsConfig localFlagsConfig) {
        this(localFlagsConfig, null);
    }
Same scanner, your repo: https://repobility.com — Repobility
MixpanelAPI method · java · L92-L94 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public MixpanelAPI(RemoteFlagsConfig remoteFlagsConfig) {
        this(null, remoteFlagsConfig);
    }
MixpanelAPI method · java · L103-L105 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    private MixpanelAPI(LocalFlagsConfig localFlagsConfig, RemoteFlagsConfig remoteFlagsConfig) {
        this(null, null, null, null, false, localFlagsConfig, remoteFlagsConfig, null, null, null, null);
    }
MixpanelAPI method · java · L116-L118 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public MixpanelAPI(String eventsEndpoint, String peopleEndpoint) {
        this(eventsEndpoint, peopleEndpoint, null, null, false, null, null, null, null, null, null);
    }
MixpanelAPI method · java · L130-L132 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public MixpanelAPI(String eventsEndpoint, String peopleEndpoint, String groupsEndpoint) {
        this(eventsEndpoint, peopleEndpoint, groupsEndpoint, null, false, null, null, null, null, null, null);
    }
MixpanelAPI method · java · L145-L147 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public MixpanelAPI(String eventsEndpoint, String peopleEndpoint, String groupsEndpoint, String importEndpoint) {
        this(eventsEndpoint, peopleEndpoint, groupsEndpoint, importEndpoint, false, null, null, null, null, null, null);
    }
MixpanelAPI method · java · L161-L163 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public MixpanelAPI(String eventsEndpoint, String peopleEndpoint, String groupsEndpoint, String importEndpoint, boolean useGzipCompression) {
        this(eventsEndpoint, peopleEndpoint, groupsEndpoint, importEndpoint, useGzipCompression, null, null, null, null, null, null);
    }
MixpanelAPI method · java · L170-L184 (15 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    private MixpanelAPI(Builder builder) {
        this(
            builder.eventsEndpoint,
            builder.peopleEndpoint,
            builder.groupsEndpoint,
            builder.importEndpoint,
            builder.useGzipCompression,
            builder.flagsConfig instanceof LocalFlagsConfig ? (LocalFlagsConfig) builder.flagsConfig : null,
            builder.flagsConfig instanceof RemoteFlagsConfig ? (RemoteFlagsConfig) builder.flagsConfig : null,
            builder.jsonSerializer,
            builder.connectTimeout,
            builder.readTimeout,
            builder.importMaxMessageCount
        );
    }
MixpanelAPI method · java · L201-L243 (43 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    private MixpanelAPI(
        String eventsEndpoint,
        String peopleEndpoint,
        String groupsEndpoint,
        String importEndpoint,
        boolean useGzipCompression,
        LocalFlagsConfig localFlagsConfig,
        RemoteFlagsConfig remoteFlagsConfig,
        JsonSerializer jsonSerializer,
        Integer connectTimeout,
        Integer readTimeout,
        Integer importMaxMessageCount
    ) {
        mEventsEndpoint = eventsEndpoint != null ? eventsEndpoint : Config.BASE_ENDPOINT + "/track";
        mPeopleEndpoint = peopleEndpoint != null ? peopleEndpoint : Config.BASE_ENDPOINT + "/engage";
        mGroupsEndpoint = groupsEndpoint != null ? groupsEndpoint : Config.BASE_ENDPOINT + "/groups";
        mImportEndpoint = importEndpoint != null ? importEndpoint : Config.BASE_ENDPOINT + "/import";
        mUseGzipCompression = useGzipCompression;
        mConnectTimeout = connectTimeout != null ? connectTimeout : DEFAULT_CONNECT_TIMEOUT_MILLIS;
        mReadTimeout = r
Repobility — the code-quality scanner for AI-generated software · https://repobility.com
sendMessage method · java · L255-L260 (6 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public void sendMessage(JSONObject message)
        throws MixpanelMessageException, IOException {
        ClientDelivery delivery = new ClientDelivery();
        delivery.addMessage(message);
        deliver(delivery);
    }
deliver method · java · L270-L272 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public void deliver(ClientDelivery toSend) throws IOException {
        deliver(toSend, false);
    }
deliver method · java · L284-L289 (6 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public void deliver(ClientDelivery toSend, boolean useIpAddress) throws IOException {
        DeliveryOptions options = new DeliveryOptions.Builder()
            .useIpAddress(useIpAddress)
            .build();
        deliver(toSend, options);
    }
deliver method · java · L313-L334 (22 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public void deliver(ClientDelivery toSend, DeliveryOptions options) throws IOException {
        String ipParameter = options.useIpAddress() ? "ip=1" : "ip=0";

        String eventsUrl = mEventsEndpoint + "?" + ipParameter;
        List<JSONObject> events = toSend.getEventsMessages();
        sendMessages(events, eventsUrl);

        String peopleUrl = mPeopleEndpoint + "?" + ipParameter;
        List<JSONObject> people = toSend.getPeopleMessages();
        sendMessages(people, peopleUrl);

        String groupsUrl = mGroupsEndpoint + "?" + ipParameter;
        List<JSONObject> groupMessages = toSend.getGroupMessages();
        sendMessages(groupMessages, groupsUrl);

        List<JSONObject> importMessages = toSend.getImportMessages();
        if (importMessages.size() > 0) {
            String strictParam = options.isImportStrictMode() ? "1" : "0";
            String importUrl = mImportEndpoint + "?strict=" + strictParam;
            sendImportMessages(importMessages, importUrl)
encodeDataString method · java · L343-L351 (9 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    protected String encodeDataString(String dataString) {
        try {
            byte[] utf8data = dataString.getBytes("utf-8");
            String base64data = new String(Base64Coder.encode(utf8data));
            return URLEncoder.encode(base64data, "utf8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Mixpanel library requires utf-8 support", e);
        }
    }
sendMessages method · java · L429-L444 (16 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    private void sendMessages(List<JSONObject> messages, String endpointUrl) throws IOException {
        for (int i = 0; i < messages.size(); i += Config.MAX_MESSAGE_SIZE) {
            int endIndex = i + Config.MAX_MESSAGE_SIZE;
            endIndex = Math.min(endIndex, messages.size());
            List<JSONObject> batch = messages.subList(i, endIndex);

            if (batch.size() > 0) {
                String messagesString = dataString(batch);
                boolean accepted = sendData(messagesString, endpointUrl);

                if (! accepted) {
                    throw new MixpanelServerException("Server refused to accept messages, they may be malformed.", batch);
                }
            }
        }
    }
sendImportMessages method · java · L446-L481 (36 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    private void sendImportMessages(List<JSONObject> messages, String endpointUrl) throws IOException {
        // Extract token from first message for authentication
        // If token is missing, we'll still attempt to send and let the server reject it
        String token = "";
        if (messages.size() > 0) {
            try {
                JSONObject firstMessage = messages.get(0);
                if (firstMessage.has("properties")) {
                    JSONObject properties = firstMessage.getJSONObject("properties");
                    if (properties.has("token")) {
                        token = properties.getString("token");
                    }
                }
            } catch (JSONException e) {
                // Malformed message - continue with empty token and let server reject it
            }
        }

        // Send messages in batches (max 2000 per batch for /import by default)
        // If token is empty, the server will reject with 401 Unauthorized
 
dataString method · java · L483-L491 (9 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    private String dataString(List<JSONObject> messages) {
        try {
            return mJsonSerializer.serializeArray(messages);
        } catch (IOException e) {
            // Fallback to original implementation if serialization fails
            logger.log(Level.WARNING, "JSON serialization failed unexpectedly; falling back to org.json implementation", e);
            return mDefaultJsonSerializer.serializeArray(messages);
        }
    }
Repobility · code-quality intelligence platform · https://repobility.com
slurp method · java · L629-L643 (15 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    private String slurp(InputStream in) throws IOException {
        final StringBuilder out = new StringBuilder();
        InputStreamReader reader = new InputStreamReader(in, "utf8");

        char[] readBuffer = new char[BUFFER_SIZE];
        int readCount = 0;
        do {
            readCount = reader.read(readBuffer);
            if (readCount > 0) {
                out.append(readBuffer, 0, readCount);
            }
        } while(readCount != -1);

        return out.toString();
    }
getLocalFlags method · java · L650-L652 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public LocalFlagsProvider getLocalFlags() {
        return mLocalFlags;
    }
getRemoteFlags method · java · L659-L661 (3 LOC)
src/main/java/com/mixpanel/mixpanelapi/MixpanelAPI.java
    public RemoteFlagsProvider getRemoteFlags() {
        return mRemoteFlags;
    }
‹ prevpage 5 / 6next ›