Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Python analytics SDK #6

Closed
PSalant726 opened this issue Jan 27, 2022 · 0 comments · Fixed by #16
Closed

Create a Python analytics SDK #6

PSalant726 opened this issue Jan 27, 2022 · 0 comments · Fixed by #16
Assignees
Labels
enhancement New feature or request

Comments

@PSalant726
Copy link
Contributor

PSalant726 commented Jan 27, 2022

The SDK should implement a "managed API" interface for Python applications that wish to send analytics events to the API server. It should enable applications to:

  • Create an AnalyticsClient instance, which enables caller-specific configuration, such as API keys, UUID, etc.
  • Create an AnalyticsEvent instance, which validates attributes for presence and content, as necessary
  • Abstract away the details of sending a POST request to the API server's /events endpoint
  • Identify and handle errors

The SDK should not create any log entries. Include usage and reference documentation in a README.md file.

Usage may be as simple as:

from logging import getLogger
from os import getenv
from fideslog.sdk.python import (
	AnalyticsClient,
	AnalyticsError,
	AnalyticsEvent,
	FIDESCTL_CLI,
	get_or_create_uuid,
)
	
logger = getLogger(__name__)
client = AnalyticsClient(getenv("FIDESLOG_API_KEY"), get_or_create_uuid(), FIDESCTL_CLI)
event = AnalyticsEvent("event type", "command name", ...)

try:
	client.send(event)
except AnalyticsError as e:
	logger.warn("failed to send analytics event: %s", e["message"])
except:
	logger.warn("something else has gone wrong")
else:
	logger.info("analytics event sent")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants