@sagepilot-ai/web-events-addon 0.0.0-stage → 0.2.1
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 +122 -2
- package/dist/index.cjs +2931 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +91 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +2904 -0
- package/dist/index.js.map +1 -0
- package/dist/sagepilot-web-events.global.js +2930 -0
- package/dist/sagepilot-web-events.global.js.map +1 -0
- package/package.json +33 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
type SagepilotInstallationOwner = {
|
|
2
|
+
session_id: string;
|
|
3
|
+
customer_id: string | null;
|
|
4
|
+
};
|
|
5
|
+
type SagepilotContactInput = {
|
|
6
|
+
submission_id: string;
|
|
7
|
+
popup_revision: number;
|
|
8
|
+
name?: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
phone?: string;
|
|
11
|
+
marketing_consent: boolean;
|
|
12
|
+
};
|
|
13
|
+
type SagepilotContactResult = {
|
|
14
|
+
status: "verification_required" | "recorded";
|
|
15
|
+
challenge_id?: string;
|
|
16
|
+
expires_at?: string;
|
|
17
|
+
};
|
|
18
|
+
type SagepilotSDKObservation = {
|
|
19
|
+
event_id: string;
|
|
20
|
+
kind: "navigation" | "interaction" | "network" | "lifecycle" | "screen";
|
|
21
|
+
occurred_at: string;
|
|
22
|
+
owner: SagepilotInstallationOwner & {
|
|
23
|
+
identity_epoch: string;
|
|
24
|
+
};
|
|
25
|
+
data: Record<string, unknown>;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type ObservationKey = Pick<SagepilotSDKObservation, "event_id" | "owner">;
|
|
30
|
+
type JournalRecord<T> = {
|
|
31
|
+
id: string;
|
|
32
|
+
value: T;
|
|
33
|
+
bytes: number;
|
|
34
|
+
expires: number;
|
|
35
|
+
purge?: string;
|
|
36
|
+
};
|
|
37
|
+
type JournalDiagnostics = {
|
|
38
|
+
storage: "indexeddb" | "localStorage" | "memory";
|
|
39
|
+
pending_records: number;
|
|
40
|
+
pending_bytes: number;
|
|
41
|
+
memory_only_records: number;
|
|
42
|
+
quota_evicted: number;
|
|
43
|
+
expired_records: number;
|
|
44
|
+
storage_failures: number;
|
|
45
|
+
};
|
|
46
|
+
/** Opens a bounded journal with a small durable fallback for browsers that deny IndexedDB. */
|
|
47
|
+
declare function createJournal<T extends ObservationKey>(scope: string): {
|
|
48
|
+
/** Coalesces queued captures into one disk transaction while preserving the capture order. */
|
|
49
|
+
append(record: JournalRecord<T>): Promise<void>;
|
|
50
|
+
/** Selects a bounded upload batch without removing unacknowledged records. */
|
|
51
|
+
batch(): Promise<T[]>;
|
|
52
|
+
/** Deletes only terminal receipt IDs from memory and any writable journal. */
|
|
53
|
+
acknowledge(ids: Set<string>): Promise<void>;
|
|
54
|
+
/** Purges evidence and fences the old generation if an inaccessible IndexedDB returns later. */
|
|
55
|
+
clear(): Promise<void>;
|
|
56
|
+
/** Reports known storage limits without exposing evidence or credentials. */
|
|
57
|
+
diagnostics(): JournalDiagnostics;
|
|
58
|
+
/** Closes browser handles after earlier writes settle. */
|
|
59
|
+
close(): Promise<void>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
type SagepilotWebEventsOptions = {
|
|
63
|
+
key: string;
|
|
64
|
+
/** HTTPS gateway origin; loopback origins are supported for local development. */
|
|
65
|
+
apiHost?: string;
|
|
66
|
+
/** Explicit website collection permission; capture is off by default. */
|
|
67
|
+
collectionEnabled?: boolean;
|
|
68
|
+
/** Optional custom transport for first-party requests and local integration fixtures. */
|
|
69
|
+
fetch?: typeof fetch;
|
|
70
|
+
onError?: (error: unknown) => void;
|
|
71
|
+
};
|
|
72
|
+
type SagepilotWebEvents = {
|
|
73
|
+
start(): Promise<void>;
|
|
74
|
+
setCollectionEnabled(enabled: boolean): Promise<void>;
|
|
75
|
+
flush(): Promise<void>;
|
|
76
|
+
submitContact(input: SagepilotContactInput): Promise<SagepilotContactResult>;
|
|
77
|
+
verifyContact(challengeId: string, code: string): Promise<void>;
|
|
78
|
+
logout(): Promise<void>;
|
|
79
|
+
refreshConfig(): Promise<void>;
|
|
80
|
+
diagnostics(): ReturnType<ReturnType<typeof createJournal>["diagnostics"]> & {
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
rejected_payloads: number;
|
|
83
|
+
collector_dropped: number;
|
|
84
|
+
anonymous_id_storage: "cookie" | "localStorage" | "memory";
|
|
85
|
+
};
|
|
86
|
+
destroy(): Promise<void>;
|
|
87
|
+
};
|
|
88
|
+
/** Creates or reuses one installation collector; no hooks or HTTP calls run until start(). */
|
|
89
|
+
declare function createSagepilotWebEvents(options: SagepilotWebEventsOptions): SagepilotWebEvents;
|
|
90
|
+
|
|
91
|
+
export { type SagepilotWebEvents, type SagepilotWebEventsOptions, createSagepilotWebEvents };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
type SagepilotInstallationOwner = {
|
|
2
|
+
session_id: string;
|
|
3
|
+
customer_id: string | null;
|
|
4
|
+
};
|
|
5
|
+
type SagepilotContactInput = {
|
|
6
|
+
submission_id: string;
|
|
7
|
+
popup_revision: number;
|
|
8
|
+
name?: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
phone?: string;
|
|
11
|
+
marketing_consent: boolean;
|
|
12
|
+
};
|
|
13
|
+
type SagepilotContactResult = {
|
|
14
|
+
status: "verification_required" | "recorded";
|
|
15
|
+
challenge_id?: string;
|
|
16
|
+
expires_at?: string;
|
|
17
|
+
};
|
|
18
|
+
type SagepilotSDKObservation = {
|
|
19
|
+
event_id: string;
|
|
20
|
+
kind: "navigation" | "interaction" | "network" | "lifecycle" | "screen";
|
|
21
|
+
occurred_at: string;
|
|
22
|
+
owner: SagepilotInstallationOwner & {
|
|
23
|
+
identity_epoch: string;
|
|
24
|
+
};
|
|
25
|
+
data: Record<string, unknown>;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type ObservationKey = Pick<SagepilotSDKObservation, "event_id" | "owner">;
|
|
30
|
+
type JournalRecord<T> = {
|
|
31
|
+
id: string;
|
|
32
|
+
value: T;
|
|
33
|
+
bytes: number;
|
|
34
|
+
expires: number;
|
|
35
|
+
purge?: string;
|
|
36
|
+
};
|
|
37
|
+
type JournalDiagnostics = {
|
|
38
|
+
storage: "indexeddb" | "localStorage" | "memory";
|
|
39
|
+
pending_records: number;
|
|
40
|
+
pending_bytes: number;
|
|
41
|
+
memory_only_records: number;
|
|
42
|
+
quota_evicted: number;
|
|
43
|
+
expired_records: number;
|
|
44
|
+
storage_failures: number;
|
|
45
|
+
};
|
|
46
|
+
/** Opens a bounded journal with a small durable fallback for browsers that deny IndexedDB. */
|
|
47
|
+
declare function createJournal<T extends ObservationKey>(scope: string): {
|
|
48
|
+
/** Coalesces queued captures into one disk transaction while preserving the capture order. */
|
|
49
|
+
append(record: JournalRecord<T>): Promise<void>;
|
|
50
|
+
/** Selects a bounded upload batch without removing unacknowledged records. */
|
|
51
|
+
batch(): Promise<T[]>;
|
|
52
|
+
/** Deletes only terminal receipt IDs from memory and any writable journal. */
|
|
53
|
+
acknowledge(ids: Set<string>): Promise<void>;
|
|
54
|
+
/** Purges evidence and fences the old generation if an inaccessible IndexedDB returns later. */
|
|
55
|
+
clear(): Promise<void>;
|
|
56
|
+
/** Reports known storage limits without exposing evidence or credentials. */
|
|
57
|
+
diagnostics(): JournalDiagnostics;
|
|
58
|
+
/** Closes browser handles after earlier writes settle. */
|
|
59
|
+
close(): Promise<void>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
type SagepilotWebEventsOptions = {
|
|
63
|
+
key: string;
|
|
64
|
+
/** HTTPS gateway origin; loopback origins are supported for local development. */
|
|
65
|
+
apiHost?: string;
|
|
66
|
+
/** Explicit website collection permission; capture is off by default. */
|
|
67
|
+
collectionEnabled?: boolean;
|
|
68
|
+
/** Optional custom transport for first-party requests and local integration fixtures. */
|
|
69
|
+
fetch?: typeof fetch;
|
|
70
|
+
onError?: (error: unknown) => void;
|
|
71
|
+
};
|
|
72
|
+
type SagepilotWebEvents = {
|
|
73
|
+
start(): Promise<void>;
|
|
74
|
+
setCollectionEnabled(enabled: boolean): Promise<void>;
|
|
75
|
+
flush(): Promise<void>;
|
|
76
|
+
submitContact(input: SagepilotContactInput): Promise<SagepilotContactResult>;
|
|
77
|
+
verifyContact(challengeId: string, code: string): Promise<void>;
|
|
78
|
+
logout(): Promise<void>;
|
|
79
|
+
refreshConfig(): Promise<void>;
|
|
80
|
+
diagnostics(): ReturnType<ReturnType<typeof createJournal>["diagnostics"]> & {
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
rejected_payloads: number;
|
|
83
|
+
collector_dropped: number;
|
|
84
|
+
anonymous_id_storage: "cookie" | "localStorage" | "memory";
|
|
85
|
+
};
|
|
86
|
+
destroy(): Promise<void>;
|
|
87
|
+
};
|
|
88
|
+
/** Creates or reuses one installation collector; no hooks or HTTP calls run until start(). */
|
|
89
|
+
declare function createSagepilotWebEvents(options: SagepilotWebEventsOptions): SagepilotWebEvents;
|
|
90
|
+
|
|
91
|
+
export { type SagepilotWebEvents, type SagepilotWebEventsOptions, createSagepilotWebEvents };
|