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 ability to fetch and run recipes early on firstrun #889

Closed
Osmose opened this issue Jul 14, 2017 · 4 comments
Closed

Add ability to fetch and run recipes early on firstrun #889

Osmose opened this issue Jul 14, 2017 · 4 comments
Assignees

Comments

@Osmose
Copy link
Contributor

Osmose commented Jul 14, 2017

We'd like to add a feature to Normandy that triggers fetching and executing recipes as early on a user's first run of Firefox as we can reasonably get.

  • Once all recipes have finished executing, we should write the time since launch to telemetry so that we can analyze how reliably we can modify things like preferences at firstrun. TBD on how to structure this (a custom one-time packet? on the main ping? data review?).
    • Thinking more, we probably want to include individual recipe IDs and their finish times so we can measure a specific preference change, for example.
  • We should add a field to filter expressions to allow filtering recipes to only execute on firstrun (normandy.isFirstRun?)
@rhelmer
Copy link
Contributor

rhelmer commented Jul 14, 2017

I think that the earliest we can reasonably start running something like fetching code is after sessionstore-windows-restored (see https://developer.mozilla.org/en-US/docs/Observer_Notifications) - we'll need an observer like:

Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

let observer = {
  observe: function(subject, topic, data)
  {
    Services.obs.removeObserver("sessionstore-windows-restored", this);
    // fetch and execute recipes
  },
  QueryInterface: XPCOMUtils.generateQI([
    Components.interfaces.nsIObserver,
    Components.interfaces.nsISupportsWeakReference
  ])
};
Services.obs.addObserver("sessionstore-windows-restored", observer, true);

Since there's already an update timer being used I suspect we can just trigger it to run when the observer notification fires.

@rhelmer
Copy link
Contributor

rhelmer commented Jul 14, 2017

OK. So it looks like RecipeRunner.jsm registers a timer with the ID recipe-client-addon-run, which fetches and executes recipes.

What we should be able to do here is add a "sessionstore-windows-restored" observer early in the startup of the system add-on, which calls notify() on the timer.

@rhelmer
Copy link
Contributor

rhelmer commented Jul 18, 2017

On further reflection I think it's simpler and more readable to just run once and set the timer up after "sessionstore-windows-restored" is observed, rather than let the timer be set up and notify it explicitly etc.

@Osmose
Copy link
Contributor Author

Osmose commented Sep 7, 2017

#895 fixed this and it got uplifted and is currently in release.

@Osmose Osmose closed this as completed Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants