{ "info": { "author": "Sean O'Connor", "author_email": "sean@focuslab.io", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Brockman\n========\n\nA Python client for working with the FocusLab API.\n\n![Kent Brockman](http://upload.wikimedia.org/wikipedia/en/9/9d/Kent_Brockman.jpg)\n\nCurrently this client only implements trigger recording but eventually it will\nprovide support for the full API.\n\nGetting Started\n---------------\n\nFirst you need to create an instance of the `FocusLabClient`:\n\n```python\nfrom brockman.client import FocusLabClient\n\nclient = FocusLabClient(api_key='da9dcaa0364541498d4ae6b4865cf395')\n```\n\nThe only required parameter for the client is `api_key`. You can get your API\nkey from your [FocusLab Dashboard][1]. Optionally you can also pass an\n`endpoint` parameter but you probably shouldn't do this unless you've been\ntold to do so by somebody from FocusLab.\n\nYou're now ready to start making calls to the FocusLab API.\n\nTrigger Recording\n-----------------\n\nTo record a trigger, all you need to do is call the `record_trigger` method\non a client instance:\n\n```python\nfrom brockman.client import FocusLabClient\n\nclient = FocusLabClient(api_key='da9dcaa0364541498d4ae6b4865cf395')\n\nclient.record_trigger(\n actor_id=user.id,\n action='viewed',\n obj='blog post',\n identities={'email': user.email, 'user_id': user.id},\n attributes={'plan': user.plan},\n variables={'tags': post.tags, 'title': post.title}\n)\n```\n\nThe parameters to `record_trigger` are described below:\n\n`actor_id`\n: A required string that acts as a session token. If you are using this\n client in combination with the [javascript tracking code][2], you can use\n the `fl_actor_id` cookie value as the user's actor_id. Otherwise any\n string that will be relatively consistent for a user can be used (e.g. a\n user id).\n\n`action`\n: A required string that describes the event that the trigger is\n representing (e.g. viewed, downloaded, streamed, etc).\n\n`obj`\n: A required string that describes the thing that the event being\n represented by the trigger is happening to (e.g. artist, blog post,\n product).\n\n`identities`\n: An optional dictionary of identities for the user. Any identities\n provided will be returned when you download a group from FocusLab.\n Additionally they are used to connect together activity streams from the\n user. Dictionary values can be strings, integers, floats, or lists.\n Possible identities include email addresses, user ids, and facebook ids.\n\n`attributes`\n: An optional dictionary of attributes for the user. Attributes are pieces\n of data about a user that you'd like to filter against, but should not be\n used for connecting activity streams. Dictionary values can be strings,\n integers, floats, or lists. Possible attributes include plan type, user\n level, or date joined.\n\n`variables`\n: An optional dictionary of variables for the trigger. Variables are pieces\n of data about the event the trigger is representing. Dictionary values\n can be strings, integers, floats, or lists. Possible variables include\n genres, tags, categories, titles, product code, or author.\n\n\nDjango Integration\n------------------\n\nBrockman includes some optional pieces that make it a little easier to work\nwithin a [Django][3] environment.\n\n### Django Client\n\nThe Django Client is a version of the `FocusLabClient` class that automatically\npulls configuration info in from Django's settings module.\n\nTo use the Django Client just set `FL_API_KEY` in your settings module and\nthen use the `brockman.django.client.DjangoFocusLabClient` class instead of\n`brockman.client.FocusLabClient`.\n\n### Celery Task\n\n[Celery][4] is a popular framework for handling delayed/async tasks. By using\nthe task provided at `brockman.django.celery.tasks.record_trigger` instead of\nthe client directly, you can record a trigger to FocusLab without introducing\nany extra latency or errors to your own application. Below is an example of\nusing the `record_trigger` task.\n\n```python\nfrom brockman.django.celery.tasks import record_trigger\n\nrecord_trigger.delay(\n actor_id=user.id,\n action='viewed',\n obj='blog post',\n identities={'email': user.email, 'user_id': user.id},\n attributes={'plan': user.plan},\n variables={'tags': post.tags, 'title': post.title}\n)\n```\n\nAs you can see the method signature is the same as on the client.\n\n\n\nGetting Help\n------------\n\nIf you have any questions or run into any problems please feel free to email\nus at help@focuslab.io or to use the chat box at http://focuslab.io.\n\n\n\n[1]: https://app.focuslab.io/\n[2]: https://github.com/focuslab/willie\n[3]: https://www.djangoproject.com/\n[4]: http://www.celeryproject.org/", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/FocusLab/brockman", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "brockman", "package_url": "https://pypi.org/project/brockman/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/brockman/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/FocusLab/brockman" }, "release_url": "https://pypi.org/project/brockman/0.1dev/", "requires_dist": null, "requires_python": null, "summary": "A Python client for the FocusLab API", "version": "0.1dev" }, "last_serial": 787055, "releases": { "0.1dev": [ { "comment_text": "", "digests": { "md5": "f84d52e4f84219be05a25f839d40f79b", "sha256": "c8b8eb7dc8badb68f41c2d5e2058a67db99a25fe1aec258889222c1a2209c43b" }, "downloads": -1, "filename": "brockman-0.1dev.tar.gz", "has_sig": false, "md5_digest": "f84d52e4f84219be05a25f839d40f79b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6248, "upload_time": "2012-06-07T21:26:06", "url": "https://files.pythonhosted.org/packages/2b/a3/fea6fb6c7fda13136581ff027ed6b0274a199cdb113d325b428ec69f71b2/brockman-0.1dev.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f84d52e4f84219be05a25f839d40f79b", "sha256": "c8b8eb7dc8badb68f41c2d5e2058a67db99a25fe1aec258889222c1a2209c43b" }, "downloads": -1, "filename": "brockman-0.1dev.tar.gz", "has_sig": false, "md5_digest": "f84d52e4f84219be05a25f839d40f79b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6248, "upload_time": "2012-06-07T21:26:06", "url": "https://files.pythonhosted.org/packages/2b/a3/fea6fb6c7fda13136581ff027ed6b0274a199cdb113d325b428ec69f71b2/brockman-0.1dev.tar.gz" } ] }