Skip to content

Commit 72c6303

Browse files
committed
Release 3.0.5
1 parent 86b113a commit 72c6303

17 files changed

+278
-80
lines changed

README.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ buildscript {
1616
dependencies {
1717
classpath 'com.android.tools.build:gradle:2.2.3'
1818
//添加 android-gradle-plugin 依赖
19-
       classpath 'com.sensorsdata.analytics.android:android-gradle-plugin2:2.0.4'
19+
       classpath 'com.sensorsdata.analytics.android:android-gradle-plugin2:3.0.4'
2020
}
2121
}
2222
@@ -37,21 +37,16 @@ apply plugin: 'com.sensorsdata.analytics.android'
3737
dependencies {
3838
compile 'com.android.support:appcompat-v7:25.1.1'
3939
//添加 Sensors Analytics SDK 依赖
40-
  compile 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:2.0.2'
40+
  compile 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:3.1.0'
4141
}
4242
```
4343

44-
**
45-
1、由于 SDK 会依赖 appcompat-v7 处理下面几个控件:
46-
47-
* android.support.v7.widget.SwitchCompat
48-
* android.support.v7.app.AlertDialog
44+
## To Learn More
4945

50-
需要添加下面依赖( 如果项目中已引入了 v7包,可以不添加 ):
46+
See our [full manual](http://www.sensorsdata.cn/manual/android_sdk.html)
5147

52-
```android
53-
compile 'com.android.support:appcompat-v7:25.1.1'
54-
```
48+
或者加入 QQ 讨论群:<br>
49+
![ QQ 讨论群](https://github.com/sensorsdata/sa-sdk-android/raw/master/screenshots/qrCode.jpeg)
5550

5651
## 感谢
5752
[hugo](https://github.com/JakeWharton/hugo)
@@ -64,17 +59,14 @@ compile 'com.android.support:appcompat-v7:25.1.1'
6459

6560

6661
## 新书推荐
67-
神策数据出品的[《Android 全埋点解决方案》](https://item.jd.com/12574672.html)发售啦!!!
62+
神策数据出品的[《Android 全埋点解决方案》](https://u.jd.com/2JFaeG)发售啦!!!
6863

69-
[![《Android 全埋点解决方案》](screenshots/android_autotrack_book.png)](https://item.jd.com/12574672.html)
64+
[![《Android 全埋点解决方案》](https://github.com/sensorsdata/sa-sdk-android/raw/master/screenshots/android_autotrack_book.png)](https://u.jd.com/2JFaeG)
7065

71-
## To Learn More
72-
73-
See our [full manual](http://www.sensorsdata.cn/manual/android_sdk.html)
7466

7567
## License
7668

77-
Copyright 2015-2017 Sensors Data Inc.
69+
Copyright 2015-2019 Sensors Data Inc.
7870

7971
Licensed under the Apache License, Version 2.0 (the "License");
8072
you may not use this file except in compliance with the License.
@@ -93,3 +85,5 @@ distributed under the License is distributed on an "AS IS" BASIS,
9385
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9486
See the License for the specific language governing permissions and
9587
limitations under the License.gradle_plugin_android_aspectjx
88+
89+
**禁止一切基于神策数据开源 SDK 的商业活动!**

aop/ext.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.ext {
2-
pluginVersion = '3.0.4'
2+
pluginVersion = '3.0.5'
33
Properties properties = new Properties()
44
if (project.file('local.properties').exists()) {
55
properties.load(project.file('local.properties').newDataInputStream())

aop/src/main/groovy/com/sensorsdata/analytics/android/plugin/ClassNameAnalytics.groovy

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
/**Created by renqingyou on 2018/11/01.
2-
* Copyright © 2015-2019 Sensors Data Inc. All rights reserved. */
1+
/*
2+
* Created by renqingyou on 2018/12/01.
3+
* Copyright 2015-2019 Sensors Data Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
package com.sensorsdata.analytics.android.plugin
519

aop/src/main/groovy/com/sensorsdata/analytics/android/plugin/Logger.groovy

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1-
/**Created by wangzhuozhou on 2015/08/01.
2-
* Copyright © 2015-2019 Sensors Data Inc. All rights reserved. */
1+
/*
2+
* Created by wangzhuozhou on 2015/08/12.
3+
* Copyright 2015-2019 Sensors Data Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
318
package com.sensorsdata.analytics.android.plugin
419

520
import java.lang.reflect.Array

aop/src/main/groovy/com/sensorsdata/analytics/android/plugin/SensorsAnalyticsClassVisitor.groovy

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
/**Created by wangzhuozhou on 2015/08/01.
2-
* Copyright © 2015-2019 Sensors Data Inc. All rights reserved. */
1+
/*
2+
* Created by wangzhuohou on 2015/08/01.
3+
* Copyright 2015-2019 Sensors Data Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
package com.sensorsdata.analytics.android.plugin
519

@@ -30,7 +44,7 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
3044
return super.clone()
3145
}
3246

33-
SensorsAnalyticsClassVisitor(final ClassVisitor classVisitor,ClassNameAnalytics classNameAnalytics,SensorsAnalyticsTransformHelper transformHelper) {
47+
SensorsAnalyticsClassVisitor(final ClassVisitor classVisitor, ClassNameAnalytics classNameAnalytics, SensorsAnalyticsTransformHelper transformHelper) {
3448
super(Opcodes.ASM5, classVisitor)
3549
this.classVisitor = classVisitor
3650
this.classNameAnalytics = classNameAnalytics
@@ -102,7 +116,7 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
102116
}
103117

104118
for (cell in methodCells) {
105-
transformHelper.sensorsAnalyticsHookConfig."${cell.agentName}"(classVisitor,cell)
119+
transformHelper.sensorsAnalyticsHookConfig."${cell.agentName}"(classVisitor, cell)
106120
}
107121

108122
Logger.info("结束扫描类:${mClassName}\n")
@@ -113,14 +127,14 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
113127
FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
114128
if (classNameAnalytics.isSensorsDataAPI) {
115129
if ('VERSION' == name) {
116-
String version = (String)value
130+
String version = (String) value
117131
if (SensorsAnalyticsTransform.MIN_SDK_VERSION > version) {
118132
String errMessage = "你目前集成的神策埋点 SDK 版本号为 v${version},请升级到 v${SensorsAnalyticsTransform.MIN_SDK_VERSION} 及以上的版本。详情请参考:https://github.com/sensorsdata/sa-sdk-android"
119133
Logger.error(errMessage)
120134
throw new Error(errMessage)
121135
}
122136
} else if ('MIN_PLUGIN_VERSION' == name) {
123-
String minPluginVersion = (String)value
137+
String minPluginVersion = (String) value
124138
if (minPluginVersion != "" && minPluginVersion != null) {
125139
if (SensorsAnalyticsTransform.VERSION < minPluginVersion) {
126140
String errMessage = "你目前集成的神策插件版本号为 v${SensorsAnalyticsTransform.VERSION},请升级到 v${minPluginVersion} 及以上的版本。详情请参考:https://github.com/sensorsdata/sa-sdk-android-plugin2"
@@ -132,8 +146,8 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
132146
}
133147
return super.visitField(access, name, descriptor, signature, value)
134148
}
135-
/**
136-
* 该方法是当扫描器扫描到类的方法时进行调用
149+
/**
150+
* 该方法是当扫描器扫描到类的方法时进行调用
137151
* @param access 表示方法的修饰符
138152
* @param name 表示方法名,在 ASM 中 “visitMethod” 方法会处理(构造方法、静态代码块、私有方法、受保护的方法、共有方法、native类型方法)。
139153
* 在这些范畴中构造方法的方法名为 “<init>”,静态代码块的方法名为 “<clinit>”。
@@ -162,6 +176,7 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
162176
int variableID = 0
163177
//nameDesc是'onClick(Landroid/view/View;)V'字符串
164178
boolean isOnClickMethod = false
179+
boolean isOnItemClickMethod = false
165180
//name + desc
166181
String nameDesc
167182

@@ -188,6 +203,11 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
188203
variableID = newLocal(Type.getObjectType("java/lang/Integer"))
189204
methodVisitor.visitVarInsn(ALOAD, 1)
190205
methodVisitor.visitVarInsn(ASTORE, variableID)
206+
} else if (nameDesc == 'onItemClick(Landroid/widget/AdapterView;Landroid/view/View;IJ)V' && pubAndNoStaticAccess) {
207+
isOnItemClickMethod = true
208+
variableID = newLocal(Type.getObjectType("java/lang/Integer"))
209+
methodVisitor.visitVarInsn(ALOAD, 1)
210+
methodVisitor.visitVarInsn(ASTORE, variableID)
191211
}
192212
}
193213

@@ -319,11 +339,20 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
319339
}
320340

321341
if (mInterfaces != null && mInterfaces.length > 0) {
322-
SensorsAnalyticsMethodCell sensorsAnalyticsMethodCell = SensorsAnalyticsHookConfig.sInterfaceMethods.get(nameDesc)
323-
if (sensorsAnalyticsMethodCell != null && mInterfaces.contains(sensorsAnalyticsMethodCell.parent)) {
324-
visitMethodWithLoadedParams(methodVisitor, Opcodes.INVOKESTATIC, SensorsAnalyticsHookConfig.sSensorsAnalyticsAPI, sensorsAnalyticsMethodCell.agentName, sensorsAnalyticsMethodCell.agentDesc, sensorsAnalyticsMethodCell.paramsStart, sensorsAnalyticsMethodCell.paramsCount, sensorsAnalyticsMethodCell.opcodes)
342+
if (isOnItemClickMethod && mInterfaces.contains('android/widget/AdapterView$OnItemClickListener')) {
343+
methodVisitor.visitVarInsn(ALOAD, variableID)
344+
methodVisitor.visitVarInsn(ALOAD, 2)
345+
methodVisitor.visitVarInsn(ILOAD, 3)
346+
methodVisitor.visitMethodInsn(INVOKESTATIC, SensorsAnalyticsHookConfig.sSensorsAnalyticsAPI, "trackListView", "(Landroid/widget/AdapterView;Landroid/view/View;I)V", false)
325347
isHasTracked = true
326348
return
349+
} else {
350+
SensorsAnalyticsMethodCell sensorsAnalyticsMethodCell = SensorsAnalyticsHookConfig.sInterfaceMethods.get(nameDesc)
351+
if (sensorsAnalyticsMethodCell != null && mInterfaces.contains(sensorsAnalyticsMethodCell.parent)) {
352+
visitMethodWithLoadedParams(methodVisitor, INVOKESTATIC, SensorsAnalyticsHookConfig.sSensorsAnalyticsAPI, sensorsAnalyticsMethodCell.agentName, sensorsAnalyticsMethodCell.agentDesc, sensorsAnalyticsMethodCell.paramsStart, sensorsAnalyticsMethodCell.paramsCount, sensorsAnalyticsMethodCell.opcodes)
353+
isHasTracked = true
354+
return
355+
}
327356
}
328357
}
329358

@@ -363,7 +392,7 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
363392
void visit(String key, Object value) {
364393
super.visit(key, value)
365394
if ("eventName" == key) {
366-
eventName = (String)value
395+
eventName = (String) value
367396
} else if ("properties" == key) {
368397
eventProperties = value.toString()
369398
}

aop/src/main/groovy/com/sensorsdata/analytics/android/plugin/SensorsAnalyticsDefaultMethodVisitor.groovy

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
/**Created by wangzhuozhou on 2015/08/01.
2-
* Copyright © 2015-2019 Sensors Data Inc. All rights reserved. */
1+
/*
2+
* Created by wangzhuozhou on 2015/08/12.
3+
* Copyright 2015-2019 Sensors Data Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
package com.sensorsdata.analytics.android.plugin
519

aop/src/main/groovy/com/sensorsdata/analytics/android/plugin/SensorsAnalyticsExtension.groovy

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
/**Created by wangzhuozhou on 2015/08/01.
2-
* Copyright © 2015-2019 Sensors Data Inc. All rights reserved. */
1+
/*
2+
* Created by wangzhuozhou on 2015/08/12.
3+
* Copyright 2015-2019 Sensors Data Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
package com.sensorsdata.analytics.android.plugin
519

@@ -45,14 +59,14 @@ class SensorsAnalyticsExtension {
4559
includeBuilder.append(",")
4660
}
4761
}
48-
return " debug=" + debug + "\n" +
49-
" disableJar=" + disableJar + "\n" +
50-
" useInclude=" + useInclude + "\n" +
51-
" lambdaEnabled=" + lambdaEnabled + "\n" +
52-
" exclude=[" + excludeBuilder.toString() +"]"+ "\n" +
53-
" include=[" + includeBuilder.toString() +"]"+ "\n" +
54-
" sdk {\n" + sdk + "\n"+
55-
"}"
62+
return "\tdebug=" + debug + "\n" +
63+
"\tdisableJar=" + disableJar + "\n" +
64+
"\tuseInclude=" + useInclude + "\n" +
65+
"\tlambdaEnabled=" + lambdaEnabled + "\n" +
66+
"\texclude=[" + excludeBuilder.toString() +"]"+ "\n" +
67+
"\tinclude=[" + includeBuilder.toString() +"]"+ "\n" +
68+
"\tsdk {\n" + sdk + "\n"+
69+
"\t}"
5670
}
5771
}
5872

aop/src/main/groovy/com/sensorsdata/analytics/android/plugin/SensorsAnalyticsHookConfig.groovy

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
/**Created by wangzhuozhou on 2015/08/01.
2-
* Copyright © 2015-2019 Sensors Data Inc. All rights reserved. */
1+
/*
2+
* Created by wangzhuozhou on 2015/08/12.
3+
* Copyright 2015-2019 Sensors Data Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
package com.sensorsdata.analytics.android.plugin
519

@@ -53,14 +67,6 @@ class SensorsAnalyticsHookConfig {
5367
'(Landroid/content/DialogInterface;I)V',
5468
1, 2,
5569
[Opcodes.ALOAD, Opcodes.ILOAD]))
56-
sInterfaceMethods.put('onItemClick(Landroid/widget/AdapterView;Landroid/view/View;IJ)V', new SensorsAnalyticsMethodCell(
57-
'onItemClick',
58-
'(Landroid/widget/AdapterView;Landroid/view/View;IJ)V',
59-
'android/widget/AdapterView$OnItemClickListener',
60-
'trackListView',
61-
'(Landroid/widget/AdapterView;Landroid/view/View;I)V',
62-
1, 3,
63-
[Opcodes.ALOAD, Opcodes.ALOAD, Opcodes.ILOAD]))
6470
sInterfaceMethods.put('onItemSelected(Landroid/widget/AdapterView;Landroid/view/View;IJ)V', new SensorsAnalyticsMethodCell(
6571
'onItemSelected',
6672
'(Landroid/widget/AdapterView;Landroid/view/View;IJ)V',

aop/src/main/groovy/com/sensorsdata/analytics/android/plugin/SensorsAnalyticsJSRAdapter.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
/**Created by renqingyou on 2018/12/01.
2-
* Copyright © 2015-2019 Sensors Data Inc. All rights reserved. */
1+
/*
2+
* Created by renqingyou on 2018/12/01.
3+
* Copyright 2015-2019 Sensors Data Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
package com.sensorsdata.analytics.android.plugin;
519

aop/src/main/groovy/com/sensorsdata/analytics/android/plugin/SensorsAnalyticsMethodCell.groovy

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
/**Created by wangzhuozhou on 2015/08/01.
2-
* Copyright © 2015-2019 Sensors Data Inc. All rights reserved. */
1+
/*
2+
* Created by wangzhuozhou on 2015/08/12.
3+
* Copyright 2015-2019 Sensors Data Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
package com.sensorsdata.analytics.android.plugin
519

0 commit comments

Comments
 (0)