Skip to content

Commit

Permalink
Release 6.7.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dengshiwei committed Nov 20, 2023
1 parent d9c7768 commit 388e7f4
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ interface EventName{
String DEFERRED_DEEPLINK_JUMP = "$AdAppDeferredDeepLinkJump";
String DYNAMIC_SLINK_CREATE = "$AdDynamicSlinkCreate";
String DEEPLINK_LAUNCH = "$AppDeeplinkLaunch";
String APP_INTERACT = "$AppInteract";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@
import android.os.Build;
import android.text.TextUtils;

import com.sensorsdata.analytics.android.sdk.SALog;
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
import com.sensorsdata.analytics.android.sdk.advert.SAAdvertConstants;
import com.sensorsdata.analytics.android.sdk.advert.oaid.SAOaidHelper;
import com.sensorsdata.analytics.android.sdk.advert.utils.ChannelUtils;
import com.sensorsdata.analytics.android.sdk.advert.utils.SAAdvertUtils;
import com.sensorsdata.analytics.android.sdk.core.SACoreHelper;
import com.sensorsdata.analytics.android.sdk.SALog;
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
import com.sensorsdata.analytics.android.sdk.internal.beans.ServerUrl;
import com.sensorsdata.analytics.android.sdk.core.event.InputData;
import com.sensorsdata.analytics.android.sdk.core.eventbus.SAEventBus;
import com.sensorsdata.analytics.android.sdk.core.eventbus.SAEventBusConstants;
import com.sensorsdata.analytics.android.sdk.deeplink.SADeepLinkObject;
import com.sensorsdata.analytics.android.sdk.deeplink.SensorsDataDeepLinkCallback;
import com.sensorsdata.analytics.android.sdk.deeplink.SensorsDataDeferredDeepLinkCallback;
import com.sensorsdata.analytics.android.sdk.internal.beans.EventType;
import com.sensorsdata.analytics.android.sdk.internal.beans.ServerUrl;
import com.sensorsdata.analytics.android.sdk.util.Base64Coder;
import com.sensorsdata.analytics.android.sdk.util.JSONUtils;
import com.sensorsdata.analytics.android.sdk.util.NetworkUtils;
Expand Down Expand Up @@ -70,7 +71,7 @@ public enum DeepLinkType {
* @param intent Intent
* @return 是否是 DeepLink 唤起
*/
private static boolean isDeepLink(Intent intent) {
public static boolean isDeepLink(Intent intent) {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && intent != null && Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getData() != null;
}

Expand Down Expand Up @@ -141,6 +142,7 @@ private static void trackDeepLinkLaunchEvent(final Context context, DeepLinkProc
try {
properties.put(SAAdvertConstants.Properties.DEEPLINK_URL, deepLink.getDeepLinkUrl());
properties.put("$time", new Date(System.currentTimeMillis()));
properties.put("$sat_has_installed_app", SAAdvertUtils.isInstallationTracked());
} catch (JSONException e) {
SALog.printStackTrace(e);
}
Expand All @@ -160,6 +162,7 @@ public void run() {
SALog.printStackTrace(e);
}
}

SACoreHelper.getInstance().trackEvent(new InputData().setEventType(EventType.TRACK)
.setEventName(SAAdvertConstants.EventName.DEEPLINK_LAUNCH).setProperties(properties));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.sensorsdata.analytics.android.sdk.advert.plugin.SAAdvertAppViewScreenPlugin;
import com.sensorsdata.analytics.android.sdk.advert.scan.SAAdvertScanHelper;
import com.sensorsdata.analytics.android.sdk.advert.utils.ChannelUtils;
import com.sensorsdata.analytics.android.sdk.advert.utils.SAAdvertMarketHelper;
import com.sensorsdata.analytics.android.sdk.advert.utils.SAAdvertUtils;
import com.sensorsdata.analytics.android.sdk.core.SAContextManager;
import com.sensorsdata.analytics.android.sdk.core.SACoreHelper;
Expand Down Expand Up @@ -121,6 +122,10 @@ protected void delayExecution() {
}
}
}

if (mSAContextManager.getInternalConfigs().context instanceof Activity) {
SAAdvertMarketHelper.handleAdMarket((Activity) mSAContextManager.getInternalConfigs().context, mOptions.getAdvertConfig());
}
} catch (Exception e) {
SALog.printStackTrace(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import android.content.Intent;
import android.os.Bundle;

import com.sensorsdata.analytics.android.sdk.advert.deeplink.DeepLinkManager;
import com.sensorsdata.analytics.android.sdk.SAConfigOptions;
import com.sensorsdata.analytics.android.sdk.SALog;
import com.sensorsdata.analytics.android.sdk.advert.deeplink.DeepLinkManager;
import com.sensorsdata.analytics.android.sdk.advert.utils.SAAdvertMarketHelper;
import com.sensorsdata.analytics.android.sdk.monitor.SensorsDataActivityLifecycleCallbacks;

public class SensorsDataAdvertActivityLifeCallback implements SensorsDataActivityLifecycleCallbacks.SAActivityLifecycleCallbacks {
Expand All @@ -39,12 +41,22 @@ public void onNewIntent(Intent intent) {

@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
DeepLinkManager.parseDeepLink(activity, mOptions.isSaveDeepLinkInfo());
try {
SAAdvertMarketHelper.handleAdMarket(activity, mOptions.getAdvertConfig());
DeepLinkManager.parseDeepLink(activity, mOptions.isSaveDeepLinkInfo());
} catch (Exception e) {
SALog.printStackTrace(e);
}
}

@Override
public void onActivityStarted(Activity activity) {
DeepLinkManager.parseDeepLink(activity, mOptions.isSaveDeepLinkInfo());
try {
SAAdvertMarketHelper.handleAdMarket(activity, mOptions.getAdvertConfig());
DeepLinkManager.parseDeepLink(activity, mOptions.isSaveDeepLinkInfo());
} catch (Exception e) {
SALog.printStackTrace(e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Created by dengshiwei on 2023/10/08.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.sensorsdata.analytics.android.sdk.advert.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.sensorsdata.analytics.android.sdk.SAAdvertisingConfig;
import com.sensorsdata.analytics.android.sdk.SALog;
import com.sensorsdata.analytics.android.sdk.advert.SAAdvertConstants;
import com.sensorsdata.analytics.android.sdk.advert.deeplink.DeepLinkManager;
import com.sensorsdata.analytics.android.sdk.advert.oaid.SAOaidHelper;
import com.sensorsdata.analytics.android.sdk.core.SACoreHelper;
import com.sensorsdata.analytics.android.sdk.core.event.InputData;
import com.sensorsdata.analytics.android.sdk.data.persistent.PersistentDailyDate;
import com.sensorsdata.analytics.android.sdk.data.persistent.PersistentLoader;
import com.sensorsdata.analytics.android.sdk.internal.beans.EventType;
import com.sensorsdata.analytics.android.sdk.util.SensorsDataUtils;
import com.sensorsdata.analytics.android.sdk.util.TimeUtils;

import org.json.JSONObject;

public class SAAdvertMarketHelper {

/**
* 处理在营销
*
* @param activity Activity
* @param saAdvertisingConfig SAAdvertisingConfig
*/
public static void handleAdMarket(final Activity activity, final SAAdvertisingConfig saAdvertisingConfig) {
try {
if (saAdvertisingConfig != null && saAdvertisingConfig.isEnableRemarketing() && isDailyFirst()) {
SACoreHelper.getInstance().trackQueueEvent(new Runnable() {
@Override
public void run() {
try {
Intent uriIntent = null;
if (!TextUtils.isEmpty(saAdvertisingConfig.getWakeupUrl())) {
uriIntent = Intent.parseUri(saAdvertisingConfig.getWakeupUrl(), Intent.URI_INTENT_SCHEME);
}
// 触发埋点事件
Context context = activity.getApplicationContext();
JSONObject propertyJson = new JSONObject();
propertyJson.put("$ios_install_source",
ChannelUtils.getDeviceInfo(context,
SensorsDataUtils.getIdentifier(context),
SAOaidHelper.getOpenAdIdentifier(context),
SAOaidHelper.getOpenAdIdentifierByReflection(context)));
propertyJson.put("$sat_awake_from_deeplink", DeepLinkManager.isDeepLink(activity.getIntent()) || DeepLinkManager.isDeepLink(uriIntent));
propertyJson.put("$sat_has_installed_app", SAAdvertUtils.isInstallationTracked());
SACoreHelper.getInstance().trackEvent(new InputData().setEventType(EventType.TRACK)
.setEventName(SAAdvertConstants.EventName.APP_INTERACT).setProperties(propertyJson));
} catch (Exception e) {
SALog.printStackTrace(e);
}
}
});
}
} catch (Exception e) {
SALog.printStackTrace(e);
}
}

public static boolean isDailyFirst() {
PersistentDailyDate dailyDate = PersistentLoader.getInstance().getDayDatePst();
String currentDate = TimeUtils.formatTime(System.currentTimeMillis(), TimeUtils.YYYY_MM_DD);
if (!currentDate.equals(dailyDate.get())) {
dailyDate.commit(currentDate);
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.sensorsdata.analytics.android.sdk.data.persistent.PersistentLoader;
import com.sensorsdata.analytics.android.sdk.exceptions.ConnectErrorException;
import com.sensorsdata.analytics.android.sdk.exceptions.ResponseErrorException;
import com.sensorsdata.analytics.android.sdk.plugin.encrypt.SAStoreManager;
import com.sensorsdata.analytics.android.sdk.util.JSONUtils;
import com.sensorsdata.analytics.android.sdk.util.NetworkUtils;
import com.sensorsdata.analytics.android.sdk.util.SADataHelper;
Expand Down Expand Up @@ -125,7 +126,11 @@ public static void sendData(Context context, String path, JSONObject sendData, S
SALog.printStackTrace(e);
}
}
}

// 是否触发过激活
public static boolean isInstallationTracked() {
return SAStoreManager.getInstance().isExists(DbParams.PersistentName.FIRST_INSTALL) || SAStoreManager.getInstance().isExists(DbParams.PersistentName.FIRST_INSTALL_CALLBACK);
}

private synchronized static void sendHttpRequest(String path, String crc, String gzip, String data, String rawMessage) throws ConnectErrorException, ResponseErrorException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@
import java.util.List;

public class SAAdvertisingConfig {
// 广告及时事件接收地址
public String serverUrl;
public List<String> eventNames;
public SecreteKey secreteKey;
// 在营销需求开关
private boolean enableRemarketing = false;
// 在营销需求,设置唤起 App 的 Url
private String wakeupUrl;

//serverUrl 上报到 SAT 的地址
// events 上报到 SAT 的事件列表,需填写事件名
Expand All @@ -34,4 +39,25 @@ public SAAdvertisingConfig(String serverUrl, List<String> eventNames, SecreteKey
this.serverUrl = serverUrl;
this.eventNames = eventNames;
}

public SAAdvertisingConfig() {
}

public SAAdvertisingConfig enableRemarketing() {
enableRemarketing = true;
return this;
}

public String getWakeupUrl() {
return wakeupUrl;
}

public SAAdvertisingConfig setWakeupUrl(String wakeupUrl) {
this.wakeupUrl = wakeupUrl;
return this;
}

public boolean isEnableRemarketing() {
return enableRemarketing;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ public SAConfigOptions setInstantEvents(List<String> listInstantEvents) {
return this;
}

public void setAdvertConfig(SAAdvertisingConfig config) {
public SAConfigOptions setAdvertConfig(SAAdvertisingConfig config) {
this.mSATConfig = config;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public interface PersistentName {
String VISUAL_PROPERTIES = "visual_properties";
String PERSISTENT_USER_ID = "user_ids";
String PERSISTENT_LOGIN_ID_KEY = "login_id_key";
String PERSISTENT_DAY_DATE = "daily_date";
}

private DbParams(String packageName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Created by dengshiwei on 2023/10/08.
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.sensorsdata.analytics.android.sdk.data.persistent;

import com.sensorsdata.analytics.android.sdk.data.adapter.DbParams;

public class PersistentDailyDate extends PersistentIdentity<String>{

PersistentDailyDate() {
super(DbParams.PersistentName.PERSISTENT_DAY_DATE, new PersistentSerializer<String>() {
@Override
public String load(String value) {
return value;
}

@Override
public String save(String item) {
return item;
}

@Override
public String create() {
return null;
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class PersistentLoader {
private final UserIdentityPersistent mUserIdsPst;
private final PersistentFirstStart mFirstStartPst;
private final PersistentFirstDay mFirstDayPst;
private final PersistentDailyDate mDayDatePst;
private final PersistentSuperProperties mSuperPropertiesPst;
private final PersistentVisualConfig mVisualConfigPst;
private final PersistentFirstTrackInstallation mFirstInstallationPst;
Expand All @@ -54,6 +55,7 @@ private PersistentLoader(Context context) {
mVisualConfigPst = (PersistentVisualConfig) loadPersistent(DbParams.PersistentName.VISUAL_PROPERTIES);
mFirstInstallationPst = (PersistentFirstTrackInstallation) loadPersistent(DbParams.PersistentName.FIRST_INSTALL);
mFirstInstallationWithCallbackPst = (PersistentFirstTrackInstallationWithCallback) loadPersistent(DbParams.PersistentName.FIRST_INSTALL_CALLBACK);
mDayDatePst = (PersistentDailyDate) loadPersistent(DbParams.PersistentName.PERSISTENT_DAY_DATE);
}

public static void preInit(Context context) {
Expand Down Expand Up @@ -101,6 +103,8 @@ private PersistentIdentity<?> loadPersistent(String persistentKey) {
return new LoginIdKeyPersistent();
case DbParams.APP_EXIT_DATA:
return new PersistentAppExitData();
case DbParams.PersistentName.PERSISTENT_DAY_DATE:
return new PersistentDailyDate();
default:
return null;
}
Expand Down Expand Up @@ -157,4 +161,8 @@ public PersistentFirstTrackInstallation getFirstInstallationPst() {
public PersistentFirstTrackInstallationWithCallback getFirstInstallationWithCallbackPst() {
return mFirstInstallationWithCallbackPst;
}

public PersistentDailyDate getDayDatePst() {
return mDayDatePst;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void initLoginIDAndKeyIdentities(String oldLoginIDKey, String oldLoginID
}
} else {
if (identities.has(oldLoginIDKey)) {
String identitiesLoginID = identities.getString(mLoginIDAndKey.getLoginIDKey());//oldLoginIDKey 非法的话,前面已经处理了
String identitiesLoginID = identities.optString(mLoginIDAndKey.getLoginIDKey());//oldLoginIDKey 非法的话,前面已经处理了
if (!identitiesLoginID.equals(oldLoginID)) {
identities.put(Local.getLoginIdKeyFromLocal(), Local.getLoginIdFromLocal());
clearIdentities(Arrays.asList(ANDROID_ID, ANDROID_UUID, mLoginIDAndKey.getLoginIDKey()), identities);
Expand Down Expand Up @@ -199,7 +199,7 @@ public boolean remove(String key, String value) throws JSONException {
//当 android_id、android_uuid、cookie_id 不移除对应的 identities 内容
boolean isNotRemove = Identities.ANDROID_ID.equals(key) || Identities.ANDROID_UUID.equals(key);
if (!isNotRemove) {
if (mIdentities.has(key) && mIdentities.getString(key).equals(value)) {
if (mIdentities.has(key) && mIdentities.optString(key).equals(value)) {
mIdentities.remove(key);
}
}
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.5",
sdk_version : "6.7.6",
// 最小插件版本号依赖
min_plugin_version: "3.5.2",
// 子模块版本号
module_version : "0.2.8"
module_version : "0.2.9"
]

publish = [
Expand Down

0 comments on commit 388e7f4

Please sign in to comment.