plotline-engage 4.0.7 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/build.gradle
CHANGED
|
@@ -107,44 +107,51 @@ public class RNPlotline extends ReactContextBaseJavaModule {
|
|
|
107
107
|
Plotline.track(eventName, activity);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
final Activity activity = getCurrentActivity();
|
|
113
|
-
JSONObject properties = new JSONObject();
|
|
110
|
+
public JSONObject getJSONObjectFromReadableMap(ReadableMap object) {
|
|
111
|
+
JSONObject jsonObject = new JSONObject();
|
|
114
112
|
if (object != null) {
|
|
115
113
|
ReadableMapKeySetIterator iterator = object.keySetIterator();
|
|
116
114
|
while (iterator.hasNextKey()) {
|
|
117
115
|
String key = iterator.nextKey();
|
|
118
116
|
ReadableType type = object.getType(key);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
try {
|
|
118
|
+
switch (type) {
|
|
119
|
+
case String:
|
|
120
|
+
jsonObject.put(key, object.getString(key));
|
|
121
|
+
break;
|
|
122
|
+
case Number:
|
|
123
|
+
double doubleValue = object.getDouble(key);
|
|
124
|
+
if (doubleValue == (int) doubleValue) {
|
|
125
|
+
jsonObject.put(key, (int) doubleValue);
|
|
126
|
+
} else {
|
|
127
|
+
jsonObject.put(key, doubleValue);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case Boolean:
|
|
131
|
+
jsonObject.put(key, object.getBoolean(key));
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
} catch (Exception e) {
|
|
123
137
|
e.printStackTrace();
|
|
124
|
-
}
|
|
125
138
|
}
|
|
126
139
|
}
|
|
127
140
|
}
|
|
141
|
+
return jsonObject;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@ReactMethod
|
|
146
|
+
public void track(String eventName, ReadableMap object){
|
|
147
|
+
final Activity activity = getCurrentActivity();
|
|
148
|
+
JSONObject properties = getJSONObjectFromReadableMap(object);
|
|
128
149
|
Plotline.track(eventName, properties, activity);
|
|
129
150
|
}
|
|
130
151
|
|
|
131
152
|
@ReactMethod
|
|
132
153
|
public void identify(ReadableMap object) {
|
|
133
|
-
JSONObject jsonObject =
|
|
134
|
-
if (object != null) {
|
|
135
|
-
ReadableMapKeySetIterator iterator = object.keySetIterator();
|
|
136
|
-
while (iterator.hasNextKey()) {
|
|
137
|
-
String key = iterator.nextKey();
|
|
138
|
-
ReadableType type = object.getType(key);
|
|
139
|
-
if (type == ReadableType.String) {
|
|
140
|
-
try {
|
|
141
|
-
jsonObject.put((String) key, (String) object.getString(key));
|
|
142
|
-
} catch (JSONException e) {
|
|
143
|
-
e.printStackTrace();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
154
|
+
JSONObject jsonObject = getJSONObjectFromReadableMap(object);
|
|
148
155
|
Plotline.identify(jsonObject);
|
|
149
156
|
}
|
|
150
157
|
|