Skip to content

Commit

Permalink
removed error logging for cancelled purchases, added more descriptive…
Browse files Browse the repository at this point in the history
… logging for other purchase errors
  • Loading branch information
ggurdin committed Dec 29, 2023
1 parent b298afd commit 700fc83
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/pangea/controllers/subscription_controller.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import 'dart:async';
import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:http/http.dart';
import 'package:purchases_flutter/purchases_flutter.dart';
import 'package:url_launcher/url_launcher_string.dart';

import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pangea/constants/local.key.dart';
import 'package:fluffychat/pangea/controllers/base_controller.dart';
Expand All @@ -23,6 +15,13 @@ import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:fluffychat/pangea/utils/firebase_analytics.dart';
import 'package:fluffychat/pangea/widgets/subscription/subscription_paywall.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:http/http.dart';
import 'package:purchases_flutter/purchases_flutter.dart';
import 'package:url_launcher/url_launcher_string.dart';

class SubscriptionController extends BaseController {
late PangeaController _pangeaController;
Expand Down Expand Up @@ -242,8 +241,15 @@ class SubscriptionController extends BaseController {
await Purchases.purchasePackage(selectedSubscription.package!);
GoogleAnalytics.updateUserSubscriptionStatus(true);
} catch (err) {
final errCode = PurchasesErrorHelper.getErrorCode(
err as PlatformException,
);
if (errCode == PurchasesErrorCode.purchaseCancelledError) {
debugPrint("User cancelled purchase");
return;
}
ErrorHandler.logError(
m: "Failed to purchase revenuecat package for user ${_pangeaController.matrixState.client.userID}",
m: "Failed to purchase revenuecat package for user ${_pangeaController.matrixState.client.userID} with error code $errCode",
s: StackTrace.current,
);
return;
Expand Down

0 comments on commit 700fc83

Please sign in to comment.