{"id":18975079,"url":"https://github.com/bufferapp/buffer","last_synced_at":"2026-04-08T18:30:18.494Z","repository":{"id":45593564,"uuid":"72366726","full_name":"bufferapp/buffer","owner":"bufferapp","description":"buffer","archived":false,"fork":false,"pushed_at":"2022-01-04T19:56:00.000Z","size":318,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-01T09:09:38.080Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bufferapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-30T18:17:50.000Z","updated_at":"2024-09-12T05:07:04.000Z","dependencies_parsed_at":"2022-08-24T11:10:56.079Z","dependency_job_id":null,"html_url":"https://github.com/bufferapp/buffer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fbuffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fbuffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fbuffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fbuffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bufferapp","download_url":"https://codeload.github.com/bufferapp/buffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239972564,"owners_count":19727401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T15:17:15.389Z","updated_at":"2026-04-08T18:30:18.386Z","avatar_url":"https://github.com/bufferapp.png","language":"R","readme":"# The Buffer R package\nThe `buffer` package is an internal R package whose purpose is to abstract common operations like reading and writing data from Buffer's data warehouses. \n\n## Getting Started\nTo download the `buffer` package, you'll need to install the [devtools](https://www.rstudio.com/products/rpackages/devtools/) package.\n\n```\ninstall.packages(\"devtools\")\n```\n\nThen, use the `install_github()` function to install the `buffer` package.\n\n```\ndevtools::install_github(\"bufferapp/buffer\")\n```\n\n## Querying BigQuery\nTo query Redshift, you'll first need to make sure that you have your environment variables set in your .Renviron. Your .Renviron file might look something like this.\n\n```\nCHARTMOGUL_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nCHARTMOGUL_API_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nMIXPANEL_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nMIXPANEL_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nMIXPANEL_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n```\n\nTo set an environment variable, use the `Sys.setenv()` function.\n\n```\nSys.setenv(MIXPANEL_KEY = \"examplekeythatyoulluse\"\n```\n\nOnce these are set, you can connect to BigQuery with the `bq_connect()` function. It may prompt you to authenticate with your Google account.\n\n```\n# create connection\ncon \u003c- bq_connect()\n```\n\nYou'll then be able to run SQL queries from R, like so:\n\n```\n# define query\nsql \u003c- \"select * from dbt_buffer.buffer_users limit 10\"\n\n# run query\nusers \u003c- bq_query(con, sql)\n```\n\nEt voila!\n\n\n## Getting data from ChartMogul\nThe `get_mrr_metrics` function grabs data from [ChartMogul's metrics API](https://dev.chartmogul.com/reference#introduction-metrics-api). You will need to add your ChartMogul API token and secret to your .Renviron file to use this function.\n\n```\n# add API credentials\nSys.setenv(CHARTMOGUL_API_TOKEN = token)\nSys.setenv(CHARTMOGUL_API_SECRET = secret)\n```\n\nThere are several useful metrics we can collect from this API. We can retrieve [all key MRR metrics](https://dev.chartmogul.com/reference#retrieve-all-key-metrics) by setting `metric = \"all\"`. These include MRR, ARR, average revenue per account (ARPA), number of customers, LTV, the MRR churn rate, and the customer churn rate for each date. Here is an example.\n\n```\n# get key metrics\nall \u003c- get_mrr_metrics(metric = \"all\", start_date = \"2019-01-01\", end_date = \"2019-06-01\", interval = \"day\")\n```\n\nThe MRR metrics include all of the MRR movements (new, reactivation, expansion, contraction, and churn).\n\n```{r}\n# get mrr metrics\nmrr \u003c- get_mrr_metrics(metric = \"mrr\", start_date = \"2019-01-01\", end_date = \"2019-06-01\", interval = \"day\")\n```\n\n## Get Customer MRR Events\nThe `get_customer_mrr_events` function returns a dataframe of activities for a given customer. It only returns the events of a single customer, and the ChartMogul UUID must be used.\n\n```{r}\n# get mrr events\nactivities \u003c- get_customer_mrr_events(\"cus_b8eb4d54-687a-11e9-a881-17e8291a772a\")\n```\n\n## Plotting with `buffplot()`\nThe `buffplot()` function is a wrapper around the `ggplot()` function that does a couple things. It sets the plot's theme to `buffer_theme` and makes the default color palette colorblind-friendly.\n\n```\ndata(mtcars)\n\n# plot\nbuffplot(mtcars, aes(x = wt, y = mpg, color = as.factor(gear))) + \n    geom_point() + \n    labs(x = \"Weight\", y = \"MPG\", color = \"Gear\")\n```\n![](https://i.imgur.com/zfGmB3Y.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufferapp%2Fbuffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbufferapp%2Fbuffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufferapp%2Fbuffer/lists"}