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

Add an explanation about config.debug and Posthog().debug() #121

Closed
jakobhec opened this issue Nov 12, 2024 · 4 comments
Closed

Add an explanation about config.debug and Posthog().debug() #121

jakobhec opened this issue Nov 12, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@jakobhec
Copy link

Problem Statement

It would be really helpful if the com.posthog.posthog.DEBUG parameter, config.debug and Posthog().debug() had an explanation, ideally directly in the code.

  1. What does config.debug do in this example from the documentation? https://github.com/PostHog/posthog-flutter

    Future<void> main() async {
        // init WidgetsFlutterBinding if not yet
        WidgetsFlutterBinding.ensureInitialized();
        final config = PostHogConfig('YOUR_API_KEY_GOES_HERE');
        config.debug = true;  // <=== this here
        config.captureApplicationLifecycleEvents = true;
        // or EU Host: 'https://eu.i.posthog.com'
        config.host = 'https://us.i.posthog.com';
        await Posthog().setup(config);
        runApp(MyApp());
    }
  2. Does it do the same as Posthog().debug(true)?

    Or does this code do the same as the code from the example above? I set it to false initially but then use .debug(true)?

    Future<void> main() async {
        // init WidgetsFlutterBinding if not yet
        WidgetsFlutterBinding.ensureInitialized();
        final config = PostHogConfig('YOUR_API_KEY_GOES_HERE');
        config.debug = false; // <=== this has changed
        config.captureApplicationLifecycleEvents = true;
        // or EU Host: 'https://eu.i.posthog.com'
        config.host = 'https://us.i.posthog.com';
        await Posthog().setup(config);
        
        Posthog().debug(true); // <=== this has changed
        
        runApp(MyApp());
    }
  3. Why is this always set to true in the examples? Does it make sense to set it to true only if we’re debugging the app? Does it make a difference?

    import 'package:flutter/foundation.dart';
    
    Posthog().debug(kDebugMode);

Solution Brainstorm

No response

@jakobhec jakobhec added the enhancement New feature or request label Nov 12, 2024
@marandaneto
Copy link
Member

Hello,

config.debug = true is just a shortcut for Posthog().debug(true), so the SDK already starts in debug mode and logs things in the console.
Calling Posthog().debug(kDebugMode); at runtime will enable and disable logging based on your needs.

@marandaneto
Copy link
Member

Somehow a dupe of #88 that we can address in this other ssue

@marandaneto marandaneto closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
@jakobhec
Copy link
Author

So, this is just about printing to the console? It doesn’t affect the functionality or the events being sent at all?

@marandaneto
Copy link
Member

So, this is just about printing to the console? It doesn’t affect the functionality or the events being sent at all?

Correct.
https://posthog.com/docs/libraries/android#all-configuration-options

// Logs the SDK messages into Logcat. (off/false by default)

Same goes for iOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants