@sagepilot-ai/web-events-addon 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/index.cjs +9 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/sagepilot-web-events.global.js +9 -8
- package/dist/sagepilot-web-events.global.js.map +1 -1
- package/package.json +6 -21
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -211,18 +211,19 @@ var SagepilotInstallationClient = class {
|
|
|
211
211
|
if (new TextEncoder().encode(body).byteLength > 128 * 1024) throw new Error("SDK batch exceeds the upload limit.");
|
|
212
212
|
return validateSagepilotInstallationReceipt(await this.request(auth.url, { method: "POST", headers: auth.headers, body }), observations.map((item) => item.event_id));
|
|
213
213
|
}
|
|
214
|
-
/** Submits contact and adopts only a scoped
|
|
214
|
+
/** Submits contact and adopts only a scoped customer session returned by the server. */
|
|
215
215
|
async submitContact(input) {
|
|
216
216
|
if (!UUID.test(input.submission_id) || !Number.isSafeInteger(input.popup_revision) || input.popup_revision < 1 || typeof input.marketing_consent !== "boolean") throw new Error("Invalid popup submission.");
|
|
217
217
|
if (this.transitioning) throw new Error("An SDK identity operation is already running.");
|
|
218
218
|
this.transitioning = true;
|
|
219
219
|
const generation = this.generation, prior = this.current;
|
|
220
220
|
try {
|
|
221
|
-
const
|
|
221
|
+
const body = prior?.popup_submission_events === true ? { ...input, server_submission_event: true } : input;
|
|
222
|
+
const result = await this.authenticated("/contact", body);
|
|
222
223
|
if (!result || !["recorded", "verification_required"].includes(result.status) || result.status === "verification_required" && (!result.challenge_id || !UUID.test(result.challenge_id) || !Number.isFinite(Date.parse(result.expires_at ?? "")))) throw new Error("Invalid popup submission response.");
|
|
223
224
|
const { session, ...acknowledgement } = result;
|
|
224
225
|
if (session != null) {
|
|
225
|
-
if (result.status !== "recorded" || prior?.customer_id !== null) throw new Error("Invalid popup
|
|
226
|
+
if (result.status !== "recorded" || prior?.customer_id !== null) throw new Error("Invalid popup customer session.");
|
|
226
227
|
await this.adoptTransition(session, prior, generation, true);
|
|
227
228
|
}
|
|
228
229
|
return acknowledgement;
|
|
@@ -368,7 +369,7 @@ function createSagepilotInstallationClient(options) {
|
|
|
368
369
|
|
|
369
370
|
// package.json
|
|
370
371
|
var name = "@sagepilot-ai/web-events-addon";
|
|
371
|
-
var version = "0.2.
|
|
372
|
+
var version = "0.2.6";
|
|
372
373
|
|
|
373
374
|
// src/projection.ts
|
|
374
375
|
var sensitive = /password|passwd|secret|token|authorization|cookie|session|email|phone|contact|address|card|payment|cvv|ssn|dob|birth|customer|user|account|person|profile|name|description|message|content|text|search|query/i;
|
|
@@ -2920,12 +2921,12 @@ function createSagepilotWebEvents(options) {
|
|
|
2920
2921
|
}
|
|
2921
2922
|
},
|
|
2922
2923
|
flush,
|
|
2923
|
-
/** Keeps contact
|
|
2924
|
+
/** Keeps contact on the identity endpoint and fences capture while adopting the customer. */
|
|
2924
2925
|
async submitContact(input) {
|
|
2925
2926
|
const session = client.session();
|
|
2926
2927
|
const result = session?.popup?.verification === "none" && session.customer_id === null ? await changeIdentity(() => client.submitContact(input)) : await client.submitContact(input);
|
|
2927
2928
|
if (result.status === "recorded") {
|
|
2928
|
-
emitPopup("popup_submitted");
|
|
2929
|
+
if (result.popup_submission_recorded !== true) emitPopup("popup_submitted");
|
|
2929
2930
|
await completeVisitor(session?.anonymous_id);
|
|
2930
2931
|
}
|
|
2931
2932
|
return result;
|
|
@@ -2933,8 +2934,8 @@ function createSagepilotWebEvents(options) {
|
|
|
2933
2934
|
/** Verifies proof behind a capture fence; buffered anonymous observations remain anonymous. */
|
|
2934
2935
|
async verifyContact(challengeId, code) {
|
|
2935
2936
|
const anonymousId = client.session()?.anonymous_id;
|
|
2936
|
-
await changeIdentity(() => client.verifyContact(challengeId, code));
|
|
2937
|
-
emitPopup("popup_submitted");
|
|
2937
|
+
const session = await changeIdentity(() => client.verifyContact(challengeId, code));
|
|
2938
|
+
if (session.popup_submission_recorded !== true) emitPopup("popup_submitted");
|
|
2938
2939
|
await completeVisitor(anonymousId);
|
|
2939
2940
|
},
|
|
2940
2941
|
/** Applies an explicit logout boundary without relabeling earlier observations. */
|