Skip to content

Support frontend recording #38

@lachrist

Description

@lachrist

Problem

This specification needs to be adapted to enable the js agent to record browser applications. That is because sources can no longer be assumed to be static files. Indeed, on browser, code comes from http responses and not static files. For instance, when the man-in-the-middle proxy intercepts the http response of GET http://localhost:8080/script.js, it has no idea to which static file this source should be linked. This static file might not even exist if the source has been dynamically generated.

Solution

Currently, the agent is breaking the spec in two places:

  1. The root packages of classmaps can be url origins. For instance, when the source is associated to http://localhost:8080/directory/script.js the root package will be http://localhost:8080.
  2. The location of functions can be urls -- eg: http://localhost:8080/directory/script.js. Note that the visualizer should not attempt to fetch these. This code can only be retrieved if it was inlined in the appmap.
classMap:
  - type: package
    name: "http://localhost:8080"
    children:
      - type: package
        name: directory
        children:
          - type: class
            name: script
            children:
              - type: function
                location: "http://localhost:8080/directory/script.js"

File URLs

It may be worthwhile to support file urls. That way, function locations could consistently be provided as (absolute) urls. File urls would represent static sources that can be fetched while other urls would represent dynamic sources that cannot be fetched. That would simplify the js agent and probably the visualizer as well as it helps avoiding shenanigans related to windows path.

Relative URLs

Absolute urls are not great to visualize. In some projects it makes express absolute urls relatively to a reference absolute url. There is two ways we can go about this:

  1. The appmap contains only absolute urls. The reference url could be provided in appmap.yml or using a heuristic such as: if more then half of the urls start with http://localhost:8080:/public then use it as reference url. In any case, it becomes the job of the visualizer to decide how these absolute urls should be displayed and this specification remains not impacted by this consideration.
  2. The appmap may contains relative urls. We should then provide the reference url inside the appmap itself. Maybe something like: metadata.home = "http://localhost:8080/public". If this field is missing we can assume that it is the directory containing the appmap.yml file.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions