• Stars
    star
    693
  • Rank 65,262 (Top 2 %)
  • Language SCSS
  • License
    Other
  • Created almost 10 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The US federal government's web traffic.

Code Climate CircleCI Dependency Status

analytics.usa.gov

A project to publish website analytics for the US federal government.

For a detailed description of how the site works, read 18F's blog post on analytics.usa.gov.

Other organizations who have reused this project for their analytics dashboard:

The City of Anchorage, AK The City of Boulder, CO
The City of Los Angeles, CA The City of Santa Monica, CA
The City of Omaha, NE The City of San Francisco, CA
The City of Sacramento, CA Carbarrus County, NC
Cook County, IL data.jerseycitynj.gov
City of Seattle Douglas County, NE
Washington State University State of Indiana
The States of Jersey The City of Pittsburgh
U.S. Department of Education U.S. Department of Veterans Affairs
USA.gov - General Services Administration Government of Canada
State of Georgia State of Kansas
State of Delaware

This blog post details their implementations and lessons learned.

About the components

Ths app uses Jekyll to build the site, and Sass, Bourbon, and Neat for CSS.

The javascript provided is a webpacked aggregation of several different modules, leveraging d3 for the visualizations. Learn more on the webpack configuration

Developing locally

There are a couple of different ways to develop locally. Either using docker or running without docker.

Setup using Docker

You need Docker and docker-compose.

To build and run the app with docker-compose, run docker-compose up -d then you can access the app from http://localhost:4000, as the local filesystem is mounted on top of the docker container you can edit the files as you are developing locally.

  • this does not yet run the webpack script.

To see the jekyll logs, run:

docker-compose logs -f

Running locally without docker.

Run Jekyll with development settings:

make dev
npm install
npm run build-dev

(This runs bundle exec jekyll serve --watch --config=_config.yml,_development.yml.)

Adding Additional Agencies

  1. Ensure that data is being collected for a specific agency's Google Analytics ID. Visit 18F's analytics-reporter for more information. Save the url path for the data collection path.
  2. Create a new html file in the _agencies directory. The name of the file will be the url path.
    touch _agencies/agencyx.html
  3. Create a new html file in the _data_pages directory. Use the same name you used in step 2. This will be the data download page for this agency
    touch _data_pages/agencyx.html
  4. Set the required data for for the new files. (Both files need this data.) example:
    ---
    name: Agency X # Name of the page
    slug: agencyx # Same as the name of the html files. Used to generate data page links.
    layout: default # type of layout used. available layouts are in `_layouts`
    ---
  5. Agency page: Below the data you just entered, include the page content you want. The _agencies page will use the charts.html partial and the _data_pages pages will use the data_download.html partial. example:
    {% include charts.html %}

Developing with local data

The development settings assume data is available at /fakedata. You can change this in _development.yml.

Developing with real live data from analytics-reporter

If also working off of local data, e.g. using analytics-reporter, you will need to make the data available over HTTP and through CORS.

Various tools can do this. This project recommends using the Node module serve:

npm install -g serve

Generate data to a directory:

analytics --output [dir]

Then run serve from the output directory:

serve --cors

The data will be available at http://localhost:3000 over CORS, with no path prefix. For example, device data will be at http://localhost:3000/devices.json.

Javascript Modules

  • Index - includes the main dom selection and rendering queue of components, and the entry point for the webpack bundler.
  • lib/barchart the d3 configuration of the bar charts
  • lib/blocks an object of the specific components
  • lib/consoleprint the console messages displayed to users
  • lib/exceptions agency data to be changed by discrete exception rules
  • lib/formatters methods to help format the display of visualization scales and values
  • lib/renderblock d3 manipulator to load and render data for a component block
  • lib/timeseries the d3 configuration of the timeseries charts
  • lib/transformers helper methods to manipulate and consolidate raw data into proportional data.

Deploying the app

To deploy to analytics.usa.gov after building the site with the details in _config.yml:

make deploy_production

To deploy to analytics-staging.app.cloud.gov after building the site with the details in _config.yml and _staging.yml:

make deploy_staging

Deploying the app using Docker

NOTE: 18F does not use Docker in production!

If you are using Docker in production and you want to deploy just the static pages, you can build an nginx container with the static files built in, running the following command:

make docker-build-production PROD_IMAGE=yourvendor/your-image-name PROD_TAG=production

The resulting image will be an nginx server image that you can safely push and deploy to your server.

The image accepts an environment variable to specify the S3 URL that data at /data/* is served from:

docker run -p 8080:80 -e S3_BUCKET_URL=https://s3-us-gov-west-1.amazonaws.com/your-s3-bucket/data yourvendor/your-image-name:production

Building & Pushing Docker Images

This repo has git tags. The tag for Docker images built for this repo relate to these git tags. In the examples below, <version refers to the tag value of the current commit. When building a new version, be sure to increment the git tag appropriately.

When building images there are 2 images to build: <version> and <version>-production.

To build the images:

docker build -f ./Dockerfile -t 18fgsa/analytics.usa.gov:<version> .
docker build -f ./Dockerfile.production -t 18fgsa/analytics.usa.gov:<version>-production .

To push the images:

docker push 18fgsa/analytics.usa.gov:<version>
docker push 18fgsa/analytics.usa.gov:<version>-production

Environments

Environment Branch URL
Production master https://analytics.usa.gov
Staging master https://analytics-staging.app.cloud.gov

Webpack Configuration

The application compiles es6 modules into web friendly js via Wepback and the babel loader.

The webpack configuration is set in the wepback.config.js.

The current configuration uses babel present-env.

The webpack also includes linting using eslint leveraging the AirBnb linting preset.

The webconfig uses the UglifyJSPlugin to minimize the bundle.

The resulting uglified bundle is build into assest/bundle.js.

NPM webpack commands

Command purpose
npm run build-dev a watch command rebuilding the webpack with a development configuration (i.e. no minifiecation)
npm run build-prod a webpack command to build a minified and transpiled bundle.js

Public domain

This project is in the worldwide public domain. As stated in CONTRIBUTING:

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.

More Repositories

1

development-guide

A set of guidelines and best practices for an awesome software engineering team
HTML
1,159
star
2

analytics-reporter

Lightweight analytics reporting and publishing tool for Google Analytics data.
JavaScript
616
star
3

technology-budgeting

See https://derisking-guide.18f.gov/
492
star
4

api-standards

API Standards for 18F
488
star
5

identity-idp

Login.gov Core App: Identity Provider (IdP)
Ruby
476
star
6

domain-scan

A lightweight pipeline, locally or in Lambda, for scanning things like HTTPS, third party service use, and web accessibility.
Python
369
star
7

checklistomania

Centrally managed todo lists for complex processes - onboarding, offboarding, management changes, etc.
JavaScript
364
star
8

accessibility

A repo to organize the guidelines and best practices for accessibility at 18f.
HTML
328
star
9

rdbms-subsetter

Generates a subset of a relational database that respects foreign key constraints
Python
317
star
10

laptop

DEPRECATED: A shell script which turns your Mac into an awesome web development machine.
Shell
317
star
11

open-source-guide

18F’s Style guide for open source project documentation
Ruby
290
star
12

18f.gsa.gov

This repository contains 18F's website.
HTML
289
star
13

methods

The methods 18F uses to practice human-centered design.
SCSS
221
star
14

jekyll-get

DEPRECATED - see https://github.com/brockfanning/jekyll-get-json instead
Ruby
212
star
15

open-data-maker

make it easy to turn a lot of potentially large csv files into easily accessible open data
Ruby
201
star
16

ads-bpa

A guide for the Agile Delivery Services BPA
Ruby
193
star
17

dolores-landingham-slack-bot

A Slack bot to welcome new 18F hires with the authority and compassion of Mrs. Landingham
Ruby
189
star
18

API-All-the-X

Resources and Materials for the /Developer Program
CSS
167
star
19

https

(Deprecated) https guidance for the 18F team
158
star
20

uswds-jekyll

A Jekyll theme showcasing the U.S. Web Design System
JavaScript
132
star
21

docker-compose-django-react

A strawman set up for using both Django and React in a new app
JavaScript
128
star
22

frontend

18F's Front End Guild –  content has been moved to https://github.com/18F/development-guide
Ruby
122
star
23

tock

We use Tock to track and report our time at 18F
Python
120
star
24

handbook

The home of policies and guidelines that make up TTS.
HTML
115
star
25

C2

an approval process automation tool
Ruby
104
star
26

fbopen

[DEPRECATED] An open API server, data import tools, and sample apps to help small businesses search for opportunities to work with the U.S. government.
JavaScript
101
star
27

pulse

How the federal .gov domain space is doing at best practices and policies.
CSS
94
star
28

standup-slack-bot

A Slack bot to streamline team standup without disturbing the overall flow of conversation
JavaScript
87
star
29

api.data.gov

A hosted, shared-service that provides an API key, analytics, and proxy solution for government web services.
HTML
84
star
30

content-guide

18F Content Guide
HTML
79
star
31

ux-guide

Resources, norms, and practices for doing user experience research and design work at 18F.
HTML
76
star
32

crime-data-explorer

Moved to https://github.com/fbi-cde
69
star
33

micropurchase

18F's micro-purchase threshold experiment management app.
Ruby
68
star
34

pages

DEPRECATED: Publishing platform for 18F sites a la GitHub pages
Ruby
63
star
35

transformation-research

Best practices in government digital transformation
60
star
36

doc_processing_toolkit

Python library to extract text from PDF, and default to OCR when text extraction fails.
Python
55
star
37

automated-testing-playbook

A set of principles, practices, idioms, and strategies pertaining to automated software testing and its adoption
Ruby
52
star
38

eligibility-rules-service

Researching an eligibility rules service - project documentation and task management
51
star
39

2015-foia

Please check out https://github.com/18F/foia-hub/issues to track our work. This repo is for project wide discussion, blogging, and scratch space for 18F's FOIA modernization team.
Python
50
star
40

us-federal-holidays

A Node.js package for getting US federal holidays for a given year, or determining if a date is a federal holiday.
JavaScript
49
star
41

guides-template

Jekyll template for 18F Guides, based on CFPB/DOCter
Ruby
49
star
42

2015-foia-hub

A consolidated FOIA request hub.
CSS
47
star
43

glossary

A glossary panel for your site to help readers understand jargon
JavaScript
46
star
44

agile

Agile Principles and Practice, documented by the 18F Agile Guild
HTML
46
star
45

lean-product-design

A guide to using Lean Product Design on your project
Ruby
46
star
46

hub

DEPRECATED: Documentation hub for the 18F team
JavaScript
46
star
47

web-design-standards-drupal

A Drupal base theme that uses the U.S. Web Design System. (ARCHIVED)
CSS
46
star
48

dashboard

DEPRECATED: A site to track our projects' status and much, much more...
JavaScript
44
star
49

autoapi

A basic spreadsheet to api engine
Python
43
star
50

eng-hiring

18F Engineering's guide to candidate selection, from resume screen to offer.
HTML
43
star
51

jekyll_pages_api

a Jekyll Plugin that generates a JSON file with data for all the Pages in your Site
Ruby
43
star
52

myusa

MyUSA was a single sign-on project for government, now deprecated. (More info: https://18f.gsa.gov/2015/05/18/myusa/)
Ruby
43
star
53

dns

DNS configuration for domains managed by GSA TTS
HCL
42
star
54

pdf-forms-tutorial

A step-by-step guide for programatically filling out PDF forms
Java
41
star
55

jekyll_pages_api_search

DEPRECATED - Jekyll search plugin based on lunr.js and jekyll_pages_api
Ruby
40
star
56

before-you-ship

merged into the TTS Handbook
Ruby
38
star
57

piipan

A privacy-preserving system for storing and matching de-identified Personal Identifiable Information (PII) records.
C#
37
star
58

stylelint-rules

A style (CSS, Sass) linter for the 18F style guide
JavaScript
36
star
59

joining-18f

A guide for anyone interested in joining the 18F team
CSS
36
star
60

charlie

18F's Slack bot, Charlie. Built on Bolt
JavaScript
35
star
61

identity-site

This is the Login.gov main website where the public is able to learn about their one account for government.
HTML
34
star
62

ReVAL

ReVAL: Reusable Validation Library - A Django App for validating data via API and web interface
Python
32
star
63

product-guide

A handbook for the 18F product team and to promote our product management best practices.
HTML
32
star
64

compliance-toolkit

Compliance at the speed of Delivery.
31
star
65

continua11y

continuous integration for website accessibility
JavaScript
31
star
66

fedramp-data

A repository for the data underlying the FedRamp Dashboard
JavaScript
31
star
67

emoji_search

A super simple commandline utility to search for slack messages that have been reacted to with a specific emoji
Python
31
star
68

slides

Slides for 18F - built automatically using Federalist
HTML
30
star
69

about_yml

.about.yml project metadata schema and tools
Ruby
30
star
70

identity-dev-docs

Login.gov developer documentation
HTML
29
star
71

raktabija

Bootstrap AWS account with Terraform and Go.CD
Python
29
star
72

confidential-survey

A Rails app for conducting confidential surveys without violating user privacy
Ruby
29
star
73

javascript-lessons

Beginning and Advanced lessons in javascript with a focus on functional programming. This repo contains both exercises and solutions. It is used by 18F to train its internal staff, but of course anyone is welcome to use it and possibly contribute.
JavaScript
29
star
74

jekyll_frontmatter_tests

A Jekyll plugin to test frontmatter on posts and other documents in a Jekyll site.
Ruby
28
star
75

data-federation-project

A project focused on tools and best practices to supported federated data collection efforts
28
star
76

tech-talks

Suggestions, schedules, and other information about the Engineering Chapter's Tech Talk meetings.
Jupyter Notebook
28
star
77

ifgovthenthat

If Gov Then That website, a project to promote gov open data by designing clever uses for government APIs. (Currently on hold.)
CSS
27
star
78

foia-recommendations

National FOIA Project: Research and Recommendations
HTML
27
star
79

brand

18F Brand
SCSS
26
star
80

onboarding-documents

Forms, emails, and checklists to help with onboarding
26
star
81

18f-scaffolding

A scaffold/generator to standardize 18F project setup
Shell
26
star
82

bpa-fedramp-dashboard

FedRAMP Dashboard BPA Order
25
star
83

culper

Culper is the foundation for eApp, a part of the National Background Investigation System (NBIS), supporting the SF-86, SF-85, and SF-85P. This is its source code and developer documentation. For background information and a demo video see https://github.com/18F/culper/wiki
JavaScript
25
star
84

vulnerability-disclosure-policy

The vulnerability disclosure policy for 18F and GSA's Technology Transformation Service.
25
star
85

code-of-conduct

18F's code of conduct.
24
star
86

scrapebox

A simple, system independent infrastructure for performing web scraping. Utilizes Vagrant virtualbox interface and puppet provisioning to create and execute scraping of web content to structured data quickly and easily without modifying your core system.
Python
24
star
87

identity-oidc-sinatra

Example OpenID Connect relying party as a Sinatra app
Ruby
23
star
88

identity-design-system

An extension of the U.S. Web Design System used on Login.gov sites to consistently identify the Login.gov brand.
SCSS
22
star
89

elasticsearch-rails-ha-gem

high availability extensions to the Elasticsearch::Rails standard tasks
Ruby
21
star
90

html-proofer-docker

HTML validation, made easy
Shell
21
star
91

fedramp-dashboard

JavaScript
21
star
92

tts-tech-portfolio

Home of the TTS Technology Portfolio team
JavaScript
21
star
93

linkify-citations

Turns legal citations in the DOM into links
HTML
20
star
94

ghad

GitHub administration command line tool
JavaScript
20
star
95

archived-guides

A collection of 18F guides.
HTML
20
star
96

Modular-Contracting-And-Agile-Development

Modular contracting and agile development resources.
CSS
20
star
97

data-act-pilot

This small DATA Act pilot contains code that translates agency data to a uniform DATA act format.
Python
20
star
98

shipper

Continuous deployment made easy and secure
Go
19
star
99

project-artifacts

Resources for running path analysis projects at 18F
19
star
100

urlsize

get the size of one or more URLs
JavaScript
19
star