GithubHelp home page GithubHelp logo

fastly / compute-starter-kit-rust-beacon-termination Goto Github PK

View Code? Open in Web Editor NEW
6.0 10.0 5.0 90 KB

Beacon Termination package template for Rust based Fastly Compute projects.

Home Page: https://developer.fastly.com/solutions/starters/

License: MIT License

Rust 100.00%
compute-starter fastly-oss-tier1

compute-starter-kit-rust-beacon-termination's Introduction

Beacon Termination Starter Kit for Rust

Capture beacon data from the browser, divert beacon request payloads to a log endpoint, and avoid putting load on your own infrastructure.

For more details about this and other starter kits for Fastly Compute, see the Fastly Developer Hub.

What are beacons?

Beacons are HTTP requests, usually POSTs, sent from a web browser to record some analytics data. Browsers offer native support for beacons via the navigator.sendBeacon method, and via the Reporting API for out-of-band reports on browser-generated warnings like CSP and feature policy violations, deprecations, browser interventions, and network errors. Native apps will also often send beacon data back to base.

For an in-depth guide to beacon termination using VCL, see the Beacon Termination tutorial.

Features

  • Exposes a POST /reports endpoint to receive beacon reports (in batches)
  • Deserializes individual reports from JSON to Rust data structures, with optional type-checking (see Payload examples)
  • Enriches the data with information available at the edge, e.g. by adding geo data
  • Sends reports to a logging endpoint as individual JSON lines N.B.: Depending on which logging endpoint type is chosen, these lines may be batched.
  • Responds with a synthetic 204

Payload examples

This starter kit allows an individual report to be any valid JSON value.

For optional type-checking, it also includes the data structures for some common report payloads. These structures can be imported from modules following the example_... naming convention:

  • CSP Violations
    mod example_csp_violation;
    use crate::example_csp_violation::ReportBody;
    
  • Network Errors
    mod example_network_error_log;
    use crate::example_network_error_log::ReportBody;
    
  • Core Web Vitals
    mod example_core_web_vital;
    use crate::example_core_web_vital::ReportBody;
    
    Tip: Use the web-vitals JavaScript library to measure all the Core Web Vitals.

Requirements

The following resources need to exist on your active Fastly service version for this starter kit to work:

Security issues

Please see SECURITY.md for guidance on reporting security-related issues.

compute-starter-kit-rust-beacon-termination's People

Contributors

doramatadora avatar gfx avatar harmony7 avatar integralist avatar jakechampion avatar journie-fastly avatar triblondon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.