PostHog URL Regex Plugin
A PostHog plugin to apply regex expressions to your urls, which allows you to perform parses easier, etc. This is especially suitable for content management websites/apps which have predefined patterns for url categorization.
Using Regexed URLs will allow you to gain better insights from your url data, specific to your categorization needs. This plugin can be used as a preprocessing step for your data, before you use PostHog Cloud or any external database.
Example
PostHog is the first open-source analytics platform, especially designed for startups and developers. PostHog allows users to use their tools either on the managed PostHog Cloud, or the self-hosted version. Try it out and show your support!
Join the PH Slack community.
Get started
Configure the plugin by entering your parameters for the
regexPattern
,regexFlag
,replacement
andmergeFlag
.
regexPattern
is a self-explanatory required string that has to be passed with your config. Strings not
following regex-valid patterns will not show an error - they will pass the same value unchanged.regexFlag
is a self-explanatory required string that has to be passed with your config. The default flag is global (g
).replacement
is an optional string that can be passed with your config to substitute values in the regex operation. The default value for this is@@@@@
(no reason in particular)mergeFlag
is a boolean flag value that has to be passed with your config, and determines whether the regexed output changes will be merged into theproperties.$current_url
field, else it creates a new columnproperties$regexed_url
fieldHelpful Tip!
Always test out your desired regex expressions elsewhere before using this plugin, else you might get some nasty, unwanted results!! I had 99 problems before I used Regex to solve them - now I have 100 problems. I personally used Regexr and Regex101
Developing Locally
To develop this plugin locally, first clone it and then run specs. Please make sure you've got Node and Yarn (recommended) or npm installed.
- git clone https://github.com/clockworkscorpion/posthog-url-regex-plugin.git
- yarn install
- yarn test --watch
Installation
You have three options to install this plugin
- Open PostHog Cloud -> Apps -> Installed Apps -> URL Regex Plugin
- Install from Github or Gitlab using this repository's URL
- Install using npm with the url from npmjs.com
Roadmap
This plugin was created as a starter project, so feel free to contribute, start a discussion or leave an issue if there are features you'd like to see added. For most purposes, it can be considered to be feature complete.
Contributing
Contributions of code, issues, reviews and documentation are always welcome! This is my first Github-based Open Source contribution, as well as one of my first TypeScript projects. All feedback is welcome!