use of com.microsoft.appcenter.analytics.EventProperties in project mobile-center-sdk-android by Microsoft.
the class EventActivity method send.
@Override
public void send(View view) {
AnalyticsTransmissionTarget target = getSelectedTarget();
PersistenceFlag persistenceFlag = PersistenceFlag.values()[mPersistenceFlagSpinner.getSelectedItemPosition()];
int flags = getFlags(persistenceFlag);
String name = mName.getText().toString();
Map<String, String> properties = null;
EventProperties typedProperties = null;
if (mProperties.size() > 0) {
if (onlyStringProperties()) {
properties = readStringProperties();
} else {
typedProperties = new EventProperties();
for (TypedPropertyFragment fragment : mProperties) {
fragment.set(typedProperties);
}
}
}
/* First item is always empty as it's default value which means either AppCenter, one collector or both. */
for (int i = 0; i < getNumberOfLogs(); i++) {
boolean useExplicitFlags = persistenceFlag != PersistenceFlag.DEFAULT;
if (target == null) {
if (properties != null) {
if (useExplicitFlags) {
Analytics.trackEvent(name, properties, flags);
} else {
Analytics.trackEvent(name, properties);
}
} else if (typedProperties != null || useExplicitFlags) {
if (useExplicitFlags) {
Analytics.trackEvent(name, typedProperties, flags);
} else {
Analytics.trackEvent(name, typedProperties);
}
} else {
Analytics.trackEvent(name);
}
} else {
if (properties != null) {
if (useExplicitFlags) {
target.trackEvent(name, properties, flags);
} else {
target.trackEvent(name, properties);
}
} else if (typedProperties != null || useExplicitFlags) {
if (useExplicitFlags) {
target.trackEvent(name, typedProperties, flags);
} else {
target.trackEvent(name, typedProperties);
}
} else {
target.trackEvent(name);
}
}
}
}
use of com.microsoft.appcenter.analytics.EventProperties in project mobile-center-sdk-android by Microsoft.
the class EventPropertiesActivity method updatePropertyList.
@SuppressWarnings({ "unchecked", "ConstantConditions" })
private void updatePropertyList() {
try {
Field field = getSelectedTarget().getPropertyConfigurator().getClass().getDeclaredField("mEventProperties");
field.setAccessible(true);
EventProperties eventProperties;
try {
eventProperties = (EventProperties) field.get(getSelectedTarget().getPropertyConfigurator());
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
Method method = eventProperties.getClass().getDeclaredMethod("getProperties");
method.setAccessible(true);
Map<String, TypedProperty> properties = (Map<String, TypedProperty>) method.invoke(eventProperties);
mPropertyListAdapter.mList.clear();
for (Map.Entry<String, TypedProperty> entry : properties.entrySet()) {
Object value = entry.getValue().getClass().getMethod("getValue").invoke(entry.getValue());
mPropertyListAdapter.mList.add(new Pair<>(entry.getKey(), value));
}
mListView.setAdapter(mPropertyListAdapter);
mPropertyListAdapter.notifyDataSetChanged();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations