feat(leads): submit contact requests to native platform intake
This commit is contained in:
1 parent
41664c3d0d
commit
079764d93d
12 files changed
+760
-154
No files matched your search
@@ -0,0 +1,49 @@
|
||||
(function (root, factory) {
|
||||
"use strict";
|
||||
var api = factory();
|
||||
if (typeof module === "object" && module.exports) module.exports = api;
|
||||
if (root) root.ToolCtrlSubmission = api;
|
||||
})(typeof globalThis === "object" ? globalThis : this, function () {
|
||||
"use strict";
|
||||
|
||||
function createSubmissionId(cryptoApi) {
|
||||
if (!cryptoApi || typeof cryptoApi.getRandomValues !== "function") {
|
||||
throw new Error("Secure browser randomness is unavailable");
|
||||
}
|
||||
if (typeof cryptoApi.randomUUID === "function") {
|
||||
return cryptoApi.randomUUID();
|
||||
}
|
||||
var bytes = new Uint8Array(16);
|
||||
cryptoApi.getRandomValues(bytes);
|
||||
return "web-" + Array.from(bytes, function (value) {
|
||||
return value.toString(16).padStart(2, "0");
|
||||
}).join("");
|
||||
}
|
||||
|
||||
function normalizedName(value) {
|
||||
return String(value || "").trim().replace(/\s+/g, " ");
|
||||
}
|
||||
|
||||
function createLeadFingerprint(input) {
|
||||
return JSON.stringify({
|
||||
name: normalizedName(input.name),
|
||||
company: String(input.firma || "").trim(),
|
||||
email: String(input.email || "").trim().toLowerCase(),
|
||||
phone: String(input.telefon || "").trim(),
|
||||
message: String(input.nachricht || "").trim(),
|
||||
formId: "contact-form",
|
||||
consent: true
|
||||
});
|
||||
}
|
||||
|
||||
function bindSubmissionId(pending, fingerprint, createId) {
|
||||
if (pending && pending.fingerprint === fingerprint) return pending;
|
||||
return { id: createId(), fingerprint: fingerprint };
|
||||
}
|
||||
|
||||
return {
|
||||
bindSubmissionId: bindSubmissionId,
|
||||
createLeadFingerprint: createLeadFingerprint,
|
||||
createSubmissionId: createSubmissionId
|
||||
};
|
||||
});
|
||||
Reference in new issue
Block a user