-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
.vscode/ | ||
build/ | ||
local.properties | ||
sentry.properties | ||
obj/ | ||
service_account_credentials.json | ||
__pycache__/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/AnalyticsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package tw.nekomimi.nekogram.helpers; | ||
|
||
import android.app.Application; | ||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import org.telegram.messenger.BuildConfig; | ||
import org.telegram.messenger.BuildVars; | ||
|
||
|
||
import io.sentry.Sentry; | ||
import io.sentry.SentryLevel; | ||
import io.sentry.android.core.SentryAndroid; | ||
|
||
public class AnalyticsHelper { | ||
public static String DSN = "https://58f21343622b885cb7ad43fee0943f77@o416616.ingest.us.sentry.io/4507212454428672"; | ||
public static boolean loaded = false; | ||
|
||
public static void start(Application application) { | ||
if (!getSentryStatus(application)) { | ||
return; | ||
} | ||
SentryAndroid.init(application, options -> { | ||
options.setDsn(DSN); | ||
options.setEnvironment(BuildVars.DEBUG_VERSION ? "debug" : "release"); | ||
options.setEnableAutoSessionTracking(true); | ||
options.setTracesSampleRate(1.0); | ||
options.setAttachAnrThreadDump(true); | ||
options.setRelease(BuildConfig.APPLICATION_ID + "@" + BuildConfig.VERSION_NAME + "+" + BuildConfig.VERSION_CODE); | ||
options.setBeforeScreenshotCaptureCallback((event, hint, debounce) -> { | ||
// always capture crashed events | ||
if (event.isCrashed()) { | ||
return true; | ||
} | ||
|
||
// if debounce is active, skip capturing | ||
if (debounce) { | ||
return false; | ||
} else { | ||
// also capture fatal events | ||
return event.getLevel() == SentryLevel.FATAL; | ||
} | ||
}); | ||
}); | ||
loaded = true; | ||
} | ||
|
||
public static void captureException(Throwable e) { | ||
if (loaded) { | ||
Sentry.captureException(e); | ||
} | ||
} | ||
|
||
public static boolean getSentryStatus(Application application) { | ||
SharedPreferences preferences = application.getApplicationContext().getSharedPreferences( | ||
"nkmrcfg", | ||
Context.MODE_PRIVATE | ||
); | ||
return preferences.getBoolean("SentryAnalytics", true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters