# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['ga4mp']

package_data = \
{'': ['*']}

setup_kwargs = {
    'name': 'ga4mp',
    'version': '2.0.3',
    'description': 'Google Analytics 4 Measurement Protocol Python Module',
    'long_description': '# GA4 Measurement Protocol Support for Python\n\nThis library provides an interface for sending data to Google Analytics, supporting the GA4 Measurement Protocol.\n\n**NOTE**: This project is in *beta* and will be continually updated to cover relevant features of the GA4 Measurement Protocol. Please feel free to file issues for feature requests.\n\n[Meet the next generation of Google Analytics: Learn about the new Google Analytics and how to get started](https://support.google.com/analytics/answer/10089681)\n\n## Contact\n\nEmail: `analytics-help@adswerve.com`\n\n## Installation\n\nThe easiest way to install GA4 Measurement Protocol Support for Python is directly from PyPi using `pip` by running the following command:\n\n`pip install ga4mp`\n\n\n## Usage\n> **NOTE**: Recent changes have added new platform specific subclasses. In order to take advantage of new functionality, you will need to update the class name of the GA4 object(s) being created in your code.\n\nThis library supports both gtag and Firebase data collection models. When creating your tracking object, use either `GtagMP` or `FirebaseMP`, depending on your needs.\n\nThe required credentials for sending events to GA4 using **gtag** comprise the following:\n\n| Credential     | Description                                                                                                                                                                                               |\n| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| api_secret     | Generated through the Google Analytics UI. To create a new secret, navigate in the Google Analytics UI to: **Admin** > **Data Streams** > **choose your stream** > **Measurement Protocol API secrets** > **Create** |\n| measurement_id | The identifier for a Data Stream. Found in the Google Analytics UI under:  **Admin** > **Data Streams** > **choose your stream** > **Measurement ID**                                                     |\n| client_id      | A unique identifier for a client, representing a specific browser/device.                                                                                                                                 |\n\nThe required credentials for sending events to **Firebase** comprise the following:\n\n| Credential      | Description                                                                                                                                                                                               |\n| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| api_secret      | Generated throught the Google Analytics UI. To create a new secret, navigate in the Google Analytics UI to: **Admin** > **Data Streams** > **choose your stream** > **Measurement Protocol API secrets** > **Create** |\n| firebase_app_id | The identifier for a Firebase app. Found in the Firebase console under: **Project Settings** > **General** > **Your Apps** > **App ID**.                                                                  |\n| app_instance_id | A unique identifier for a Firebase app instance. See [Required parameters > 2. JSON body](https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=firebase#required_parameters) for details. |\n\nCreate your *credentials.json* file and put in your "./credentials" subdirectory.\n\n``` json\n{"API_SECRET": "<YOUR_API_SECRET>",\n "MEASUREMENT_ID": "<YOUR_MEASUREMENT_ID>",\n "CLIENT_ID": "<YOUR_CLIENT_ID>",\n "FIREBASE_APP_ID": "<YOUR_FIREBASE_APP_ID>",\n "APP_INSTANCE_ID": "<YOUR_APP_INSTANCE_ID>"}\n```\n\n### Built-In Tracking Object Commands\n* `<TRACKER>.create_new_event(name)`: See "Creating an Event" section below.\n* `<TRACKER>.send(events, validation_hit, postpone, date)`: Takes `events` in the form of a list of dictionaries, then sends them as a POST request to GA4 or Firebase. `validation_hit` defaults to `False` and may be safely omitted; setting it to `True` will send the hit to the validation domain. `postpone` defaults to `False` and may also be omitted; if you do not want to send the event immediately, setting `postpone` to `True` will enqueue the POST request. The optional `date` field accepts a Python datetime option for sending historical hits up to 48 hours in the past. **NOTE**: if `date` is specified, `postpone` must be `False` (the default value).\n* `<TRACKER>.postponed_send()`: Sends all enqueued POST requests (i.e., anything added via `send(events, postpone=True)`), then empties the queue.\n* `<TRACKER>.append_event_to_params_dict(new_name_and_parameters)`: If necessary, add a new event and its expected parameters to the built-in `utils.py` dictionary. `new_name_and_parameters` takes a dictionary of with single key-value pair. Its key should be the new event name, and its value should be a list of parameters names (e.g., `{\'new_name\': [\'new_param_1\', \'new_param_2\', \'new_param_3\']}`). **NOTE**: the `utils.py` dictionary is used for error checking on automatically collected and recommended event types, and appending your own custom events is necessary only if you want them to be checked against the dictionary when using the `send()` command.\n* `<GTAG_TRACKER>.random_client_id()`: If using the `GtagMP` tracking object, this utility function will generate and return a new client ID matching the typical format of 10 random digits and the UNIX timestamp in seconds, joined by a period. This function will not overwrite the client ID on its own, but you may do so yourself using `example_tracker.client_id = example_tracker.random_client_id()`.\n\n## Memory Storage\nIn order to solve questions around persistence, this library includes two options for storage:\n* `DictStore`, a built-in dictionary class that will persist for the life of the tracking object\n* `FileStore`, a built-in dictionary class that will read from and save to a JSON file in a specified location\n\nUse of one of these two is required for session parameters (e.g., `session_id`) and user properties, so initialization of the tracking object will also initialize a default `DictStore` if a store object is not supplied as an argument.\n\nIn order to create your own store object, import either `DictStore` or `FileStore` from `ga4mp.store`, and then use the new store object when initializing your tracker.\n\n### Initializing the Tracker with a Store (Example)\n```py\nfrom ga4mp import GtagMP\nfrom ga4mp.store import DictStore, FileStore\n\n# DictStoreexpects a dict object\nnew_dict_store = DictStore(data=your_dictionary)\n# FileStore expects a string pointing to a specific existing JSON file - or desired location and name of a new JSON file to be created automatically.\nnew_file_store = FileStore(data_location=".folder/file.json")\n\n# Include whichever type of store you choose as an initialization argument for your tracker.\ntracker = GtagMP(api_secret="934TXS", measurement_id="G-12345", client_id="1234852.1235081235", store=new_file_store)\n```\n\n### Built-In Memory Storage Commands (DictStore Specific)\n* `<TRACKER>.store.save()`: Returns the current contents of the dictionary so that you can save them outside of the tracking object.\n\n### Built-In Memory Storage Commands (FileStore Specific)\n* `<TRACKER>.store.save()`: Try to overwrite the JSON file at the `data_location` given at time of store initialization with the current contents of the tracking object\'s dictionary.\n\n### Built-In Memory Storage Commands (Both Classes)\n> **NOTE**: The memory storage classes operate on 3 different types of data: **user properties**, which are sent to GA/Firebase with all events, **session parameters**, which should temporarily store information relevant to a single session (e.g., a session ID or the last time an event was sent), and **other**, for anything else you might want to save that wouldn\'t be sent to GA/Firebase.\n\nUse one of the following to set a new `value` with key `name` as a user property, session parameter, or other type of stored data:\n* `<TRACKER>.store.set_user_property(name, value)`\n* `<TRACKER>.store.set_session_parameter(name, value)`\n* `<TRACKER>.store.set_other_parameter(name, value)`\n\nUse one of the following to get the value of key `name` for a user property, session parameter, or other type of stored data:\n* `<TRACKER>.store.get_user_property(name)`\n* `<TRACKER>.store.get_session_parameter(name)`\n* `<TRACKER>.store.get_other_parameter(name)`\n\nUse one of the following to get all keys and values stored as a user property, session parameter, or other type of stored data:\n* `<TRACKER>.store.get_all_user_properties()`\n* `<TRACKER>.store.get_all_session_parameters()`\n* `<TRACKER>.store.get_all_other_parameters()`\n\nUse one of the following to clear all keys and values stored as a user property, session parameter, or other type of stored data:\n* `<TRACKER>.store.clear_user_properties()`\n* `<TRACKER>.store.clear_session_parameters()`\n* `<TRACKER>.store.clear_other_parameters()`\n\n## Events and Ecommerce Items\nWhile you may construct your own events and ecommerce items as dictionaries, the built-in Event and Item classes should eliminate guesswork about how to properly structure them.\n\n### Creating an Event\nTo create an event, begin by using the following command from your tracking object:\n`<TRACKER>.create_new_event(name)`\n* `name`: Corresponds to the Event Name that you would want to see in your GA4/Firebase reporting. Per Google\'s requirements, Event Names must be 40 characters or fewer, may only contain alpha-numeric characters and underscores, and must start with an alphabetic character.\n\nThe function will return an Event object with its own functions (see below). Once the Event is complete, you will be able to pass it to your tracking object\'s `send()` function within a list of 1 or more events.\n\n### Built-In Event Commands\n* `<EVENT>.set_event_name(name)`: Overwrite the current Event Name of the Event object with `name`.\n* `<EVENT>.get_event_name()`: Return the current Event Name of the Event object.\n* `<EVENT>.set_event_param(name, value)`: Set a new `value` with key `name` as an Event parameter. If the key already exists, its value will be overwritten; otherwise, a new key-value pair will be added.\n* `<EVENT>.get_event_params()`: Return a dictionary of all parameters associated with the Event.\n* `<EVENT>.delete_event_param(name)`: Delete a single key-value pair with a key of `name` from the Event\'s parameters.\n* `<EVENT>.create_new_item(item_id, item_name)`: See "Creating an Item" section below.\n* `<EVENT>.add_item_to_event(item)`: Add a single Item to the Event\'s `items` list parameter. Note that `item` is expected to be a single Item object or dictionary - not a list.\n\n### Creating an Item\nWhile building an ecommerce event, create a new item by using the following command from your Event object: `<EVENT>.create_new_item(item_id, item_name)`\n* `item_id`: The product SKU for the specific item.\n* `item_name`: The name for the specific item.\n\nAt least one of `item_id` or `item_name` must be included; however, it is recommended to use both, if applicable.\n\nThe function will return an Item object with its own functions (see below). Once the Item is complete, you will be able to pass it to the associated Event object\'s `add_item_to_event()` function.\n\n### Built-In Item Commands\n* `<ITEM>.set_parameter(name, value)`: Set a new `value` with key `name` as an Item parameter.\n\n## Example Code\nThe following represents an example of building and sending a custom event to GA4:\n``` python\nfrom ga4mp import GtagMP\nfrom ga4mp.store import DictStore\n\n# Create a DictStore\nmy_store = DictStore(data=<DICTIONARY>)\n\n# Create an instance of GA4 object using gtag, including the new DictStore.\ngtag_tracker = GtagMP(api_secret=<API_SECRET>, measurement_id=<MEASUREMENT_ID>, client_id=<CLIENT_ID>, store=my_store)\n\n# Create a new event for purchase.\npurchase_event = gtag_tracker.create_new_event(name="purchase")\n\n# Set transaction_id, value, and currency.\npurchase_event.set_event_param(name="transaction_id", value="T_12345")\npurchase_event.set_event_param(name="currency", value="USD")\npurchase_event.set_event_param(name="value", value=12.21)\n\n# Create an item and add details about the item.\nshirt = purchase_event.create_new_item(item_id="SKU_12345", item_name="Stan and Friends Tee")\nshirt.set_parameter("price", 9.99)\nshirt.set_parameter("quantity", 1)\nshirt.set_parameter("item_category", "Apparel")\n\n# Add the item to the purchase event.\npurchase_event.add_item_to_event(shirt)\n\n# Add a user property based on what you know about the user.\ngtag_tracker.store.set_user_property(name="shirt_wearer", value="yes")\n\n# Send the event to GA4 immediately.\nevent_list = [purchase_event]\ngtag_tracker.send(events=event_list)\n```\n\n## Google Developer Documentation\nSome relevant documentation from Google may be found below...\n\n### How to construct Events\nFor more information on constructing events, please review the [GA4 Measurement Protocol reference](https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference).\n\n### User properties\nFor more information on what user properties are in GA4 and what you can do with them, [please review here](https://developers.google.com/analytics/devguides/collection/protocol/ga4/user-properties?client_type=gtag)\n\n## License\nGA4 Measurement Protocol Support for Python is licensed under the [BSD License](./LICENSE).\n',
    'author': 'Adswerve',
    'author_email': 'analytics-help@adswerve.com',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'None',
    'packages': packages,
    'package_data': package_data,
    'python_requires': '>=3.6,<4.0',
}


setup(**setup_kwargs)
