Skip to content

Commit

Permalink
Merged in release/15.1.0 (pull request #26)
Browse files Browse the repository at this point in the history
Release/15.1.0
  • Loading branch information
mstanic-shake committed Dec 24, 2021
2 parents a7c9878 + 5459dab commit cf7372c
Show file tree
Hide file tree
Showing 20 changed files with 233 additions and 55 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 15.1.0

Real-time chat

# 15.0.0

Shake 15 release
Expand Down
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# Shake for Flutter
# Shake Flutter SDK

Flutter plugin for [Shake](https://www.shakebugs.com).
[![pub package](https://img.shields.io/pub/v/shake_flutter)](https://pub.dev/packages/shake_flutter)

Flutter plugin for [bug reporting](https://www.shakebugs.com).

## Features

| Feature | Available |
|:---------------:|:---------:|
| Bug reporting ||
| Crash reporting ||
| Users ||

## Requirements

| Platform | Version |
|:----------:|:---------:|
| Flutter | 1.12 |
| Android | 7.0 |
| iOS | 12.0 |

## How to use

Expand All @@ -9,15 +27,15 @@ Flutter plugin for [Shake](https://www.shakebugs.com).
Add Shake to your `pubspec.yaml` file.
```yaml
dependencies:
shake_flutter: ^15.0.0
shake_flutter: ^15.1.0
```
Install package by running command in terminal.
```bash
flutter packages get
```

## Start Shake
### Start Shake

Add Shake import.
```dart
Expand All @@ -41,6 +59,6 @@ void main() {

Replace `client-id` and `client-secret` with the actual values you have in [your workspace settings](https://app.shakebugs.com/settings/workspace#general).

## Documentation
## Resources

Visit [documentation](https://www.shakebugs.com/docs) for more details.
- [Official docs](https://www.shakebugs.com/docs/)
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api "$System.env.ANDROID_DEPENDENCY:15.0.+"
api "$System.env.ANDROID_DEPENDENCY:15.1.+"
}
34 changes: 28 additions & 6 deletions android/src/main/kotlin/com/shakebugs/flutter/ShakePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import com.shakebugs.flutter.utils.Constants
import com.shakebugs.flutter.utils.Logger
import com.shakebugs.shake.Shake
import com.shakebugs.shake.ShakeInfo
import com.shakebugs.shake.internal.data.NetworkRequest
import com.shakebugs.shake.internal.data.NotificationEvent
import com.shakebugs.shake.ShakeScreen
import com.shakebugs.shake.internal.domain.models.NetworkRequest
import com.shakebugs.shake.internal.domain.models.NotificationEvent
import com.shakebugs.shake.report.FeedbackType
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
Expand Down Expand Up @@ -75,6 +76,8 @@ class ShakePlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
"getShakingThreshold" -> getShakingThreshold(result)
"setInvokeShakeOnScreenshot" -> setInvokeShakeOnScreenshot(call)
"isInvokeShakeOnScreenshot" -> isInvokeShakeOnScreenshot(result)
"getDefaultScreen" -> getDefaultScreen(result)
"setDefaultScreen" -> setDefaultScreen(call)
"setScreenshotIncluded" -> setScreenshotIncluded(call)
"isScreenshotIncluded" -> isScreenshotIncluded(result)
"getEmailField" -> getEmailField(result)
Expand All @@ -93,6 +96,7 @@ class ShakePlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
"setConsoleLogsEnabled" -> setConsoleLogsEnabled(call)
"log" -> log(call)
"setMetadata" -> setMetadata(call)
"clearMetadata" -> clearMetadata()
"setShakeReportData" -> setShakeReportData(call)
"silentReport" -> silentReport(call)
"registerUser" -> registerUser(call)
Expand Down Expand Up @@ -204,8 +208,22 @@ class ShakePlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
result.success(enabled)
}

private fun getShakingThreshold(result: Result){
val threshold: Int? = Shake.getReportConfiguration().getShakingThreshold()
private fun getDefaultScreen(result: Result) {
val defaultScreen: ShakeScreen = Shake.getReportConfiguration().defaultScreen
val defaultScreenStr: String = mapper?.shakeScreenToString(defaultScreen) ?: "newTicket"
result.success(defaultScreenStr)
}

private fun setDefaultScreen(call: MethodCall) {
val defaultScreenStr: String? = call.argument("shakeScreen")
val defaultScreen: ShakeScreen? = mapper?.mapToShakeScreen(defaultScreenStr)
defaultScreen?.let {
Shake.getReportConfiguration().defaultScreen = defaultScreen
}
}

private fun getShakingThreshold(result: Result) {
val threshold: Int = Shake.getReportConfiguration().shakingThreshold
result.success(threshold)
}

Expand All @@ -228,12 +246,12 @@ class ShakePlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
result.success(enabled)
}

private fun isScreenshotIncluded(result: Result){
private fun isScreenshotIncluded(result: Result) {
val enabled: Boolean = Shake.getReportConfiguration().isScreenshotIncluded
result.success(enabled)
}

private fun setScreenshotIncluded(call: MethodCall){
private fun setScreenshotIncluded(call: MethodCall) {
val enabled: Boolean? = call.argument("enabled")
enabled?.let {
Shake.getReportConfiguration().isScreenshotIncluded = it
Expand Down Expand Up @@ -287,6 +305,10 @@ class ShakePlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
Shake.setMetadata(key, value)
}

private fun clearMetadata() {
Shake.clearMetadata()
}

private fun log(call: MethodCall) {
val logLevelStr: String? = call.argument("level")
val message: String? = call.argument("message")
Expand Down
32 changes: 25 additions & 7 deletions android/src/main/kotlin/com/shakebugs/flutter/ShakeReflection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ import android.app.Activity
import com.shakebugs.flutter.utils.Logger
import com.shakebugs.flutter.utils.Reflection
import com.shakebugs.shake.ShakeInfo
import com.shakebugs.shake.internal.data.NetworkRequest
import com.shakebugs.shake.internal.data.NotificationEvent
import com.shakebugs.shake.internal.domain.models.NetworkRequest
import com.shakebugs.shake.internal.domain.models.NotificationEvent
import java.lang.reflect.Method

object ShakeReflection {
private const val CLASS_NAME = "com.shakebugs.shake.Shake"

fun start(activity: Activity?, clientId: String?, clientSecret: String?) {
try {
val method: Method? = Reflection.getMethod(Class.forName(CLASS_NAME), "startFromWrapper", Activity::class.java, String::class.java, String::class.java)
val method: Method? = Reflection.getMethod(
Class.forName(CLASS_NAME),
"startFromWrapper",
Activity::class.java,
String::class.java,
String::class.java
)
method?.invoke(null, activity, clientId, clientSecret)
} catch (e: Exception) {
Logger.e("Failed to start Shake", e)
Expand All @@ -22,7 +28,11 @@ object ShakeReflection {

fun setShakeInfo(shakeInfo: ShakeInfo?) {
try {
val method: Method? = Reflection.getMethod(Class.forName(CLASS_NAME), "setShakeInfo", ShakeInfo::class.java)
val method: Method? = Reflection.getMethod(
Class.forName(CLASS_NAME),
"setShakeInfo",
ShakeInfo::class.java
)
method?.invoke(null, shakeInfo)
} catch (e: Exception) {
Logger.e("Failed to set shake info", e)
Expand All @@ -31,7 +41,11 @@ object ShakeReflection {

fun insertNetworkRequest(networkRequest: NetworkRequest?) {
try {
val method: Method? = Reflection.getMethod(Class.forName(CLASS_NAME), "insertNetworkRequest", NetworkRequest::class.java)
val method: Method? = Reflection.getMethod(
Class.forName(CLASS_NAME),
"insertNetworkRequest",
NetworkRequest::class.java
)
method?.invoke(null, networkRequest)
} catch (e: Exception) {
Logger.e("Failed to insert network request", e)
Expand All @@ -40,7 +54,11 @@ object ShakeReflection {

fun insertNotificationEvent(notificationEvent: NotificationEvent?) {
try {
val method: Method? = Reflection.getMethod(Class.forName(CLASS_NAME), "insertNotificationEvent", NotificationEvent::class.java)
val method: Method? = Reflection.getMethod(
Class.forName(CLASS_NAME),
"insertNotificationEvent",
NotificationEvent::class.java
)
method?.invoke(null, notificationEvent)
} catch (e: Exception) {
Logger.e("Failed to insert notification event", e)
Expand Down
14 changes: 11 additions & 3 deletions android/src/main/kotlin/com/shakebugs/flutter/helpers/Mapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import com.shakebugs.flutter.utils.Resources
import com.shakebugs.shake.LogLevel
import com.shakebugs.shake.ShakeReportConfiguration
import com.shakebugs.shake.ShakeScreen
import com.shakebugs.shake.internal.data.NetworkRequest
import com.shakebugs.shake.internal.data.NotificationEvent
import com.shakebugs.shake.internal.domain.models.NetworkRequest
import com.shakebugs.shake.internal.domain.models.NotificationEvent
import com.shakebugs.shake.report.FeedbackType
import com.shakebugs.shake.report.ShakeFile


class Mapper(private val context: Context) {
fun mapToShakeScreen(shakeScreenStr: String?): ShakeScreen {
return when (shakeScreenStr) {
Expand All @@ -22,6 +21,14 @@ class Mapper(private val context: Context) {
}
}

fun shakeScreenToString(shakeScreen: ShakeScreen): String? {
return when (shakeScreen) {
ShakeScreen.HOME -> "home"
ShakeScreen.NEW -> "newTicket"
else -> null
}
}

fun mapToShakeFiles(data: List<HashMap<String, Any>>?): List<ShakeFile>? {
return data?.map {
val path: String = it["path"] as String
Expand Down Expand Up @@ -65,6 +72,7 @@ class Mapper(private val context: Context) {
config.activityHistoryData = data["activityHistoryData"] as Boolean
config.blackBoxData = data["blackBoxData"] as Boolean
config.screenshot = data["screenshot"] as Boolean
config.video = data["video"] as Boolean
config.showReportSentMessage = data["showReportSentMessage"] as Boolean
}
return config
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Shake"
android:label="Shake Flutter"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round">
<activity
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://github.com/CocoaPods/Specs.git'
source 'git@github.com:shakebugs/Specs.git'

# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ PODS:
- Flutter
- path_provider (0.0.1):
- Flutter
- Shake-Staging (15.0.0-rc.1373)
- Shake-Staging (15.1.0-rc.1447)
- shake_flutter (0.0.1):
- Flutter
- Shake-Staging (~> 15.0.0-rc)
- Shake-Staging (~> 15.1.0-rc.1447)
- Toast (4.0.0)
- url_launcher (0.0.1):
- Flutter
Expand Down Expand Up @@ -54,11 +54,11 @@ SPEC CHECKSUMS:
fluttertoast: 6122fa75143e992b1d3470f61000f591a798cc58
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
path_provider: d1e9807085df1f9cc9318206cd649dc0b76be3de
Shake-Staging: d7d5af5607f7b377723fd88915c7e2e410b349b8
shake_flutter: ca19f9aa0119392650d6d6764245d653a6e38def
Shake-Staging: 1e48bab5826b8192d7c0a3917f3e1e7d44d6b02e
shake_flutter: f21bd5c31b35e9b3963146422751633b596672bb
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
url_launcher: b6e016d912f04be9f5bf6e8e82dc599b7ba59649

PODFILE CHECKSUM: 350b23a1ddb073e6f234cd77e085ec2d3d146984
PODFILE CHECKSUM: 18de14b99602a19f41203ed1bd1f3eb50097dbcf

COCOAPODS: 1.11.2
Loading

0 comments on commit cf7372c

Please sign in to comment.