{
  "$meta": {
    "package": "@walkeros/web-destination-heap",
    "version": "4.2.1",
    "type": "destination",
    "platform": [
      "web"
    ],
    "docs": "https://www.walkeros.io/docs/destinations/web/heap",
    "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/web/destinations/heap/src"
  },
  "schemas": {
    "mapping": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "identify": {
          "description": "Per-event identity. Resolves to a string for heap.identify(). Example: { \"key\": \"data.email\" }."
        },
        "reset": {
          "description": "Reset Heap identity on this event. Set to true to call heap.resetIdentity()."
        },
        "userProperties": {
          "description": "Per-event user properties. Resolves to object for heap.addUserProperties()."
        },
        "eventProperties": {
          "description": "Per-event persistent event properties. Resolves to object for heap.addEventProperties() (persisted across page loads)."
        },
        "clearEventProperties": {
          "description": "Clear all persistent event properties. Set to true to call heap.clearEventProperties()."
        }
      },
      "additionalProperties": false
    },
    "settings": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "appId": {
          "type": "string",
          "minLength": 1,
          "description": "Heap App ID. Find it in your Heap project under Settings > App ID."
        },
        "disableTextCapture": {
          "type": "boolean",
          "description": "Disable Heap auto text capture. Default: true."
        },
        "disablePageviewAutocapture": {
          "type": "boolean",
          "description": "Disable Heap automatic pageview tracking. Default: true (walkerOS sources handle pageviews)."
        },
        "disableSessionReplay": {
          "type": "boolean",
          "description": "Disable Heap session replay."
        },
        "secureCookie": {
          "type": "boolean",
          "description": "SSL-only cookies."
        },
        "ingestServer": {
          "type": "string",
          "format": "uri",
          "description": "Custom server endpoint for proxying Heap data."
        },
        "identify": {
          "description": "Destination-level identity mapping. Resolves to a string for heap.identify(). Example: { \"key\": \"user.id\" }."
        },
        "userProperties": {
          "description": "Destination-level user properties mapping. Resolves to object for heap.addUserProperties(). Example: { \"map\": { \"plan\": \"data.plan\" } }."
        }
      },
      "required": [
        "appId"
      ],
      "additionalProperties": false
    }
  },
  "examples": {
    "env": {
      "init": {
        "window": {
          "heap": {
            "load": {
              "$code": "()=>{}"
            },
            "track": {
              "$code": "()=>{}"
            },
            "identify": {
              "$code": "()=>{}"
            },
            "resetIdentity": {
              "$code": "()=>{}"
            },
            "addUserProperties": {
              "$code": "()=>{}"
            },
            "addEventProperties": {
              "$code": "()=>{}"
            },
            "clearEventProperties": {
              "$code": "()=>{}"
            },
            "startTracking": {
              "$code": "()=>{}"
            },
            "stopTracking": {
              "$code": "()=>{}"
            }
          }
        }
      },
      "push": {
        "window": {
          "heap": {
            "load": {
              "$code": "()=>{}"
            },
            "track": {
              "$code": "()=>{}"
            },
            "identify": {
              "$code": "()=>{}"
            },
            "resetIdentity": {
              "$code": "()=>{}"
            },
            "addUserProperties": {
              "$code": "()=>{}"
            },
            "addEventProperties": {
              "$code": "()=>{}"
            },
            "clearEventProperties": {
              "$code": "()=>{}"
            },
            "startTracking": {
              "$code": "()=>{}"
            },
            "stopTracking": {
              "$code": "()=>{}"
            }
          }
        }
      },
      "simulation": [
        "call:window.heap.track",
        "call:window.heap.identify",
        "call:window.heap.resetIdentity",
        "call:window.heap.addUserProperties",
        "call:window.heap.addEventProperties",
        "call:window.heap.clearEventProperties",
        "call:window.heap.startTracking",
        "call:window.heap.stopTracking"
      ]
    },
    "step": {
      "consentGrantStartTracking": {
        "title": "Consent granted",
        "description": "A walker consent grant for analytics calls heap.startTracking to resume event capture.",
        "command": "consent",
        "in": {
          "analytics": true
        },
        "out": [
          [
            "heap.startTracking"
          ]
        ]
      },
      "consentRevokeStopTracking": {
        "title": "Consent revoked",
        "description": "After analytics consent is granted (Heap loads and starts tracking), revoking it calls heap.stopTracking to pause event capture.",
        "command": "consent",
        "before": {
          "analytics": true
        },
        "in": {
          "analytics": false
        },
        "out": [
          [
            "heap.startTracking"
          ],
          [
            "heap.stopTracking"
          ]
        ]
      },
      "defaultEventForwarding": {
        "title": "Default track",
        "description": "A walker event becomes a Heap track call with the event name and empty properties.",
        "in": {
          "name": "product view",
          "data": {
            "id": "ers",
            "name": "Everyday Ruck Snack",
            "color": "black",
            "size": "l",
            "price": 420
          },
          "context": {
            "shopping": [
              "detail",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [],
          "consent": {
            "functional": true
          },
          "id": "038ecaa58dc3db8e",
          "trigger": "load",
          "entity": "product",
          "action": "view",
          "timestamp": 1700000100,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "out": [
          [
            "heap.track",
            "product view",
            {}
          ]
        ]
      },
      "destinationLevelIdentify": {
        "title": "Destination identify",
        "description": "Destination-level identify calls heap.identify with the user id before firing the default track.",
        "in": {
          "name": "page view",
          "data": {
            "domain": "www.example.com",
            "title": "walkerOS documentation",
            "referrer": "https://www.walkeros.io/",
            "search": "?foo=bar",
            "hash": "#hash",
            "id": "/docs/"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "pagegroup": "docs"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "322f6e08f6e75df2",
          "trigger": "load",
          "entity": "page",
          "action": "view",
          "timestamp": 1700000102,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "settings": {
          "identify": "user.id"
        },
        "out": [
          [
            "heap.identify",
            "us3r"
          ],
          [
            "heap.track",
            "page view",
            {}
          ]
        ]
      },
      "destinationLevelInclude": {
        "title": "Renamed purchase",
        "description": "An order complete is renamed to purchase and mapped to Heap track properties such as order_id, total, and currency.",
        "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": "0a73d3acfa301722",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000101,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "purchase",
          "data": {
            "map": {
              "order_id": "data.id",
              "total": "data.total",
              "currency": {
                "key": "data.currency",
                "value": "EUR"
              }
            }
          }
        },
        "out": [
          [
            "heap.track",
            "purchase",
            {
              "order_id": "0rd3r1d",
              "total": 555,
              "currency": "EUR"
            }
          ]
        ]
      },
      "eventWithUserProperties": {
        "title": "User properties on event",
        "description": "An order fires Heap addUserProperties with last-order fields and then tracks the event.",
        "in": {
          "name": "order complete",
          "data": {
            "id": "0rd3r1d",
            "total": 555,
            "currency": "EUR"
          },
          "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": "0d10b6123d3a272b",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000105,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "settings": {
            "userProperties": {
              "map": {
                "last_order_value": "data.total",
                "last_order_currency": "data.currency"
              }
            }
          }
        },
        "out": [
          [
            "heap.addUserProperties",
            {
              "last_order_value": 555,
              "last_order_currency": "EUR"
            }
          ],
          [
            "heap.track",
            "order complete",
            {}
          ]
        ]
      },
      "globalEventProperties": {
        "title": "Global event properties",
        "description": "A page view sets persistent Heap event properties so all subsequent events include the page category.",
        "in": {
          "name": "page view",
          "data": {
            "category": "docs"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "pagegroup": "docs"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "cab9976313a4a0d3",
          "trigger": "load",
          "entity": "page",
          "action": "view",
          "timestamp": 1700000106,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "silent": true,
          "settings": {
            "eventProperties": {
              "map": {
                "page_category": "data.category"
              }
            }
          }
        },
        "out": [
          [
            "heap.addEventProperties",
            {
              "page_category": "docs"
            }
          ]
        ]
      },
      "userLoginIdentify": {
        "title": "User login identify",
        "description": "A user login identifies the Heap user by email and adds user properties while skipping the track.",
        "in": {
          "name": "user login",
          "data": {
            "email": "user@example.com",
            "plan": "premium",
            "company": "Acme"
          },
          "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": "fca84aabfa9db09b",
          "trigger": "test",
          "entity": "user",
          "action": "login",
          "timestamp": 1700000103,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "silent": true,
          "settings": {
            "identify": "data.email",
            "userProperties": {
              "map": {
                "plan": "data.plan",
                "company": "data.company"
              }
            }
          }
        },
        "out": [
          [
            "heap.identify",
            "user@example.com"
          ],
          [
            "heap.addUserProperties",
            {
              "plan": "premium",
              "company": "Acme"
            }
          ]
        ]
      },
      "userLogoutReset": {
        "title": "User logout reset",
        "description": "A user logout calls heap.resetIdentity to clear the identified user from the Heap client.",
        "in": {
          "name": "user logout",
          "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": "813990716fced224",
          "trigger": "test",
          "entity": "user",
          "action": "logout",
          "timestamp": 1700000104,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "silent": true,
          "settings": {
            "reset": true
          }
        },
        "out": [
          [
            "heap.resetIdentity"
          ]
        ]
      }
    }
  }
}