vercel

package
v0.0.0-...-4ba1516 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

Testing locally

Use either Tunnelmole, an open source tunneling tool, or ngrok, a popular closed source tunnelling tool, to start your local server.

With Tunnelmole

Install Tunnelmole with one of the following options:

  • NPM: npm install -g tunnelmole
  • Linux: curl -s https://tunnelmole.com/sh/install-linux.sh | sudo bash
  • Mac: curl -s https://tunnelmole.com/sh/install-mac.sh --output install-mac.sh && sudo bash install-mac.sh
  • Windows: Install with NPM, or if you don't have NodeJS installed, download the exe file for Windows here and put it somewhere in your PATH.

Then, start Tunnelmole using:

tmole 8082

Grab the generated URL. For example:

https://bvdo5f-ip-49-183-170-144.tunnelmole.net is forwarding to localhost:8082

With ngrok

Start ngrok:

ngrok http https://localhost:8082

Grab the generated URL. For example:

https://c0fd-75-166-97-48.ngrok-free.app

Modifications

Modify the projectID check in vercel.HandleLog

-       projectVerboseID := r.Header.Get(LogDrainProjectHeader)
-       projectID, err := model2.FromVerboseID(projectVerboseID)
-       if err != nil {
-               log.WithContext(r.Context()).WithError(err).WithField("projectVerboseID", projectVerboseID).Error("failed to parse highlight project id from vercel request")
-               http.Error(w, err.Error(), http.StatusBadRequest)
-               return
-       }
+       // projectVerboseID := r.Header.Get(LogDrainProjectHeader)
+       // projectID, err := model2.FromVerboseID(projectVerboseID)
+       // if err != nil {
+       //      log.WithContext(r.Context()).WithError(err).WithField("projectVerboseID", projectVerboseID).Error("failed to parse highlight project id from
 vercel request")
+       //      http.Error(w, err.Error(), http.StatusBadRequest)
+       //      return
+       // }
+       projectID := 3

Setting up logs

Set up a log drain using the following config

Screenshot 2023-08-10 at 1 06 16 PM

Click "Test Log Drain"

Wait about a minute for the logs to go through the OTEL pipeline

Observe logs in app with the start date set to 2022 (Vercel hardcodes the timestamp to something really old using Test Log Drain)

Screenshot 2023-08-10 at 1 07 55 PM

Documentation

Index

Constants

View Source
const (
	SourcemapEnvKey = "HIGHLIGHT_SOURCEMAP_UPLOAD_API_KEY"
	ProjectIdEnvVar = "NEXT_PUBLIC_HIGHLIGHT_PROJECT_ID"
)

Variables

View Source
var (
	ApiBaseUrl = "https://api.vercel.com"
)

Functions

func CreateLogDrain

func CreateLogDrain(ctx context.Context, vercelTeamID *string, vercelProjectIDs []string, projectVerboseID string, name string, accessToken string) error

func GetProjects

func GetProjects(accessToken string, teamId *string) ([]*privateModel.VercelProject, error)

func HandleLog

func HandleLog(w http.ResponseWriter, r *http.Request)

func Listen

func Listen(r *chi.Mux, t trace.Tracer)

func RemoveConfiguration

func RemoveConfiguration(configId string, accessToken string, teamId *string) error

func RemoveLogDrain

func RemoveLogDrain(logDrainId string, accessToken string, teamId *string) error

func RemoveLogDrains

func RemoveLogDrains(ctx context.Context, vercelTeamID *string, accessToken string) error

func SetEnvVariable

func SetEnvVariable(projectId string, apiKey string, accessToken string, teamId *string, envId *string, key string) error

Types

type VercelAccessTokenResponse

type VercelAccessTokenResponse struct {
	AccessToken string  `json:"access_token"`
	TeamID      *string `json:"team_id"`
}

func GetAccessToken

func GetAccessToken(code string) (VercelAccessTokenResponse, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL