Giter VIP home page Giter VIP logo

activity-stream-storage-prototype's People

Contributors

rfk avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

thomcc

activity-stream-storage-prototype's Issues

Implement recordPlaceAction and queryPlaceAction, using simple in-memory storage

In order to expose an API on different platforms, we need to have an API to expose :-)

In [1] @mhammond proposed recordPlaceAction and queryPlaceAction so they seem like as good a place as any to start. We don't need to bikeshed the API just yet, because we're more interested in the technical details of exposing it for this first prototype.

So, let's implement a basic memory-backed version of recordPlaceAction and queryPlaceAction that can associate an action to a particular URL at a particular time, and then query out the URLs on which a given action was performed, most recent first.

[1] https://docs.google.com/document/d/1g3OzUc38V-t4EXkO9MUOJ4_TmCqSsz9IJPGh0fCcIgg/edit#

Wiki changes

FYI: The following changes were made to this repository's wiki:

These were made as the result of a recent automated defacement of publically writeable wikis.

Sketch out an API for recording events

Storing events seems like it'll be simpler than querying, so let's start brainstorming how writing new events might work! Based on @fluffyemily's explorations in https://github.com/fluffyemily/cross-platform-rust/, I'm guessing we'll need to expose a more low-level API in Rust, and wrap that in C++/Java/Swift for Gecko and Fennec to use.

I'm not really fond of the "key is a string" design in this one...it's too easy to mask typos, and using an Event struct might also let us do interesting things like composing multiple events when we build up queries.

// Sets up the SQLite database, attaches to Places, etc.
let store = Store::open(...).expect("Failed to open store");

// Record some metadata for the URL.
store.record("http://example.com", |recorder| {
  // Record page metadata: number of images, videos, etc. We can replace these
  // directly, without storing the previous values: the number of images or
  // videos on the page might change, but the old values aren't interesting.
  // These are linked to rows in `moz_places`.
  //
  // In this sketch, it's possible to just declare the key and value: we'll create
  // it if it doesn't exist, and overload `set()` for different value types:
  // i64, time::Duration, &str, bool. A more structured design might add a
  // `store.define()` API for every event we'd like to record. `define` would
  // return an `Event` struct, which we could pass to `set` instead of the
  // string name.
  let page = recorder.page();
  page.set("images", 4);
  page.set("videos", 14);

  // Record visit metadata: dwell time, time the page was left open in the
  // background, referring search query, and so on. These are linked to rows
  // in `moz_historyvisits`, which also gives us info that Places records like
  // the visit time, referrer, and transition (link, bookmark, typed into
  // awesomebar, etc).
  let visit = recorder.visit();
  visit.set("dwell-time", Duration::minutes(2));
  visit.set("background-time", Duration::seconds(3));
  visit.set("referring-search-query", "lolcats");

  // Record actions for the visit. We can store timestamps and other
  // interesting info automatically.
  visit.action("share", "send-to-device");
  visit.action("play", "#cat-video-1");
  visit.action("pause", "#cat-video-1");

  // Everything in this function happens in a transaction. At the end, the
  // transaction commits.
}).expect("Failed to record metadata");

Integrate the "place actions" API into a Desktop Firefox build

Once the API from #3 exists, we'll need to figure out how to expose it to Desktop Firefox. I expect there are some existing patterns for doing this from other rust-based Firefox components, but I don't know enough about them to write them down in this bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.