Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter min version test #966

Merged
merged 22 commits into from Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/min_version_test.yml
@@ -0,0 +1,37 @@
name: min version test
on:
push:
branches:
- main
- release/**
pull_request:
paths-ignore:
- 'logging/**'
- 'dio/**'
marandaneto marked this conversation as resolved.
Show resolved Hide resolved
defaults:
run:
shell: bash
jobs:
build:
name: Build
runs-on: macos-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'

- uses: subosito/flutter-action@v2
with:
flutter-version: '2.0.0'

- name: Build
run: |
cd min_version_test
flutter pub get
flutter build ios --no-codesign
flutter build appbundle
3 changes: 2 additions & 1 deletion dart/lib/src/client_reports/client_report_recorder.dart
@@ -1,6 +1,7 @@
import 'package:meta/meta.dart';

import '../sentry_options.dart';
import '../utils/hash_code.dart';
import 'client_report.dart';
import 'discarded_event.dart';
import 'discard_reason.dart';
Expand Down Expand Up @@ -43,7 +44,7 @@ class _QuantityKey {
final DataCategory category;

@override
int get hashCode => Object.hash(reason, category);
int get hashCode => hash2(reason.hashCode, category.hashCode);

@override
bool operator ==(dynamic other) {
Expand Down
24 changes: 24 additions & 0 deletions dart/lib/src/utils/hash_code.dart
@@ -0,0 +1,24 @@
// Borrowed from https://api.dart.dev/stable/2.17.6/dart-core/Object/hash.html
// Since Object.hash(a, b) is only available from Dart 2.14

// A per-isolate seed for hash code computations.
final int _hashSeed = identityHashCode(Object);

int _combine(int hash, int value) {
hash = 0x1fffffff & (hash + value);
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
return hash ^ (hash >> 6);
}

int hash2(int v1, int v2) {
int hash = _hashSeed;
hash = _combine(hash, v1);
hash = _combine(hash, v2);
return _finish(hash);
}

int _finish(int hash) {
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
hash = hash ^ (hash >> 11);
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
}
10 changes: 10 additions & 0 deletions flutter/example/lib/main.dart
Expand Up @@ -4,13 +4,15 @@ import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:logging/logging.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:universal_platform/universal_platform.dart';
import 'package:feedback/feedback.dart' as feedback;
import 'package:provider/provider.dart';
import 'user_feedback_dialog.dart';
import 'package:dio/dio.dart';
import 'package:sentry_dio/sentry_dio.dart';
import 'package:sentry_logging/sentry_logging.dart';

// ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io
const String _exampleDsn =
Expand All @@ -28,6 +30,7 @@ Future<void> main() async {
options.considerInAppFramesByDefault = false;
options.attachThreads = true;
options.enableWindowMetricBreadcrumbs = true;
options.addIntegration(LoggingIntegration());
},
// Init your App.
appRunner: () => runApp(
Expand Down Expand Up @@ -391,6 +394,13 @@ class AndroidExample extends StatelessWidget {
},
child: const Text('Platform exception'),
),
ElevatedButton(
onPressed: () {
final log = Logger('Logging');
log.info('My Logging test');
},
child: const Text('Logging'),
),
]);
}
}
Expand Down
4 changes: 4 additions & 0 deletions flutter/example/pubspec.yaml
Expand Up @@ -14,10 +14,12 @@ dependencies:
sentry:
sentry_flutter:
sentry_dio:
sentry_logging:
universal_platform: ^1.0.0-nullsafety
feedback: ^2.0.0
provider: ^6.0.0
dio: ^4.0.0
logging: ^1.0.2

dev_dependencies:
pedantic: ^1.11.1
Expand All @@ -30,6 +32,8 @@ dependency_overrides:
path: ../
sentry_dio:
path: ../../dio
sentry_logging:
path: ../../logging

flutter:
uses-material-design: true
Expand Down
10 changes: 9 additions & 1 deletion flutter/lib/src/integrations/on_error_integration.dart
Expand Up @@ -3,6 +3,7 @@ import 'dart:ui';

import 'package:flutter/widgets.dart';
import 'package:sentry/sentry.dart';
import '../binding_utils.dart';
import '../sentry_flutter_options.dart';

typedef ErrorCallback = bool Function(Object exception, StackTrace stackTrace);
Expand All @@ -28,9 +29,16 @@ class OnErrorIntegration implements Integration<SentryFlutterOptions> {
@override
void call(Hub hub, SentryFlutterOptions options) {
_options = options;
// remove when https://github.com/getsentry/sentry-dart/pull/965/files gets merged
final binding = BindingUtils.getWidgetsBindingInstance();

if (binding == null) {
return;
}

final wrapper = dispatchWrapper ??
// WidgetsBinding works with WidgetsFlutterBinding and other custom bindings
PlatformDispatcherWrapper(WidgetsBinding.instance.platformDispatcher);
PlatformDispatcherWrapper(binding.platformDispatcher);

if (!wrapper.isOnErrorSupported(options)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion flutter/pubspec.yaml
Expand Up @@ -7,7 +7,7 @@ issue_tracker: https://github.com/getsentry/sentry-dart/issues

environment:
sdk: '>=2.12.0 <3.0.0'
flutter: '>=1.17.0'
flutter: '>=2.0.0'

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions logging/README.md
Expand Up @@ -24,6 +24,7 @@ Integration for the [`logging`](https://pub.dev/packages/logging) package.

```dart
import 'package:sentry/sentry.dart';
import 'package:sentry_logging/sentry_logging.dart';

Future<void> main() async {
await Sentry.init(
Expand Down
44 changes: 44 additions & 0 deletions min_version_test/.gitignore
@@ -0,0 +1,44 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
45 changes: 45 additions & 0 deletions min_version_test/.metadata
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.

version:
revision: f1875d570e39de09040c8f79aa13cc56baab8db1
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: android
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: ios
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: linux
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: macos
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: web
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: windows
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
16 changes: 16 additions & 0 deletions min_version_test/README.md
@@ -0,0 +1,16 @@
# min_version_test

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
13 changes: 13 additions & 0 deletions min_version_test/android/.gitignore
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
84 changes: 84 additions & 0 deletions min_version_test/android/app/build.gradle
@@ -0,0 +1,84 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
ndkVersion '21.4.7075529'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.min_version_test"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 16
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

externalNativeBuild {
cmake {
arguments.add(0, "-DANDROID_STL=c++_static")
}
}

ndk {
// Flutter does not currently support building for x86 Android (See Issue 9253).
abiFilters("armeabi-v7a", "x86_64", "arm64-v8a")
}
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
8 changes: 8 additions & 0 deletions min_version_test/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.min_version_test">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>