Skip to content

Commit

Permalink
analytics adapter hook (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacm authored Feb 29, 2024
1 parent f413e22 commit b7dad0f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public object HookInjectorClass {
TARGET_HOOK_CLASSES.add(HookData("com/sensorsdata/analytics/android/sdk/SensorsDataAPI","disableSDK","()V","com/growingio/android/analytics/sensor/SensorAnalyticsInjector","disableSDK","()V",false))
TARGET_HOOK_CLASSES.add(HookData("com/sensorsdata/analytics/android/sdk/SensorsDataAPI","enableSDK","()V","com/growingio/android/analytics/sensor/SensorAnalyticsInjector","enableSDK","()V",false))
TARGET_HOOK_CLASSES.add(HookData("com/sensorsdata/analytics/android/sdk/AbstractSensorsDataAPI","trackEvent","(Lcom/sensorsdata/analytics/android/sdk/internal/beans/EventType;Ljava/lang/String;Lorg/json/JSONObject;Ljava/lang/String;)V","com/growingio/android/analytics/sensor/SensorAnalyticsInjector","trackEvent","(Lcom/sensorsdata/analytics/android/sdk/internal/beans/EventType;Ljava/lang/String;Lorg/json/JSONObject;Ljava/lang/String;)V",false))
TARGET_HOOK_CLASSES.add(HookData("com/sensorsdata/analytics/android/sdk/core/event/imp/TrackEventAssemble","assembleData","(Lcom/sensorsdata/analytics/android/sdk/core/event/InputData;)Lcom/sensorsdata/analytics/android/sdk/core/event/Event;","com/growingio/android/analytics/sensor/SensorAnalyticsInjector","trackItemEvent","(Lcom/sensorsdata/analytics/android/sdk/core/event/InputData;)V",true))
return TARGET_HOOK_CLASSES
}

Expand Down
4 changes: 2 additions & 2 deletions autotracker-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ buildscript {
set("kotlin_version", "1.8.20")
set("agp_version", "8.1.0")
set("low_agp_version", "4.2.2")
set("releaseVersion", "4.1.0")
set("releaseVersionCode", 40100)
set("releaseVersion", "4.2.0-SNAPSHOT")
set("releaseVersionCode", 40200)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ fun initInjectClass(extension: AutoTrackerExtension) {
EXECUTE_INJECT_CLASS.add(ANALYTIC_ADAPTER_INJECT_CLASS[2])
INCLUDED_PACKAGES.add("com.sensorsdata.analytics.android.sdk.SensorsDataAPI")
INCLUDED_PACKAGES.add("com.sensorsdata.analytics.android.sdk.AbstractSensorsDataAPI")
INCLUDED_PACKAGES.add("com.sensorsdata.analytics.android.sdk.core.event.imp.TrackEventAssemble")
} else {
INCLUDED_PACKAGES.remove("com.sensorsdata.analytics.android.sdk.SensorsDataAPI")
INCLUDED_PACKAGES.remove("com.sensorsdata.analytics.android.sdk.AbstractSensorsDataAPI")
INCLUDED_PACKAGES.remove("com.sensorsdata.analytics.android.sdk.core.event.imp.TrackEventAssemble")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,16 @@ interface SensorAnalyticsInjector {
type = 0
)
fun trackEvent()

// for sensor sdk >=6.6.9
@Inject(
targetClazz = "com/sensorsdata/analytics/android/sdk/core/event/imp/TrackEventAssemble",
targetMethod = "assembleData",
targetMethodDesc = "(Lcom/sensorsdata/analytics/android/sdk/core/event/InputData;)Lcom/sensorsdata/analytics/android/sdk/core/event/Event;",
injectMethod = "trackItemEvent",
injectMethodDesc = "(Lcom/sensorsdata/analytics/android/sdk/core/event/InputData;)V",
isAfter = true,
type = 0
)
fun trackItemEvent()
}

0 comments on commit b7dad0f

Please sign in to comment.