traffic

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package traffic owns the M4 "traffic" plugin. It aggregates per- repository view counts from REST /repos/{owner}/{repo}/traffic/views for every repository in base.Computed.RepositoryList. The endpoint requires the `repo` OAuth scope; without it the plugin returns Skipped=true. Repositories that return 403 (owner-only endpoint) are dropped silently and aggregation continues.

Index

Constants

View Source
const Name = "traffic"

Name is the canonical plugin slug.

Variables

View Source
var Plugin plugins.Plugin = &trafficPlugin{}

Plugin is the singleton registered with the global plugin registry.

Functions

func Partial

Partial renders the classic SVG fragment for the traffic plugin. Upstream classic does not ship a standalone traffic.ejs (the data is merged into base.repositories); we emit a self-contained section with header + aggregate counts + per-repo breakdown so downstream consumers can see the data the plugin actually collects.

Output structure:

<section data-section="traffic">
  <h2 class="field"><svg/>Traffic</h2>
  <div class="row"><section>
    <div class="field"><span class="label">N views (M unique)</span></div>
    [for each repo with views]:
      <div class="field"><span class="repo">${name}</span>: ${views} views (${uniques} unique)</div>
  </section></div>
</section>

When `plugin_traffic_hide_empty` is true (default), repositories with Count == 0 are filtered before sorting/rendering so the per-repo breakdown only shows repos that actually received traffic.

Types

type Result

type Result struct {
	Skipped       bool                   `json:"skipped,omitempty"`
	SkippedReason string                 `json:"-"`
	Views         map[string]TrafficView `json:"views"`
	Total         TrafficView            `json:"total"`
	// HideEmpty controls whether per-repo entries with Count==0 are
	// filtered out at render time. It mirrors the
	// `plugin_traffic_hide_empty` input (default true).
	HideEmpty bool `json:"hide_empty"`
}

Result is the JSON payload published under data.Plugins["traffic"].

func (*Result) IsSkipped

func (r *Result) IsSkipped() bool

IsSkipped lets the classic dispatcher detect the skipped path.

func (*Result) TotalViews added in v1.2.0

func (r *Result) TotalViews() int

TotalViews exposes the aggregate view count without forcing base partials to import this package and create an init-time cycle.

type TrafficView

type TrafficView struct {
	Count   int `json:"count"`
	Uniques int `json:"uniques"`
}

TrafficView mirrors the upstream {count, uniques} pair.

Jump to

Keyboard shortcuts

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