• This repository has been archived on 14/Aug/2020
  • Stars
    star
    377
  • Rank 113,535 (Top 3 %)
  • Language
    Ruby
  • License
    GNU Affero Genera...
  • Created about 6 years ago
  • Updated over 4 years ago

Reviews

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

Repository Details

CodeFund is an open source platform that helps fund maintainers, bloggers, and builders through non-tracking ethical ads

Maintainability All Contributors StackShare Join the conversation FOSSA Status codecov TODOs

CircleCI ERB Lint StandardRB Prettier-Standard


Logo

CodeFund Ads

CodeFund Ads is an ethical and discreet ad platform that funds open-source. It helps your favorite projects thrive by paying maintainers the majority of all generated revenue.

Table of Contents

Publisher JavaScript Embedding

After being approved on the CodeFund platform, publishers can add CodeFund ads to their site by including the CodeFund script and adding the CodeFund div.

<div id="codefund"></div>
<script src="https://codefund.app/properties/PROPERTY_ID/funder.js" async></script>

Optional Query String Parameters

  • template - the template to use overrides the property config
  • theme - the theme to use overrides the property config
  • keywords - the keywords to use for targeting (comma delimited string) overrides the property config

Setting async on the script tag will ensure that CodeFund doens't block anything on the publisher's site.

Embed Callbacks

You may want to perform a function if the embed function does not return an ad.

To do this, you must create an event listener for the window event codefund.

Example

window.addEventListener("codefund", function(evt) {
  if (evt.detail.status !== 'ok') {
    console.log(evt.detail.status);
    // Do something
  }
});

Responses

On a successful embed, evt.detail will return:

{ "status": "ok", "house": false }

// or

{ "status": "ok", "house": true } // Ad returned is a house (fallback) ad

If an error occurs with embedding the ad, evt.detail will return:

{ "status": "error", "message": "error message" }

In the event that we do not have an available advertiser, and thus no available (paid or fallback) ad, evt.detail will return:

{ "status": "no-advertiser" }

API

The API is documented with Blueprint and is hosted on Apiary.

NOTE: Apairy doesn't fully adhere to the Blueprint 1A9 specification. Our Blueprint file may deviate from the spec to satisfy Apiary limitations.

The online version is generated from this file.

Ad Rendering and Impression/Click Tracking

The URLs/routes responsible for ad rendering are:

  • GET /properties/1/funder.js β†’ advertisements#show - embed script

    This is the embed JavaScript that publishers place on their site. It includes the ad HTML and some logic to inject the HTML to the page and setup the links and impression pixel.

  • GET /scripts/76bfe997-898a-418c-8f0b-6298b7dd320a/embed.js β†’ advertisements#show - embed script

    This endpoint is to support our legacy system (CodeFund v1) embed URLs. It points to the same endpoint as /properties/1/funder.js.

  • GET /display/76bfe997-898a-418c-8f0b-6298b7dd320a.gif β†’ impressions#show - creates an impression

    This is the impression pixel image. The impression is created after this image is requested and served successfully. This means that a matching campaign was found and the embed JavaScript did its job correctly.

  • GET /impressions/76bfe997-898a-418c-8f0b-6298b7dd320a/click?campaign_id=1 β†’ advertisement_clicks#show - creates a click

    This is the proxy/redirect URL that allows us to track the click. We immediately redirect to the advertiser's campaign URL and background the work to mark the associated impression as clicked.

Development

If you'd like to use Docker to run the app, view that documentation here.

The following is for setting the app up on your local machine:

Prerequisites

You must create a (superuser) role with the name of your OS user in your postgres configuration in order to run db operations (e.g. testing and development).

Setup

# clone the repo & cd into the project
git clone https://github.com/gitcoinco/code_fund_ads.git
cd /path/to/code_fund_ads

# setup environment variables
cp .env-example .env

# If you need a password for your postgres role, uncomment "#export PGPASSWORD='<password>' in the .env file and replace <password> with the role's password

# install dependencies
bundle install
yarn install

# db setup + tests
rails db:create db:migrate
rails test

# enable development caching
rails dev:cache

# start app and navigate to http://localhost:3000
rails s

Development Caching

This application relies heavily on caching and will not work properly without the development cache enabled.

bundle exec rails dev:cache # => Development mode is now being cached.

Database

The impressions table will seed with approximately 100k records spread over 12 months by default. You can increase this by setting the IMPRESSIONS environment variable and seeding again.

IMPRESSIONS=10_000_000 rails db:seed

Maxmind

This product includes GeoLite data created by MaxMind, available from: http://www.maxmind.com

The GeoLite2-City.tar.gz is checked into this repo at db/maxmind/GeoLite2-City.tar.gz

A fresh copy of the GeoLite2-City.tar.gz file can be obtained by running one of the following commands.

rails maxmind:download
DownloadAndExtractMaxmindFileJob.new.download

Workspace Setup

We provide a few example files for some popular tools to help you get up an running.

Tmux

SEE: sample config file

cd /path/to/code_fund_ads
./bin/tmuxinator

Teamocil

SEE: sample config file

cd /path/to/code_fund_ads
./bin/teamocil

Mert

SEE: sample config file

cd /path/to/code_fund_ads
./bin/mert

Code Standards

Enums

All enum values are managed as constants defined in config/enums.yml This file is converted to Ruby constants at runtime.

Introspect what enums are defined via the cli.

ENUMS.constants
ENUMS::USER_ROLES.constants
# etc...

Always use enums instead of "magic" values.

Linting

We avoid bike shedding by enforcing coding standards through tooling.

Ensure the code has been standardized by running the following before you commit.

./bin/standardize

Deployment

All pushes of master to Github result in a deployment to the staging environment. We use Herou build pipelines to promote the deployment to environments like production.

./bin/heroku_promote

Preboot

The application is configured for zero downtime deployments using Heroku's preboot feature.

This means that 2 versions of the application will be running simultaneously during deploys. All code changes should consider this deployment requirement to ensure that both versions of the app are valid and can run in parallel.

If breaking changes are unavoidable, disable preboot prior to deployment.

./bin/heroku_preboot_disable
./bin/heroku_promote
./bin/heroku_preboot_enable

Scheduler

There are several tasks that should be scheduled to run at different intervals. We manage this with Heroku Scheduler.

  • rails schedule:counter_updates - hourly
  • rails schedule:update_campaign_statuses - daily

Database

  • The impressions table is dynamically partitioned by advertiser (i.e. user) and date
  • The database user requires permissions to execute DDL and create schema to support dynamic partition tables

Instrumentation

CodeFund uses a self-hosted version of count.ly to gather and analyze data. This data does not include any personal identifiable information.

The pattern in which to instrument CodeFund with is as follows:

CodeFundAds::Events.track(:action, :device_id, :segmentation)

Each variable can be the following value:

  • action - the label for the action being tracked (e.g. find_virtual_impression)
  • device_id - the session or unique ID of the visit
  • segmentation - hash of key value pairs that can be used to segment the data

The segmentation typically includes:

  • status - the status of the action (e.g. success or fail)
  • ip_address - the IP address of the visitor
  • property_id - the Property ID
  • campaign_id - the Campaign ID
  • creative_id - the Creative ID
  • country_code - the country code

Example:

# Application & Environment are added by default
CodeFundAds::Events.track("Find Virtual Impression", session.id, { status: "fail", ip_address: "127.0.0.1" })
CodeFundAds::Events.track("Find Fallback Campaign", session.id, {
  status: "success",
  ip_address: "127.0.0.1",
  property_id: 1,
  country_code: "US"
})

Candidates for GEM extraction

  • Searchable ActiveStorage metadata
  • Eventable

Contributors

Thanks goes to these wonderful people (emoji key):


Nathan Hopkins

πŸ’» πŸ“– πŸ€” πŸš‡ πŸ“¦ πŸ”Œ πŸ“† πŸ‘€ ⚠️ πŸ”§

Eric Berry

πŸ’» 🎨 πŸ“– πŸ€” πŸš‡ πŸ“¦ πŸ“† πŸ‘€ ⚠️

Ron Cooke

πŸ’» πŸ“–

Mike

πŸ“–

Arun Kumar

πŸ’» πŸ“–

Maxim Dzhuliy

πŸ“–

Andrew Mason

πŸ’» 🎨 πŸ“– πŸš‡ πŸ‘€ ⚠️ πŸ”§

Matt Glaman

πŸ’» ⚠️

Aditya Anand M C

πŸ“–

dcd018

πŸ’»

Puru Dahal

πŸ’»

Curtis Mckee

⚠️ πŸ’» 🎨

jeremiG

πŸ“–

Kashif Rafique

πŸ’»

Ethan

πŸ“–

XhmikosR

πŸ’»

Jason Barnabe

πŸ’»

Руслан ΠšΠΎΡ€Π½Π΅Π²

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

License

AGPL-3.0

FOSSA Status

More Repositories

1

web

Grow Open Source
JavaScript
1,783
star
2

passport

Passport allows users to prove their identity through a secure, decentralized UI
TypeScript
937
star
3

gitcoinco

Grow Open Source
878
star
4

grants-stack

Round Manager & Grant Explorer & Project Builder of the Grants Protocol
TypeScript
315
star
5

kudosbadges

Kudos badges and creative assets for Gitcoin
Python
223
star
6

creative

a repository of creative assets for the gitcoin.co project
HTML
182
star
7

passport-scorer

Passport Scorer as a Service
Jupyter Notebook
167
star
8

codefund

Deprecated. Please go to https://github.com/gitcoinco/code_fund_ads
CSS
161
star
9

smart_contracts

Push Open Source Forward.
JavaScript
127
star
10

governance

✨ Gitcoin Community Governance Contracts
Solidity
112
star
11

awesome-gitcoin-passports

Curated list of all the awesome resources, case studies, samples, and Stamp implementations related to Gitcoin's Passport
102
star
12

passport-sdk

The Gitcoin Passport SDK is comprised of a set of libraries distributed on npm to help developers interact with Passport data living on [Ceramic](https://ceramic.network/).
TypeScript
74
star
13

quadratic-funding

This is an open source implementation of quadratic funding, a design for philanthropic and publicly-funded seeding, which allows for optimal provisioning of funds to an ecosystem of public goods.
Python
73
star
14

skunkworks

experimental laboratory
JavaScript
63
star
15

gitbook-KB

Gitcoin Gitbook Knowledgebase (support.gitcoin.co)
61
star
16

easy-retro-pgf

Retroactive Public Goods Funding for everyone.
TypeScript
54
star
17

gitcoin_cadcad_model

Jupyter Notebook
52
star
18

passport-docs

MDX
48
star
19

browser-extension

Grow Open Source
JavaScript
48
star
20

.github

46
star
21

BulkTransactions

Smart contracts for Gitcoin grants bulk checkout functionality
JavaScript
39
star
22

community

index of all the community stuff associated with gitcoin
32
star
23

Kudos721Contract

JavaScript
30
star
24

governance-docs

🌱 Welcome to the Gitcoin Community Governance documentation.
24
star
25

ios

Push Open Source Forward
Swift
23
star
26

python-api-client

Python API Client
Python
20
star
27

grant-hub

TypeScript
20
star
28

quadratictrust

QF where you fund with your clout - not your $$$
JavaScript
20
star
29

pop_api

Python
19
star
30

grants-stack-indexer

Allo Protocol Indexer for Grants Stack
TypeScript
18
star
31

eas-proxy

This EAS proxy will be the attester who will write the stamps into EAS attestations
TypeScript
17
star
32

beyondblockchainteams

Use this issue board to discuss hackathon ideas and find teams!
17
star
33

matching_contracts

TypeScript
16
star
34

PersonhoodPassport

Solidity
14
star
35

Alpha-Governor-Upgrade

Solidity
14
star
36

Splitter

A simple contract to split ERC20 payments
JavaScript
13
star
37

pluralistic.js

TypeScript
13
star
38

grants-stack-api

Rust
13
star
39

passport-components

A React-based component library for developers using Gitcoin Passport. The library will contain a set of prebuilt components that can handle various standard tasks related to Gitcoin Passport.
TypeScript
11
star
40

gitcoin-erc721

JavaScript
11
star
41

coldoutreach

coldoutreach recruitment app
Python
11
star
42

desktop-app

JavaScript
10
star
43

ethdenver

https://medium.com/gitcoin/ethdenver-request-for-project-proposals-9ed979dafbbe
10
star
44

bailoutmainst

JavaScript
10
star
45

allo-multi-round-checkout

Solidity
10
star
46

gtc

Solidity
10
star
47

statuses-bitmap

TypeScript
9
star
48

gh-workflows

Reusable Github Workflows and Actions
9
star
49

grants-infographic

TypeScript
9
star
50

codefund_fm

https://codefund.fm
Ruby
9
star
51

id-staking

CSS
9
star
52

allo-indexer-client

A client for the Allo Protocol Indexer data
TypeScript
9
star
53

signatures

Email signature builder
JavaScript
9
star
54

engineering

Engineering @ Gitcoin
Astro
8
star
55

proofofpersonhood_com

CSS
7
star
56

ethindia

Gitcoin bounty information and issues related to ethindia!
6
star
57

allo_grant_stack_analytics

Directory of python and SQL script used for all Allo/Grant stack analytics
6
star
58

allo-crosschain-poc

Solidity
6
star
59

pgn-docs

Documentation site for Public Goods Network
TypeScript
6
star
60

codefund-ghost-theme

CodeFund Ghost Theme
CSS
5
star
61

passport-reader

TypeScript
5
star
62

avatar-builder

JavaScript
5
star
63

android

android version of the mobile app
4
star
64

downtownstimulus

4
star
65

pnpm-docker

docker image with node16 + pnpm + libudev + libusb
Dockerfile
4
star
66

honeypot_money

JavaScript
4
star
67

sxsw

sxsw hackathon 2018
3
star
68

codefund_wordpress_plugin

Official WordPress plugin for CodeFund
PHP
3
star
69

data-ops

WIP readme for data-ops
Jupyter Notebook
3
star
70

metagraph

Metagraph watches Ethereum smart contracts events emitting metadata pointers to IPFS files and pins them on an IPFS node.
Go
3
star
71

gitcoin-checker

Leveraging the Gitcoin Indexer, this tool simplifies the process for round managers to select projects for inclusion. By defining specific evaluation criteria, managers can utilize ChatGPT for automated project assessments and scoring.
Vue
3
star
72

op-rf4-voting-ui

TypeScript
3
star
73

simplegrants.xyz

Web2 Quadratic Funding platform
TypeScript
3
star
74

qf-calculator

Python
3
star
75

hacksummit

hacksummit submissions
JavaScript
2
star
76

passport-scoring

2
star
77

cerebro

2
star
78

hacktoberfest-2020

2
star
79

discourse-codefund

Official CodeFund Advertising Plugin for Discourse. Install & Start Serving Ethical Ads on Your Discourse Forum
JavaScript
2
star
80

road-to-devcon-teams

Road to Devcon Team formation repo
2
star
81

id-staking-v2

TypeScript
2
star
82

content

2
star
83

command_line_standardbounties_funder

command_line_standardbounties_funder
Python
2
star
84

MACI_QF

TypeScript
2
star
85

grants-stack-search

Python
2
star
86

ethical_advertising

ethicaladvertising.org
CSS
1
star
87

pgn-documentation

PGN Documentation
TypeScript
1
star
88

codefund-web

CodeFund frontend application
Vue
1
star
89

scorer

Scoring service for gitcoin passport
Python
1
star
90

static-data

1
star
91

code_fund_web

WIP
JavaScript
1
star
92

ethereal-blocks-teams

1
star
93

passport-redash

Shell
1
star
94

alpha_round_data_retriever

Python
1
star
95

grants-stack-widget-react

TypeScript
1
star