com.joshdholtz.sentry.Sentry Java Examples

The following examples show how to use com.joshdholtz.sentry.Sentry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainApplication.java    From android_gisapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
    public void onCreate() {
        if (!BuildConfig.DEBUG)
            Sentry.init(this, BuildConfig.SENTRY_DSN);
//        Sentry.captureMessage("NGM2 Sentry is init.", Sentry.SentryEventLevel.DEBUG);

        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

        GoogleAnalytics.getInstance(this).setAppOptOut(!mSharedPreferences.getBoolean(KEY_PREF_GA, true));
        GoogleAnalytics.getInstance(this).setDryRun(DEBUG_MODE);
        getTracker();
        setExceptionHandler();

        super.onCreate();
        updateFromOldVersion();
    }
 
Example #2
Source File: MainActivity.java    From Sentry-Android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String yourDSN = "your-dsn";
    Sentry.init(this, yourDSN);
    Sentry.debug = true;


    Sentry.setMaxBreadcrumbs(8);
    for (int i=0; i<15; i++) {
        Sentry.addBreadcrumb("Limit Test", Integer.toString(i));
    }
    Sentry.captureMessage("8 breadcrumbs test.");

    Sentry.addNavigationBreadcrumb("activity.main", "here", "there");
    Sentry.addHttpBreadcrumb("http://example.com", "GET", 202);

    Sentry.captureEvent(new Sentry.SentryEventBuilder()
        .setMessage("This event has a message and a stacktrace.")
        .setStackTrace(Thread.currentThread().getStackTrace())
    );

}
 
Example #3
Source File: MainActivity.java    From Sentry-Android with MIT License 6 votes vote down vote up
public void onClickCapture(View view) {
    Sentry.addBreadcrumb("button.click", "capture button");
    try {
        crash();
    } catch (Exception e) {
        Map<String, String> tags = new HashMap<>();
        tags.put("color", "yellow");
        tags.put("shape", "square");
        Sentry.captureEvent(new Sentry.SentryEventBuilder()
            .setException(e)
            .setMessage("Exception caught in click handler")
            .setServerName("https://badssl.com/")
            .setCulprit("https://untrusted-root.badssl.com/")
            .setLevel(Sentry.SentryEventLevel.WARNING)
            .setLogger("A logger")
            .setRelease("f035a895a5167ebd20a597d47761e033995e6689")
            .setTags(tags));
    }
}
 
Example #4
Source File: SettingsFragment.java    From pretixdroid with GNU General Public License v3.0 5 votes vote down vote up
private void asset_dialog(@RawRes int htmlRes, @StringRes int title) {
    final View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_about, null, false);
    final AlertDialog dialog = new AlertDialog.Builder(getActivity())
            .setTitle(title)
            .setView(view)
            .setPositiveButton(R.string.dismiss, null)
            .create();

    TextView textView = (TextView) view.findViewById(R.id.aboutText);

    String text = "";

    StringBuilder builder = new StringBuilder();
    InputStream fis;
    try {
        fis = getResources().openRawResource(htmlRes);
        BufferedReader reader = new BufferedReader(new InputStreamReader(fis, "utf-8"));
        String line;
        while ((line = reader.readLine()) != null) {
            builder.append(line);
        }

        text = builder.toString();
        fis.close();
    } catch (IOException e) {
        Sentry.captureException(e);
        e.printStackTrace();
    }

    textView.setText(Html.fromHtml(text));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    dialog.show();
}
 
Example #5
Source File: MainActivity.java    From pretixdroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case PERMISSIONS_REQUEST_CAMERA: {
            // If request is cancelled, the result arrays are empty.
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                Sentry.addBreadcrumb("main.startup", "Permission granted");
                if (config.getCamera()) {
                    qrView.startCamera();
                }
            } else {
                Sentry.addBreadcrumb("main.startup", "Permission request denied");
                Toast.makeText(this, R.string.permission_required, Toast.LENGTH_LONG).show();
                finish();
            }
        }
        case PERMISSIONS_REQUEST_WRITE_STORAGE: {
            try {
                dataWedgeHelper.install();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
 
Example #6
Source File: MainActivity.java    From pretixdroid with GNU General Public License v3.0 5 votes vote down vote up
private void handleConfigScanned(String s) {
    Sentry.addBreadcrumb("main.scanned", "Config scanned");

    try {
        JSONObject jsonObject = new JSONObject(s);
        if (jsonObject.getInt("version") > PretixApi.SUPPORTED_API_VERSION) {
            displayScanResult(new TicketCheckProvider.CheckResult(
                    TicketCheckProvider.CheckResult.Type.ERROR,
                    getString(R.string.err_qr_version)), null, false);
        } else {
            if (jsonObject.getInt("version") < 3) {
                config.setAsyncModeEnabled(false);
            }
            config.setEventConfig(jsonObject.getString("url"), jsonObject.getString("key"),
                    jsonObject.getInt("version"), jsonObject.optBoolean("show_info", true),
                    jsonObject.optBoolean("allow_search", true));
            checkProvider = ((PretixDroid) getApplication()).getNewCheckProvider();
            displayScanResult(new TicketCheckProvider.CheckResult(
                    TicketCheckProvider.CheckResult.Type.VALID,
                    getString(R.string.config_done)), null, false);

            triggerSync();
        }
    } catch (JSONException e) {
        displayScanResult(new TicketCheckProvider.CheckResult(
                TicketCheckProvider.CheckResult.Type.ERROR,
                getString(R.string.err_qr_invalid)), null, false);
    }
}
 
Example #7
Source File: MainActivity.java    From pretixdroid with GNU General Public License v3.0 5 votes vote down vote up
private void handleTicketScanned(String s, List<TicketCheckProvider.Answer> answers, boolean ignore_unpaid) {
    Sentry.addBreadcrumb("main.scanned", "Ticket scanned");

    state = State.LOADING;
    findViewById(R.id.tvScanResult).setVisibility(View.GONE);
    findViewById(R.id.pbScan).setVisibility(View.VISIBLE);
    new CheckTask().execute(s, answers, ignore_unpaid);
}
 
Example #8
Source File: MainActivity.java    From pretixdroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    if (BuildConfig.SENTRY_DSN != null) {
        Sentry.init(this, BuildConfig.SENTRY_DSN);
    }

    checkProvider = ((PretixDroid) getApplication()).getNewCheckProvider();
    config = new AppConfig(this);

    setContentView(R.layout.activity_main);

    qrView = (CustomizedScannerView) findViewById(R.id.qrdecoderview);
    qrView.setResultHandler(this);
    qrView.setAutoFocus(config.getAutofocus());
    qrView.setFlash(config.getFlashlight());

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        Sentry.addBreadcrumb("main.startup", "Permission request started");
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.CAMERA},
                PERMISSIONS_REQUEST_CAMERA);
    }

    List<BarcodeFormat> formats = new ArrayList<>();
    formats.add(BarcodeFormat.QR_CODE);

    qrView.setFormats(formats);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    mediaPlayer = buildMediaPlayer(this);

    timeoutHandler = new Handler();
    blinkHandler = new Handler();

    findViewById(R.id.rlSyncStatus).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showSyncStatusDetails();
        }
    });

    resetView();

    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setIcon(R.drawable.ic_logo);

    dataWedgeHelper = new DataWedgeHelper(this);
    if (dataWedgeHelper.isInstalled()) {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    PERMISSIONS_REQUEST_WRITE_STORAGE);
        } else {
            try {
                dataWedgeHelper.install();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
 
Example #9
Source File: AndroidSentryImplementation.java    From pretixdroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addHttpBreadcrumb(String url, String method, int statusCode) {
    Sentry.addHttpBreadcrumb(url, method, statusCode);
}
 
Example #10
Source File: AndroidSentryImplementation.java    From pretixdroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addBreadcrumb(String a, String b) {
    Sentry.addBreadcrumb(a, b);
}
 
Example #11
Source File: AndroidSentryImplementation.java    From pretixdroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void captureException(Throwable t) {
    Sentry.captureException(t);
}
 
Example #12
Source File: AndroidSentryImplementation.java    From pretixdroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void captureException(Throwable t, String message) {
    Sentry.captureException(t, message);
}
 
Example #13
Source File: MainActivity.java    From Sentry-Android with MIT License 4 votes vote down vote up
public void onClickBreak(View view) {
    Sentry.addBreadcrumb("button.click", "break button");
    crash();

}