-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chenru
committed
Mar 1, 2021
1 parent
736f853
commit 90bda7c
Showing
23 changed files
with
373 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
android/src/main/java/com/sensorsdata/analytics/property/LibMethodInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Created by chenru on 2021/01/05. | ||
* Copyright 2015-2021 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.property; | ||
|
||
import com.sensorsdata.analytics.property.RNPropertyManager.Interceptor; | ||
|
||
import org.json.JSONObject; | ||
|
||
public class LibMethodInterceptor implements Interceptor { | ||
|
||
public JSONObject proceed(JSONObject properties, boolean isAuto) { | ||
if (properties == null) { | ||
properties = new JSONObject(); | ||
} | ||
try { | ||
if (!"autoTrack".equals(properties.optString("$lib_method"))) { | ||
if (isAuto) { | ||
properties.put("$lib_method", "autoTrack"); | ||
} else { | ||
properties.put("$lib_method", "code"); | ||
} | ||
} | ||
} catch (Exception ignored) { | ||
|
||
} | ||
return properties; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
android/src/main/java/com/sensorsdata/analytics/property/PluginVersionInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Created by chenru on 2020/12/27. | ||
* Copyright 2015-2021 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.property; | ||
|
||
import com.sensorsdata.analytics.RNSensorsAnalyticsPackage; | ||
import com.sensorsdata.analytics.property.RNPropertyManager.Interceptor; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
|
||
public class PluginVersionInterceptor implements Interceptor { | ||
private static boolean isMergePluginVersion = false; | ||
|
||
public JSONObject proceed(JSONObject properties, boolean isAuto){ | ||
if(!isMergePluginVersion){ | ||
if(properties == null){ | ||
properties = new JSONObject(); | ||
}else if(properties.has("$lib_plugin_version")){ | ||
return properties; | ||
} | ||
try{ | ||
JSONArray array = new JSONArray(); | ||
array.put("react_native:" + RNSensorsAnalyticsPackage.VERSION); | ||
properties.put("$lib_plugin_version",array); | ||
}catch (Exception ignored){ | ||
//ignore | ||
} | ||
isMergePluginVersion = true; | ||
} | ||
return properties; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
android/src/main/java/com/sensorsdata/analytics/property/RNPropertyManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Created by chenru on 2020/12/27. | ||
* Copyright 2015-2021 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.property; | ||
|
||
import org.json.JSONObject; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class RNPropertyManager { | ||
|
||
public static List<Interceptor> interceptors = new ArrayList<>(); | ||
|
||
public static void addInterceptor(Interceptor interceptor){ | ||
interceptors.add(interceptor); | ||
} | ||
|
||
public static JSONObject mergeProperty(JSONObject properties){ | ||
return mergeProperty(properties, false); | ||
} | ||
|
||
public static JSONObject mergeProperty(JSONObject properties, boolean isAuto){ | ||
for(Interceptor interceptor:interceptors){ | ||
properties = interceptor.proceed(properties, isAuto); | ||
} | ||
return properties; | ||
} | ||
|
||
interface Interceptor{ | ||
JSONObject proceed(JSONObject properties, boolean isAuto); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.