Skip to content

Commit 41307b2

Browse files
committed
Align Save-Impression parsing with Measure-Conversion
1 parent e72f3a9 commit 41307b2

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
@@ -1905,7 +1905,10 @@ Save-Impression: histogram-index=3, match-value=2, conversion-sites=("advertiser
19051905

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

19101913
<dl dfn-for=save-impression>
19111914
<dt><dfn noexport><code>conversion-sites</code></dfn></dt>
@@ -1914,15 +1917,15 @@ the {{AttributionImpressionOptions}} dictionary passed to
19141917
an [=structured header/inner list=] containing [=structured header/string|strings=].
19151918
Each string value includes a domain name using A-labels only;
19161919
[[RFC5890|Internationalized Domain Names]] therefore need to use [[RFC3492|punycode]].
1917-
This key is optional. If not supplied, an empty set is saved for [=impression/Conversion Sites=].
1920+
This key is optional.
19181921
</dd>
19191922
<dt><dfn noexport><code>conversion-callers</code></dfn></dt>
19201923
<dd>
19211924
Value of <a dict-member for=AttributionImpressionOptions>conversionCallers</a>,
19221925
an [=structured header/inner list=] containing [=structured header/string|strings=].
19231926
Each string value includes a domain name using A-labels only;
19241927
[[RFC5890|Internationalized Domain Names]] therefore need to use [[RFC3492|punycode]].
1925-
This key is optional. If not supplied, an empty set is saved for [=impression/Conversion Callers=].
1928+
This key is optional.
19261929
</dd>
19271930
<dt><dfn noexport><code>histogram-index</code></dfn></dt>
19281931
<dd>
@@ -1938,13 +1941,11 @@ the {{AttributionImpressionOptions}} dictionary passed to
19381941
<dd>
19391942
Value of <a dict-member for=AttributionImpressionOptions>matchValue</a>,
19401943
a non-negative [=structured header/integer=]. This key is optional.
1941-
If not supplied, a value of 0 is saved for [=impression/Match Value=].
19421944
</dd>
19431945
<dt><dfn noexport><code>lifetime-days</code></dfn></dt>
19441946
<dd>
19451947
Value of <a dict-member for=AttributionImpressionOptions>lifetimeDays</a>,
19461948
a positive [=structured header/integer=]. This key is optional.
1947-
If not supplied, 30 days is saved for [=impression/Lifetime=].
19481949
</dd>
19491950
</dl>
19501951

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

19881991
</div>
19891992

0 commit comments

Comments
 (0)