PostHog / posthog-flutter

PostHog Flutter SDK
https://posthog.com/docs/libraries/flutter
MIT License
48 stars 34 forks source link

Need Control over Autocapture events #82

Closed kamaravichow closed 5 months ago

kamaravichow commented 5 months ago

Problem Statement

Auto events like app open, backgrounded are wasting events counts, It would be really helpful to disable auto capture events for flutter sdk.

Solution Brainstorm

Autocapture - NOT GOOD

PostHog autocapture automatically tracks the following events for you:

Application Opened - when the app is opened from a closed state or when the app comes to the foreground (e.g. from the app switcher) Application Backgrounded - when the app is sent to the background by the user Application Installed - when the app is installed. Application Updated - when the app is updated.

marandaneto commented 5 months ago

@kamaravichow you can disable them, check the documentation https://posthog.com/docs/libraries/flutter

Android:

<meta-data android:name="com.posthog.posthog.TRACK_APPLICATION_LIFECYCLE_EVENTS" android:value="false" />

iOS:

<key>com.posthog.posthog.CAPTURE_APPLICATION_LIFECYCLE_EVENTS</key>
<false/>
alexlozdev commented 3 months ago

Web

<!-- posthog -->
  <script>
    !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
    posthog.init('phc_e9hZMrbbewlycMR1qlcqyZ9jRwKofloONLwe5cqSxKL', {api_host: 'https://app.posthog.com', autocapture: false})
  </script>
{api_host: 'https://app.posthog.com', autocapture: false}
marandaneto commented 3 months ago

For the web you can also disable it remotely via project configuration. https://us.posthog.com/project/{your_project_id}/settings/project-autocapture