Java Code Examples for com.crashlytics.android.answers.Answers

The following are top voted examples for showing how to use com.crashlytics.android.answers.Answers. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Unofficial-Ups   File: AnalyticsManager.java   View source code 6 votes vote down vote up
public static void eventLogin(Context context,boolean success){
    //Fabric
    Answers.getInstance().logSignUp(new SignUpEvent()
            .putMethod("Normal")
            .putSuccess(success));

    //Firebase
    Bundle params = new Bundle();
    params.putBoolean("Success",success);
    FirebaseAnalytics.getInstance(context).logEvent(AnalyticsConstants.EVENT_LOGIN,params);

    //Amplitude
    try {
        Amplitude.getInstance().logEvent(AnalyticsConstants.EVENT_LOGIN,new JSONObject().put("Success",success));
    } catch (JSONException e) {
        Crashlytics.logException(e);
    }

}
 
Example 2
Project: Unofficial-Ups   File: AnalyticsManager.java   View source code 6 votes vote down vote up
public static void eventCalculate(Context context,Course course, double grade){
    //Fabric
    Answers.getInstance().logCustom(new CustomEvent(AnalyticsConstants.EVENT_CALCULATION)
            .putCustomAttribute("Course name", course.getName())
            .putCustomAttribute("Course code", course.getCode())
            .putCustomAttribute("Result", grade));

    //Firebase
    Bundle params = new Bundle();
    params.putString("course_name",course.getName());
    params.putString("course_code",course.getCode());
    params.putDouble("result",grade);
    FirebaseAnalytics.getInstance(context).logEvent(AnalyticsConstants.EVENT_CALCULATION,params);

    //Amplitude
    try {
        Amplitude.getInstance().logEvent(AnalyticsConstants.EVENT_CALCULATION, new JSONObject()
                .put("Course name",course.getName())
                .put("Course code",course.getCode())
                .put("Result",grade));
    } catch (JSONException e) {
        Crashlytics.logException(e);
    }

}
 
Example 3
Project: Unofficial-Ups   File: AnalyticsManager.java   View source code 6 votes vote down vote up
public static void eventReserve(String resourceType, String venue, int hourOfDay){
    //Fabric
    Answers.getInstance().logCustom(new CustomEvent(AnalyticsConstants.EVENT_RESERVE)
            .putCustomAttribute("Resource Type", resourceType)
            .putCustomAttribute("Venue", venue)
            .putCustomAttribute("Hour", hourOfDay));
    //Amplitude
    try {
        Amplitude.getInstance().logEvent(AnalyticsConstants.EVENT_RESERVE, new JSONObject()
                .put("Resource Type",resourceType)
                .put("Venue",venue)
                .put("Hour",hourOfDay));
    } catch (JSONException e) {
        Crashlytics.logException(e);
    }
}
 
Example 4
Project: Unofficial-Ups   File: AnalyticsManager.java   View source code 6 votes vote down vote up
public static void eventUpdated(Context context, int fromVersion, int toVersion){
    //Fabric
    Answers.getInstance().logCustom(new CustomEvent(AnalyticsConstants.EVENT_UPDATE)
            .putCustomAttribute("From Version", fromVersion)
            .putCustomAttribute("To Version", toVersion));

    //Firebase
    Bundle params = new Bundle();
    params.putInt("from_version",fromVersion);
    params.putInt("to_version",toVersion);
    FirebaseAnalytics.getInstance(context).logEvent(AnalyticsConstants.EVENT_UPDATE,params);

    //Amplitude
    try {
        Amplitude.getInstance().logEvent(AnalyticsConstants.EVENT_UPDATE, new JSONObject()
                .put("From Version",fromVersion)
                .put("To Version",toVersion));
    } catch (JSONException e) {
        Crashlytics.logException(e);
    }

}
 
Example 5
Project: My-Android-Base-Code   File: CrashLyticManager.java   View source code 6 votes vote down vote up
@Override
public void sendUserProperties(String name, String value) {
    switch (name) {
        case AnalyticConstant.USER_EMAIL:
            Crashlytics.setUserEmail(value);
            break;
        case AnalyticConstant.USER_NAME:
            Crashlytics.setUserName(value);
            break;
        case AnalyticConstant.USER_SIGN_IN:
            Answers.getInstance().logLogin(new LoginEvent().putMethod(value).putSuccess(true));
            break;
        case AnalyticConstant.USER_SIGN_UP:
            Answers.getInstance().logSignUp(new SignUpEvent().putMethod(value).putSuccess(true));
            break;
        default:
            Answers.getInstance().logCustom(new CustomEvent("Custom_Event").putCustomAttribute(name, value));
            break;
    }

}
 
Example 6
Project: MVP-Android   File: CrashLyticManager.java   View source code 6 votes vote down vote up
@Override
public void sendUserProperties(String name, String value) {
    switch (name) {
        case AnalyticConstant.USER_EMAIL:
            Crashlytics.setUserEmail(value);
            break;
        case AnalyticConstant.USER_NAME:
            Crashlytics.setUserName(value);
            break;
        case AnalyticConstant.USER_SIGN_IN:
            Answers.getInstance().logLogin(new LoginEvent().putMethod(value).putSuccess(true));
            break;
        case AnalyticConstant.USER_SIGN_UP:
            Answers.getInstance().logSignUp(new SignUpEvent().putMethod(value).putSuccess(true));
            break;
        default:
            Answers.getInstance().logCustom(new CustomEvent("Custom_Event").putCustomAttribute(name, value));
            break;
    }

}
 
Example 7
Project: letv   File: Crashlytics.java   View source code 6 votes vote down vote up
public Crashlytics build() {
    if (this.coreBuilder != null) {
        if (this.core != null) {
            throw new IllegalStateException("Must not use Deprecated methods delay(), disabled(), listener(), pinningInfoProvider() with core()");
        }
        this.core = this.coreBuilder.build();
    }
    if (this.answers == null) {
        this.answers = new Answers();
    }
    if (this.beta == null) {
        this.beta = new Beta();
    }
    if (this.core == null) {
        this.core = new CrashlyticsCore();
    }
    return new Crashlytics(this.answers, this.beta, this.core);
}
 
Example 8
Project: Android-Scrapper   File: TallyStackerApplication.java   View source code 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    TallyStackerApplication.instance = this;
    JodaTimeAndroid.init(this);
    Fabric.with(this, new Crashlytics());
    Fabric.with(this, new Answers());
    Stetho.initializeWithDefaults(this);
    // Setup handler for uncaught exceptions.
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread thread, Throwable e) {
            if (!(e instanceof ExpectedElementNotFound))
                handleUncaughtException(e);
        }
    });
}
 
Example 9
Project: Brevent   File: StatsUtils.java   View source code 6 votes vote down vote up
public static void logInvite(Map<String, Object> attributes) {
    try {
        InviteEvent inviteEvent = new InviteEvent();
        for (Map.Entry<String, Object> entry : attributes.entrySet()) {
            Object value = entry.getValue();
            if (value instanceof String) {
                inviteEvent.putCustomAttribute(entry.getKey(), (String) value);
            } else if (value instanceof Number) {
                inviteEvent.putCustomAttribute(entry.getKey(), (Number) value);
            }
        }
        Answers.getInstance().logInvite(inviteEvent);
    } catch (IllegalStateException e) { // NOSONAR
        // do nothing
    }
}
 
Example 10
Project: Brevent   File: StatsUtils.java   View source code 6 votes vote down vote up
public static void logLogin(Map<String, Object> attributes) {
    try {
        LoginEvent loginEvent = new LoginEvent();
        for (Map.Entry<String, Object> entry : attributes.entrySet()) {
            Object value = entry.getValue();
            if (value instanceof String) {
                loginEvent.putCustomAttribute(entry.getKey(), (String) value);
            } else if (value instanceof Number) {
                loginEvent.putCustomAttribute(entry.getKey(), (Number) value);
            }
        }
        Answers.getInstance().logLogin(loginEvent);
    } catch (IllegalStateException e) { // NOSONAR
        // do nothing
    }
}
 
Example 11
Project: Telephoto   File: BuyActivity.java   View source code 6 votes vote down vote up
private void afterPayment() {
    PrefsController.instance.makePro();
    Answers.getInstance().logCustom(new CustomEvent(ANSWER_STEP_BUY).putCustomAttribute("step", "Go Pro!"));
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AlertDialog.Builder(BuyActivity.this)
                    .setTitle(R.string.warning)
                    .setMessage(R.string.buy_thank_you_for_bought)
                    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            BuyActivity.this.finish();
                        }
                    })
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .show();
        }
    });
}
 
Example 12
Project: Ghost-Android   File: SpectreApplication.java   View source code 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    Fabric.with(this, new Crashlytics(), new Answers());
    Log.useEnvironment(BuildConfig.DEBUG ? Log.Environment.DEBUG : Log.Environment.RELEASE);
    Log.i(TAG, "APP LAUNCHED");

    BusProvider.getBus().register(this);
    sInstance = this;

    RxJavaPlugins.setErrorHandler(this::uncaughtRxException);

    setupMetadataRealm();
    setupFonts();
    initOkHttpClient();
    initPicasso();

    NetworkService networkService = new NetworkService();
    mHACKListener = networkService;
    networkService.start(mOkHttpClient);

    mAnalyticsService = new AnalyticsService(BusProvider.getBus());
    mAnalyticsService.start();
}
 
Example 13
Project: ttnmapper_android_v2   File: LogInToTTN.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_log_in_to_ttn);

    clientId = getString(R.string.oauth_client_id);
    clientSecret = getString(R.string.oauth_client_secret);
    redirectURI = getString(R.string.oauth_redirect_url);

    service = new ServiceBuilder()
            .apiKey(clientId)
            .apiSecret(clientSecret)
            .state(secretState)
            .callback(redirectURI)
            .build(TheThingsNetworkOathApi.instance());

    MyApplication mApplication = (MyApplication)getApplicationContext();
    mApplication.ttnApplications = new ArrayList<>();
    mApplication.chosenTtnApplication = null;

    Answers.getInstance().logCustom(new CustomEvent("Device configure").putCustomAttribute("method", "oauth2"));

    loadLoginPage();
}
 
Example 14
Project: ttnmapper_android_v2   File: DevicesList.java   View source code 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    String selectedDevice = (String) adapterView.getAdapter().getItem(i);
    MyApplication mApplication = (MyApplication)getApplicationContext();

    mApplication.setTtnDeviceId(selectedDevice);
    if (selectedDevice.equals("+")) {
        Answers.getInstance().logCustom(new CustomEvent("Levices")
                .putCustomAttribute("all devices", "" + true));
    } else {
        Answers.getInstance().logCustom(new CustomEvent("Levices")
                .putCustomAttribute("all devices", "" + false));
    }

    mApplication.ttnApplications.clear(); //free some memory
    finish();
}
 
Example 15
Project: ttnmapper_android_v2   File: SettingsActivity.java   View source code 6 votes vote down vote up
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
    if (resultCode == Activity.RESULT_OK && requestCode == 5) {
        Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);

        SharedPreferences myPrefs = this.getSharedPreferences(SettingConstants.PREFERENCES, MODE_PRIVATE);
        SharedPreferences.Editor prefsEditor = myPrefs.edit();
        if (uri != null) {
            prefsEditor.putString(SettingConstants.SOUNDFILE, uri.toString());
            prefsEditor.apply();
            Log.d(TAG, "Chosen sound: " + uri.toString());

            Answers.getInstance().logCustom(new CustomEvent("Sound")
                    .putCustomAttribute("uri", uri.toString()));
        } else {
            prefsEditor.putString(SettingConstants.SOUNDFILE, "");
            prefsEditor.apply();
        }
        TextView soundTV = (TextView) findViewById(R.id.textViewCurrentSound);
        soundTV.setText(myPrefs.getString(SettingConstants.SOUNDFILE, SettingConstants.SOUNDFILE_DEFAULT));
    }
}
 
Example 16
Project: ttnmapper_android_v2   File: MapsActivity.java   View source code 6 votes vote down vote up
public void onToggleScreen(View v) {
    com.github.clans.fab.FloatingActionButton floatingActionButton = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabItemScreenOn);
    SharedPreferences myPrefs = this.getSharedPreferences(SettingConstants.PREFERENCES, MODE_PRIVATE);
    boolean previousState = myPrefs.getBoolean(SettingConstants.KEEP_SCREEN_ON, SettingConstants.KEEP_SCREEN_ON_DEFAULT);

    SharedPreferences.Editor prefsEditor = myPrefs.edit();
    prefsEditor.putBoolean(SettingConstants.KEEP_SCREEN_ON, !previousState);
    prefsEditor.apply();

    if (previousState) {
        floatingActionButton.setColorNormalResId(R.color.fab_disabled);
        floatingActionButton.setColorPressedResId(R.color.fab_disabled_pressed);

        //It was on, now off
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        floatingActionButton.setColorNormalResId(R.color.fab_green_dark);
        floatingActionButton.setColorPressedResId(R.color.fab_green_light);

        //It was off, now on
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    Answers.getInstance().logCustom(new CustomEvent(SettingConstants.KEEP_SCREEN_ON)
            .putCustomAttribute("on", "" + !previousState));
}
 
Example 17
Project: ttnmapper_android_v2   File: MapsActivity.java   View source code 6 votes vote down vote up
public void onToggleAutoCenter(View v) {
    com.github.clans.fab.FloatingActionButton floatingActionButton = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabItemAutoCenter);
    SharedPreferences myPrefs = this.getSharedPreferences(SettingConstants.PREFERENCES, MODE_PRIVATE);
    boolean previousState = myPrefs.getBoolean(SettingConstants.AUTO_CENTER, SettingConstants.AUTO_CENTER_DEFAULT);

    SharedPreferences.Editor prefsEditor = myPrefs.edit();
    prefsEditor.putBoolean(SettingConstants.AUTO_CENTER, !previousState);
    prefsEditor.apply();

    if (previousState) {
        floatingActionButton.setColorNormalResId(R.color.fab_disabled);
        floatingActionButton.setColorPressedResId(R.color.fab_disabled_pressed);

        //It's off now, do nothing
    } else {
        floatingActionButton.setColorNormalResId(R.color.fab_green_dark);
        floatingActionButton.setColorPressedResId(R.color.fab_green_light);

        autoCenterMap();
    }

    Answers.getInstance().logCustom(new CustomEvent(SettingConstants.AUTO_CENTER)
            .putCustomAttribute("on", "" + !previousState));
}
 
Example 18
Project: ttnmapper_android_v2   File: MapsActivity.java   View source code 6 votes vote down vote up
public void onToggleAutoZoom(View v) {
    com.github.clans.fab.FloatingActionButton floatingActionButton = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabItemAutoZoom);
    SharedPreferences myPrefs = this.getSharedPreferences(SettingConstants.PREFERENCES, MODE_PRIVATE);
    boolean previousState = myPrefs.getBoolean(SettingConstants.AUTO_ZOOM, SettingConstants.AUTO_ZOOM_DEFAULT);

    SharedPreferences.Editor prefsEditor = myPrefs.edit();
    prefsEditor.putBoolean(SettingConstants.AUTO_ZOOM, !previousState);
    prefsEditor.apply();

    if (previousState) {
        floatingActionButton.setColorNormalResId(R.color.fab_disabled);
        floatingActionButton.setColorPressedResId(R.color.fab_disabled_pressed);

        //It's off now, do nothing
    } else {
        floatingActionButton.setColorNormalResId(R.color.fab_green_dark);
        floatingActionButton.setColorPressedResId(R.color.fab_green_light);

        autoZoomMap();
    }

    Answers.getInstance().logCustom(new CustomEvent(SettingConstants.AUTO_ZOOM)
            .putCustomAttribute("on", "" + !previousState));
}
 
Example 19
Project: ttnmapper_android_v2   File: MapsActivity.java   View source code 6 votes vote down vote up
public void onToggleLordrive(View v) {
    com.github.clans.fab.FloatingActionButton floatingActionButton = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabItemLordrive);
    SharedPreferences myPrefs = this.getSharedPreferences(SettingConstants.PREFERENCES, MODE_PRIVATE);
    boolean previousState = myPrefs.getBoolean(SettingConstants.LORDRIVE, SettingConstants.LORDRIVE_DEFAULT);

    SharedPreferences.Editor prefsEditor = myPrefs.edit();
    prefsEditor.putBoolean(SettingConstants.LORDRIVE, !previousState);
    prefsEditor.apply();

    if (previousState) {
        floatingActionButton.setColorNormalResId(R.color.fab_disabled);
        floatingActionButton.setColorPressedResId(R.color.fab_disabled_pressed);

        clearAndReaddAllToMap();
    } else {
        floatingActionButton.setColorNormalResId(R.color.fab_green_dark);
        floatingActionButton.setColorPressedResId(R.color.fab_green_light);

        clearAndReaddAllToMap();
    }

    Answers.getInstance().logCustom(new CustomEvent(SettingConstants.LORDRIVE)
            .putCustomAttribute("on", "" + !previousState));
}
 
Example 20
Project: speedr   File: MainActivity.java   View source code 6 votes vote down vote up
private void startMainService() {
    Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "MainService start chain");
    if (checkPlayServicesPrereq() && hasAcceptedTerms() && requestLocationPermission() && checkGPSPrereq() && checkNetworkPrereq()) {
        styleStartStopButton(true);
        reset.setVisibility(View.INVISIBLE);

        startService(new Intent(this, MainService.class));
        bindService(new Intent(this, MainService.class), mainServiceConn, BIND_AUTO_CREATE);
        driveTimeHandler.postDelayed(driveTimeRunnable, DRIVE_TIME_REFRESH_FREQ);

        Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "MainService started");
        Answers.getInstance().logCustom(new CustomEvent(useHereMaps ? "Using HERE" : "Using Overpass"));
        Answers.getInstance().logCustom(new CustomEvent(Prefs.isUseKph(this) ? "Using kph" : "Using mph"));
    } else {
        Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "MainService not started");
    }
}
 
