Edit in GitHubLog an issue

SDK Events

Description#

When initializing the SDK, the options["events"] dict is an optional object with event name keys and callback function values. It can be used to subscribe to various events that occur within the SDK. For instance, the client_ready event may be used with a callback function that will be invoked when the SDK is ready for method calls.

When the callback function is called, an event object is passed in. Each event has a type corresponding to the event name, and some events include additional properties with pertinent information.

Events#

Event Name (type)DescriptionAdditional Event Properties
client_readyEmitted when the artifact has downloaded and the SDK is ready for get_offers calls. Recommended when usingon-device decisioning method.
artifact_download_succeededEmitted each time a new artifact is downloaded.artifact_payload, artifact_location
artifact_download_failedEmitted each time an artifact fails to download.artifact_location, error

Example#

Copied to your clipboard
1def client_ready_callback():
2 # make get_offers requests
3
4def artifact_download_succeeded(event):
5 print("The artifact was successfully downloaded from {}".format(event.artifact_location))
6 # optionally do something with event.artifact_payload, like persist it
7
8def artifact_download_failed(event):
9 print("The artifact failed to download from {} with the following error: {}"
10 .format(event.artifact_location, str(event.error)))
11
12client_options = {
13 "client": "acmeclient",
14 "organization_id": "1234567890@AdobeOrg",
15 "events": {
16 "client_ready": client_ready_callback,
17 "artifact_download_succeeded": artifact_download_succeeded,
18 "artifact_download_failed": artifact_download_failed
19 }
20}
21target_client = target_client.create(client_options)
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.