getsentry / sentry-dart

Sentry SDK for Dart and Flutter
https://sentry.io/for/flutter/
MIT License
764 stars 239 forks source link

Migrate from hive to hive_ce #2400

Closed SlayerOrnstein closed 2 weeks ago

SlayerOrnstein commented 2 weeks ago

Problem Statement

hive_ce is a fork of hive that adds WASM support and it's more up to date then the current stable hive version. It would also avoid having to add more dependencies since hive v4 is based on isar and requires isar_flutter_libs

Solution Brainstorm

Migrating from hive to hive_ce seems to just be replacing hive with hive_ce in imports

# old dependencies
dependencies:
  hive: ^2.0.0
  hive_flutter: ^1.0.0

dev_dependencies:
  hive_generator: ^1.0.0

# new dependencies
dependencies:
  hive_ce: latest
  hive_ce_flutter: latest

dev_dependencies:
  hive_ce_generator: latest
// old imports
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';

// new imports
import 'package:hive_ce/hive.dart';
import 'package:hive_ce_flutter/hive_flutter.dart';

Are you willing to submit a PR?

Yes

vaind commented 2 weeks ago

Today, hive is still a much more popular package (just judging from the limited information available on pub.dev. Also, it's very easy for the hive_ce users to use to override the dependency using dependency_overrides.

Related to https://github.com/getsentry/sentry-dart/pull/2297 for another package from the same developer. In that PR I've suggested updating docs in the fork to instruct users to use the dependency override.

I don't believe it's desirable for the majority of users to do this change at the moment because it would break all existing hive users using Sentry SDK, requiring them to change the dependency. Future will tell which package takes over the user-base and we should revisit this decision later.

Rexios80 commented 3 days ago

Maintainer of hive_ce here. Hive is more popular because it has existed for 5 years, while my fork has only existed for 6 months. However, the last update for Hive was over 2 years ago, while my fork is actively maintained. The original Hive does not support WASM compilation, which is a big blocker for a lot of people and the main reason I created hive_ce.

It is not possible to use dependency overrides to replace hive with hive_ce in a project since the packages have different names.

Also, switching to hive_ce is not a breaking change. It looks like sentry_hive wraps the hive implementation, so how would migrating to hive_ce be breaking?

vaind commented 2 days ago

It would be breaking a breaking change to all users using sentry_hive, because after updating, they'd be required to change their dependency from hive to hive_ce

Rexios80 commented 12 hours ago

I made a mapping package to allow overriding hive with hive_ce. You can see how to use it in the Hive CE README: https://pub.dev/packages/hive_ce#workaround-for-transitive-hive-dependencies