Skip to content

put_event async

put_event(
    app_id: AppId,
    user_id: UserId,
    event_type: SourceEventType,
    quantity: Quantity,
    timestamp: Timestamp,
    scope: RequestScope,
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    properties: Optional[EventProperties] = None,
) -> PutEventResponse

Records a usage event for a user of an app. Usage events are the raw input that metrics aggregate.

Parameters:

  • app_id (AppId) –

    The ID of the app the event belongs to.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, the service ignores the request but does not return an error.

  • user_id (UserId) –

    The ID of the end user the event is attributed to. Do not include personally identifiable or otherwise sensitive data in this value.

  • event_type (SourceEventType) –

    The event type. Correlates with the event type of the metrics that aggregate it.

  • quantity (Quantity) –

    The amount of usage the event represents, as a non-negative decimal string (for example, "1" or "12.5").

  • timestamp (Timestamp) –

    The time the event occurred.

  • properties (Optional[EventProperties], default: None ) –

    The key/value properties carried on the event, usable in metric filters and grouping. When a metric sums or takes the max of a property, that property's value must be a plain non-negative decimal (up to 15 digits before the point and 6 after; no sign, exponent, spaces, or commas, for example "1200" or "12.5"), and events that break this are rejected.

  • scope (RequestScope) –

    The environment of the app that this operation applies to: the live app or the app's isolated sandbox test environment.

Raises:

Source code in docs_src/capo_appmonetization/_services/async_app_monetization.py
async def put_event(
    self,
    app_id: "capo_appmonetization.types.app_id.AppId",
    user_id: "capo_appmonetization.types.user_id.UserId",
    event_type: "capo_appmonetization.types.source_event_type.SourceEventType",
    quantity: "capo_appmonetization.types.quantity.Quantity",
    timestamp: "capo_appmonetization.types.timestamp.Timestamp",
    scope: "capo_appmonetization.types.request_scope.RequestScope",
    *,
    config_overrides: Optional[AsyncAppMonetizationClientConfig] = None,
    client_token: Optional[
        "capo_appmonetization.types.client_token.ClientToken"
    ] = None,
    properties: Optional[
        "capo_appmonetization.types.event_properties.EventProperties"
    ] = None,
) -> "capo_appmonetization.types.put_event_response.PutEventResponse":
    """Records a usage event for a user of an app. Usage events are the raw input that metrics aggregate.

    Args:
        app_id: The ID of the app the event belongs to.
        client_token: A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, the service ignores the request but does not return an error.
        user_id: The ID of the end user the event is attributed to. Do not include personally identifiable or otherwise sensitive data in this value.
        event_type: The event type. Correlates with the event type of the metrics that aggregate it.
        quantity: The amount of usage the event represents, as a non-negative decimal string (for example, "1" or "12.5").
        timestamp: The time the event occurred.
        properties: The key/value properties carried on the event, usable in metric filters and grouping. When a metric sums or takes the max of a property, that property's value must be a plain non-negative decimal (up to 15 digits before the point and 6 after; no sign, exponent, spaces, or commas, for example "1200" or "12.5"), and events that break this are rejected.
        scope: The environment of the app that this operation applies to: the live app or the app's isolated sandbox test environment.

    Raises:
        capo_appmonetization.errors.access_denied_exception.AccessDeniedException: The caller does not have sufficient permission to perform this action.
        capo_appmonetization.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_appmonetization.errors.resource_not_found_exception.ResourceNotFoundException: The referenced resource does not exist.
        capo_appmonetization.errors.throttling_exception.ThrottlingException: The request was denied due to request throttling.
        capo_appmonetization.errors.validation_exception.ValidationException: The request failed input validation.
        capo_appmonetization.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_appmonetization.types.put_event_request.PutEventRequest]",
    ) -> AsyncOperationResponse[
        "capo_appmonetization.types.put_event_response.PutEventResponse"
    ]:
        import capo_appmonetization._operations.aws_monetization_ai_front_end.put_event

        (
            output,
            http_response,
        ) = await capo_appmonetization._operations.aws_monetization_ai_front_end.put_event.async_put_event(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutEvent")
    )
    input_: capo_appmonetization.types.put_event_request.PutEventRequest = {
        "app_id": app_id,
        "user_id": user_id,
        "event_type": event_type,
        "quantity": quantity,
        "timestamp": timestamp,
        "scope": scope,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if properties is not None:
        input_["properties"] = properties

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output