Skip to content

Commit 260bfe4

Browse files
authored
Merge pull request #226 from apasel422/impl
WIP: JS-based reference implementation
2 parents e4d63eb + 7d0df96 commit 260bfe4

File tree

13 files changed

+4285
-0
lines changed

13 files changed

+4285
-0
lines changed

.github/workflows/test-typescript.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: TypeScript Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- '.github/workflow/test-typescript.yml'
8+
- 'impl/**'
9+
pull_request:
10+
branches: [ main ]
11+
paths:
12+
- '.github/workflow/test-typescript.yml'
13+
- 'impl/**'
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: 'impl'
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-node@v4
25+
- run: npm ci
26+
- run: npm run build --if-present
27+
- run: npm test
28+
- run: npm run pretty:check
29+
- run: npm run lint

impl/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules

impl/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Usage:
2+
3+
```sh
4+
npm install && npm run pack && npm run serve-local
5+
```

impl/eslint.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
3+
4+
export default tseslint.config(...tseslint.configs.recommendedTypeChecked, {
5+
languageOptions: {
6+
parserOptions: {
7+
project: true,
8+
tsconfigRootDir: import.meta.dirname,
9+
},
10+
},
11+
});

impl/index.html

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<!doctype html>
2+
<meta charset="utf-8" />
3+
<title>Attribution Simulator</title>
4+
<style>
5+
* {
6+
box-sizing: border-box;
7+
}
8+
9+
dl {
10+
display: grid;
11+
grid-gap: 0.25em;
12+
grid-template-columns: max-content;
13+
14+
dd {
15+
grid-column-start: 2;
16+
17+
input,
18+
select {
19+
width: 100%;
20+
}
21+
}
22+
}
23+
24+
body,
25+
div,
26+
nav {
27+
display: flex;
28+
gap: 1em;
29+
width: 100%;
30+
}
31+
32+
body {
33+
flex-direction: column;
34+
margin: 0;
35+
padding: 0.5em;
36+
}
37+
38+
form,
39+
section {
40+
border: 1px solid #000;
41+
padding: 0.5em;
42+
flex: 1;
43+
}
44+
45+
table {
46+
border-collapse: collapse;
47+
}
48+
49+
th,
50+
td {
51+
padding: 0.5em;
52+
border: 1px solid #000;
53+
}
54+
</style>
55+
<body>
56+
<nav>
57+
<!-- TODO: Expose actions for simulating user- and site-initiated data clears -->
58+
<form id="time">
59+
<h2>Time: <time></time></h2>
60+
<button>Advance</button> by
61+
<label
62+
><input id="days" type="number" min="0" value="1" step="0.25" />
63+
days</label
64+
>
65+
</form>
66+
<section>
67+
<h2>Epoch Starts</h2>
68+
<dl id="epochStarts"></dl>
69+
</section>
70+
<section>
71+
<h2>Privacy Budget Entries</h2>
72+
<dl id="privacyBudgetEntries"></dl>
73+
</section>
74+
</nav>
75+
<div>
76+
<form id="saveImpression">
77+
<h2>Save Impression</h2>
78+
<dl>
79+
<dt><label for="impressionSite">Impression Site</label></dt>
80+
<dd><input id="impressionSite" value="publisher.example" /></dd>
81+
<dt><label for="impressionIntermediary">Intermediary Site</label></dt>
82+
<dd><input id="impressionIntermediary" /></dd>
83+
<dt><label for="histogramIndex">Histogram Index</label></dt>
84+
<dd>
85+
<input type="number" required id="histogramIndex" />
86+
</dd>
87+
<dt><label for="matchValue">Match Value</label></dt>
88+
<dd><input type="number" id="matchValue" /></dd>
89+
<dt><label for="lifetimeDays">Lifetime Days</label></dt>
90+
<dd><input type="number" id="lifetimeDays" /></dd>
91+
<dt><label for="priority">Priority</label></dt>
92+
<dd><input type="number" id="priority" /></dd>
93+
<dt><label for="conversionSites">Conversion Sites</label></dt>
94+
<dd><input id="conversionSites" /></dd>
95+
<dt><label for="conversionCallers">Conversion Callers</label></dt>
96+
<dd><input id="conversionCallers" /></dd>
97+
</dl>
98+
<button>Submit</button>
99+
<output>
100+
<h3>Results</h3>
101+
<ol></ol>
102+
</output>
103+
<table>
104+
<thead>
105+
<tr>
106+
<th>Timestamp</th>
107+
<th>Impression Site</th>
108+
<th>Intermediary Site</th>
109+
<th>Histogram Index</th>
110+
<th>Match Value</th>
111+
<th>Lifetime Days</th>
112+
<th>Priority</th>
113+
<th>Conversion Sites</th>
114+
<th>Conversion Callers</th>
115+
</tr>
116+
</thead>
117+
<tbody></tbody>
118+
</table>
119+
</form>
120+
<form id="measureConversion">
121+
<h2>Measure Conversion</h2>
122+
<dl>
123+
<dt><label for="conversionSite">Conversion Site</label></dt>
124+
<dd>
125+
<input id="conversionSite" value="advertiser.example" />
126+
</dd>
127+
<dt><label for="conversionIntermediary">Intermediary Site</label></dt>
128+
<dd><input id="conversionIntermediary" /></dd>
129+
<dt><label for="histogramSize">Histogram Size</label></dt>
130+
<dd><input type="number" required id="histogramSize" /></dd>
131+
<dt><label for="lookbackDays">Lookback Days</label></dt>
132+
<dd><input type="number" id="lookbackDays" /></dd>
133+
<dt><label for="matchValues">Match Values</label></dt>
134+
<dd>
135+
<input id="matchValues" pattern="^\s*([0-9]+)(\s+[0-9]+)*\s*$" />
136+
</dd>
137+
<dt><label for="logic">Logic</label></dt>
138+
<dd>
139+
<select id="logic">
140+
<option>last-n-touch</option>
141+
</select>
142+
</dd>
143+
<dt><label for="credit">Credit</label></dt>
144+
<dd>
145+
<input
146+
id="credit"
147+
pattern="^\s*([0-9]+(\.[0-9]+)?)(\s+[0-9]+(\.[0-9]+)?)*\s*$"
148+
value="1"
149+
/>
150+
</dd>
151+
<dt><label for="value">Value</label></dt>
152+
<dd><input type="number" id="value" /></dd>
153+
<dt><label for="maxValue">Max Value</label></dt>
154+
<dd><input type="number" id="maxValue" /></dd>
155+
<dt><label for="epsilon">Epsilon</label></dt>
156+
<dd>
157+
<input type="number" id="epsilon" />
158+
</dd>
159+
<dt><label for="impressionSites">Impression Sites</label></dt>
160+
<dd><input id="impressionSites" /></dd>
161+
<dt><label for="impressionCallers">Impression Callers</label></dt>
162+
<dd><input id="impressionCallers" /></dd>
163+
</dl>
164+
<button>Submit</button>
165+
<output>
166+
<h3>Results</h3>
167+
<ol></ol>
168+
</output>
169+
</form>
170+
</div>
171+
<script src="dist/simulator.js"></script>
172+
</body>

0 commit comments

Comments
 (0)