{
  "$meta": {
    "package": "@walkeros/server-destination-customerio",
    "version": "4.2.1",
    "type": "destination",
    "platform": [
      "server"
    ],
    "docs": "https://www.walkeros.io/docs/destinations/server/customerio",
    "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/server/destinations/customerio/src"
  },
  "schemas": {
    "mapping": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "identify": {
          "description": "Per-event identify attributes. Resolves to { email?, first_name?, ... }. Use with silent: true on login/identify events."
        },
        "page": {
          "description": "Per-event page view. Resolves to { url, ... }. Calls trackPageView(). Use with silent: true."
        },
        "destroy": {
          "type": "boolean",
          "description": "Permanently delete person from Customer.io. Set true on delete events with silent: true."
        },
        "suppress": {
          "type": "boolean",
          "description": "Suppress person (stop messaging without deleting data). Set true with silent: true."
        },
        "unsuppress": {
          "type": "boolean",
          "description": "Unsuppress person (resume messaging). Set true with silent: true."
        },
        "addDevice": {
          "description": "Register push device. Resolves to { deviceId, platform, data? }. Use with silent: true."
        },
        "deleteDevice": {
          "description": "Remove push device. Resolves to { deviceId, platform }. Use with silent: true."
        },
        "merge": {
          "description": "Merge duplicate profiles. Resolves to { primaryType, primaryId, secondaryType, secondaryId }. Use with silent: true."
        },
        "sendEmail": {
          "description": "Send transactional email. Resolves to { to, transactional_message_id, message_data?, identifiers? }. Requires appApiKey. Use with silent: true."
        },
        "sendPush": {
          "description": "Send transactional push. Resolves to { transactional_message_id, message_data?, identifiers? }. Requires appApiKey. Use with silent: true."
        }
      },
      "additionalProperties": false
    },
    "settings": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "siteId": {
          "type": "string",
          "minLength": 1,
          "description": "Customer.io Site ID. Find it in Settings > Workspace Settings > API Credentials."
        },
        "apiKey": {
          "type": "string",
          "minLength": 1,
          "description": "Customer.io API Key. Find it in Settings > Workspace Settings > API Credentials."
        },
        "appApiKey": {
          "type": "string",
          "description": "App API Key for transactional messaging (sendEmail/sendPush). Find it in Settings > Workspace Settings > API Credentials > App API Keys."
        },
        "region": {
          "type": "string",
          "enum": [
            "us",
            "eu"
          ],
          "description": "Data center region. Must match where your Customer.io workspace was created. Default: us."
        },
        "timeout": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991,
          "description": "HTTP request timeout in milliseconds. Default: 10000."
        },
        "customerId": {
          "type": "string",
          "description": "walkerOS mapping value path to resolve customerId from each event (like user.id)."
        },
        "anonymousId": {
          "type": "string",
          "description": "walkerOS mapping value path to resolve anonymousId from each event (like user.session)."
        },
        "identify": {
          "description": "Destination-level identity mapping. Resolves to { email?, first_name?, ... } attributes. Fires identify() on first push and re-fires when values change."
        }
      },
      "required": [
        "siteId",
        "apiKey"
      ],
      "additionalProperties": false
    }
  },
  "examples": {
    "env": {
      "push": {
        "trackClient": {
          "identify": {
            "$code": "()=>Promise.resolve()"
          },
          "track": {
            "$code": "()=>Promise.resolve()"
          },
          "trackAnonymous": {
            "$code": "()=>Promise.resolve()"
          },
          "trackPageView": {
            "$code": "()=>Promise.resolve()"
          },
          "destroy": {
            "$code": "()=>Promise.resolve()"
          },
          "suppress": {
            "$code": "()=>Promise.resolve()"
          },
          "unsuppress": {
            "$code": "()=>Promise.resolve()"
          },
          "addDevice": {
            "$code": "()=>Promise.resolve()"
          },
          "deleteDevice": {
            "$code": "()=>Promise.resolve()"
          },
          "mergeCustomers": {
            "$code": "()=>Promise.resolve()"
          }
        },
        "apiClient": {
          "sendEmail": {
            "$code": "()=>Promise.resolve()"
          },
          "sendPush": {
            "$code": "()=>Promise.resolve()"
          }
        }
      },
      "simulation": [
        "call:trackClient.identify",
        "call:trackClient.track",
        "call:trackClient.trackAnonymous",
        "call:trackClient.trackPageView",
        "call:trackClient.destroy",
        "call:trackClient.suppress",
        "call:trackClient.unsuppress",
        "call:trackClient.addDevice",
        "call:trackClient.deleteDevice",
        "call:trackClient.mergeCustomers",
        "call:apiClient.sendEmail",
        "call:apiClient.sendPush"
      ]
    },
    "step": {
      "anonymousTrack": {
        "title": "Anonymous track",
        "description": "When no customer id is resolved the event is sent via trackAnonymous keyed by the session id.",
        "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": {
            "session": "s3ss10n"
          },
          "nested": [],
          "consent": {
            "functional": true
          },
          "id": "cb6f923f898f6530",
          "trigger": "load",
          "entity": "product",
          "action": "view",
          "timestamp": 1700000103,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "settings": {},
        "out": [
          [
            "trackClient.trackAnonymous",
            "s3ss10n",
            {
              "name": "product view",
              "data": {},
              "timestamp": 1700000
            }
          ]
        ]
      },
      "defaultTrack": {
        "title": "Default track",
        "description": "A walkerOS event is forwarded to Customer.io as a track call keyed by the user id.",
        "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",
            "session": "s3ss10n"
          },
          "nested": [],
          "consent": {
            "functional": true
          },
          "id": "e082e91751fe3bfc",
          "trigger": "load",
          "entity": "product",
          "action": "view",
          "timestamp": 1700000100,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "out": [
          [
            "trackClient.track",
            "us3r",
            {
              "name": "product view",
              "data": {},
              "timestamp": 1700000
            }
          ]
        ]
      },
      "destinationIdentify": {
        "title": "Destination identify",
        "description": "Destination-level identify fires a Customer.io identify call once on the first push, before the track, attaching user attributes.",
        "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",
            "session": "s3ss10n",
            "email": "user@example.com"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "ed0432b7aa512b6d",
          "trigger": "load",
          "entity": "page",
          "action": "view",
          "timestamp": 1700000104,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "settings": {
          "identify": {
            "map": {
              "email": "user.email"
            }
          }
        },
        "out": [
          [
            "trackClient.identify",
            "us3r",
            {
              "email": "user@example.com"
            }
          ],
          [
            "trackClient.track",
            "us3r",
            {
              "name": "page view",
              "data": {},
              "timestamp": 1700000
            }
          ]
        ]
      },
      "destroyPerson": {
        "title": "Destroy person",
        "description": "A user delete event permanently removes the person from Customer.io via trackClient.destroy.",
        "in": {
          "name": "user delete",
          "data": {
            "string": "foo",
            "number": 1,
            "boolean": true,
            "array": [
              0,
              "text",
              false
            ]
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "2593d524043c4c85",
          "trigger": "test",
          "entity": "user",
          "action": "delete",
          "timestamp": 1700000107,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "silent": true,
          "settings": {
            "destroy": true
          }
        },
        "out": [
          [
            "trackClient.destroy",
            "us3r"
          ]
        ]
      },
      "mappedData": {
        "title": "Mapped properties",
        "description": "A data mapping transforms the event payload into Customer.io track properties for an order.",
        "in": {
          "name": "order complete",
          "data": {
            "id": "0rd3r1d",
            "total": 555,
            "currency": "EUR"
          },
          "context": {
            "shopping": [
              "complete",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "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": "34f15fd622823a5f",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000102,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "purchase",
          "data": {
            "map": {
              "order_id": "data.id",
              "value": "data.total",
              "currency": "data.currency"
            }
          }
        },
        "out": [
          [
            "trackClient.track",
            "us3r",
            {
              "name": "purchase",
              "data": {
                "order_id": "0rd3r1d",
                "value": 555,
                "currency": "EUR"
              },
              "timestamp": 1700000
            }
          ]
        ]
      },
      "mappedEventName": {
        "title": "Rename event",
        "description": "A mapping rule renames the walker event to a Customer.io-specific event name such as purchase.",
        "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",
            "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": "0020702934e77c69",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000101,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "purchase"
        },
        "out": [
          [
            "trackClient.track",
            "us3r",
            {
              "name": "purchase",
              "data": {},
              "timestamp": 1700000
            }
          ]
        ]
      },
      "pageView": {
        "title": "Page view",
        "description": "A page view fires trackPageView with the URL and referrer instead of a generic track call.",
        "in": {
          "name": "page view",
          "data": {
            "url": "https://example.com/pricing",
            "referrer": "https://google.com"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "pagegroup": "docs"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "3311782d773dc771",
          "trigger": "load",
          "entity": "page",
          "action": "view",
          "timestamp": 1700000106,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "silent": true,
          "settings": {
            "page": {
              "map": {
                "url": "data.url",
                "referrer": "data.referrer"
              }
            }
          }
        },
        "out": [
          [
            "trackClient.trackPageView",
            "us3r",
            "https://example.com/pricing",
            {
              "referrer": "https://google.com"
            }
          ]
        ]
      },
      "suppressPerson": {
        "title": "Suppress person",
        "description": "A user suppress event stops messaging for the person without deleting their profile data.",
        "in": {
          "name": "user suppress",
          "data": {
            "string": "foo",
            "number": 1,
            "boolean": true,
            "array": [
              0,
              "text",
              false
            ]
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "30d81dc194632b17",
          "trigger": "test",
          "entity": "user",
          "action": "suppress",
          "timestamp": 1700000108,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "silent": true,
          "settings": {
            "suppress": true
          }
        },
        "out": [
          [
            "trackClient.suppress",
            "us3r"
          ]
        ]
      },
      "unsuppressPerson": {
        "title": "Unsuppress person",
        "description": "A user unsuppress event resumes messaging for a previously suppressed Customer.io profile.",
        "in": {
          "name": "user unsuppress",
          "data": {
            "string": "foo",
            "number": 1,
            "boolean": true,
            "array": [
              0,
              "text",
              false
            ]
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "eba6abc29974aa1f",
          "trigger": "test",
          "entity": "user",
          "action": "unsuppress",
          "timestamp": 1700000109,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "silent": true,
          "settings": {
            "unsuppress": true
          }
        },
        "out": [
          [
            "trackClient.unsuppress",
            "us3r"
          ]
        ]
      },
      "userLoginIdentify": {
        "title": "User login identify",
        "description": "A user login triggers only a Customer.io identify call with profile attributes, skipping the track.",
        "in": {
          "name": "user login",
          "data": {
            "email": "user@acme.com",
            "first_name": "Jane",
            "plan": "premium"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "547cfc70023ed927",
          "trigger": "test",
          "entity": "user",
          "action": "login",
          "timestamp": 1700000105,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "silent": true,
          "settings": {
            "identify": {
              "map": {
                "email": "data.email",
                "first_name": "data.first_name",
                "plan": "data.plan"
              }
            }
          }
        },
        "out": [
          [
            "trackClient.identify",
            "us3r",
            {
              "email": "user@acme.com",
              "first_name": "Jane",
              "plan": "premium"
            }
          ]
        ]
      },
      "wildcardIgnored": {
        "public": false,
        "in": {
          "name": "debug noise",
          "data": {
            "string": "foo",
            "number": 1,
            "boolean": true,
            "array": [
              0,
              "text",
              false
            ]
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "bd429fa8231fb164",
          "trigger": "test",
          "entity": "debug",
          "action": "noise",
          "timestamp": 1700000110,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "ignore": true
        },
        "out": []
      }
    }
  }
}