provider-plausible

module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2025 License: Apache-2.0

README

Crossplane Provider for Plausible Analytics (v2 Native)

✅ BUILD STATUS: WORKING - v2 native provider with namespaced resources (v0.2.0)

Build Status Go Report Card License

A Crossplane v2 native provider for managing Plausible Analytics resources programmatically through Kubernetes with namespace isolation.

Container Registry

  • Primary: ghcr.io/rossigee/provider-plausible:v0.2.0
  • Harbor: Available via environment configuration
  • Upbound: Available via environment configuration

Overview

The Plausible provider enables platform teams to manage Plausible Analytics sites and goals as Kubernetes resources. This allows for:

  • Declarative configuration of analytics infrastructure
  • GitOps workflows for analytics management
  • Integration with existing Kubernetes tooling
  • Consistent lifecycle management across environments

Features

  • 🚀 v2 Native: Namespaced resources for better multi-tenancy and isolation
  • Site Management: Create, update, and delete Plausible sites
  • Goal Tracking: Manage conversion goals with event and page-based tracking
  • Shared Links: Create and manage dashboard sharing links with optional password protection
  • Custom Properties: Define custom event properties for advanced analytics dimensions
  • Guest Access: Manage team member invitations and access permissions (viewer/admin roles)
  • Team Management: Monitor team API access and organizational structure (read-only)
  • Multi-tenant: Support for team-based site management with namespace isolation
  • Cross-references: Reference sites from goals using Kubernetes selectors
  • Observability: Built-in status reporting and condition management

API Coverage

✅ Comprehensive Plausible API Support - ~85% API coverage with 19 endpoints

Core Resources (v1beta1 namespaced)
  • Sites: Full CRUD operations, domain management, timezone configuration
  • Goals: Event and page-based goals, conversion tracking, goal management
  • SharedLinks: Dashboard sharing with password protection, link management
  • CustomProperties: Custom event dimensions, analytics enhancement
  • Guests: Team collaboration, role-based access (viewer/admin)
  • Teams: Organizational structure monitoring (read-only)
Advanced Features
  • Pagination Support: Efficient handling of large datasets
  • Error Handling: Comprehensive error reporting and recovery
  • Cross-Resource References: Site references from dependent resources
  • Multi-tenancy: Namespace-based isolation for team workflows

Prerequisites

  • Kubernetes cluster with Crossplane v1.20+ installed
  • Plausible Analytics account with Sites API access
  • API key with comprehensive scopes:
    • sites:provision:* - Site management
    • sites:read:* - Site listing and details
    • goals:provision:* - Goal management
    • sites:shared-links:* - Dashboard sharing
    • sites:custom-props:* - Custom properties
    • teams:read:* - Team information (optional)

Installation

Quick Start
kubectl crossplane install provider ghcr.io/rossigee/provider-plausible:v0.2.0
Declarative Installation
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: provider-plausible
spec:
  package: ghcr.io/rossigee/provider-plausible:v0.2.0

Configuration

1. Create API Key Secret

Create a Plausible API key with comprehensive scopes in your Plausible dashboard, then create a Kubernetes secret:

kubectl create secret generic plausible-credentials \
  --from-literal=credentials='{"apiKey":"YOUR_API_KEY_HERE"}' \
  -n crossplane-system
2. Configure Provider
apiVersion: plausible.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  # baseURL: "https://plausible.yourdomain.com"  # Optional: defaults to plausible.io
  credentials:
    source: Secret
    secretRef:
      name: plausible-credentials
      namespace: crossplane-system
      key: credentials

Usage Examples

Basic Site Creation
apiVersion: site.plausible.m.crossplane.io/v1beta1
kind: Site
metadata:
  name: company-website
  namespace: production
spec:
  forProvider:
    domain: company.example.com
    timezone: "America/New_York"
  providerConfigRef:
    name: default
Site with Team Assignment
apiVersion: site.plausible.m.crossplane.io/v1beta1
kind: Site
metadata:
  name: team-site
  namespace: team-marketing
spec:
  forProvider:
    domain: team.example.com
    timezone: "UTC"
    teamID: "team-123"
  providerConfigRef:
    name: default
Updating Site Domain
apiVersion: site.plausible.m.crossplane.io/v1beta1
kind: Site
metadata:
  name: rebranded-site
  namespace: production
spec:
  forProvider:
    domain: old-domain.com
    newDomain: new-domain.com  # Will migrate analytics data
    timezone: "Europe/London"
  providerConfigRef:
    name: default
Event Goal Creation
apiVersion: goal.plausible.m.crossplane.io/v1beta1
kind: Goal
metadata:
  name: signup-conversion
  namespace: production
spec:
  forProvider:
    siteDomainRef:
      name: company-website
    goalType: event
    eventName: "Sign Up"
  providerConfigRef:
    name: default
Page Goal Creation
apiVersion: goal.plausible.m.crossplane.io/v1beta1
kind: Goal
metadata:
  name: thank-you-page
  namespace: production
spec:
  forProvider:
    siteDomainRef:
      name: company-website
    goalType: page
    pagePath: "/thank-you"
  providerConfigRef:
    name: default
Cross-Reference Example
# Create multiple sites and goals that reference them
apiVersion: site.plausible.m.crossplane.io/v1beta1
kind: Site
metadata:
  name: marketing-site
  namespace: marketing
  labels:
    team: marketing
spec:
  forProvider:
    domain: marketing.example.com
    timezone: "America/Los_Angeles"
---
apiVersion: goal.plausible.m.crossplane.io/v1beta1
kind: Goal
metadata:
  name: marketing-signup
  namespace: marketing
spec:
  forProvider:
    siteDomainRef:
      name: marketing-site
    goalType: event
    eventName: "Newsletter Signup"
---
apiVersion: goal.plausible.m.crossplane.io/v1beta1
kind: Goal
metadata:
  name: marketing-download
  namespace: marketing
spec:
  forProvider:
    siteDomainRef:
      name: marketing-site
    goalType: page
    pagePath: "/download"
Advanced Resources Examples
# Create a password-protected shared dashboard
apiVersion: sharedlink.plausible.m.crossplane.io/v1beta1
kind: SharedLink
metadata:
  name: client-dashboard
  namespace: marketing
spec:
  forProvider:
    siteDomainRef:
      name: marketing-site
    name: "Client Dashboard Q4"
    password: "secure-client-access-2024"
  providerConfigRef:
    name: default
Custom Analytics Properties
# Define custom event properties for enhanced tracking
apiVersion: customproperty.plausible.m.crossplane.io/v1beta1
kind: CustomProperty
metadata:
  name: user-segment
  namespace: marketing
spec:
  forProvider:
    siteDomainRef:
      name: marketing-site
    key: "user_segment"
    description: "Customer segment classification"
  providerConfigRef:
    name: default
Team Collaboration
# Invite team members with specific roles
apiVersion: guest.plausible.m.crossplane.io/v1beta1
kind: Guest
metadata:
  name: data-analyst
  namespace: marketing
spec:
  forProvider:
    siteDomainRef:
      name: marketing-site
    email: "analyst@company.com"
    role: "viewer"  # or "admin"
  providerConfigRef:
    name: default

Resource Reference

Site Resource
Spec Fields
Field Type Required Description
domain string Yes Website domain (e.g., "example.com")
timezone string No Site timezone (default: "UTC")
newDomain string No New domain for migration
teamID string No Team ID for multi-tenant setups
Status Fields
Field Type Description
siteID string Plausible site identifier
conditions []Condition Resource status conditions
Goal Resource
Spec Fields
Field Type Required Description
siteDomainRef.name string Yes Reference to Site resource
goalType string Yes "event" or "page"
eventName string Conditional Required for event goals
pagePath string Conditional Required for page goals
Status Fields
Field Type Description
goalID string Plausible goal identifier
conditions []Condition Resource status conditions

Development

Prerequisites
  • Go 1.21+
  • Docker
  • kubectl
  • crossplane CLI
Building from Source
# Clone the repository
git clone https://github.com/crossplane-contrib/provider-plausible.git
cd provider-plausible

# Generate code and manifests
make generate

# Run tests
make test

# Build binary
make build

# Build Docker image
make docker-build

# Package for Crossplane
make build-package
Running Locally
# Start the provider locally (requires kubeconfig)
make run
Testing

✅ Comprehensive Test Coverage: 50.0% - Robust testing across all components

# Run unit tests
make test

# Run integration tests (requires Plausible instance)
make test-integration

# Run linting
make lint

# Generate coverage report
go test ./internal/... -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html

Test Coverage Breakdown:

  • Client Library: 76.3% - All API operations, error handling, pagination
  • Controller Logic: 50.0% - Setup and configuration management
  • Goal Controller: Comprehensive - All CRUD operations, domain resolution, error scenarios
  • Site Controller: Comprehensive - All CRUD operations, domain updates, validation
  • Overall Internal: 50.0% - Strong foundation for reliability and maintainability

Troubleshooting

Common Issues
401 Unauthorized
  • Verify API key has required scopes (see Prerequisites section)
  • Check API key is correctly formatted in secret
  • Ensure Plausible instance has Sites API enabled
406 Not Acceptable
  • Verify your Plausible account has Sites API access
  • Check API key has all required scopes for the resources you're managing
Connection Errors
  • Verify baseURL in ProviderConfig
  • Check network connectivity to Plausible instance
  • Verify TLS certificates if using custom domain
Debug Mode

Enable debug logging by setting the provider's log level:

apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: provider-plausible
spec:
  package: ghcr.io/rossigee/provider-plausible:v0.2.0
  runtimeConfigRef:
    name: debug-config
---
apiVersion: pkg.crossplane.io/v1beta1
kind: DeploymentRuntimeConfig
metadata:
  name: debug-config
spec:
  deploymentTemplate:
    spec:
      template:
        spec:
          containers:
          - name: package-runtime
            args:
            - --debug
Getting Help

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Workflow
  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add comprehensive tests (maintain 50%+ coverage)
  5. Run make test lint and verify all tests pass
  6. Update documentation as needed
  7. Submit a pull request

Quality Standards:

  • Maintain test coverage above 50%
  • All new API methods require corresponding tests
  • Controller changes must include test coverage
  • Follow existing patterns for consistency

Security

For security concerns, please email security@crossplane.io rather than opening a public issue.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgments

Directories

Path Synopsis
Package apis contains Kubernetes API for the Plausible provider.
Package apis contains Kubernetes API for the Plausible provider.
customproperty/v1beta1
Package v1beta1 contains the v1beta1 group Plausible resources of the Plausible provider.
Package v1beta1 contains the v1beta1 group Plausible resources of the Plausible provider.
goal/v1beta1
Package v1beta1 contains managed resources for Plausible goals (v2 native).
Package v1beta1 contains managed resources for Plausible goals (v2 native).
guest/v1beta1
Package v1beta1 contains the v1beta1 group Plausible resources of the Plausible provider.
Package v1beta1 contains the v1beta1 group Plausible resources of the Plausible provider.
sharedlink/v1beta1
Package v1beta1 contains the v1beta1 group Plausible resources of the Plausible provider.
Package v1beta1 contains the v1beta1 group Plausible resources of the Plausible provider.
site/v1beta1
Package v1beta1 contains managed resources for Plausible sites (v2 native).
Package v1beta1 contains managed resources for Plausible sites (v2 native).
team/v1beta1
Package v1beta1 contains the v1beta1 group Plausible resources of the Plausible provider.
Package v1beta1 contains the v1beta1 group Plausible resources of the Plausible provider.
v1beta1
Package v1beta1 contains the core resources of the Plausible provider.
Package v1beta1 contains the core resources of the Plausible provider.
cmd
provider command
internal
version
Package version contains the version of this repo
Package version contains the version of this repo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL