Search in sources :

Example 1 with AnalyticsTransmissionTarget

use of com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget 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 AnalyticsTransmissionTarget

use of com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget in project mobile-center-sdk-android by Microsoft.

the class EventActivity method toggleDeviceIdEnabled.

public void toggleDeviceIdEnabled(View view) {
    final AnalyticsTransmissionTarget target = getSelectedTarget();
    if (target != null) {
        updateButtonStates(target);
        target.getPropertyConfigurator().collectDeviceId();
        mDeviceIdEnabledCheckBox.setChecked(true);
        mDeviceIdEnabledCheckBox.setText(R.string.device_id_enabled);
        mDeviceIdEnabledCheckBox.setEnabled(false);
        DEVICE_ID_ENABLED.add(target);
    }
}
Also used : AnalyticsTransmissionTarget(com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget)

Example 3 with AnalyticsTransmissionTarget

use of com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget in project mobile-center-sdk-android by Microsoft.

the class EventActivity method toggleTransmissionEnabled.

public void toggleTransmissionEnabled(View view) {
    boolean checked = mTransmissionEnabledCheckBox.isChecked();
    final AnalyticsTransmissionTarget target = getSelectedTarget();
    if (target != null) {
        target.setEnabledAsync(checked);
        updateButtonStates(target);
    }
}
Also used : AnalyticsTransmissionTarget(com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget)

Example 4 with AnalyticsTransmissionTarget

use of com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget in project mobile-center-sdk-android by Microsoft.

the class EventActivityUtil method getAnalyticTransmissionTargetList.

public static List<AnalyticsTransmissionTarget> getAnalyticTransmissionTargetList(Activity activity) {
    List<AnalyticsTransmissionTarget> targets = new ArrayList<>();
    /*
         * The first element is a placeholder for default transmission.
         * The second one is the parent transmission target, the third one is a child,
         * the forth is a grandchild, etc...
         */
    String[] targetTokens = activity.getResources().getStringArray(R.array.target_id_values);
    targets.add(null);
    targets.add(Analytics.getTransmissionTarget(targetTokens[1]));
    for (int i = 2; i < targetTokens.length; i++) {
        String targetToken = targetTokens[i];
        AnalyticsTransmissionTarget target = targets.get(i - 1).getTransmissionTarget(targetToken);
        targets.add(target);
    }
    return targets;
}
Also used : AnalyticsTransmissionTarget(com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget) ArrayList(java.util.ArrayList)

Aggregations

AnalyticsTransmissionTarget (com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget)4 EventProperties (com.microsoft.appcenter.analytics.EventProperties)1 TypedPropertyFragment (com.microsoft.appcenter.sasquatch.fragments.TypedPropertyFragment)1 ArrayList (java.util.ArrayList)1