@metrixorg/react-native-plugin 1.2.0-beta08 → 1.2.0-beta09
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.
|
@@ -12,6 +12,9 @@ import com.facebook.react.bridge.ReactMethod;
|
|
|
12
12
|
import com.facebook.react.bridge.ReadableMap;
|
|
13
13
|
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
14
14
|
import com.facebook.react.bridge.WritableMap;
|
|
15
|
+
|
|
16
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
17
|
+
|
|
15
18
|
import android.util.Log;
|
|
16
19
|
|
|
17
20
|
import java.util.HashMap;
|
|
@@ -108,48 +111,39 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
@ReactMethod
|
|
111
|
-
public void setOnAttributionChangedListener(
|
|
114
|
+
public void setOnAttributionChangedListener() {
|
|
115
|
+
ir.metrix.Metrix.setOnAttributionChangedListener(
|
|
116
|
+
new OnAttributionChangeListener() {
|
|
117
|
+
@Override
|
|
118
|
+
public void onAttributionChanged(AttributionData attributionData) {
|
|
119
|
+
WritableMap map = getWritableMapFromAttributionModel(attributionData);
|
|
112
120
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
@Override
|
|
117
|
-
public void onAttributionChanged(AttributionData attributionData) {
|
|
118
|
-
WritableMap map = getWritableMapFromAttributionModel(attributionData);
|
|
119
|
-
|
|
120
|
-
callback.invoke(map);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
121
|
+
sendObjectEvent("onAttributionChangedListener", map);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
@ReactMethod
|
|
127
|
-
public void setUserIdListener(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
127
|
+
public void setUserIdListener() {
|
|
128
|
+
ir.metrix.Metrix.setUserIdListener(
|
|
129
|
+
new UserIdListener() {
|
|
130
|
+
@Override
|
|
131
|
+
public void onUserIdReceived(String userId) {
|
|
132
|
+
sendStringEvent("onUserIdListener", userId);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
138
135
|
}
|
|
139
136
|
|
|
140
137
|
@ReactMethod
|
|
141
|
-
public void setOnDeeplinkResponseListener(final boolean shouldLaunchDeeplink
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
138
|
+
public void setOnDeeplinkResponseListener(final boolean shouldLaunchDeeplink) {
|
|
139
|
+
ir.metrix.Metrix.setOnDeeplinkResponseListener(
|
|
140
|
+
new OnDeeplinkResponseListener() {
|
|
141
|
+
@Override
|
|
142
|
+
public boolean launchReceivedDeeplink(Uri deeplink) {
|
|
143
|
+
sendStringEvent("onDeeplinkResponseListener", deeplink.toString());
|
|
144
|
+
return shouldLaunchDeeplink;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
153
147
|
}
|
|
154
148
|
|
|
155
149
|
private WritableMap getWritableMapFromAttributionModel(AttributionData attributionData) {
|
|
@@ -177,4 +171,16 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
177
171
|
}
|
|
178
172
|
return map;
|
|
179
173
|
}
|
|
174
|
+
|
|
175
|
+
private void sendObjectEvent(String eventName, WritableMap param) {
|
|
176
|
+
getReactApplicationContext()
|
|
177
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
178
|
+
.emit(eventName, param);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private void sendStringEvent(String eventName, String param) {
|
|
182
|
+
getReactApplicationContext()
|
|
183
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
184
|
+
.emit(eventName, param);
|
|
185
|
+
}
|
|
180
186
|
}
|
package/index.js
CHANGED
|
@@ -31,30 +31,18 @@ Metrix.getSessionId = function(callback) {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
Metrix.setOnAttributionChangedListener = function(callback) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} else {
|
|
37
|
-
eventEmitter.addListener('onAttributionChangedListener', callback);
|
|
38
|
-
module_metrix.setOnAttributionChangedListener();
|
|
39
|
-
}
|
|
34
|
+
eventEmitter.addListener('onAttributionChangedListener', callback);
|
|
35
|
+
module_metrix.setOnAttributionChangedListener();
|
|
40
36
|
};
|
|
41
37
|
|
|
42
38
|
Metrix.setOnDeeplinkResponseListener = function(callback) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} else {
|
|
46
|
-
eventEmitter.addListener('onDeeplinkResponseListener', callback);
|
|
47
|
-
module_metrix.setOnDeeplinkResponseListener(this.shouldLaunchDeeplink);
|
|
48
|
-
}
|
|
39
|
+
eventEmitter.addListener('onDeeplinkResponseListener', callback);
|
|
40
|
+
module_metrix.setOnDeeplinkResponseListener(this.shouldLaunchDeeplink);
|
|
49
41
|
};
|
|
50
42
|
|
|
51
43
|
Metrix.setUserIdListener = function(callback) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} else {
|
|
55
|
-
eventEmitter.addListener('onUserIdListener', callback);
|
|
56
|
-
module_metrix.setUserIdListener();
|
|
57
|
-
}
|
|
44
|
+
eventEmitter.addListener('onUserIdListener', callback);
|
|
45
|
+
module_metrix.setUserIdListener();
|
|
58
46
|
};
|
|
59
47
|
|
|
60
48
|
Metrix.newEvent = function(eventName, customAttributes) {
|