biothings.web.analytics

biothings.web.analytics.channels

class biothings.web.analytics.channels.Channel[source]

Bases: object

async handles(event)[source]
async send(event)[source]
class biothings.web.analytics.channels.GA4Channel(measurement_id, api_secret, uid_version=1)[source]

Bases: Channel

async handles(event)[source]
async send(event)[source]
async send_request(session, url, data)[source]
class biothings.web.analytics.channels.SlackChannel(hook_urls)[source]

Bases: Channel

async handles(event)[source]
async send(event)[source]
async send_request(session, url, event)[source]

biothings.web.analytics.events

class biothings.web.analytics.events.Event(dict=None, /, **kwargs)[source]

Bases: UserDict

to_GA4_payload(measurement_id, cid_version=1)[source]
class biothings.web.analytics.events.GAEvent(dict=None, /, **kwargs)[source]

Bases: Event

to_GA4_payload(measurement_id, cid_version=1)[source]
class biothings.web.analytics.events.Message(dict=None, /, **kwargs)[source]

Bases: Event

Logical document that can be sent through services. Processable fields: title, body, url, url_text, image, image_altext Optionally define default field values below.

DEFAULTS = {'image_altext': '<IMAGE>', 'title': 'Notification Message', 'url_text': 'View Details'}
to_ADF()[source]

Generate ADF for Atlassian Jira payload. Overwrite this to build differently. https://developer.atlassian.com/cloud/jira/platform/apis/document/playground/

to_email_payload(sendfrom, sendto)[source]

Build a MIMEMultipart message that can be sent as an email. https://docs.aws.amazon.com/ses/latest/DeveloperGuide/examples-send-using-smtp.html

to_jira_payload(profile)[source]

Combine notification message with project profile to genereate jira issue tracking ticket request payload.

to_slack_payload()[source]

Generate slack webhook notification payload. https://api.slack.com/messaging/composing/layouts

biothings.web.analytics.notifiers

class biothings.web.analytics.notifiers.AnalyticsMixin(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: RequestHandler

on_finish()[source]

Called after the end of a request.

Override this method to perform cleanup, logging, etc. This method is primarily intended as a counterpart to prepare. However, there are a few error cases where on_finish may be called when prepare has not. (These are considered bugs and may be fixed in the future, but for now you may need to check to see if the initialization work done in prepare has occurred)

on_finish may not produce any output, as it is called after the response has been sent to the client.

class biothings.web.analytics.notifiers.Notifier(settings)[source]

Bases: object

async broadcast(event)[source]