Skip to content

Commit

Permalink
Release 6.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dengshiwei committed Nov 10, 2023
1 parent 86c96c1 commit d9c7768
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,22 @@ public void run() {
}
}

@Override
public void resetAnonymousIdentity(final String anonymousId) {
if (mTrackTaskManager != null) {
mTrackTaskManager.addTrackEventTask(new Runnable() {
@Override
public void run() {
try {
mSAContextManager.getUserIdentityAPI().resetAnonymousIdentity(anonymousId);
} catch (Exception e) {
SALog.printStackTrace(e);
}
}
});
}
}

@Override
public void trackInstallation(String eventName, JSONObject properties, final boolean disableCallback) {
SAModuleManager.getInstance().invokeModuleFunction(Modules.Advert.MODULE_NAME, Modules.Advert.METHOD_TRACK_INSTALLATION, eventName, properties, disableCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public Event assembleData(InputData input) {
if (propertiesObject == null) {
propertiesObject = new JSONObject();
}
boolean isOverrideDeviceId = propertiesObject.has("$device_id") || propertiesObject.has("$anonymization_id");
trackEvent.setProperties(propertiesObject);

String type = trackEvent.getExtras().getString("type");
Expand Down Expand Up @@ -116,7 +115,9 @@ private void overrideH5Ids(EventType eventType, TrackEvent trackEvent, SensorsDa
private void appendDefaultProperty(TrackEvent trackEvent) {
try {
trackEvent.getExtras().put("_hybrid_h5", true);
trackEvent.getExtras().put("time", System.currentTimeMillis());
if (!trackEvent.getExtras().has("time")) {
trackEvent.getExtras().put("time", System.currentTimeMillis());
}
SecureRandom secureRandom = new SecureRandom();
trackEvent.getExtras().put("_track_id", secureRandom.nextInt());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,6 @@ public interface IUserIdentityAPI {
* @throws InvalidDataException 数据不合法
*/
void unbind(String key, String value) throws InvalidDataException;

void resetAnonymousIdentity(String anonymousId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ public void updateSpecialIDKeyAndValue(SpecialID specialID, String value) throws
saveIdentities();
}

public void updateIDKeyAndValue(String value) throws JSONException {
if (mIdentities.has(Identities.ANDROID_ID)) {
mIdentities.put(ANDROID_ID, value);
} else if (mIdentities.has(Identities.ANDROID_UUID)) {
mIdentities.put(ANDROID_UUID, value);
}
saveIdentities();
}

//正常是不需要的,内部改变,自身是感知的;但是为了兼容以前的设计方案需要一个 saveIdentities 来保持逻辑的一致性
private void saveIdentities() {
if (!isValidIdentities(mIdentities)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,34 @@ public void unbind(String key, String value) {
unbindBack(key, value);
}

@Override
public void resetAnonymousIdentity(String anonymousId) {
try {
if (!TextUtils.isEmpty(mLoginIdValue)) {
SALog.i(TAG, "resetAnonymousIdentity 需退出登录后调用");
return;
}
if (TextUtils.isEmpty(anonymousId)) {
anonymousId = UUID.randomUUID().toString();
}
mAnonymousId.commit(anonymousId);
mIdentitiesInstance.updateIDKeyAndValue(anonymousId);
// 通知调用 resetAnonymousId 接口
if (mSAContextManager.getEventListenerList() != null) {
for (SAEventListener eventListener : mSAContextManager.getEventListenerList()) {
try {
eventListener.resetAnonymousId();
} catch (Exception e) {
SALog.printStackTrace(e);
}
}
}
TrackMonitor.getInstance().callResetAnonymousId(anonymousId);
} catch (Exception e) {
SALog.printStackTrace(e);
}
}

public boolean unbindBack(String key, String value) {
boolean flag;
try {
Expand Down
4 changes: 2 additions & 2 deletions script_config/config.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ext {
versions = [
// 全量 SDK 版本号
sdk_version : "6.7.4",
sdk_version : "6.7.5",
// 最小插件版本号依赖
min_plugin_version: "3.5.2",
// 子模块版本号
module_version : "0.2.7"
module_version : "0.2.8"
]

publish = [
Expand Down

0 comments on commit d9c7768

Please sign in to comment.