Example 21
Project: speedr   File: MainActivity.java   View source code 6 votes vote down vote up
private boolean checkPlayServicesPrereq() {
    GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
    int result = googleAPI.isGooglePlayServicesAvailable(this);
    if (result != ConnectionResult.SUCCESS) {
        if (googleAPI.isUserResolvableError(result)) {
            googleAPI.getErrorDialog(this, result, 0).show();

            Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "PlayServices update required");
            Answers.getInstance().logCustom(new CustomEvent("PlayServices update required"));
        } else {
            playServicesErrorToast.show();

            Crashlytics.log(Log.ERROR, MainActivity.class.getSimpleName(), "PlayServices incompatible");
            Answers.getInstance().logCustom(new CustomEvent("PlayServices incompatible"));
        }
        return false;
    }

    Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "PlayServices compatible");
    return true;
}
 
Example 22
Project: speedr   File: SettingsActivity.java   View source code 6 votes vote down vote up
private boolean newHereCredentials() {
    if (appIdField.getText().toString().trim().length() < APP_ID_LENGTH) {
        return false;
    }
    if (appCodeField.getText().toString().trim().length() < APP_CODE_LENGTH) {
        return false;
    }
    if (appIdField.getText().toString().trim().equals(Prefs.getHereAppId(this)) &&
            appCodeField.getText().toString().trim().equals(Prefs.getHereAppCode(this))) {
        return false;
    }
    if (Prefs.isUseHereMaps(this)) {
        return false;
    }

    limitProviderSelectorHandler(true);
    Toast.makeText(this, R.string.enabled_here_maps_toast, Toast.LENGTH_LONG).show();

    Answers.getInstance().logCustom(new CustomEvent("Auto enabled HERE"));

    return true;
}
 
Example 23
Project: speedr   File: SettingsActivity.java   View source code 6 votes vote down vote up
private void showHereMapsTerms() {
    Crashlytics.log(Log.INFO, SettingsActivity.class.getSimpleName(), "showHereMapsTerms()");

    WebView webView = new WebView(this);
    webView.setWebViewClient(new WebViewClient());
    webView.loadUrl(getString(R.string.here_maps_terms_url));

    new AlertDialog.Builder(this)
            .setView(webView)
            .setCancelable(true)
            .setPositiveButton(R.string.accept_terms_button_text, new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    Prefs.setHereMapsTermsAccepted(SettingsActivity.this, true);
                    limitProviderSelectorHandler(true); //Set limit provider now that terms have been accepted
                    Answers.getInstance().logCustom(new CustomEvent("Enabled HERE"));
                }})
            .setNegativeButton(R.string.reject_terms_button_text, null)
            .show();
}
 
Example 24
Project: speedr   File: SettingsActivity.java   View source code 6 votes vote down vote up
public void privacyAndTermsOnClick(View view) {
    Crashlytics.log(Log.INFO, SettingsActivity.class.getSimpleName(), "privacyAndTermsOnClick()");

    String content = getString(R.string.privacy_policy_content).replace("HERE_TERMS_PLACEHOLDER", getString(R.string.here_maps_terms_url));

    String localizedTerms = getString(R.string.speedr_terms_content);
    String englishTerms = "Speedr is for informational purposes only. Its function is to quantify how much time, or how little time, one saves when speeding in their car to help the user decide if speeding is worth the safety, monetary, and legal risks. Speeding is illegal and dangerous. By accepting these terms you absolve the Speedr developers, speed limit providers, and all other parties of any responsibility for accidents, legal consequences, and any and all other outcomes. The data presented by Speedr is not guaranteed to be accurate. Outdated/incorrect speed limit data and innaccurate GPS sensors may produce faulty data. Pay attention to the posted speed limits of roads as Speedr may not present accurate speed limits and pay attention to your vehicles' speedometer as Speedr may not present accurate current speed readings.";

    //These terms are important. Always show original in addition to localized terms since we can't rely on translators to correctly word this.
    if (!localizedTerms.equals(englishTerms)) {
        content += "<br><br>" + localizedTerms + "<br><br>" + englishTerms;
    } else {
        content += "<br><br>" + englishTerms;
    }

    ((TextView) new AlertDialog.Builder(this)
            .setTitle(R.string.privacy_policy_title)
            .setMessage(Html.fromHtml(content))
            .setCancelable(true)
            .setNegativeButton(R.string.close_dialog_button, null)
            .show()
            .findViewById(android.R.id.message)) //These 2 lines make the hyperlinks clickable
            .setMovementMethod(LinkMovementMethod.getInstance());

    Answers.getInstance().logCustom(new CustomEvent("Viewed privacy policy"));
}
 
