|
2 | 2 |
|
3 | 3 | import static com.rollbar.android.util.Constants.ROLLBAR_NAMESPACE; |
4 | 4 |
|
| 5 | +import android.app.Application; |
5 | 6 | import android.content.Context; |
6 | 7 | import android.content.pm.ApplicationInfo; |
7 | 8 | import android.content.pm.PackageManager; |
|
19 | 20 | import com.rollbar.api.payload.data.TelemetryType; |
20 | 21 | import com.rollbar.api.payload.data.body.RollbarThread; |
21 | 22 | import com.rollbar.notifier.config.ConfigProvider; |
| 23 | +import com.rollbar.notifier.telemetry.TelemetryEventTracker; |
22 | 24 | import com.rollbar.notifier.uncaughtexception.RollbarUncaughtExceptionHandler; |
23 | 25 | import com.rollbar.android.provider.NotifierProvider; |
24 | 26 | import com.rollbar.android.provider.PersonProvider; |
@@ -233,6 +235,7 @@ public static Rollbar init( |
233 | 235 | suspendWhenNetworkIsUnavailable); |
234 | 236 | if (androidConfiguration != null) { |
235 | 237 | initAnrDetector(context, androidConfiguration); |
| 238 | + initAutomaticCaptureOfNavigationTelemetryEvents(context, androidConfiguration); |
236 | 239 | } |
237 | 240 | } |
238 | 241 |
|
@@ -273,6 +276,7 @@ public static Rollbar init(Context context, ConfigProvider provider) { |
273 | 276 | notifier = new Rollbar(context, null, null, true, false, provider); |
274 | 277 | AndroidConfiguration androidConfiguration = makeDefaultAndroidConfiguration(); |
275 | 278 | initAnrDetector(context, androidConfiguration); |
| 279 | + initAutomaticCaptureOfNavigationTelemetryEvents(context, androidConfiguration); |
276 | 280 | } |
277 | 281 | return notifier; |
278 | 282 | } |
@@ -1173,6 +1177,31 @@ public void run() { |
1173 | 1177 | }); |
1174 | 1178 | } |
1175 | 1179 |
|
| 1180 | + private static void initAutomaticCaptureOfNavigationTelemetryEvents( |
| 1181 | + Context context, |
| 1182 | + AndroidConfiguration androidConfiguration |
| 1183 | + ) { |
| 1184 | + if (!androidConfiguration.mustCaptureNavigationEvents()) { |
| 1185 | + return; |
| 1186 | + } |
| 1187 | + |
| 1188 | + com.rollbar.notifier.Rollbar rollbarNotifier = notifier.rollbar; |
| 1189 | + if (rollbarNotifier == null) { |
| 1190 | + return; |
| 1191 | + } |
| 1192 | + |
| 1193 | + TelemetryEventTracker telemetryEventTracker = rollbarNotifier.getTelemetryEventTracker(); |
| 1194 | + if (telemetryEventTracker == null) { |
| 1195 | + return; |
| 1196 | + } |
| 1197 | + |
| 1198 | + Context appContext = context.getApplicationContext(); |
| 1199 | + if (appContext instanceof Application) { |
| 1200 | + Application application = (Application) appContext; |
| 1201 | + application.registerActivityLifecycleCallbacks(new TelemetryNavigationCallbacks(telemetryEventTracker)); |
| 1202 | + } |
| 1203 | + } |
| 1204 | + |
1176 | 1205 | private String loadAccessTokenFromManifest(Context context) throws NameNotFoundException { |
1177 | 1206 | Context appContext = context.getApplicationContext(); |
1178 | 1207 | ApplicationInfo ai = appContext.getPackageManager().getApplicationInfo(appContext.getPackageName(), PackageManager.GET_META_DATA); |
|
0 commit comments