Create a client ID and secret on the developer settings page and save the secret for later use.
Get a temporary access token.
package main | |
import ( | |
"cloud.google.com/go/storage" | |
"context" | |
"github.com/minio/minio-go" | |
"google.golang.org/api/iterator" | |
"log" | |
"os" | |
) |
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"time" | |
) | |
func runTimed(tick time.Duration, f func()) context.CancelFunc { |
var { Client } = require("pirsch-sdk"); | |
var client = new Client({ | |
hostname: "your-domain", // don't forget to set these! | |
clientID: "your-client-id", | |
clientSecret: "your-client-secret" | |
}); | |
client.domain() | |
.then(d => { |
(function() { | |
"use strict"; | |
if(navigator.doNotTrack === "1" || localStorage.getItem("disable_pirsch")) { | |
return; | |
} | |
const script = document.querySelector("#pirschjs"); | |
const endpoint = script.getAttribute("data-endpoint") || "https://api.pirsch.io/hit"; | |
const identificationCode = script.getAttribute("data-code"); |
(function() { | |
"use strict"; | |
window.pirsch = (name, options) => { | |
console.log(`Pirsch event: ${name}${options ? " "+JSON.stringify(options) : ""}`); | |
return Promise.resolve(null); | |
}; | |
if(navigator.doNotTrack === "1" || localStorage.getItem("disable_pirsch")) { | |
return; |
(function () { | |
"use strict"; | |
// The identification code for your website from the settings page. | |
// Required. | |
const identificationCode = ""; | |
// A comma-separated list of path patterns (regular expressions) to include. | |
// Optional. | |
const includePaths = ""; |
# Uncomment everything not specified here and change the domain. | |
proxy.yourdomain.com:443 { | |
reverse_proxy localhost:8080 | |
} |
package main | |
import ( | |
"log" | |
"time" | |
"github.com/robertkrimen/otto" | |
) | |
const ( |
This step is only required if you use a client ID + secret. A single access key allows you to skip the step, but it cannot be used to read statistics as with the other method. For write-only clients, we recommend using an access key.
Replace the CLIENT_ID
and CLIENT_SECRET
in the body. The access token in the response will be valid for 15 minutes.
curl --location --request POST 'https://api.pirsch.io/api/v1/token' \
--header 'Content-Type: application/json' \
--data-raw '{