Skip to content

Commit

Permalink
Release 1.6.15
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzhzh committed Sep 29, 2016
1 parent c9569f8 commit 161dc77
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is the official Android SDK for Sensors Analytics.
dependencies {
// ...
compile 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:1.+'
compile 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:latest.integration'
}
```
2. Add permissions to app/src/main/AndroidManifest.xml
Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/SensorsAnalyticsSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "1.6.14"
version = "1.6.15"

android {
compileSdkVersion 21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,50 @@ public void clearTrackTimer() {
}
}

/**
* 获取LastScreenUrl
* @return String
*/
public String getLastScreenUrl() {
return mLastScreenUrl;
}

/**
* 获取LastScreenTrackProperties
* @return JSONObject
*/
public JSONObject getLastScreenTrackProperties() {
return mLastScreenTrackProperties;
}

/**
* Track进入页面事件
* @param url String
* @param properties JSONObject
* @throws InvalidDataException 当公共属性不符合规范时抛出异常
*/
public void trackViewScreen(String url, JSONObject properties) throws InvalidDataException {
if (!TextUtils.isEmpty(url) || properties != null) {
try {
JSONObject trackProperties = new JSONObject();
mLastScreenTrackProperties = properties;

if (!TextUtils.isEmpty(mLastScreenUrl)) {
trackProperties.put("$referrer", mLastScreenUrl);
}

trackProperties.put("$url", url);
mLastScreenUrl = url;
if (properties != null) {
mergeJSONObject(properties, trackProperties);
}
track("$AppViewScreen", trackProperties);
} catch (JSONException e) {
Log.w(LOGTAG, "trackViewScreen:" + e);
}
}
}

/**
* app进入后台
* 遍历mTrackTimer
Expand Down Expand Up @@ -1170,19 +1214,16 @@ public void onActivityResumed(Activity activity) {
if (activity instanceof ScreenAutoTracker) {
ScreenAutoTracker screenAutoTracker = (ScreenAutoTracker) activity;

if (!TextUtils.isEmpty(mLastScreenUrl)) {
properties.put("$referrer", mLastScreenUrl);
}
mLastScreenUrl = screenAutoTracker.getScreenUrl();
properties.put("$url", mLastScreenUrl);

String screenUrl = screenAutoTracker.getScreenUrl();
JSONObject otherProperties = screenAutoTracker.getTrackProperties();
if (otherProperties != null) {
mergeJSONObject(otherProperties, properties);
}
}

track("$AppViewScreen", properties);
trackViewScreen(screenUrl, properties);
} else {
track("$AppViewScreen", properties);
}
} catch (InvalidDataException | JSONException e) {
Log.w(LOGTAG, e);
}
Expand Down Expand Up @@ -1343,7 +1384,7 @@ private static void mergeJSONObject(final JSONObject source, JSONObject dest)
static final int VTRACK_SUPPORTED_MIN_API = 16;

// SDK版本
static final String VERSION = "1.6.14";
static final String VERSION = "1.6.15";

static Boolean ENABLE_LOG = false;

Expand Down Expand Up @@ -1372,6 +1413,7 @@ private static void mergeJSONObject(final JSONObject source, JSONObject dest)
private boolean mEnableVTrack;
/* 上个页面的Url*/
private String mLastScreenUrl;
private JSONObject mLastScreenTrackProperties;

private final Context mContext;
private final Context mActivityContext;
Expand Down

0 comments on commit 161dc77

Please sign in to comment.