{ "info": { "author": "Peter Dolak", "author_email": "peter.dolak@infinario.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Infinario Python SDK\n====================\n\n.. image:: https://travis-ci.org/Infinario/python-sdk.svg\n :target: https://travis-ci.org/Infinario/python-sdk\n :alt: Travis CI\n\nThe `infinario.Infinario` class provides access to the Infinario Python tracking API,\nsupporting both synchronous and asynchronous modes.\n\nYou can install the SDK using `pip`::\n\n pip install infinario\n\nIn order to track events, instantiate the class at least with your project token\n(can be found in Project Management in your Infinario account), for example:\n\n.. code-block:: python\n\n from infinario import Infinario\n\n client = Infinario('12345678-90ab-cdef-1234-567890abcdef') # PRODUCTION ENVIRONMENT\n # client = Infinario('12345678-90ab-cdef-1234-567890abcdef', silent=False) # DEVELOPMENT ENVIRONMENT\n\nWe recommend to set the `silent` parameter to `False` in a development environment, as it will cause the Infinario API\nto throw exceptions if something goes wrong. When left to the default value `True`, all errors will be logged\n(also see the `logger` parameter).\n\n\nTo get results of existing analyses stored in your Infinario project, you need to initialize the client\nwith the Infinario project secret (found in the Overview screen) as the `secret` keyword argument.\n\n.. code-block:: python\n\n client = Infinario('12345678-90ab-cdef-1234-567890abcdef',\n secret='fedcba09-8765-4321-fedc-ba0987654321')\n\n\nIdentifying the customer\n------------------------\n\nWhen tracking events, you have to specify which customer generated\nthem. This can be either done right when calling the client's\nconstructor.\n\n.. code-block:: python\n\n python\n client = Infinario('12345678-90ab-cdef-1234-567890abcdef', customer='john123')\n\nor by calling `identify`.\n\n.. code-block:: python\n\n client.identify('john123')\n\nTracking events\n---------------\n\nTo track events for the currently selected customer, simply\ncall the `track` method.\n\n.. code-block:: python\n\n client.track('purchase')\n\nYou can also specify a dictionary of event properties to store\nwith the event.\n\n.. code-block:: python\n\n client.track('purchase', {'product': 'bottle', 'amount': 5})\n\nSpecify the POSIX timestamp of the event using:\n\n.. code-block:: python\n\n timestamp = time.time()\n\n # .. time passes ..\n\n client.track('purchase', timestamp=timestamp)\n\nUpdating customer properties\n----------------------------\n\nYou can also update information that is stored with a customer.\n\n.. code-block:: python\n\n client.update({'first_name': 'John', 'last_name': 'Smith'})\n\nGetting HTML from campaign\n--------------------------\n\n.. code-block:: python\n\n client.get_html('Banner left')\n\nwill return::\n\n ''\n\n\nAnalysis export\n---------------\n\nTo export the entire result of an analysis, use the `export_analysis` client method.\nIt is necessary to authenticate during initialization of the client (see above).\nFirst argument is type of analysis (funnel, report, retention, segmentation), second argument is JSON object\ncontaining at least the ID of the analysis to export.\nOptional parameters include `format` (one of `'native-json'` (default), `'table-json'`, `'csv'`),\n `timezone` (according to the IANA time zone database, default `'UTC'`)\n and `execution_time` (UNIX timestamp specifying the upper bound of events to include, default is now).\n\n.. code-block:: python\n\n client = Infinario('12345678-90ab-cdef-1234-567890abcdef',\n secret='fedcba09-8765-4321-fedc-ba0987654321')\n\n data = client.export_analysis('funnel', {\n 'analysis_id': '2f86608f-24f5-11e3-9950-c48508494cf5',\n 'format': 'native-json',\n 'timezone': 'UTC',\n })\n\nThe data could contain\n\n.. code-block:: python\n\n {\n \"success\": true,\n \"name\": \"Conversion funnel\",\n \"steps\": [\"First visit\", \"Registration\", \"First log in\", \"Purchase\", \"Payment\"],\n \"total\": {\n \"counts\": [48632, 24120, 20398, 1256, 1250],\n \"times\": [-1, 680, 4502, 45, 540, 300],\n \"metric\": 1987562\n },\n \"drill_down\": {\n \"type\": \"none\",\n \"series\": []\n },\n \"metric\": {\n \"step\": 4,\n \"property\": \"price\"\n }\n }\n\n\nSegmentation result\n-------------------\n\nYou can also export the result of a segmentation for a specific customer\n(whom you need to specify either at initialization, or using the `identify` method).\nIt is necessary to authenticate during initialization of the client (see above).\n\n.. code-block:: python\n\n client = Infinario('12345678-90ab-cdef-1234-567890abcdef',\n secret='fedcba09-8765-4321-fedc-ba0987654321',\n customer='john123')\n\n segment = client.segment_for('11112222-3333-4444-5555-666677778888',\n timezone='UTC', timeout=0.5)\n\nThe result is the segmentation name, a string like `'Heavy payer'`. In case the customer doesn't belong to any\ndefined segment or their segmentation could not be determined within the given timeout, the method will return `None`.\nThe `timezone` and `timeout` parameters are optional with the defaults as in the example.\n\n\nTransport types\n---------------\n\nBy default the client uses a simple non-buffered synchronous transport. The three available transport types are:\n* `NullTransport` - No requests, useful for disabling tracking in the Infinario constructor.\n* `SynchronousTransport` - (default) Most operations are blocking for the time of a request to the Infinario API\n* `AsynchronousTransport` - Most operations are non-blocking (see the code for more information),\n buffered and using a single worker thread. Infinario client must be closed when no more data is to be tracked.\n **We recommend against using the AsynchronousTransport, as it cannot be guaranteed the data will be sent.**\n Data loss can for example happen in various events of system failure or even due to misuse.\n If you would like to track data from your code asynchronously, consider creating your own asynchronous workers\n using a library such as celery and use the SynchronousTransport to send the data from there.\n\nExample of choosing `AsynchronousTransport`:\n\n.. code-block:: python\n\n from infinario import Infinario, AsynchronousTransport\n\n client = Infinario('12345678-90ab-cdef-1234-567890abcdef',\n transport=AsynchronousTransport)\n\n # ...\n\n client.close()\n\n\nUsing on the command line\n-------------------------\n\nThe python client also has a command-line interface that allows to call its essential functions:\n\n.. code-block:: sh\n\n TOKEN='12345678-90ab-cdef-1234-567890abcdef'\n CUSTOMER='john123'\n\n # Track event\n ./infinario.py track \"$TOKEN\" \"$CUSTOMER\" purchase --properties product=bottle amount=5\n\n # Update customer properties\n ./infinario.py update \"$TOKEN\" \"$CUSTOMER\" first_name=John last_name=Smith\n\n # Get HTML from campaign\n ./infinario.py get_html \"$TOKEN\" \"$CUSTOMER\" \"Banner left\"\n", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/infinario/python-sdk", "keywords": null, "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "infinario", "package_url": "https://pypi.org/project/infinario/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/infinario/", "project_urls": { "Homepage": "https://github.com/infinario/python-sdk" }, "release_url": "https://pypi.org/project/infinario/2.0.1/", "requires_dist": [ "requests (>=2.2.1)" ], "requires_python": null, "summary": "Infinario Python SDK", "version": "2.0.1" }, "last_serial": 3471695, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "91a9e3a61dbb76c30fa3c35fee26a8d3", "sha256": "b144f5902f4182312d502d8fcdff21f800b37988dec3ad0a620bdf690ee3fbf4" }, "downloads": -1, "filename": "infinario-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "91a9e3a61dbb76c30fa3c35fee26a8d3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6531, "upload_time": "2015-11-05T12:56:57", "url": "https://files.pythonhosted.org/packages/d1/15/9a4329e4708225d4177c9fef30fb90a9969b049bc899f3a8eb74ddae257e/infinario-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f72414a8852d1989a65778aaa36d07ea", "sha256": "d2ca1d5d84135b44c75ed6d3634cd5a1323075ec3249a5b34ef04268a6951b21" }, "downloads": -1, "filename": "infinario-1.0.0.tar.gz", "has_sig": false, "md5_digest": "f72414a8852d1989a65778aaa36d07ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7002, "upload_time": "2015-11-05T12:57:01", "url": "https://files.pythonhosted.org/packages/f4/5c/fcb87fdae038aae7147aca76fafca379828248575f94acc531083c2cfd40/infinario-1.0.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "64983041f71cff34030c4cac721a2c18", "sha256": "2e14804ba2bd6dd45835673ed9be375783090956630f91e02b480b0edc32b89c" }, "downloads": -1, "filename": "infinario-2.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "64983041f71cff34030c4cac721a2c18", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6961, "upload_time": "2015-12-22T10:47:13", "url": "https://files.pythonhosted.org/packages/f4/23/66b421c4e2b558e4d6d50265244e60c372d5848ea8fbd7b7f9d92d9dfbbd/infinario-2.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "805a2284d824e870ffb87c65241c7b7d", "sha256": "9dee47cec3437d7400c289f20458dc775d39a42eaeb82f73566d87c5a3f6dc0d" }, "downloads": -1, "filename": "infinario-2.0.1.tar.gz", "has_sig": false, "md5_digest": "805a2284d824e870ffb87c65241c7b7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7980, "upload_time": "2015-12-22T10:47:26", "url": "https://files.pythonhosted.org/packages/e9/ef/2e655259e6b1892b2f3eb43e6c809baedfcc47023a48342dd9ba49c3d31a/infinario-2.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "64983041f71cff34030c4cac721a2c18", "sha256": "2e14804ba2bd6dd45835673ed9be375783090956630f91e02b480b0edc32b89c" }, "downloads": -1, "filename": "infinario-2.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "64983041f71cff34030c4cac721a2c18", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6961, "upload_time": "2015-12-22T10:47:13", "url": "https://files.pythonhosted.org/packages/f4/23/66b421c4e2b558e4d6d50265244e60c372d5848ea8fbd7b7f9d92d9dfbbd/infinario-2.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "805a2284d824e870ffb87c65241c7b7d", "sha256": "9dee47cec3437d7400c289f20458dc775d39a42eaeb82f73566d87c5a3f6dc0d" }, "downloads": -1, "filename": "infinario-2.0.1.tar.gz", "has_sig": false, "md5_digest": "805a2284d824e870ffb87c65241c7b7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7980, "upload_time": "2015-12-22T10:47:26", "url": "https://files.pythonhosted.org/packages/e9/ef/2e655259e6b1892b2f3eb43e6c809baedfcc47023a48342dd9ba49c3d31a/infinario-2.0.1.tar.gz" } ] }