/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

syntax = "proto3";

package skywalking.v3;

option java_multiple_files = true;
option java_package = "org.apache.skywalking.apm.network.language.agent.v3";
option csharp_namespace = "SkyWalking.NetworkProtocol.V3";
option go_package = "skywalking.apache.org/repo/goapi/collect/language/agent/v3";

import "common/Command.proto";

// Collect performance raw data from browser.
service BrowserPerfService {

    // report once per page
    rpc collectPerfData (BrowserPerfData) returns (Commands) {
    }

    // report one or more error logs for pages, could report multiple times.
    rpc collectErrorLogs (stream BrowserErrorLog) returns (Commands) {
    }
}

message BrowserPerfData {
    string service = 1;
    // Service version in browser is the Instance concept in the backend.
    string serviceVersion = 2;
    // Perf data time, set by the backend side.
    int64 time = 3;
    // Page path in browser is the endpoint concept in the backend
    // Page path in the browser, mostly it is URI, without parameter
    string pagePath = 4;
    // Unit of all time related field should be `ms`.
    int32 redirectTime = 5;
    // DNS query time
    int32 dnsTime = 6;
    // Time to first Byte
    int32 ttfbTime = 7;
    //  TCP connection time
    int32 tcpTime = 8;
    // Content transfer time
    int32 transTime = 9;
    // Dom parsing time
    int32 domAnalysisTime = 10;
    // First paint time or blank screen time
    int32 fptTime = 11;
    // Dom ready time
    int32 domReadyTime = 12;
    // Page full load time
    int32 loadPageTime = 13;
    // Synchronous load resources in the page
    int32 resTime = 14;
    // Only valid for HTTPS
    int32 sslTime = 15;
    // Time to interact
    int32 ttlTime = 16;
    // First pack time
    int32 firstPackTime = 17;
    // First Meaningful Paint
    int32 fmpTime = 18;
}

message BrowserErrorLog {
    // UUID
    string uniqueId = 1;
    string service = 2;
    // Service version in browser is the Instance concept in the backend.
    string serviceVersion = 3;
    // Error log time, set by the backend side.
    int64 time = 4;
    // Page path in browser is the endpoint concept in the backend
    // Page path in the browser, mostly it is URI, without parameter
    string pagePath = 5;
    ErrorCategory category = 6;
    string grade = 7;
    string message = 8;
    int32 line = 9;
    int32 col = 10;
    string stack = 11;
    string errorUrl = 12;
    // Then the PV with error is only calculated when firstReportedError is true.
    bool firstReportedError = 13;
}

enum ErrorCategory {
    ajax = 0;
    resource = 1;
    vue = 2;
    promise = 3;
    js = 4;
    unknown = 5;
}

