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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No event sent on web #207

Closed
Masadow opened this issue Sep 27, 2024 · 1 comment
Closed

No event sent on web #207

Masadow opened this issue Sep 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Masadow
Copy link

Masadow commented Sep 27, 2024

Expected Behavior

I should see events in my Amplitude Dashboard

Current Behavior

Nothing is recorded, when inspecting network, I see amplitude_web.dart.lib.js and amplitude.dart.lib.js being loaded but no subsequent calls to any amplitude API is made

Steps to Reproduce

import 'package:amplitude_flutter/amplitude.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

class Analytics {
  static late final Amplitude instance;
  
  static Future<void> init() {
    instance = Amplitude.getInstance(instanceName: 'medami');
    instance.setServerZone('EU');
    instance.trackingSessionEvents(false);
    instance.setEventUploadPeriodMillis(2000);
    instance.setEventUploadThreshold(1);
    return instance.init(dotenv.get('AMPLITUDE_KEY'));
  }

  static Future<void> log(String eventType, {Map<String, dynamic>? eventProperties}) async {
    return instance.logEvent(eventType, eventProperties: eventProperties);
  }

  static Future<void> addUserProperties(Map<String, dynamic> userProperties) {
    return instance.setUserProperties(userProperties);
  }

  static Future<void> clearUserProperties() {
    return instance.clearUserProperties();
  }
}

main.dart

Future<void> main() async {
  await runZonedGuarded(() async {
    await dotenv.load(fileName: "assets/.env");
    await SentryFlutter.init(
      (options) {
        options.dsn = dotenv.get('SENTRY_DSN');
        // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
        // We recommend adjusting this value in production.
        options.tracesSampleRate = 1.0;
        // The sampling rate for profiling is relative to tracesSampleRate
        // Setting to 1.0 will profile 100% of sampled transactions:
        options.profilesSampleRate = 1.0;
        options.environment = dotenv.get('STAGE');
      },
    );
    Analytics.init();
    Analytics.log('App start');

    GoogleFonts.config.allowRuntimeFetching = false;
    await Hive.initFlutter();
    await GraphQLClient.init(dotenv.get('GRAPHQL_ENDPOINT'), (request, e) {
      Sentry.captureException(e.originalException,
          stackTrace: e.originalStackTrace, withScope: (scope) {
        scope.setContexts('request', {
          'operation': request.operation.operationName,
        });
        if (e is HttpLinkServerException) {
          scope.setContexts('response', {
            'headers': e.response.headers,
            'statusCode': e.statusCode,
            'body': e.response.body
          });
        }
      });
    });
    ToastableState.init(navigatorKey);

    runApp(const MyApp());
  }, (exception, stackTrace) async {
    await Sentry.captureException(exception, stackTrace: stackTrace);
  });
}

Environment

  • SDK Version: 3.16.4
  • Flutter Version: 3.24.3
  • Device: Web
  • Device OS and Version: Chrome
@Masadow Masadow added the bug Something isn't working label Sep 27, 2024
@Masadow Masadow changed the title No event sent No event sent on web Sep 27, 2024
@Masadow
Copy link
Author

Masadow commented Sep 27, 2024

Nevermind, zoneGuarded was silently killing the exception, my issue is related to #89

@Masadow Masadow closed this as completed Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant