@@ -30,6 +30,7 @@ def event(
3030 * ,
3131 user : UpsertedUser ,
3232 value : float ,
33+ idempotency_key : typing .Optional [str ] = None ,
3334 attributes : typing .Optional [typing .Dict [str , str ]] = OMIT ,
3435 request_options : typing .Optional [RequestOptions ] = None ,
3536 ) -> EventResponse :
@@ -47,6 +48,9 @@ def event(
4748 value : float
4849 The value to add to the user's current total for the given metric.
4950
51+ idempotency_key : typing.Optional[str]
52+ The idempotency key for the event.
53+
5054 attributes : typing.Optional[typing.Dict[str, str]]
5155 Event attributes as key-value pairs. Keys must match existing event attributes set up in the Trophy dashboard.
5256
@@ -67,6 +71,7 @@ def event(
6771 )
6872 client.metrics.event(
6973 key="words-written",
74+ idempotency_key="e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
7075 user=UpsertedUser(
7176 email="user@example.com",
7277 tz="Europe/London",
@@ -89,6 +94,9 @@ def event(
8994 },
9095 headers = {
9196 "content-type" : "application/json" ,
97+ "Idempotency-Key" : str (idempotency_key )
98+ if idempotency_key is not None
99+ else None ,
92100 },
93101 request_options = request_options ,
94102 omit = OMIT ,
@@ -148,6 +156,7 @@ async def event(
148156 * ,
149157 user : UpsertedUser ,
150158 value : float ,
159+ idempotency_key : typing .Optional [str ] = None ,
151160 attributes : typing .Optional [typing .Dict [str , str ]] = OMIT ,
152161 request_options : typing .Optional [RequestOptions ] = None ,
153162 ) -> EventResponse :
@@ -165,6 +174,9 @@ async def event(
165174 value : float
166175 The value to add to the user's current total for the given metric.
167176
177+ idempotency_key : typing.Optional[str]
178+ The idempotency key for the event.
179+
168180 attributes : typing.Optional[typing.Dict[str, str]]
169181 Event attributes as key-value pairs. Keys must match existing event attributes set up in the Trophy dashboard.
170182
@@ -190,6 +202,7 @@ async def event(
190202 async def main() -> None:
191203 await client.metrics.event(
192204 key="words-written",
205+ idempotency_key="e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
193206 user=UpsertedUser(
194207 email="user@example.com",
195208 tz="Europe/London",
@@ -215,6 +228,9 @@ async def main() -> None:
215228 },
216229 headers = {
217230 "content-type" : "application/json" ,
231+ "Idempotency-Key" : str (idempotency_key )
232+ if idempotency_key is not None
233+ else None ,
218234 },
219235 request_options = request_options ,
220236 omit = OMIT ,
0 commit comments