Skip to content

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqiangliu committed Apr 6, 2023
1 parent f0b9b0a commit bd5719c
Show file tree
Hide file tree
Showing 33 changed files with 2,349 additions and 465 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ More**](https://www.sensorsdata.cn/about/aboutus.html)

## SDK 简介

A/B Testing SDK 是一款用于 A/B 测试的 SDK。
Java A/B Testing SDK 是一款用于 A/B 测试的 SDK。

## 集成文档

Expand Down Expand Up @@ -49,7 +49,7 @@ A/B Testing SDK 是一款用于 A/B 测试的 SDK。

## License

Copyright 2015-2021 Sensors Data Inc.
Copyright 2015-2023 Sensors Data Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
Expand Down
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>com.sensorsdata.analytics.javasdk</groupId>
<artifactId>SensorsABTesting</artifactId>
<version>0.0.7</version>
<version>1.0.0</version>

<name>SensorsABTesting</name>
<url>http://sensorsdata.cn</url>
Expand Down Expand Up @@ -100,6 +100,18 @@
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.sensorsdata.analytics.javasdk.bean.Experiment;
import com.sensorsdata.analytics.javasdk.exceptions.InvalidArgumentException;


import lombok.NonNull;

import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.sensorsdata.analytics.javasdk;

import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.Map;

Expand All @@ -12,7 +11,6 @@
* @version 1.0.0
* @since 2021/10/22 15:42
*/
@Getter
public class SensorsABParams<T> {
/**
* 匿名ID/业务ID
Expand Down Expand Up @@ -200,4 +198,40 @@ public SensorsABParams.Builder<T> addCustomId(String key, String value) {
return this;
}
}

public String getDistinctId() {
return distinctId;
}

public Boolean getIsLoginId() {
return isLoginId;
}

public String getExperimentVariableName() {
return experimentVariableName;
}

public T getDefaultValue() {
return defaultValue;
}

public Boolean getEnableAutoTrackEvent() {
return enableAutoTrackEvent;
}

public Integer getTimeoutMilliseconds() {
return timeoutMilliseconds;
}

public Boolean getEnableCache() {
return enableCache;
}

public Map<String, Object> getProperties() {
return properties;
}

public Map<String, String> getCustomIds() {
return customIds;
}
}
24 changes: 15 additions & 9 deletions src/main/java/com/sensorsdata/analytics/javasdk/SensorsABTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.sensorsdata.analytics.javasdk.bean.Experiment;
import com.sensorsdata.analytics.javasdk.exceptions.InvalidArgumentException;

import lombok.NonNull;

import java.util.Map;

/**
Expand All @@ -22,8 +20,12 @@ public SensorsABTest(ABGlobalConfig config) {
}

@Override
public <T> Experiment<T> asyncFetchABTest(@NonNull SensorsABParams<T> sensorsParams) {
return worker.fetchABTest(sensorsParams);
public <T> Experiment<T> asyncFetchABTest(SensorsABParams<T> sensorsParams) {
if (sensorsParams == null) {
throw new NullPointerException("sensorsParams is marked non-null but is null");
} else {
return this.worker.fetchABTest(sensorsParams);
}
}

@Override
Expand Down Expand Up @@ -127,8 +129,12 @@ public <T> Experiment<T> asyncFetchABTest(String distinctId, boolean isLoginId,
}

@Override
public <T> Experiment<T> fastFetchABTest(@NonNull SensorsABParams<T> sensorsParams) {
return worker.fetchABTest(sensorsParams.setEnableCache(true));
public <T> Experiment<T> fastFetchABTest(SensorsABParams<T> sensorsParams) {
if (sensorsParams == null) {
throw new NullPointerException("sensorsParams is marked non-null but is null");
} else {
return this.worker.fetchABTest(sensorsParams.setEnableCache(true));
}
}

@Override
Expand Down Expand Up @@ -241,20 +247,20 @@ public <T> Experiment<T> fastFetchABTest(String distinctId, boolean isLoginId, S

@Override
public <T> void trackABTestTrigger(Experiment<T> experiment) throws InvalidArgumentException {
worker.trackABTestTrigger(experiment, null, null);
worker.trackABTestTrigger(experiment, null, null, null);
}

@Override
public <T> void trackABTestTrigger(Experiment<T> experiment, Map<String, Object> properties)
throws InvalidArgumentException {
worker.trackABTestTrigger(experiment, properties, null);
worker.trackABTestTrigger(experiment, properties, null, null);
}

@Override
public <T> void trackABTestTrigger(Experiment<T> experiment, Map<String, Object> properties,
Map<String, String> customIds)
throws InvalidArgumentException {
worker.trackABTestTrigger(experiment, properties, customIds);
worker.trackABTestTrigger(experiment, properties, customIds, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,41 @@ private SensorsABTestConst() {

static final String JAVA = "Java";

static final String VERSION = "0.0.7";
public static final String VERSION = "1.0.0";

static final String VERSION_KEY = "abtest_lib_version";

/**
* 上报事件使用的key
*/
static final String EXPERIMENT_ID = "$abtest_experiment_id";
static final String EXPERIMENT_GROUP_ID = "$abtest_experiment_group_id";
static final String EVENT_TYPE = "$ABTestTrigger";
static final String LIB_PLUGIN_VERSION = "$lib_plugin_version";
static final String AB_TEST_EVENT_LIB_VERSION = "java_abtesting";
public static final String EXPERIMENT_ID = "$abtest_experiment_id";
public static final String EXPERIMENT_GROUP_ID = "$abtest_experiment_group_id";
public static final String EVENT_TYPE = "$ABTestTrigger";
public static final String LIB_PLUGIN_VERSION = "$lib_plugin_version";
public static final String AB_TEST_EVENT_LIB_VERSION = "java_abtesting";

public static final String ANONYMOUS_ID = "anonymous_id";

public static final String DEVICE_SUBJECT_NAME = "DEVICE";
/**
* 返回json里面的key
*/
public static final String EXPERIMENT_ID_KEY = "abtest_experiment_id";
public static final String EXPERIMENT_GROUP_ID_KEY = "abtest_experiment_group_id";

public static final String ABTEST_UNIQUE_ID = "abtest_unique_id";
public static final String ABTEST_EXPERIMENT_RESULT_ID_KEY = "abtest_experiment_result_id";
public static final String ABTEST_EXPERIMENT_VERSION_KEY = "abtest_experiment_version";

public static final String ABTEST_TRACK_CONFIG_KEY = "track_config";
public static final String ABTEST_SUBJECT_NAME_KEY = "subject_name";
public static final String ABTEST_SUBJECT_ID_KEY = "subject_id";
public static final String ABTEST_STICKINESS_KEY = "stickiness";
public static final String ABTEST_CACHEABLE_KEY = "cacheable";
public static final String IS_CONTROL_GROUP_KEY = "is_control_group";
public static final String IS_WHITE_LIST_KEY = "is_white_list";
public static final String VARIABLES_KEY = "variables";
public static final String RESULTS_KEY = "results";
public static final String OUT_LIST_KEY = "out_list";
public static final String STATUS_KEY = "status";

public static final String NAME_KEY = "name";
Expand All @@ -47,7 +59,9 @@ private SensorsABTestConst() {

public static final String VALUE_KEY = "value";
public static final String SUCCESS = "SUCCESS";


public static final String INVALID_ABTEST_UNIQUE_ID = "-1";

// 自定义主体 id
public static final String CUSTOM_ID = "custom_id";

Expand Down
Loading

0 comments on commit bd5719c

Please sign in to comment.