Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb1a8d62

Browse files
authored
Merge pull request#53 from aminekarimii/feature/sentry-addon
feat: Add Sentry.io addon integration
2 parents4c9f6c7 +92c506a commitb1a8d62

File tree

8 files changed

+470
-11
lines changed

8 files changed

+470
-11
lines changed

‎README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ dependencies {
7979
implementation 'io.github.aminekarimii:analytiks-addon-amplitude'
8080
implementation 'io.github.aminekarimii:analytiks-addon-googleanalytics'
8181
implementation 'io.github.aminekarimii:analytiks-addon-mixpanel'
82+
implementation 'io.github.aminekarimii:analytiks-addon-sentry'
8283
implementation 'io.github.aminekarimii:analytiks-addon-timber'
8384
implementation 'io.github.aminekarimii:analytiks-addon-segment'
8485
}
@@ -100,12 +101,13 @@ dependencies {
100101
implementation 'io.github.aminekarimii:analytiks-addon-segment:1.4.0'
101102
implementation 'io.github.aminekarimii:analytiks-addon-amplitude:1.4.0'
102103
implementation 'io.github.aminekarimii:analytiks-appsflyer:1.4.0'
104+
implementation 'io.github.aminekarimii:analytiks-addon-sentry:1.4.0'
103105
implementation 'io.github.aminekarimii:analytiks-addon-timber:1.4.0'
104106
implementation 'io.github.aminekarimii:analytiks-addon-appvisor:1.4.0'
105107
}
106108
```
107109

108-
>**Note**: Check[Maven Central](https://search.maven.org/search?q=g:io.github.aminekarimii) for the latest version.
110+
>**Note**: Check[Maven Central](https://central.sonatype.com/namespace/io.github.aminekarimii) for the latest version.
109111
110112
---
111113

@@ -226,14 +228,14 @@ analytiks.reset()
226228
|**Segment**| ✅ Available|[Setup Guide](./addon/analytiks-segment/README.md)|[Segment Docs](https://segment.com/docs/connections/sources/catalog/libraries/mobile/kotlin-android/)|
227229
|**Mixpanel**| ✅ Available|[Setup Guide](./addon/analytiks-mixpanel/README.md)|[Mixpanel Docs](https://developer.mixpanel.com/docs/android)|
228230
|**Amplitude**| ✅ Available|[Setup Guide](./addon/analytiks-amplitude/README.md)|[Amplitude Docs](https://www.docs.developers.amplitude.com/data/sdks/sdk-quickstart/)|
231+
|**AppsFlyer**| ✅ Available|[Setup Guide](./addon/analytiks-appsflyer/README.md)|[AppsFlyer Docs](https://dev.appsflyer.com/hc/docs/android-sdk)|
232+
|**Sentry**| ✅ Available|[Setup Guide](./addon/analytiks-sentry/README.md)|[Sentry Docs](https://docs.sentry.io/platforms/android/)|
229233
|**Timber (Local Logging)**| ✅ Available| Built-in|[Timber GitHub](https://github.com/JakeWharton/timber)|
230234
|**Custom Analytics**| ✅ Available|[Create Custom Addon](./analytiks-core)| -|
231-
|**AppsFlyer**|| <ahref="./addon/analytiks-appsflyer/README.md">AppsFlyer Addon doc</a>| <ahref="https://dev.appsflyer.com/hc/docs/android-sdk">AppsFlyer doc</a>|
232235
|**Flurry Analytics**| 🚧 Coming Soon| -| -|
233236
|**CleverTap**| 🚧 Coming Soon| -| -|
234237
|**MoEngage**| 🚧 Coming Soon| -| -|
235238
|**Adjust**| 🚧 Coming Soon| -| -|
236-
|**AppsFlyer**| 🚧 Coming Soon| -| -|
237239

238240
###Request New Integrations
239241
Can't find your analytics service?[Open an issue](https://github.com/aminekarimii/analytiks/issues/new) with the service name and documentation link.

‎addon/analytiks-sentry/README.md‎

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
#Sentry Addon for Analytiks
2+
3+
Integration of[Sentry](https://sentry.io/) error tracking and performance monitoring with the Analytiks library.
4+
5+
##Features
6+
7+
-**Event Tracking**: Track custom events as Sentry breadcrumbs
8+
-**User Identification**: Associate events with specific users
9+
-**User Properties**: Set user email, username, IP address, and custom data
10+
-**Screen Tracking**: Track screen views
11+
-**Error Context**: Enrich error reports with analytics events
12+
-**Performance Monitoring**: Leverage Sentry's performance tracking capabilities
13+
14+
##Installation
15+
16+
###Using BOM (Recommended)
17+
18+
```gradle
19+
dependencies {
20+
implementation platform('io.github.aminekarimii:analytiks-bom:1.4.0')
21+
implementation 'io.github.aminekarimii:analytiks-addon-sentry'
22+
23+
// Sentry Android SDK (if not already included)
24+
implementation 'io.sentry:sentry-android:7.0.0'
25+
}
26+
```
27+
28+
###Manual Version
29+
30+
```gradle
31+
dependencies {
32+
implementation 'io.github.aminekarimii:analytiks-core:1.4.0'
33+
implementation 'io.github.aminekarimii:analytiks:1.4.0'
34+
implementation 'io.github.aminekarimii:analytiks-addon-sentry:1.4.0'
35+
36+
// Sentry Android SDK
37+
implementation 'io.sentry:sentry-android:7.0.0'
38+
}
39+
```
40+
41+
##Setup
42+
43+
###1. Initialize Sentry
44+
45+
First, initialize Sentry in your`Application` class or`AndroidManifest.xml`:
46+
47+
####Option A: In Application Class
48+
49+
```kotlin
50+
classMyApplication :Application() {
51+
overridefunonCreate() {
52+
super.onCreate()
53+
54+
SentryAndroid.init(this) { options->
55+
options.dsn="YOUR_SENTRY_DSN"
56+
options.environment=if (BuildConfig.DEBUG)"development"else"production"
57+
options.tracesSampleRate=1.0
58+
options.isEnableAutoSessionTracking=true
59+
}
60+
}
61+
}
62+
```
63+
64+
####Option B: In AndroidManifest.xml
65+
66+
```xml
67+
<application>
68+
<meta-data
69+
android:name="io.sentry.dsn"
70+
android:value="YOUR_SENTRY_DSN" />
71+
<meta-data
72+
android:name="io.sentry.environment"
73+
android:value="production" />
74+
</application>
75+
```
76+
77+
###2. Add to Analytiks
78+
79+
```kotlin
80+
classMainActivity :AppCompatActivity() {
81+
privatelateinitvar analytiks:Analytiks
82+
83+
overridefunonCreate(savedInstanceState:Bundle?) {
84+
super.onCreate(savedInstanceState)
85+
86+
analytiks=Analytiks.Builder()
87+
.addClient(SentryClient(context= applicationContext))
88+
.addClient(/* other analytics clients*/)
89+
.build()
90+
91+
analytiks.initialize(applicationContext)
92+
}
93+
}
94+
```
95+
96+
##Usage
97+
98+
###Track Events
99+
100+
Events are tracked as Sentry breadcrumbs with INFO level:
101+
102+
```kotlin
103+
// Simple event
104+
analytiks.logEvent("button_clicked")
105+
106+
// Event with properties
107+
analytiks.logEvent(
108+
eventName="purchase_completed",
109+
properties=mapOf(
110+
"product_id" to"12345",
111+
"price" to29.99,
112+
"currency" to"USD"
113+
)
114+
)
115+
```
116+
117+
###Identify Users
118+
119+
```kotlin
120+
// Identify user
121+
analytiks.identify(userId="user_12345")
122+
```
123+
124+
###Set User Properties
125+
126+
```kotlin
127+
// Set email
128+
analytiks.setUserProperty("email","user@example.com")
129+
130+
// Set username
131+
analytiks.setUserProperty("username","john_doe")
132+
133+
// Set IP address
134+
analytiks.setUserProperty("ip_address","192.168.1.1")
135+
136+
// Set custom properties
137+
analytiks.setUserProperty("subscription_tier","premium")
138+
analytiks.setUserProperty("account_age_days",365)
139+
```
140+
141+
###Track Screens
142+
143+
```kotlin
144+
// Track screen view
145+
analytiks.trackScreen(
146+
screenName="HomeScreen",
147+
properties=mapOf(
148+
"section" to"main",
149+
"tab" to"featured"
150+
)
151+
)
152+
```
153+
154+
###Reset User Data
155+
156+
```kotlin
157+
// Clear user data and breadcrumbs
158+
analytiks.reset()
159+
```
160+
161+
##How It Works
162+
163+
###Event Tracking
164+
- Events are sent to Sentry as**breadcrumbs** with level`INFO`
165+
- Event properties are included in the breadcrumb data
166+
- Breadcrumbs provide context for errors and crashes
167+
168+
###User Management
169+
- User ID is set using Sentry's user identification
170+
- Special properties are mapped to Sentry's User object:
171+
-`email` → User.email
172+
-`username` → User.username
173+
-`ip_address` /`ipaddress` → User.ipAddress
174+
- Custom properties are stored in User.data
175+
176+
###Screen Tracking
177+
- Screen views are tracked as breadcrumbs with category "navigation"
178+
- Screen properties are included in the breadcrumb data
179+
180+
##Benefits of Sentry Integration
181+
182+
1.**Error Context**: Analytics events appear as breadcrumbs in error reports, helping you understand what users were doing before an error occurred
183+
184+
2.**User Tracking**: Associate errors with specific users and their properties
185+
186+
3.**Performance Monitoring**: Combine analytics with Sentry's performance tracking
187+
188+
4.**Release Tracking**: Track analytics across different app versions
189+
190+
5.**Environment Separation**: Separate development and production analytics
191+
192+
##Example: Complete Setup
193+
194+
```kotlin
195+
classMyApplication :Application() {
196+
privatelateinitvar analytiks:Analytiks
197+
198+
overridefunonCreate() {
199+
super.onCreate()
200+
201+
// Initialize Sentry
202+
SentryAndroid.init(this) { options->
203+
options.dsn="YOUR_SENTRY_DSN"
204+
options.environment=if (BuildConfig.DEBUG)"development"else"production"
205+
options.tracesSampleRate=1.0
206+
options.isEnableAutoSessionTracking=true
207+
options.isEnableUserInteractionTracing=true
208+
}
209+
210+
// Initialize Analytiks with Sentry
211+
analytiks=Analytiks.Builder()
212+
.addClient(SentryClient(context=this))
213+
.addClient(TimberAnalyticsClient())// For debug logging
214+
.build()
215+
216+
analytiks.initialize(this)
217+
218+
// Identify user
219+
analytiks.identify("user_12345")
220+
analytiks.setUserProperty("email","user@example.com")
221+
analytiks.setUserProperty("plan","premium")
222+
}
223+
}
224+
```
225+
226+
##Advanced Configuration
227+
228+
###Custom Sentry Options
229+
230+
You can configure Sentry with additional options before initializing Analytiks:
231+
232+
```kotlin
233+
SentryAndroid.init(this) { options->
234+
options.dsn="YOUR_SENTRY_DSN"
235+
options.environment="production"
236+
options.release="my-app@1.0.0"
237+
options.dist="1"
238+
239+
// Performance monitoring
240+
options.tracesSampleRate=1.0
241+
options.profilesSampleRate=1.0
242+
243+
// Session tracking
244+
options.isEnableAutoSessionTracking=true
245+
options.sessionTrackingIntervalMillis=30000
246+
247+
// User interaction tracking
248+
options.isEnableUserInteractionTracing=true
249+
options.isEnableUserInteractionBreadcrumbs=true
250+
251+
// Network tracking
252+
options.isEnableNetworkEventBreadcrumbs=true
253+
254+
// Before send callback
255+
options.beforeSend=SentryOptions.BeforeSendCallback { event, hint->
256+
// Modify or filter events before sending
257+
event
258+
}
259+
}
260+
```
261+
262+
##Resources
263+
264+
-[Sentry Android Documentation](https://docs.sentry.io/platforms/android/)
265+
-[Sentry Breadcrumbs](https://docs.sentry.io/platforms/android/enriching-events/breadcrumbs/)
266+
-[Sentry User Context](https://docs.sentry.io/platforms/android/enriching-events/identify-user/)
267+
-[Analytiks Core Documentation](../../analytiks-core/README.md)
268+
269+
##Support
270+
271+
For issues specific to the Sentry addon, please[open an issue](https://github.com/aminekarimii/analytiks/issues) on GitHub.
272+
273+
For Sentry-specific questions, refer to the[Sentry documentation](https://docs.sentry.io/) or[Sentry support](https://sentry.io/support/).
274+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
plugins {
2+
id'com.android.library'
3+
id'org.jetbrains.kotlin.android'
4+
}
5+
6+
ext {
7+
PUBLISH_ARTIFACT_ID='analytiks-sentry'
8+
}
9+
applyfrom:"${rootProject.projectDir}/scripts/publish-module.gradle"
10+
11+
android {
12+
namespace'com.analytiks.addon.sentry'
13+
compileSdk rootProject.compileSdk
14+
15+
defaultConfig {
16+
minSdk21
17+
targetSdk rootProject.targetSdk
18+
19+
testInstrumentationRunner"androidx.test.runner.AndroidJUnitRunner"
20+
}
21+
22+
buildTypes {
23+
release {
24+
minifyEnabledfalse
25+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
26+
}
27+
}
28+
compileOptions {
29+
sourceCompatibilityJavaVersion.VERSION_17
30+
targetCompatibilityJavaVersion.VERSION_17
31+
}
32+
kotlinOptions {
33+
jvmTarget='17'
34+
}
35+
}
36+
37+
dependencies {
38+
implementation project(':analytiks-core')
39+
implementation'io.sentry:sentry-android:8.23.0'
40+
}
41+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp