tracking

package
v0.0.0-...-6a2234f Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package tracker provides a mechanism to track short link lookups/redirects.

Index

Constants

This section is empty.

Variables

View Source
var DefaultAWSTrustedHeaders = []string{
	"User-Agent",
	"X-Forwarded-For",
	"CloudFront-Viewer-Country",
	"CloudFront-Viewer-City",
	"CloudFront-Is-Desktop-Viewer",
	"CloudFront-Is-Mobile-Viewer",
	"CloudFront-Is-SmartTV-Viewer",
	"CloudFront-Is-Tablet-Viewer",
}
View Source
var DefaultCloudflareTrustedHeaders = []string{
	"User-Agent",
	"CF-Connecting-IP",
	"CF-IP-Country",
}

Functions

func WithSNSClient

func WithSNSClient(client SNSPublisher) func(*SNSTracker)

Types

type PayloadBuilder

type PayloadBuilder struct {
	// contains filtered or unexported fields
}

func NewPayloadBuilder

func NewPayloadBuilder(trustedHeaders []string) *PayloadBuilder

func (*PayloadBuilder) BuildShortLinkLookupPayload

func (pb *PayloadBuilder) BuildShortLinkLookupPayload(
	ctx context.Context,
	shortLinkID string,
	shortLink *models.ShortLink,
	r *http.Request,
	responseStatusCode int,
	responseLocation string,
) (*ShortLinkLookupPayload, error)

type SNSPublisher

type SNSPublisher interface {
	Publish(ctx context.Context, params *sns.PublishInput, optFns ...func(*sns.Options)) (*sns.PublishOutput, error)
}

type SNSTracker

type SNSTracker struct {
	// contains filtered or unexported fields
}

func NewSNSTracker

func NewSNSTracker(ctx context.Context, topicARN string, options ...func(*SNSTracker)) (*SNSTracker, error)

func (*SNSTracker) TrackShortLinkLookupRequest

func (t *SNSTracker) TrackShortLinkLookupRequest(ctx context.Context, payload *ShortLinkLookupPayload) error

type ShortLinkLookupPayload

type ShortLinkLookupPayload struct {
	ShortLinkID        string            `json:"shortLinkId"`
	ShortLinkFound     bool              `json:"shortLinkFound"`
	ShortLinkExpired   bool              `json:"shortLinkExpired"`
	TargetURL          string            `json:"targetUrl"` // not necessarily the same as the actual redirect URL (`ResponseLocation`)
	RequestHost        string            `json:"requestHost"`
	RequestHeaders     map[string]string `json:"requestHeaders"`
	RequestedAt        string            `json:"requestedAt"`
	ResponseStatusCode int               `json:"responseStatusCode"`
	ResponseLocation   string            `json:"responseLocation"`
}

type Tracker

type Tracker interface {
	TrackShortLinkLookupRequest(ctx context.Context, payload *ShortLinkLookupPayload) error
}

Jump to

Keyboard shortcuts

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