Skip to content

muety/caddy-pirsch-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Coding Time

caddy-pirsch-plugin

A Caddy v2 plugin to track requests in Pirsch Analytics.

Usage

pirsch [<matcher>] {
    client_id <pirsch-client-id>
    client_secret <pirsch-client-secret>
    base_url <alternative-api-url>
}

You can obtain these parameters from the Settings section of your Pirsch dashboard.

Because this directive does not come standard with Caddy, you need to put the directive in order. The correct place is up to you, but usually putting it near the end works if no other terminal directives match the same requests. It's common to pair a Pirsch handler with a file_server, so ordering it just before is often a good choice:

{
	order pirsch before file_server
}

Alternatively, you may use route to order it the way you want. For example:

localhost
root * /srv
route {
	pirsch * {
		[...]
	}
	file_server
}

Example

Track all requests to HTML pages in Pirsch. You might want to extend the matcher regexp to also include / or, alternatively, match everything but assets (like .css, .js, ...) since usually you wouldn't want to track those.

{
    order pirsch before file_server
}

http://localhost:8080 {
    @html path_regexp .*\.html$

    pirsch @html {
        client_id cCfoZttXzRH5AyOpiu97wqXH3j5lYXcg
        client_secret olshVxS73jWQFhXJE86DdoR4McPBh02OendvyLtajX2EA3aasfywb3q3uZio9tDL
    }

    file_server
}

License

Apache 2.0

About

A Caddy v2 plugin to track requests in Pirsch analytics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages