Skip to content

Commit

Permalink
Merge pull request #1 from dgirardi/initial
Browse files Browse the repository at this point in the history
user sync utilities
  • Loading branch information
bretg committed Jul 3, 2024
2 parents 58bed90 + 5cd0eff commit 68d03e1
Show file tree
Hide file tree
Showing 19 changed files with 30,115 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
]
]
}
53 changes: 53 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#

aliases:
- &environment
docker:
# specify the version you desire here
- image: cimg/node:16.20-browsers
resource_class: xlarge
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4
working_directory: ~/user-sync

- &restore_dep_cache
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- &save_dep_cache
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

- &build
name: Unit tests
command: npm run build

- &build_steps
- checkout
- restore_cache: *restore_dep_cache
- run: npm ci
- save_cache: *save_dep_cache
- run: *build

version: 2
jobs:
build:
<<: *environment
steps: *build_steps

workflows:
version: 2
commit:
jobs:
- build

experimental:
pipelines: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/dist
/node_modules
/build

28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Prebid User Sync utilities

`npm run build` generates two HTML files, `dist/load_cookie.html` and `dist/load-cookie-with-consent.html`, which can be used to initiate the bidder cookie sync with Prebid Server as documented [here](https://docs.prebid.org/prebid-server/developers/pbs-cookie-sync.html#manually-initiating-a-sync).

The two versions are identical except in how they interface with AMP to retrieve consent data:

- `load-cookie.html` will attempt to poll AMP for consent data only when `source` is set to `"amp"`, and does not require consent data to run syncs (`defaultGdprScope` defaults to `0`);
- `load-cookie-with-consent` will always attempt to poll AMP, and does not run syncs unless it can retrieve consent data (`defaultGdprScope` defaults to `1`).

Note: these files were formerly housed within the [Prebid Universal Creative repository](https://github.com/prebid/prebid-universal-creative). Now publishers and managed services will want to periodically= source these files from this repo to update their CDN.

## Query string parameters

Both pages accept the following query string parameters:

| Parameter | Scope | Type | Description | Example |
|------------------|--------------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| endpoint | recommended | string | A URL-encoded pointer to Prebid Server | https%3A%2F%2Fprebid-server.example.com%2Fcookie_sync |
| max_sync_count | optional | integer | How many syncs are allowed | 5 |
| bidders | optional(*) | string | Which bidders are in the page. Required if coop-sync is not on for Prebid Server. This is a URL-encoded comma-separate list of bidder codes. | bidderA%2CbidderB |
| source | optional(*) | string | Recommended for AMP. If set to 'amp' will force the response to be pixels only; `load-cookie.html` will also attempt to retrieve consent data from AMP. | amp |
| gdpr | optional | integer | 1 if the request is in GDPR-scope, 0 if not. | 0 |
| gdpr_consent | optional | string | TCF consent string | |
| defaultGdprScope | optional | integer | If set to 1, do not run syncs when consent data cannot be retrieved from AMP. | 0 |
| gpp_sid | optional | string | GPP Section ID(s). Number in string form or comma-separated list of numbers | 6,7 |
| gpp | optional | string | Global Privacy Platform string | |
| timeout | optional | integer | Timeout (in milliseconds) to wait for consent data from AMP. Defaults to 10000. | 500 |
| args | optional | string | Passed through to the /cookie_sync call query string. Used by some host companies. | |
68 changes: 68 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: './',

plugins: [
'karma-mocha',
'karma-chrome-launcher',
'karma-chai',
'karma-sourcemap-loader',
'karma-sinon',
'karma-mocha-reporter',
'karma-webpack'
],
webpack: require('./webpack.config.js'),
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai', 'sinon'],

// list of files / patterns to load in the browser
files: ['test/test_index.js'],

// list of files / patterns to exclude
exclude: [
],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/test_index.js': [ 'webpack', 'sourcemap' ]
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['mocha'],
mochaReporter: {
showDiff: true,
output: 'minimal'
},

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeHeadless'],

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
browserDisconnectTimeout: 100000,
browserDisconnectTolerance: 1, // default 0
browserNoActivityTimeout: 4 * 60 * 1000, // default 10000
captureTimeout: 4 * 60 * 1000, // default 60000
})
}
7 changes: 7 additions & 0 deletions load-cookie.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
doctype html
html
head
meta(charset="utf-8")
title Prebid User Sync
body
script !{source}
Loading

0 comments on commit 68d03e1

Please sign in to comment.