{
  "$meta": {
    "package": "@walkeros/web-destination-plausible",
    "version": "4.2.1",
    "type": "destination",
    "platform": [
      "web"
    ],
    "docs": "https://www.walkeros.io/docs/destinations/web/plausible",
    "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/web/destinations/plausible/src"
  },
  "schemas": {
    "mapping": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {},
      "additionalProperties": false
    },
    "settings": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "domain": {
          "type": "string",
          "pattern": "^(?=.{1,253}$)(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.[A-Za-z0-9-]{1,63}(?<!-))*$",
          "description": "The domain of your site as registered in Plausible (like walkeros.io)"
        }
      },
      "additionalProperties": false
    }
  },
  "examples": {
    "env": {
      "init": {
        "window": {},
        "document": {
          "createElement": {
            "$code": "()=>({src:\"\",dataset:{},setAttribute:()=>{},removeAttribute:()=>{}})"
          },
          "head": {
            "appendChild": {
              "$code": "()=>{}"
            }
          },
          "querySelector": {
            "$code": "()=>null"
          }
        }
      },
      "push": {
        "window": {
          "plausible": {
            "$code": "()=>{}"
          }
        },
        "document": {
          "createElement": {
            "$code": "()=>({src:\"\",dataset:{},setAttribute:()=>{},removeAttribute:()=>{}})"
          },
          "head": {
            "appendChild": {
              "$code": "()=>{}"
            }
          },
          "querySelector": {
            "$code": "()=>null"
          }
        }
      },
      "simulation": [
        "call:window.plausible"
      ]
    },
    "step": {
      "customEvent": {
        "title": "Custom event",
        "description": "A generic entity action fires a Plausible custom event with mapped props and a revenue field.",
        "in": {
          "name": "entity action",
          "data": {
            "string": "foo",
            "number": 1,
            "boolean": true,
            "array": [
              0,
              "text",
              false
            ]
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "c73f68bf78201cde",
          "trigger": "test",
          "entity": "entity",
          "action": "action",
          "timestamp": 1700000201,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "Custom Event",
          "data": {
            "map": {
              "props": "data",
              "revenue": "data.number"
            }
          }
        },
        "out": [
          [
            "plausible",
            "Custom Event",
            {
              "props": {
                "string": "foo",
                "number": 1,
                "boolean": true,
                "array": [
                  0,
                  "text",
                  false
                ]
              },
              "revenue": 1
            }
          ]
        ]
      },
      "init": {
        "title": "Initialization",
        "description": "Destination bootstrap loads the Plausible script for the configured domain and installs the queue.",
        "in": {
          "loadScript": true,
          "settings": {
            "domain": "example.com"
          }
        },
        "out": [
          [
            "script.appendChild",
            {
              "src": "https://plausible.io/js/script.manual.js",
              "domain": "example.com"
            }
          ]
        ]
      },
      "purchase": {
        "title": "Purchase",
        "description": "A completed order fires a Plausible purchase event with revenue currency and amount.",
        "in": {
          "name": "order complete",
          "data": {
            "id": "0rd3r1d",
            "currency": "EUR",
            "shipping": 5.22,
            "taxes": 73.76,
            "total": 555
          },
          "context": {
            "shopping": [
              "complete",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "product",
              "data": {
                "id": "ers",
                "name": "Everyday Ruck Snack",
                "color": "black",
                "size": "l",
                "price": 420
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "product",
              "data": {
                "id": "cc",
                "name": "Cool Cap",
                "size": "one size",
                "price": 42
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "gift",
              "data": {
                "name": "Surprise"
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "d2d2affdac1b9892",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000200,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "purchase",
          "data": {
            "map": {
              "revenue": {
                "map": {
                  "currency": {
                    "value": "EUR"
                  },
                  "amount": "data.total"
                }
              }
            }
          }
        },
        "out": [
          [
            "plausible",
            "purchase",
            {
              "revenue": {
                "currency": "EUR",
                "amount": 555
              }
            }
          ]
        ]
      }
    }
  }
}