@sightspool/sdk 0.1.0
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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +192 -0
- package/dist/chunk-4PADVIIO.js +41 -0
- package/dist/chunk-4PADVIIO.js.map +1 -0
- package/dist/index.cjs +813 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +607 -0
- package/dist/index.js.map +1 -0
- package/dist/prompt-GDFYC75D.js +139 -0
- package/dist/prompt-GDFYC75D.js.map +1 -0
- package/dist/sdk.global.js +21 -0
- package/dist/sdk.global.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Sightspool
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @sightspool/sdk
|
|
2
|
+
|
|
3
|
+
In-product capture for [Sightspool](https://github.com/sightspool). Drop it into your web app and
|
|
4
|
+
it captures, **at the moment of friction**, what a user was trying to do (*intent*),
|
|
5
|
+
how hard it was (*effort*), and the account behind it — emitting one linked **Signal**
|
|
6
|
+
into your Sightspool workspace.
|
|
7
|
+
|
|
8
|
+
It's the one source of data that exists nowhere else: the *silent failures* (the user
|
|
9
|
+
who calmly couldn't do the thing, hit no error, filed no ticket, and left) and the
|
|
10
|
+
*unmet demand* (goals your product has no path for, so no funnel or error ever records
|
|
11
|
+
them).
|
|
12
|
+
|
|
13
|
+
> **Status:** v0.1, collect-side. The SDK *senses* — it captures and analyses. It does
|
|
14
|
+
> **not** act on your surface (surveys/nudges/experiments are Wave 0005, and every one
|
|
15
|
+
> is human-gated). Trigger sensitivity and intent inference calibrate with live traffic.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Install — two lines
|
|
20
|
+
|
|
21
|
+
### npm / bundler
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @sightspool/sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import Sightspool from '@sightspool/sdk'
|
|
29
|
+
|
|
30
|
+
Sightspool.init({ key: 'pk_live_…' })
|
|
31
|
+
|
|
32
|
+
// once you know who the user is:
|
|
33
|
+
Sightspool.identify(currentUser.id, { account: 'Vertex Logistics', plan: 'growth' })
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`init` boots passive capture immediately. `identify` attaches the user to an **account**
|
|
37
|
+
and **plan** — the only required wiring, and it's what lets Sightspool rank by customer
|
|
38
|
+
(and, with a connected billing source, by MRR). Most apps already make an equivalent
|
|
39
|
+
call for their analytics/support tools.
|
|
40
|
+
|
|
41
|
+
### Script tag (no build step)
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<script
|
|
45
|
+
async
|
|
46
|
+
src="https://app.sightspool.com/sdk.global.js"
|
|
47
|
+
data-sightspool-key="pk_live_…"
|
|
48
|
+
></script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The tag auto-`init`s from its `data-sightspool-key`. Call `identify` once the user is
|
|
52
|
+
known:
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<script>
|
|
56
|
+
window.Sightspool && window.Sightspool.identify(userId, { account, plan })
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
(Loading the script before `Sightspool` is defined? Calls are safe to make against
|
|
61
|
+
`window.Sightspool` once the script has loaded; until then, guard with `&&` as above.)
|
|
62
|
+
|
|
63
|
+
The script tag also reads these optional attributes (the no-build equivalent of the
|
|
64
|
+
`init` options — comma-separate selector lists):
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<script
|
|
68
|
+
async
|
|
69
|
+
src="https://app.sightspool.com/sdk.global.js"
|
|
70
|
+
data-sightspool-key="pk_live_…"
|
|
71
|
+
data-sightspool-block=".billing-panel, [data-private]"
|
|
72
|
+
data-sightspool-redact=".customer-name"
|
|
73
|
+
data-sightspool-debug
|
|
74
|
+
data-sightspool-capture-localhost
|
|
75
|
+
></script>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Configuration
|
|
81
|
+
|
|
82
|
+
`init(config)` — all optional except `key`:
|
|
83
|
+
|
|
84
|
+
| option | type | default | purpose |
|
|
85
|
+
|---|---|---|---|
|
|
86
|
+
| `key` | `string` | — | **required.** Your publishable key (`pk_live_…`), from the Connections → In-product SDK card. Publishable — safe to ship in client JS. |
|
|
87
|
+
| `endpoint` | `string` | the bundle's origin (script tag) / `https://app.sightspool.com` (npm) | Ingest base URL. The `<script>` install auto-resolves it to wherever `sdk.global.js` was served from (your app), so the key alone is enough; override for a CDN-hosted bundle or dev. |
|
|
88
|
+
| `boundaryAsk` | `boolean` | `true` | Show the one-tap "did you do what you came to do?" ask at session boundaries. |
|
|
89
|
+
| `consent` | `boolean` | `true` | Start capturing immediately. Set `false` to stay paused until you call `Sightspool.consent(true)` (or `start()`) after obtaining consent. |
|
|
90
|
+
| `redact` | `string[]` | `[]` | CSS selectors whose captured text is **masked** (replaced with `‹redacted›`) before anything leaves the page. The event is still recorded — only its label is masked. |
|
|
91
|
+
| `block` | `string[]` | `[]` | CSS selectors whose events are **dropped entirely** (the hard opt-out). Equivalent to putting `data-sightspool-ignore` on the element. |
|
|
92
|
+
| `captureOnLocalhost` | `boolean` | `false` | By default the SDK **no-ops on localhost** (`localhost`, `127.0.0.1`, `*.local`, `*.localhost`) so your `npm run dev` traffic never pollutes analytics. Set `true` to capture locally (e.g. to test the install). |
|
|
93
|
+
| `debug` | `boolean` | `false` | Log every capture decision to the console (`[sightspool] …`) so you can watch it work. |
|
|
94
|
+
|
|
95
|
+
Server-side config (allowed CORS origins, additional redaction rules) lives on the
|
|
96
|
+
Connections card and is enforced at ingest — the key alone can't post from an
|
|
97
|
+
un-allowlisted origin.
|
|
98
|
+
|
|
99
|
+
### Privacy controls at a glance
|
|
100
|
+
|
|
101
|
+
| You want to… | Use |
|
|
102
|
+
|---|---|
|
|
103
|
+
| Never capture a subtree (e.g. a billing panel) | `data-sightspool-ignore` on the element, or a `block` selector |
|
|
104
|
+
| Mask a field's text but still log the interaction | a `redact` selector (text → `‹redacted›`) |
|
|
105
|
+
| Wait for cookie-banner consent | init `{ consent: false }` then `Sightspool.consent(true)` |
|
|
106
|
+
| Keep dev traffic out of analytics | nothing — localhost is suppressed by default |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## What it captures
|
|
111
|
+
|
|
112
|
+
- **Passively, no wiring** — route/screen sequence, clicks, **dead-clicks** and
|
|
113
|
+
**rage-clicks**, client-side errors and failed requests, and a rolling trail of the
|
|
114
|
+
last meaningful events.
|
|
115
|
+
- **Stated intent** — typed queries in search / filter / command-palette / empty-state
|
|
116
|
+
inputs, especially **zero-result** searches (the highest-signal intent, no question).
|
|
117
|
+
- **The one-tap ask** (at a session boundary or after detected friction, rate-limited
|
|
118
|
+
and fatigue-aware): *"Were you able to do what you came here to do today?"* → on "Not
|
|
119
|
+
really," a short shortlist of likely goals + an always-present "Something else."
|
|
120
|
+
|
|
121
|
+
Each capture emits one **Signal** (`intent + path + account + effort`). Intent and
|
|
122
|
+
effort are *constructed* server-side with calibrated confidence — the SDK ships the
|
|
123
|
+
raw trace and the answer; it never guesses.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Safety & privacy
|
|
128
|
+
|
|
129
|
+
Privacy-conscious **by default** — these are on without any config:
|
|
130
|
+
|
|
131
|
+
- **PII is masked before it leaves the page.** Emails and long digit runs (card /
|
|
132
|
+
account-number-ish) in any captured label are replaced with `‹email›` / `‹num›`.
|
|
133
|
+
Password, email, `tel`, and credit-card inputs are dropped entirely — their values
|
|
134
|
+
are **never** captured.
|
|
135
|
+
- **No cookies, no `localStorage`, no raw keystrokes.** The SDK reads none of them. It
|
|
136
|
+
captures *debounced* search-input values (stated intent) and interaction events — not
|
|
137
|
+
a keylog.
|
|
138
|
+
- **You control the rest.** Drop any subtree with `data-sightspool-ignore` or a `block`
|
|
139
|
+
selector; mask a field's text with a `redact` selector; gate everything behind
|
|
140
|
+
`Sightspool.consent(false)` until your cookie banner says otherwise.
|
|
141
|
+
- **Suppressed on localhost** so dev traffic never pollutes analytics (opt back in with
|
|
142
|
+
`captureOnLocalhost`).
|
|
143
|
+
|
|
144
|
+
And the engineering guarantees:
|
|
145
|
+
|
|
146
|
+
- **Never throws into your app.** Every path is wrapped; capture degrades silently
|
|
147
|
+
(no Signal is worth a broken host UI).
|
|
148
|
+
- **Tiny + non-blocking.** The prompt UI lazy-loads into a shadow root, so it can't be
|
|
149
|
+
styled-broken by your CSS and adds ~nothing to your bundle until it's needed.
|
|
150
|
+
- **Processor posture.** Sightspool processes on your behalf; the prompt discloses that
|
|
151
|
+
diagnostic context is attached.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## API
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
Sightspool.init(config: SightspoolConfig): void
|
|
159
|
+
Sightspool.identify(userId: string, traits?: { account?: string; plan?: string }): void
|
|
160
|
+
Sightspool.consent(granted: boolean): void // runtime consent toggle (wire to your cookie banner)
|
|
161
|
+
Sightspool.start(): void // begin capture if init'd with { consent: false } (alias of consent(true))
|
|
162
|
+
Sightspool.stop(): void // pause capture and flush (alias of consent(false))
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Roadmap (not yet built)
|
|
168
|
+
|
|
169
|
+
Deliberately deferred from the v1 collect side. Most are **data-gated** — they need real
|
|
170
|
+
traffic to calibrate, so they wait for the first production installs.
|
|
171
|
+
|
|
172
|
+
- **Server-LLM State-B candidates** (`/api/sdk/candidates`). Today the prompt's candidate goals
|
|
173
|
+
are derived **locally** (recent search query + page label) — instant and free, but shallow. A
|
|
174
|
+
server endpoint would generate sharper candidates in the app's own feature vocabulary, at the
|
|
175
|
+
cost of a per-prompt round-trip; it must fall back to the local/generic ask within a tight
|
|
176
|
+
latency budget.
|
|
177
|
+
- **Adaptive micro-interview** on high-value / high-MRR friction — a short, session-grounded,
|
|
178
|
+
agent-authored follow-up beyond the one-tap default, under the same fatigue caps.
|
|
179
|
+
- **Reliable zero-result detection.** v1 harvests the typed query; flagging it as *zero-result*
|
|
180
|
+
(the highest-signal intent) is best-effort and needs per-app empty-state hints.
|
|
181
|
+
- **Server-to-server signed (HMAC) ingest** — for non-browser / backend Signal sources (the
|
|
182
|
+
publishable-key + origin-allowlist posture is browser-only).
|
|
183
|
+
- **Mobile / native SDK** — web-first for now.
|
|
184
|
+
|
|
185
|
+
## Develop
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pnpm install
|
|
189
|
+
pnpm build # tsup → dist/ (ESM + CJS + types + dist/sdk.global.js)
|
|
190
|
+
pnpm type-check
|
|
191
|
+
pnpm test # node --test over the pure cores
|
|
192
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/privacy.ts
|
|
2
|
+
var EMAIL_RE = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g;
|
|
3
|
+
var LONG_DIGITS_RE = /\d{6,}/g;
|
|
4
|
+
var MAX_LABEL_LEN = 280;
|
|
5
|
+
function redactText(input) {
|
|
6
|
+
if (!input) return "";
|
|
7
|
+
try {
|
|
8
|
+
return String(input).replace(EMAIL_RE, "\u2039email\u203A").replace(LONG_DIGITS_RE, "\u2039num\u203A").replace(/\s+/g, " ").trim().slice(0, MAX_LABEL_LEN);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
var ATTACH_DISCLOSURE = "Session and account attached automatically.";
|
|
14
|
+
var REDACTED = "\u2039redacted\u203A";
|
|
15
|
+
var IGNORE_ATTR = "data-sightspool-ignore";
|
|
16
|
+
function safeClosest(el, selector) {
|
|
17
|
+
try {
|
|
18
|
+
return typeof el.closest === "function" && el.closest(selector) != null;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function isIgnoredElement(el, blockSelectors = []) {
|
|
24
|
+
if (!el || typeof el.closest !== "function") return false;
|
|
25
|
+
if (safeClosest(el, `[${IGNORE_ATTR}]`)) return true;
|
|
26
|
+
for (const sel of blockSelectors) {
|
|
27
|
+
if (sel && safeClosest(el, sel)) return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
function matchesRedactSelector(el, redactSelectors = []) {
|
|
32
|
+
if (!el || typeof el.closest !== "function") return false;
|
|
33
|
+
for (const sel of redactSelectors) {
|
|
34
|
+
if (sel && safeClosest(el, sel)) return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { ATTACH_DISCLOSURE, REDACTED, isIgnoredElement, matchesRedactSelector, redactText };
|
|
40
|
+
//# sourceMappingURL=chunk-4PADVIIO.js.map
|
|
41
|
+
//# sourceMappingURL=chunk-4PADVIIO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/privacy.ts"],"names":[],"mappings":";AAIA,IAAM,QAAA,GAAW,iDAAA;AACjB,IAAM,cAAA,GAAiB,SAAA;AAEhB,IAAM,aAAA,GAAgB,GAAA;AAMtB,SAAS,WAAW,KAAA,EAA0C;AACnE,EAAA,IAAI,CAAC,OAAO,OAAO,EAAA;AACnB,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,KAAK,CAAA,CAChB,QAAQ,QAAA,EAAU,mBAAS,EAC3B,OAAA,CAAQ,cAAA,EAAgB,iBAAO,CAAA,CAC/B,OAAA,CAAQ,QAAQ,GAAG,CAAA,CACnB,MAAK,CACL,KAAA,CAAM,GAAG,aAAa,CAAA;AAAA,EAC3B,CAAA,CAAA,OAAQ,CAAA,EAAA;AACN,IAAA,OAAO,EAAA;AAAA,EACT;AACF;AAQO,IAAM,iBAAA,GAAoB;AAG1B,IAAM,QAAA,GAAW;AAGjB,IAAM,WAAA,GAAc,wBAAA;AAK3B,SAAS,WAAA,CAAY,IAAe,QAAA,EAA2B;AAC7D,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,EAAA,CAAG,OAAA,KAAY,cAAc,EAAA,CAAG,OAAA,CAAQ,QAAQ,CAAA,IAAK,IAAA;AAAA,EACrE,CAAA,CAAA,OAAQ,CAAA,EAAA;AAIN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAOO,SAAS,gBAAA,CACd,EAAA,EACA,cAAA,GAAoC,EAAC,EAC5B;AACT,EAAA,IAAI,CAAC,EAAA,IAAM,OAAO,EAAA,CAAG,OAAA,KAAY,YAAY,OAAO,KAAA;AACpD,EAAA,IAAI,YAAY,EAAA,EAAI,CAAA,CAAA,EAAI,WAAW,CAAA,CAAA,CAAG,GAAG,OAAO,IAAA;AAChD,EAAA,KAAA,MAAW,OAAO,cAAA,EAAgB;AAChC,IAAA,IAAI,GAAA,IAAO,WAAA,CAAY,EAAA,EAAI,GAAG,GAAG,OAAO,IAAA;AAAA,EAC1C;AACA,EAAA,OAAO,KAAA;AACT;AAOO,SAAS,qBAAA,CACd,EAAA,EACA,eAAA,GAAqC,EAAC,EAC7B;AACT,EAAA,IAAI,CAAC,EAAA,IAAM,OAAO,EAAA,CAAG,OAAA,KAAY,YAAY,OAAO,KAAA;AACpD,EAAA,KAAA,MAAW,OAAO,eAAA,EAAiB;AACjC,IAAA,IAAI,GAAA,IAAO,WAAA,CAAY,EAAA,EAAI,GAAG,GAAG,OAAO,IAAA;AAAA,EAC1C;AACA,EAAA,OAAO,KAAA;AACT","file":"chunk-4PADVIIO.js","sourcesContent":["// Redaction — mask sensitive text before it ever leaves the page (GOV-3). The\n// pure string helpers are unit-tested; the DOM-querying part (selector masking)\n// lives in capture.ts and calls in here.\n\nconst EMAIL_RE = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}/g;\nconst LONG_DIGITS_RE = /\\d{6,}/g; // card / account-number-ish runs\n\nexport const MAX_LABEL_LEN = 280;\n\n/**\n * Mask PII-ish substrings in a captured label/verbatim and clamp length.\n * Conservative: emails and long digit runs become placeholders. Never throws.\n */\nexport function redactText(input: string | null | undefined): string {\n if (!input) return \"\";\n try {\n return String(input)\n .replace(EMAIL_RE, \"‹email›\")\n .replace(LONG_DIGITS_RE, \"‹num›\")\n .replace(/\\s+/g, \" \")\n .trim()\n .slice(0, MAX_LABEL_LEN);\n } catch {\n return \"\";\n }\n}\n\n/** Should a captured element's value be dropped entirely (not just masked)? */\nexport function isSensitiveInput(type: string | null | undefined): boolean {\n const t = (type ?? \"\").toLowerCase();\n return t === \"password\" || t === \"email\" || t === \"tel\" || t === \"creditcard\";\n}\n\nexport const ATTACH_DISCLOSURE = \"Session and account attached automatically.\";\n\n/** Placeholder substituted for the text of a `redact`-matched element (GOV-3). */\nexport const REDACTED = \"‹redacted›\";\n\n/** The per-element opt-out attribute: a click/input inside `[data-sightspool-ignore]` is dropped entirely. */\nexport const IGNORE_ATTR = \"data-sightspool-ignore\";\n\n/** Anything with a `.closest(selector)` — the bit of Element we depend on (kept DOM-free for unit tests). */\ntype Closeable = { closest?: (selectors: string) => unknown };\n\nfunction safeClosest(el: Closeable, selector: string): boolean {\n try {\n return typeof el.closest === \"function\" && el.closest(selector) != null;\n } catch {\n // An invalid selector (host misconfig) must never throw into capture — and must\n // never *accidentally capture* what was meant to be excluded: treat as no-match\n // for that one selector and let the others decide.\n return false;\n }\n}\n\n/**\n * Should this element's events be dropped entirely (not just masked)? True when the\n * element — or any ancestor — carries `data-sightspool-ignore` or matches one of the\n * configured `block` selectors. The host's hard privacy opt-out (GOV-3).\n */\nexport function isIgnoredElement(\n el: Closeable | null | undefined,\n blockSelectors: readonly string[] = [],\n): boolean {\n if (!el || typeof el.closest !== \"function\") return false;\n if (safeClosest(el, `[${IGNORE_ATTR}]`)) return true;\n for (const sel of blockSelectors) {\n if (sel && safeClosest(el, sel)) return true;\n }\n return false;\n}\n\n/**\n * Should this element's captured text be masked wholesale? True when the element —\n * or any ancestor — matches one of the configured `redact` selectors. (The event is\n * still recorded; only its label becomes {@link REDACTED}.)\n */\nexport function matchesRedactSelector(\n el: Closeable | null | undefined,\n redactSelectors: readonly string[] = [],\n): boolean {\n if (!el || typeof el.closest !== \"function\") return false;\n for (const sel of redactSelectors) {\n if (sel && safeClosest(el, sel)) return true;\n }\n return false;\n}\n"]}
|