Skip to content

Commit 9eed763

Browse files
committed
Align Save-Impression parsing with Measure-Conversion
1 parent db721f3 commit 9eed763

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

api.bs

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,10 @@ Save-Impression: histogram-index=3, match-value=2, conversion-sites=("advertiser
19061906

19071907
The following keys are defined, corresponding to the members of
19081908
the {{AttributionImpressionOptions}} dictionary passed to
1909-
<a method for=Attribution>saveImpression()</a>.
1909+
<a method for=Attribution>saveImpression()</a>. Default values for omitted
1910+
optional keys are populated the same way as the corresponding
1911+
{{AttributionImpressionOptions}} field.
1912+
19101913

19111914
<dl dfn-for=save-impression>
19121915
<dt><dfn noexport><code>conversion-sites</code></dfn></dt>
@@ -1915,15 +1918,15 @@ the {{AttributionImpressionOptions}} dictionary passed to
19151918
an [=structured header/inner list=] containing [=structured header/string|strings=].
19161919
Each string value includes a domain name using A-labels only;
19171920
[[RFC5890|Internationalized Domain Names]] therefore need to use [[RFC3492|punycode]].
1918-
This key is optional. If not supplied, an empty set is saved for [=impression/Conversion Sites=].
1921+
This key is optional.
19191922
</dd>
19201923
<dt><dfn noexport><code>conversion-callers</code></dfn></dt>
19211924
<dd>
19221925
Value of <a dict-member for=AttributionImpressionOptions>conversionCallers</a>,
19231926
an [=structured header/inner list=] containing [=structured header/string|strings=].
19241927
Each string value includes a domain name using A-labels only;
19251928
[[RFC5890|Internationalized Domain Names]] therefore need to use [[RFC3492|punycode]].
1926-
This key is optional. If not supplied, an empty set is saved for [=impression/Conversion Callers=].
1929+
This key is optional.
19271930
</dd>
19281931
<dt><dfn noexport><code>histogram-index</code></dfn></dt>
19291932
<dd>
@@ -1939,13 +1942,11 @@ the {{AttributionImpressionOptions}} dictionary passed to
19391942
<dd>
19401943
Value of <a dict-member for=AttributionImpressionOptions>matchValue</a>,
19411944
a non-negative [=structured header/integer=]. This key is optional.
1942-
If not supplied, a value of 0 is saved for [=impression/Match Value=].
19431945
</dd>
19441946
<dt><dfn noexport><code>lifetime-days</code></dfn></dt>
19451947
<dd>
19461948
Value of <a dict-member for=AttributionImpressionOptions>lifetimeDays</a>,
19471949
a positive [=structured header/integer=]. This key is optional.
1948-
If not supplied, 30 days is saved for [=impression/Lifetime=].
19491950
</dd>
19501951
</dl>
19511952

@@ -1957,34 +1958,36 @@ To <dfn noexport>parse a `Save-Impression` header</dfn> given a [=header value=]
19571958
with <var ignore>input_bytes</var> set to |input| and
19581959
<var ignore>field_type</var> set to "`dictionary`".
19591960
1. If parsing failed, return an error.
1960-
1. If |dict|["<code>[=save-impression/histogram-index=]</code>"] does not [=map/exist=] or
1961-
is not an [=structured header/integer=] or is less than 0, return an error.
1962-
1. Let |histogramIndex| be |dict|["<code>[=save-impression/histogram-index=]</code>"].
1963-
1. Let |conversionSites| be |dict|["<code>[=save-impression/conversion-sites=]</code>"]
1964-
[=map/with default=] an empty [=structured header/inner list=].
1965-
1. If |conversionSites| is not an [=structured header/inner list=], or if any of |conversionSites|' [=list/items=] is not a [=structured header/string=], return an error.
1966-
1. Let |conversionCallers| be |dict|["<code>[=save-impression/conversion-callers=]</code>"]
1967-
[=map/with default=] an empty [=structured header/inner list=].
1968-
1. If |conversionCallers| is not an [=structured header/inner list=], or if any of |conversionCallers|' [=list/items=] is not a [=structured header/string=], return an error.
1969-
1. Let |matchValue| be |dict|["<code>[=save-impression/match-value=]</code>"] [=map/with default=] 0.
1970-
1. If |matchValue| is not an [=structured header/integer=] or is less than 0, return an error.
1971-
1. Let |lifetimeDays| be |dict|["<code>[=save-impression/lifetime-days=]</code>"] [=map/with default=] 30.
1972-
1. If |lifetimeDays| is not an [=structured header/integer=] or is less than or equal to 0, return an error.
1973-
1. Let |priority| be |dict|["<code>[=save-impression/priority=]</code>"] [=map/with default=] 0.
1974-
1. If |priority| is not an [=structured header/integer=], return an error.
1975-
1. Return a new {{AttributionImpressionOptions}} with the following items:
1961+
1. Let |histogramIndex| be |dict|["<code>[=save-impression/histogram-index=]</code>"] [=map/with default=] `undefined`.
1962+
1. If |histogramIndex| is not a non-negative [=structured header/integer=], return an error.
1963+
1. Let |opts| be a new {{AttributionImpressionOptions}} with the following items:
19761964
: {{AttributionImpressionOptions/histogramIndex}}
19771965
:: |histogramIndex|
1978-
: {{AttributionImpressionOptions/matchValue}}
1979-
:: |matchValue|
1980-
: {{AttributionImpressionOptions/conversionSites}}
1981-
:: |conversionSites|
1982-
: {{AttributionImpressionOptions/conversionCallers}}
1983-
:: |conversionCallers|
1984-
: {{AttributionImpressionOptions/lifetimeDays}}
1985-
:: |lifetimeDays|
1986-
: {{AttributionImpressionOptions/priority}}
1987-
:: |priority|
1966+
1. If |dict|["<code>[=save-impression/conversion-sites=]</code>"] [=map/exists=]:
1967+
1. Let |conversionSites| be its [=map/value=].
1968+
1. If |conversionSites| is not an [=structured header/inner list=], or if any of
1969+
|conversionSites|' [=list/items=] is not a [=structured header/string=],
1970+
return an error.
1971+
1. Set |opts|.{{AttributionImpressionOptions/conversionSites}} to |conversionSites|.
1972+
1. If |dict|["<code>[=save-impression/conversion-callers=]</code>"] [=map/exists=]:
1973+
1. Let |conversionCallers| be its [=map/value=].
1974+
1. If |conversionCallers| is not an [=structured header/inner list=], or if any of
1975+
|conversionCallers|' [=list/items=] is not a [=structured header/string=],
1976+
return an error.
1977+
1. Set |opts|.{{AttributionImpressionOptions/conversionCallers}} to |conversionCallers|.
1978+
1. If |dict|["<code>[=save-impression/match-value=]</code>"] [=map/exists=]:
1979+
1. Let |matchValue| be its [=map/value=].
1980+
1. If |matchValue| is not a non-negative [=structured header/integer=], return an error.
1981+
1. Set |opts|.{{AttributionImpressionOptions/matchValue}} to |matchValue|.
1982+
1. If |dict|["<code>[=save-impression/lifetime-days=]</code>"] [=map/exists=]:
1983+
1. Let |lifetimeDays| be its [=map/value=].
1984+
1. If |lifetimeDays| is not a positive [=structured header/integer=], return an error.
1985+
1. Set |opts|.{{AttributionImpressionOptions/lifetimeDays}} to |lifetimeDays|.
1986+
1. If |dict|["<code>[=save-impression/priority=]</code>"] [=map/exists=]:
1987+
1. Let |priority| be its [=map/value=].
1988+
1. If |priority| is not an [=structured header/integer=], return an error.
1989+
1. Set |opts|.{{AttributionImpressionOptions/priority}} to |priority|.
1990+
1. Return |opts|.
19881991

19891992
</div>
19901993

0 commit comments

Comments
 (0)