Search in sources :

Example 1 with TypedPropertyFragment

use of com.microsoft.appcenter.sasquatch.fragments.TypedPropertyFragment 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);
            }
        }
    }
}
Also used : AnalyticsTransmissionTarget(com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget) EventProperties(com.microsoft.appcenter.analytics.EventProperties) TypedPropertyFragment(com.microsoft.appcenter.sasquatch.fragments.TypedPropertyFragment)

Example 2 with TypedPropertyFragment

use of com.microsoft.appcenter.sasquatch.fragments.TypedPropertyFragment in project mobile-center-sdk-android by Microsoft.

the class PropertyActivity method addProperty.

private void addProperty() {
    TypedPropertyFragment fragment = new TypedPropertyFragment();
    Bundle bundle = new Bundle();
    bundle.putBoolean(TypedPropertyFragment.STRING_TYPE_ONLY_KEY, isStringTypeOnly());
    fragment.setArguments(bundle);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.add(R.id.list, fragment).commit();
    mProperties.add(fragment);
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) Bundle(android.os.Bundle) TypedPropertyFragment(com.microsoft.appcenter.sasquatch.fragments.TypedPropertyFragment)

Aggregations

TypedPropertyFragment (com.microsoft.appcenter.sasquatch.fragments.TypedPropertyFragment)2 Bundle (android.os.Bundle)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 AnalyticsTransmissionTarget (com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget)1 EventProperties (com.microsoft.appcenter.analytics.EventProperties)1