biothings.web.analytics

biothings.web.analytics.channels

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

Bases: object

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

Bases: Channel

handles(event)[source]
send(payload)[source]

Limitations: https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag

class biothings.web.analytics.channels.GAChannel(tracking_id, uid_version=1)[source]

Bases: Channel

handles(event)[source]
send(payload)[source]
class biothings.web.analytics.channels.SlackChannel(hook_urls)[source]

Bases: Channel

handles(event)[source]
send(message)[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]
to_GA_payload(tracking_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]
to_GA_payload(tracking_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 a counterpart to prepare. 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

broadcast(event)[source]