Example 25
Project: cryptogram   File: PuzzleProgress.java   View source code 6 votes vote down vote up
private synchronized void onCompleted(@NonNull Puzzle puzzle) {
    {
        // Analytics
        int puzzleNumber = puzzle.getNumber();
        Float score = getScore(puzzle);
        String puzzleId = String.valueOf(puzzle.getId());
        Bundle bundle = new Bundle();
        bundle.putString(FirebaseAnalytics.Param.LEVEL, puzzleId);
        LevelEndEvent event = new LevelEndEvent()
                .putLevelName("Puzzle #" + puzzleNumber)
                .putSuccess(true);
        if (score != null) {
            bundle.putFloat(FirebaseAnalytics.Param.SCORE, score);
            event.putScore(score);
        }
        CryptogramApp.getInstance().getFirebaseAnalytics().logEvent(CryptogramApp.EVENT_LEVEL_END, bundle);
        Answers.getInstance().logLevelEnd(event);
    }

    EventProvider.postEventDelayed(
            new PuzzleEvent.PuzzleCompletedEvent(puzzle));
}
 
Example 26
Project: velociraptor   File: OsmLimitProvider.java   View source code 6 votes vote down vote up
private void logOsmError(OsmApiEndpoint endpoint, Throwable throwable) {
    if (!BuildConfig.DEBUG) {
        if (throwable instanceof IOException) {
            Answers.getInstance().logCustom(new CustomEvent("Network Error")
                    .putCustomAttribute("Server", endpoint.getBaseUrl())
                    .putCustomAttribute("Message", throwable.getMessage()));

            String endpointString = Uri.parse(endpoint.getBaseUrl()).getAuthority()
                    .replace(".", "_")
                    .replace("-", "_");
            String key = "osm_error_" + endpointString;
            FirebaseAnalytics.getInstance(context).logEvent(key, new Bundle());
        }

        Crashlytics.logException(throwable);
    }
}
 
Example 27
Project: sabbath-school-android   File: SSEvent.java   View source code 6 votes vote down vote up
public static void track(String event_name, HashMap<String, ?> values){
    FirebaseAuth ssFirebaseAuth = FirebaseAuth.getInstance();
    FirebaseUser ssUser = ssFirebaseAuth.getCurrentUser();

    CustomEvent newEvent = new CustomEvent(event_name);
    if (ssUser != null && ssUser.getDisplayName() != null){
        newEvent.putCustomAttribute(SSConstants.SS_EVENT_PARAM_USER_ID, ssUser.getUid());
        newEvent.putCustomAttribute(SSConstants.SS_EVENT_PARAM_USER_NAME, ssUser.getDisplayName());
    } else {
        newEvent.putCustomAttribute(SSConstants.SS_EVENT_PARAM_USER_NAME, "Anonymous");
    }

    for (Map.Entry<String, ?> entry : values.entrySet()) {
        if (entry.getValue() instanceof Integer){
            newEvent.putCustomAttribute(entry.getKey(), (Integer)entry.getValue());
        } else {
            newEvent.putCustomAttribute(entry.getKey(), (String)entry.getValue());
        }
    }

    Answers.getInstance().logCustom(newEvent);
}
 
Example 28
Project: tribbble   File: DeckFragment.java   View source code 6 votes vote down vote up
@Override void onCardSwiped(int direction, int swipedIndex) {
  mCurrentPosition++;
  if (mAdapter.getCount() - swipedIndex <= PRELOAD_THRESHOLD) {
    mCurrentPage++;
    loadNext(0);
  }

  if (direction == RIGHT) {
    Answers.getInstance().logCustom(new CustomEvent("Shot Archived"));
    Shot shot = mAdapter.getItem(swipedIndex);
    ArchiveManager.instance().archive(shot);
    ((MainActivity) getActivity()).notifyShotArchived(shot);
  } else if (direction == LEFT) {
    Answers.getInstance().logCustom(new CustomEvent("Shot Discarded"));
    ArchiveManager.instance().discard(mAdapter.getItem(swipedIndex));
  }
}
 
Example 29
Project: BusyBox   File: MainApp.java   View source code 6 votes vote down vote up
@Override public void onCreate() {
  super.onCreate();
  MultiDex.install(this);

  // Logging
  if (BuildConfig.DEBUG) {
    Jot.add(new Jot.DebugLogger());
  } else {
    Jot.add(new CrashlyticsLogger());
  }

  // Fabric
  Fabric.with(this, new Crashlytics(), new Answers());
  Analytics.add(AnswersLogger.getInstance());
  // Crashlytics
  Crashlytics.setString("GIT_SHA", BuildConfig.GIT_SHA);
  Crashlytics.setString("BUILD_TIME", BuildConfig.BUILD_TIME);

  FirebaseMessaging.getInstance().subscribeToTopic("main-" + BuildConfig.FLAVOR);
}
 
Example 30
Project: cryptogram   File: PuzzleProgress.java   View source code 6 votes vote down vote up
private synchronized void onStart(Puzzle puzzle) {
    {
        // Analytics
        int puzzleNumber = puzzle.getNumber();
        String puzzleId = String.valueOf(puzzle.getId());
        Bundle bundle = new Bundle();
        bundle.putString(FirebaseAnalytics.Param.LEVEL, puzzleId);
        CryptogramApp.getInstance().getFirebaseAnalytics().logEvent(CryptogramApp.EVENT_LEVEL_START, bundle);
        Answers.getInstance().logLevelStart(
                new LevelStartEvent()
                        .putLevelName("Puzzle #" + puzzleNumber));
    }

    EventProvider.postEvent(
            new PuzzleEvent.PuzzleStartedEvent(puzzle));
}
 
Example 31
Project: block-this   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    Fragment fragment = null;

    //noinspection SimplifiableIfStatement
    switch(id) {
        case R.id.action_settings:
            Answers.getInstance().logCustom(new CustomEvent("3.0 Menu").putCustomAttribute("Type", "Settings"));
            fragment = new SettingsFragment();
            break;
    }

    //replacing the fragment
    if (fragment != null) {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.content_frame, fragment);
        ft.commit();
    }

    return super.onOptionsItemSelected(item);
}
 
Example 32
Project: aptoide-client-v8   File: AptoideApplication.java   View source code 6 votes vote down vote up
public InstallManager getInstallManager(int installerType) {

    if (installManagers == null) {
      installManagers = new SparseArray<>();
    }

    InstallManager installManager = installManagers.get(installerType);
    if (installManager == null) {

      installManager = new InstallManager(getApplicationContext(), getDownloadManager(),
          new InstallerFactory(new MinimalAdMapper(),
              new InstallFabricEvents(Analytics.getInstance(), Answers.getInstance(),
                  AppEventsLogger.newLogger(this)), getImageCachePath()).create(this,
              installerType), getRootAvailabilityManager(), getDefaultSharedPreferences(),
          SecurePreferencesImplementation.getInstance(getApplicationContext(),
              getDefaultSharedPreferences()),
          RepositoryFactory.getDownloadRepository(getApplicationContext().getApplicationContext()),
          RepositoryFactory.getInstalledRepository(
              getApplicationContext().getApplicationContext()));
      installManagers.put(installerType, installManager);
    }

    return installManager;
  }
 
Example 33
Project: aptoide-client-v8   File: InstallService.java   View source code 6 votes vote down vote up
@Override public void onCreate() {
  super.onCreate();
  Logger.d(TAG, "Install service is starting");
  final AptoideApplication application = (AptoideApplication) getApplicationContext();
  marketName = application.getMarketName();
  downloadManager = application.getDownloadManager();
  final MinimalAdMapper adMapper = new MinimalAdMapper();
  InstallerFactory installerFactory = new InstallerFactory(adMapper,
      new InstallFabricEvents(Analytics.getInstance(), Answers.getInstance(),
          AppEventsLogger.newLogger(getApplicationContext())), application.getImageCachePath());
  defaultInstaller = installerFactory.create(this, InstallerFactory.DEFAULT);
  rollbackInstaller = installerFactory.create(this, InstallerFactory.ROLLBACK);
  installManager =
      ((AptoideApplication) getApplicationContext()).getInstallManager(InstallerFactory.ROLLBACK);
  subscriptions = new CompositeSubscription();
  setupNotification();
  installerTypeMap = new HashMap();
  analytics = Analytics.getInstance();
  installedRepository = RepositoryFactory.getInstalledRepository(getApplicationContext());
}
 
Example 34
Project: prayer-times-android   File: WebTimes.java   View source code 6 votes vote down vote up
@NonNull
public static Times add(@NonNull Source source, String city, String id, double lat, double lng, long _id) {
    if (source == Source.Calc) throw new RuntimeException("Calc is not a WebTimes");
    WebTimes t;
    try {
        t = (WebTimes) source.clz.getConstructor(long.class).newInstance(_id);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    t.setSource(source);
    t.setName(city);
    t.setLat(lat);
    t.setLng(lng);
    t.setId(id);
    t.setSortId(99);
    t.scheduleJob();

    Answers.getInstance().logCustom(new CustomEvent("AddCity")
            .putCustomAttribute("Source", source.name())
            .putCustomAttribute("City", city)
    );
    return t;
}
 
Example 35
Project: prayer-times-android   File: SettingsFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onPreferenceChange(@NonNull Preference pref, Object newValue) {

    if ("language".equals(pref.getKey()) || "digits".equals(pref.getKey())) {
        if ("language".equals(pref.getKey())) Utils.changeLanguage((String) newValue);
        Activity act = getActivity();
        act.finish();
        Intent i = new Intent(act, act.getClass());
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        act.startActivity(i);

        Answers.getInstance().logCustom(new CustomEvent("Language")
                .putCustomAttribute("lang", (String) newValue)
        );
    }
    return true;
}
 
Example 36
Project: EasyVPN-Free   File: ServerActivity.java   View source code 6 votes vote down vote up
private void prepareStopVPN() {
    if (!BuildConfig.DEBUG) {
        try {
            String download = trafficIn.getText().toString();
            download = download.substring(download.lastIndexOf(":") + 2);

            Answers.getInstance().logCustom(new CustomEvent("Connection info")
                    .putCustomAttribute("Country", connectedServer.getCountryLong())
                    .putCustomAttribute("Download", download)
                    .putCustomAttribute("Time", stopwatch.getElapsedTime()));
        } catch (Exception e) {

        }
    }

    statusConnection = false;
    if (waitConnection != null)
        waitConnection.cancel(false);
    connectingProgress.setVisibility(View.GONE);
    adbBlockCheck.setEnabled(availableFilterAds);
    lastLog.setText(R.string.server_not_connected);
    serverConnect.setText(getString(R.string.server_btn_connect));
    connectedServer = null;
}
 
Example 37
Project: EasyVPN-Free   File: HomeActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    homeContextRL = (RelativeLayout) findViewById(R.id.homeContextRL);
    countryList = dbHelper.getUniqueCountries();

    long totalServ = dbHelper.getCount();
    if (!BuildConfig.DEBUG)
        Answers.getInstance().logCustom(new CustomEvent("Total servers")
            .putCustomAttribute("Total servers", totalServ));

    String totalServers = String.format(getResources().getString(R.string.total_servers), totalServ);
    ((TextView) findViewById(R.id.homeTotalServers)).setText(totalServers);

    initMap();
}
 
Example 38
Project: Unofficial-Ups   File: AnalyticsManager.java   View source code 5 votes vote down vote up
public static void eventLogout(Context context){
    //Fabric
    Answers.getInstance().logCustom(new CustomEvent(AnalyticsConstants.EVENT_LOGOUT));

    //Firebase
    FirebaseAnalytics.getInstance(context).logEvent(AnalyticsConstants.EVENT_LOGOUT,new Bundle());

    //Amplitude
    Amplitude.getInstance().logEvent(AnalyticsConstants.EVENT_LOGOUT);
}
 
Example 39
Project: Quran   File: BookmarkPresenter.java   View source code 5 votes vote down vote up
public void toggleGroupByTags() {
  groupByTags = !groupByTags;
  quranSettings.setBookmarksGroupedByTags(groupByTags);
  requestData(false);
  Answers.getInstance().logCustom(
      new CustomEvent(groupByTags ? "groupByTags" : "doNotGroupByTags"));
}
 
Example 40
Project: Quran   File: BookmarkPresenter.java   View source code 5 votes vote down vote up
public void toggleShowRecents() {
  showRecents = !showRecents;
  quranSettings.setShowRecents(showRecents);
  requestData(false);
  Answers.getInstance().logCustom(
      new CustomEvent(showRecents ? "showRecents" : "doNotMinimizeRecents"));
}