[gnome-initial-setup/wip/pwithnall/misc-fixes: 62/70] eos: Report metrics from parental controls page




commit f71d55fe704e8188a4ebf7451f1dd97914333a0f
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Mar 16 13:40:07 2020 +0000

    eos: Report metrics from parental controls page
    
    If the user chooses to enable parental controls when setting up the
    computer, send a metrics event which contains the initial parental
    controls settings. Don’t send an event if parental controls are not
    enabled.
    
    This will give us an idea of the more and less popular parental controls
    features. If they are compared against parental controls settings set or
    changed after initial setup, this metric will also give us an idea of
    how people change their parental controls (presumably tweaking them
    since they set them incorrectly in the first place).
    
    This bumps the libmalcontent dependency to 0.7.0 for the new
    `mct_app_filter_serialize()` API.
    
    This commit should not be upstreamed.
    
    (Rebase 3.38: Fix minor rebase conflicts.)
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://phabricator.endlessm.com/T28742

 .../parental-controls/gis-parental-controls-page.c | 33 ++++++++++++++++++++++
 meson.build                                        |  2 +-
 2 files changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.c 
b/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.c
index 89f3e34a..e59e551e 100644
--- a/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.c
+++ b/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.c
@@ -25,6 +25,7 @@
 
 #include "config.h"
 
+#include <eosmetrics/eosmetrics.h>
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gi18n.h>
@@ -46,6 +47,35 @@ struct _GisParentalControlsPage
 
 G_DEFINE_TYPE (GisParentalControlsPage, gis_parental_controls_page, GIS_TYPE_PAGE)
 
+/* This is the same event as submitted in malcontent-control */
+#define MCT_PARENTAL_CONTROLS_EVENT "449ec188-cb7b-45d3-a0ed-291d943b9aa6"
+
+static void
+report_parental_controls_metric (GisParentalControlsPage *page,
+                                 MctAppFilter            *filter)
+{
+  EmtrEventRecorder *recorder;
+  g_autoptr(GVariant) serialised_filter = NULL;
+  g_auto(GVariantDict) dict = G_VARIANT_DICT_INIT (NULL);
+
+  if (!gis_driver_get_parental_controls_enabled (GIS_PAGE (page)->driver))
+    return;
+
+  /* Serialise the app filter which was saved against the user’s account. Add
+   * some additional fields to help group the data. */
+  recorder = emtr_event_recorder_get_default ();
+  serialised_filter = mct_app_filter_serialize (filter);
+
+  g_variant_dict_init (&dict, serialised_filter);
+  g_variant_dict_insert (&dict, "IsAdministrator", "b", FALSE);
+  g_variant_dict_insert (&dict, "IsInitialSetup", "b", TRUE);
+
+  /* Send the metrics for this user. */
+  emtr_event_recorder_record_event (recorder,
+                                    MCT_PARENTAL_CONTROLS_EVENT,
+                                    g_variant_dict_end (&dict));
+}
+
 static gboolean
 gis_parental_controls_page_save_data (GisPage  *gis_page,
                                       GError  **error)
@@ -80,6 +110,9 @@ gis_parental_controls_page_save_data (GisPage  *gis_page,
                                    error))
     return FALSE;
 
+  /* Endless-specific metrics reporting. */
+  report_parental_controls_metric (page, app_filter);
+
   return TRUE;
 }
 
diff --git a/meson.build b/meson.build
index d6927b2f..38f8efbf 100644
--- a/meson.build
+++ b/meson.build
@@ -74,7 +74,7 @@ conf.set('HAVE_IBUS', ibus_dep.found())
 
 # Needed for the parental controls pages
 libmalcontent_dep = dependency ('malcontent-0',
-                                version: '>= 0.6.0',
+                                version: '>= 0.7.0',
                                 required: get_option('parental_controls'))
 libmalcontent_ui_dep = dependency ('malcontent-ui-0',
                                    version: '>= 0.6.0',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]