public void trackException(Exception e) { if (e != null) { Tracker t = getGoogleAnalyticsTracker(); t.send(new HitBuilders.ExceptionBuilder() .setDescription( new StandardExceptionParser(this, null) .getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); } }
/*** * Tracking exception * * @param e exception to be tracked */ public void trackException(Exception e) { if (e != null) { Tracker t = getGoogleAnalyticsTracker(); t.send(new HitBuilders.ExceptionBuilder() .setDescription( new StandardExceptionParser(this, null) .getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); } }
public void trackException(Exception e) { if (e != null) { Tracker t = getGoogleAnalyticsTracker(); t.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(this, null).getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); } }
@Override public void exception(Exception e) { if (e != null) { tracker.send(new HitBuilders.ExceptionBuilder() .setDescription( new StandardExceptionParser(applicationContext, null).getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); } }
public void sendAnalyticsError(Throwable e) { String analyticsPath = this.getClass().getName(); Tracker t = ((E621Application) getApplication()).getTracker(); t.send(new HitBuilders.ExceptionBuilder(). setDescription(new StandardExceptionParser(this, null).getDescription(analyticsPath, e)). setFatal(false). build() ); }
@Inject public Tracker(@ForApplication Context context) { this.context = context; analytics = GoogleAnalytics.getInstance(context); tracker = analytics.newTracker(R.xml.google_analytics); tracker.setAppVersion(Integer.toString(BuildConfig.VERSION_CODE)); exceptionParser = new StandardExceptionParser(context, null); if (BuildConfig.DEBUG) { analytics.setDryRun(true); } }
@Override public void sendException(Throwable throwable, boolean isFatal) { this.tracker.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(this.application, null).getDescription(Thread.currentThread().getName(), throwable)) .setFatal(isFatal) .build()); }
/*** * Tracking exception * Note: LogHelper will track exceptions as well, * so no need to call if making use of LogHelper with a throwable. * * @param e exception to be tracked */ public void trackException(Exception e) { if (e != null) { Tracker tracker = getGoogleAnalyticsTracker(); tracker.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(this, null) .getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); } }
public synchronized <T extends ViewObject> T getViewObject(Class<T> clazz) { if (!data.containsKey(clazz.getName())) { try { Constructor<T> constructor = clazz.getConstructor(Context.class); data.put(clazz.getName(), constructor.newInstance(this)); } catch (Exception e) { Log.w(TAG, "failed to create empty viewstate", e); Tracker t = getTracker(); t.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(this, null).getDescription(Thread.currentThread().getName(), e)) .setFatal(false).build()); } } return (T) data.get(clazz.getName()); }
@Override public void onStartDiag() { try { Message msg = Message.obtain(null, EidService.DIAG, 0, 0); msg.replyTo = mEidServiceResponse; mEidService.send(msg); } catch (Exception e) { Tracker t = ((EidSuiteApp) this.getApplication()).getTracker(); t.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(this, null).getDescription(Thread.currentThread().getName(), e)) .setFatal(false).build()); Toast.makeText(this, R.string.toastFailed, Toast.LENGTH_LONG).show(); } }
private void navigate() { try { String urlValue = url.getText().toString(); URL parsed = new URL(urlValue.contains("://") ? urlValue : "http://" + urlValue); listener.onGo(parsed.toString()); } catch (MalformedURLException e) { Toast.makeText(GoDialog.this.getActivity(), R.string.toastInvalidUrl, Toast.LENGTH_LONG).show(); Tracker tracker = ((EidSuiteApp) GoDialog.this.getActivity().getApplication()).getTracker(); tracker.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(GoDialog.this.getActivity(), null).getDescription(Thread.currentThread().getName(), e)) .setFatal(false).build()); } }
@Override public void sendException(Context c, Exception e, boolean fatal, String additionalData) { try { Tracker t = getAppTracker(); if (t != null && e != null) { HitBuilders.ExceptionBuilder eb = new HitBuilders.ExceptionBuilder() .setFatal(fatal) .setCustomDimension(GA_DIM_EXCEPTION_NAME, e.getClass().getCanonicalName()) .setDescription( new StandardExceptionParser(c, null) .getDescription(Thread.currentThread() .getName(), e) ); if (!TextUtils.isEmpty(additionalData)) { eb.setCustomDimension(GA_DIM_ADDITIONAL_DATA, additionalData.substring(0, Math.min(additionalData.length(), 4096))); } eb.setCustomDimension(GA_DIM_EXCEPTION_MESSAGE, e.getMessage()); t.send(eb.build()); } } catch (Exception e2) { Log.e(TAG, "sendException", e2); } if (BuildConfig.DEBUG) { if (e != null) { Log.d(TAG, String.format("%s (%s)", e.getMessage(), additionalData)); } } }
private void setExceptionHandler() { ExceptionReporter handler = new ExceptionReporter(getTracker(), Thread.getDefaultUncaughtExceptionHandler(), this); StandardExceptionParser exceptionParser = new StandardExceptionParser(getApplicationContext(), null) { @Override public String getDescription(String threadName, Throwable t) { return "{" + threadName + "} " + Log.getStackTraceString(t); } }; handler.setExceptionParser(exceptionParser); Thread.setDefaultUncaughtExceptionHandler(handler); }
@Override public void trackException(String s, Exception e, boolean fatal) { final String description = new StandardExceptionParser(ctx, null) .getDescription(Thread.currentThread().getName(), e); final Map<String, String> exceptionMap = new HitBuilders.ExceptionBuilder() .setDescription(s + " " + description) .setFatal(fatal).build(); tracker.send(exceptionMap); }
/** * Send exception information. * * @param message A small message. * @param e The exception. */ public static void sendException(final String message, final Throwable e) { getDefaultTracker(); ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); exceptionBuilder .setDescription(new StandardExceptionParser(Application.getAppContext(), null) .getDescription(message == null ? Thread.currentThread().getName() : message, e)) .setFatal(false); mTracker.send(exceptionBuilder.build()); }
public void sendException (final Context context, final Exception e) { mTracker.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(context, null).getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); }
/** * O(n log n) add and sort by name */ public void parseFourteeners() { SRLOG.v(TAG, "Parsing fourteener data..."); Resources res = mCtx.getResources(); XmlResourceParser xrp = res.getXml(R.xml.mountain_data); try{ xrp.next(); // skip first 'mountains' element while (xrp.getEventType() != XmlResourceParser.END_DOCUMENT) { xrp.next(); // get first 'mountain' element if(xrp.getEventType() == XmlResourceParser.START_TAG) { // double check its the right element if(xrp.getName().equals("mountain")) { // extract the data you want int count = xrp.getAttributeCount(); String name = xrp.getAttributeValue(null, "name"); String rank = xrp.getAttributeValue(null, "rank"); String elev = xrp.getAttributeValue(null, "elevation"); String range = xrp.getAttributeValue(null, "range"); String longitude = xrp.getAttributeValue(null, "long"); String latitude = xrp.getAttributeValue(null, "lat"); String county = xrp.getAttributeValue(null, "county"); Mountain m = new Mountain(name, range , county, Double.parseDouble(longitude), Double.parseDouble(latitude), Integer.parseInt(rank), Integer.parseInt(elev)); mMnts.put(name, m); if(mRanges.containsKey(range)) { ArrayList<String> al = mRanges.get(range); al.add(name); } else { ArrayList<String> nal = new ArrayList<String>(); nal.add(name); mRanges.put(range, nal); } SRLOG.v(TAG, "Mountain Attribute Count " + count); SRLOG.v(TAG, "Peak Name " + name); SRLOG.v(TAG, "Peak Elevation " + elev); } } } } catch (Exception e) { SRLOG.e(TAG, e.toString()); mTracker.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(mCtx, null) .getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); } finally { xrp.close(); SRLOG.i(TAG, "Fourteener data parsed"); } }
@Override public WebResourceResponse shouldInterceptRequest(final WebView view, final String url) { Log.v(TAG, String.format("should Intercept: %s", url)); int iam = -1; for (int i = 0; i < iamUrls.length; i++) { if (url.startsWith(iamUrls[i])) { iam = i; } } try { if (iam != -1) { if (factory == null) { int count = 0; while (count++ < 10 && mEidService == null) { SystemClock.sleep(100 * count); } factory = new EidSSLSocketFactory(mEidService); } URL path = new URL(url); HttpsURLConnection con = (HttpsURLConnection) path.openConnection(); con.setInstanceFollowRedirects(false); con.setRequestProperty("Cookie", iamCookies[iam]); con.setSSLSocketFactory(factory); con.connect(); if (con.getHeaderFields() != null && con.getHeaderFields().get("Set-Cookie") != null) { List<String> setCookieValues = con.getHeaderFields().get("Set-Cookie"); for (String setCookieValue : setCookieValues) { CookieManager.getInstance().setCookie(url, setCookieValue); } cookieMsngr.send(Message.obtain(null, 1, iam, 0)); } //translate a redirect if needed if (con.getResponseCode() == 301 || con.getResponseCode() == 302 ) { String redirect = con.getHeaderField("Location"); String html = String.format("<html><body onload=\"timer=setTimeout(function(){ window.location='%s';}, 300)\">" + "you will be redirected soon" + "</body></html>", redirect); return new WebResourceResponse("text/html", Charset.defaultCharset().name(), new ByteArrayInputStream(html.getBytes())); } else { String[] contentTypeParts = con.getContentType().split(";[ ]*"); String encoding = contentTypeParts.length > 1 && contentTypeParts[1].startsWith("charset=") ? contentTypeParts[1].replaceFirst("charset=", "") : Charset.defaultCharset().name(); return new WebResourceResponse(contentTypeParts[0], encoding, con.getInputStream()); } } else { cookieMsngr.send(Message.obtain(null, 1, -1, 0)); } } catch (Exception e) { Log.e(TAG, "Failed HTTP intercept", e); Tracker tracker = ((EidSuiteApp) AuthActivity.this.getApplication()).getTracker(); tracker.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(AuthActivity.this, null).getDescription(Thread.currentThread().getName(), e)) .setFatal(false).build()); } return null; }
private void diagnose(Message msg) throws RemoteException { boolean foundDevice = false; boolean foundCCID = false; boolean foundCard = false; boolean foundEid = false; StringBuilder builder = new StringBuilder(); builder.append("Diagnose results: "); Map<String, UsbDevice> deviceList = usbManager.getDeviceList(); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); while (deviceIterator.hasNext()) { ccidDevice = deviceIterator.next(); Tracker t = ((EidSuiteApp) this.getApplication()).getTracker(); t.send(new HitBuilders.EventBuilder("Reader Action", "Diagnose") .setCustomDimension(1, getVendor()) .setCustomDimension(2, getProduct()).build()); try { obtainUsbPermission(); DeviceDescriptor dd = new DeviceDescriptor(usbManager, ccidDevice); builder.append("\r\n\r\n"); builder.append(dd.toString()); foundDevice = true; if (dd.hasCCID()) foundCCID = true; if (dd.hasCard()) foundCard = true; if (dd.hasEid()) foundEid = true; } catch (Exception e) { Log.w(TAG, "Failed to diagnose device", e); Tracker tracker = ((EidSuiteApp) this.getApplication()).getTracker(); tracker.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(this, null).getDescription(Thread.currentThread().getName(), e)) .setFatal(false).build()); } finally { ccidDevice = null; } } Message rsp = Message.obtain(null, DIAG_RSP, foundDevice ? 0 : 1, foundEid ? 0 : (foundCard ? 1 : (foundCCID ? 2 : 3))); rsp.getData().putString("Result", builder.toString()); msg.replyTo.send(rsp); }
private void processError(Exception e) { Throwable root = e; while (root.getCause() != null) { root = root.getCause(); } if (root instanceof UserCancelException) { uiHandler.post(new Runnable() { @Override public void run() { Toast.makeText(EidService.this, R.string.toastEidCanceled, Toast.LENGTH_SHORT).show(); } }); } else if (root instanceof AbortException) { uiHandler.post(new Runnable() { @Override public void run() { Toast.makeText(EidService.this, R.string.toastEidAborted, Toast.LENGTH_SHORT).show(); } }); } else if (root instanceof CardBlockedException) { uiHandler.post(new Runnable() { @Override public void run() { Toast.makeText(EidService.this, R.string.toastEidBlocked, Toast.LENGTH_LONG).show(); } }); } else { uiHandler.post(new Runnable() { @Override public void run() { Toast.makeText(EidService.this, R.string.toastEidFailed, Toast.LENGTH_LONG).show(); } }); } SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(EidService.this); boolean fail = sharedPref.getBoolean(SettingsActivity.KEY_PREF_FAIL, false); if (fail) { SharedPreferences.Editor edit = sharedPref.edit(); edit.putBoolean(SettingsActivity.KEY_PREF_FAIL, false); edit.commit(); if (e instanceof RuntimeException) throw (RuntimeException) e; else throw new RuntimeException(e); } else { StandardExceptionParser ep = new StandardExceptionParser(null, Collections.singleton(this.getClass().getPackage().getName())) { @Override protected String getDescription(Throwable cause, StackTraceElement element, String threadName) { String msg = super.getDescription(cause, element, threadName); if (cause instanceof CCIDException) { CCIDException ccidError = (CCIDException) cause; msg += String.format(" [CCID: %x %x]", ccidError.getStatus(), ccidError.getError()); } else if (cause instanceof APDUException) { APDUException apduException = (APDUException) cause; msg += String.format(" [APDU: %x %x]", apduException.getSW1(), apduException.getSW2()); } return msg; } }; Tracker t = ((EidSuiteApp) this.getApplication()).getTracker(); t.send(new HitBuilders.ExceptionBuilder() .setDescription(ep.getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .setCustomDimension(1, getVendor()) .setCustomDimension(2, getProduct()).build()); } }