<commit_before>import json

import scriber
from scriber import error
from scriber.http_client import new_default_http_client

SCRIBER_URL = "https://scriber.io/api/"
PLATFORM = "Web"
SDK_VERSION = "scriberpy-{0}".format(scriber.__version__)

EVENT_TYPES = (
    "app_start",
    "app_background",
    "app_foreground",
    "app_terminate",
    "record_event",
    "record_purchase",
    "record_original_purchase_receipt",
    "set_user_info",
    "logout",
)


class Scriber(object):

    def __init__(self, api_key, app_id):
        self.api_key = api_key
        self.app_id = app_id

    def record_event(self, user_id, label, properties={}, timestamp=None):
        """
        Records a single "record_event" event to scriber.
        See http://scriber.io/docs/#/?tab=API for event details

        :param user_id: The user to track with this event.
        :param label: The name of the event.
        :param properties: (optional) A key-value set of subkeys to track
        :param timestamp: (optional) An ISO 8601 formatted timestamp for
            the event
        """
        event = {
            "event_type": "record_event",
            "event_info": {
                "label": label,
                "properties": properties,
            },
        }
        if timestamp is not None:
            event["event_time"] = timestamp.isoformat()
        return self.record_events(user_id, [event, ])

    def record_events(self, user_id, events):
        """
        Records multiple events to scriber, grouped together for performance

        Events is a list of events as described in API documentation

        See http://scriber.io/docs/#/?tab=API for event details

        :param user_id: The user to track with this event.
        :param events: A dictionary representation of the event<commit_msg>Timestamp should already be formatted<commit_after>import json

import scriber
from scriber import error
from scriber.http_client import new_default_http_client

SCRIBER_URL = "https://scriber.io/api/"
PLATFORM = "Web"
SDK_VERSION = "scriberpy-{0}".format(scriber.__version__)

EVENT_TYPES = (
    "app_start",
    "app_background",
    "app_foreground",
    "app_terminate",
    "record_event",
    "record_purchase",
    "record_original_purchase_receipt",
    "set_user_info",
    "logout",
)


class Scriber(object):

    def __init__(self, api_key, app_id):
        self.api_key = api_key
        self.app_id = app_id

    def record_event(self, user_id, label, properties={}, timestamp=None):
        """
        Records a single "record_event" event to scriber.
        See http://scriber.io/docs/#/?tab=API for event details

        :param user_id: The user to track with this event.
        :param label: The name of the event.
        :param properties: (optional) A key-value set of subkeys to track
        :param timestamp: (optional) An ISO 8601 formatted timestamp for
            the event
        """
        event = {
            "event_type": "record_event",
            "event_info": {
                "label": label,
                "properties": properties,
            },
        }
        if timestamp is not None:
            event["event_time"] = timestamp
        return self.record_events(user_id, [event, ])

    def record_events(self, user_id, events):
        """
        Records multiple events to scriber, grouped together for performance

        Events is a list of events as described in API documentation

        See http://scriber.io/docs/#/?tab=API for event details

        :param user_id: The user to track with this event.
        :param events: A dictionary representation of the event
{'fraction_non_alphanumeric': 0.09556407447973712, 'fraction_numerical': 0.002738225629791895, 'mean_word_length': 2.526061776061776, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1147397', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1028, 'n_words': 317}