getappmap / getappmap/appmap

Support frontend recording

Open
#38 4 comments 0 reactions 1 assignee View on GitHub

@lachrist is already working on this.

Since Apr 18, 2023.

Dominant language
No language data
Stars
81
Forks
8
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.