# m-cheng-web/web-tracing architecture

> Architecture diagram of the GitHub repository m-cheng-web/web-tracing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m-cheng-web/web-tracing
- Repository: https://github.com/m-cheng-web/web-tracing

## Overview

##### And Highlight the Main Components
- SDK Core: Represent the central logic of the monitoring plugin. This is located in packages/core and includes various libraries (e.g., error handling, event tracking, HTTP requests, performance, etc.), observer implementations, and utility functions.
- Version-Specific Wrappers: Include separate modules for Vue2 and Vue3 (under packages/vue2 and packages/vue3) that integrate the core functionality with framework-specific features.
- Documentation and Configuration: Show the official documentation (docs folder configured with VitePress) that provides guides and API details, as well as configuration/build scripts (e.g., rollup.config.js, tsconfig.json, and the scripts directory) used for building, testing, and publishing.
- Build/Dev Tools: Identify development tooling like ESLint, npm/pnpm configurations, and testing configurations (e.g., vitest.config.mts) that ensure code quality and consistency.

##### Relationships and Interactions
- How the example projects incorporate the wrappers and core SDK to demonstrate functionality.
- Integration with external libraries/services (e.g., rrweb for screen recording, fingerprintjs for user identification, and webrtc-ip for public IP detection). Show these as external dependencies used by the core libraries.
- Build and deployment flow from code (in packages and scripts) to distributed bundles (via Rollup and the publish scripts).

##### Architectural Patterns and Design Principles
- Modularity & Abstraction: Indicate how the core functionality is encapsulated and then extended by framework-specific packages.
- Reactive Design: Note that the core makes use of a Vue-inspired reactive system for handling options objects and internal state changes.
- Configurability & Extensibility: Show that the plugin exposes various hook functions, local control methods (e.g., for batching errors or controlling event sending), and filtering mechanisms.

##### Detailed Steps for the Principal Software Engineer
- Within the SDK block, further subdivide it into:
- Core functionality (packages/core) and its submodules (lib, observer, utils, and types).
- Extension packages (packages/vue2 and packages/vue3) that adapt the core for framework-specific needs.
- Build and tooling scripts that support the monorepo configuration.
- Finally, include peripheral components such as the documentation system (docs using VitePress) and scripts that automate builds and publishing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Integration Section
    subgraph "Client Integrations"
        vanilla("Vanilla Example"):::support
        vue2Client("Vue2 Example"):::support
        vue3Client("Vue3 Example"):::support
    end

    %% Monitoring SDK Section
    subgraph "Monitoring SDK"
        core("SDK Core<br/>(Core Logic & Libraries)"):::core

        subgraph "Version-Specific Wrappers"
            vue2Adapter("Vue2 Adapter"):::adapter
            vue3Adapter("Vue3 Adapter"):::adapter
        end

        docs("Documentation<br/>(VitePress & Guides)"):::support
        externalDep("External Dependencies<br/>(rrweb, fingerprintjs, webrtc-ip)"):::external

        subgraph "Build/Dev Tools"
            buildScripts("Scripts"):::support
            rollupConfig("rollup.config.js"):::support
            tsconfig("tsconfig.json"):::support
            vitestConfig("vitest.config.mts"):::support
            pkg("package.json"):::support
        end
    end

    %% Relationships from Client Integrations to SDK
    vanilla -->|"initializes"| core
    vue2Client -->|"calls"| vue2Adapter
    vue3Client -->|"calls"| vue3Adapter

    vue2Adapter -->|"wraps"| core
    vue3Adapter -->|"wraps"| core

    %% Data dispatch and build flows
    core -->|"sends_events"| externalDep
    buildScripts -->|"builds"| core
    buildScripts -->|"builds"| vue2Adapter
    buildScripts -->|"builds"| vue3Adapter

    docs -->|"guides_usage"| vanilla
    docs -->|"guides_usage"| vue2Client
    docs -->|"guides_usage"| vue3Client
    docs -->|"details_API"| core

    %% Click Events
    click core "https://github.com/m-cheng-web/web-tracing/tree/main/packages/core"
    click vue2Adapter "https://github.com/m-cheng-web/web-tracing/tree/main/packages/vue2"
    click vue3Adapter "https://github.com/m-cheng-web/web-tracing/tree/main/packages/vue3"
    click docs "https://github.com/m-cheng-web/web-tracing/tree/main/docs"
    click vanilla "https://github.com/m-cheng-web/web-tracing/tree/main/examples/vanilla"
    click vue2Client "https://github.com/m-cheng-web/web-tracing/tree/main/examples/vue2"
    click vue3Client "https://github.com/m-cheng-web/web-tracing/tree/main/examples/vue3"
    click buildScripts "https://github.com/m-cheng-web/web-tracing/tree/main/scripts"
    click rollupConfig "https://github.com/m-cheng-web/web-tracing/blob/main/rollup.config.js"
    click tsconfig "https://github.com/m-cheng-web/web-tracing/blob/main/tsconfig.json"
    click vitestConfig "https://github.com/m-cheng-web/web-tracing/blob/main/vitest.config.mts"
    click pkg "https://github.com/m-cheng-web/web-tracing/blob/main/package.json"

    %% Styles
    classDef core fill:#99ccff,stroke:#333,stroke-width:2px;
    classDef adapter fill:#66cc66,stroke:#333,stroke-width:2px;
    classDef support fill:#ffcc66,stroke:#333,stroke-width:2px;
    classDef external fill:#ff9966,stroke:#333,stroke-width:2px;
```
