@lucida-analytics/browser 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +232 -2
- package/dist/autocapture.d.ts +78 -0
- package/dist/autocapture.js +1 -0
- package/dist/banner-2TSKJ4WK.js +1 -0
- package/dist/chunk-32K5P5GN.js +1 -0
- package/dist/chunk-AWIQCFGN.js +1 -0
- package/dist/chunk-FUE3SDQU.js +1 -0
- package/dist/chunk-NIDQQHZJ.js +1 -0
- package/dist/chunk-O4W7SZ2X.js +1 -0
- package/dist/client-BUpBXyOh.d.ts +8 -0
- package/dist/consent.d.ts +95 -0
- package/dist/consent.js +1 -0
- package/dist/core.d.ts +9 -0
- package/dist/core.js +3 -0
- package/dist/correlate.d.ts +15 -0
- package/dist/correlate.js +1 -0
- package/dist/early-access.d.ts +12 -0
- package/dist/early-access.js +1 -0
- package/dist/experiments.d.ts +199 -0
- package/dist/experiments.js +1 -0
- package/dist/flags.d.ts +13 -0
- package/dist/flags.js +3 -0
- package/dist/forms.d.ts +13 -0
- package/dist/forms.js +1 -0
- package/dist/guides.d.ts +1196 -0
- package/dist/guides.js +1 -0
- package/dist/heatmaps.d.ts +19 -0
- package/dist/heatmaps.js +1 -0
- package/dist/host-headers.d.ts +16 -0
- package/dist/host-headers.js +1 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +3 -0
- package/dist/inspector.d.ts +13 -0
- package/dist/inspector.js +1 -0
- package/dist/lucida.js +3 -0
- package/dist/modules-FANMZRDJ.js +1 -0
- package/dist/persistent-SLVINN5A.js +1 -0
- package/dist/recommendations.d.ts +2 -0
- package/dist/recommendations.js +1 -0
- package/dist/recorder-3YIZ6OKD.js +78 -0
- package/dist/replay.d.ts +18 -0
- package/dist/replay.js +1 -0
- package/dist/static/v0/autocapture.js +1 -0
- package/dist/static/v0/banner-2TSKJ4WK.js +1 -0
- package/dist/static/v0/chunk-32K5P5GN.js +1 -0
- package/dist/static/v0/chunk-AWIQCFGN.js +1 -0
- package/dist/static/v0/chunk-FUE3SDQU.js +1 -0
- package/dist/static/v0/chunk-NIDQQHZJ.js +1 -0
- package/dist/static/v0/chunk-O4W7SZ2X.js +1 -0
- package/dist/static/v0/consent.js +1 -0
- package/dist/static/v0/core.js +3 -0
- package/dist/static/v0/correlate.js +1 -0
- package/dist/static/v0/early-access.js +1 -0
- package/dist/static/v0/experiments.js +1 -0
- package/dist/static/v0/flags.js +3 -0
- package/dist/static/v0/forms.js +1 -0
- package/dist/static/v0/guides.js +1 -0
- package/dist/static/v0/heatmaps.js +1 -0
- package/dist/static/v0/host-headers.js +1 -0
- package/dist/static/v0/index.js +3 -0
- package/dist/static/v0/inspector.js +1 -0
- package/dist/static/v0/lucida.js +3 -0
- package/dist/static/v0/modules-FANMZRDJ.js +1 -0
- package/dist/static/v0/persistent-SLVINN5A.js +1 -0
- package/dist/static/v0/recommendations.js +1 -0
- package/dist/static/v0/recorder-3YIZ6OKD.js +78 -0
- package/dist/static/v0/replay.js +1 -0
- package/dist/static/v0/toolbar.js +4 -0
- package/dist/static/v0/validation-HGJXZ553.js +1 -0
- package/dist/static/v0/webmcp.js +1 -0
- package/dist/static/v0.1.1/autocapture.js +1 -0
- package/dist/static/v0.1.1/banner-2TSKJ4WK.js +1 -0
- package/dist/static/v0.1.1/chunk-32K5P5GN.js +1 -0
- package/dist/static/v0.1.1/chunk-AWIQCFGN.js +1 -0
- package/dist/static/v0.1.1/chunk-FUE3SDQU.js +1 -0
- package/dist/static/v0.1.1/chunk-NIDQQHZJ.js +1 -0
- package/dist/static/v0.1.1/chunk-O4W7SZ2X.js +1 -0
- package/dist/static/v0.1.1/consent.js +1 -0
- package/dist/static/v0.1.1/core.js +3 -0
- package/dist/static/v0.1.1/correlate.js +1 -0
- package/dist/static/v0.1.1/early-access.js +1 -0
- package/dist/static/v0.1.1/experiments.js +1 -0
- package/dist/static/v0.1.1/flags.js +3 -0
- package/dist/static/v0.1.1/forms.js +1 -0
- package/dist/static/v0.1.1/guides.js +1 -0
- package/dist/static/v0.1.1/heatmaps.js +1 -0
- package/dist/static/v0.1.1/host-headers.js +1 -0
- package/dist/static/v0.1.1/index.js +3 -0
- package/dist/static/v0.1.1/inspector.js +1 -0
- package/dist/static/v0.1.1/integrity.json +30 -0
- package/dist/static/v0.1.1/lucida.js +3 -0
- package/dist/static/v0.1.1/modules-FANMZRDJ.js +1 -0
- package/dist/static/v0.1.1/persistent-SLVINN5A.js +1 -0
- package/dist/static/v0.1.1/recommendations.js +1 -0
- package/dist/static/v0.1.1/recorder-3YIZ6OKD.js +78 -0
- package/dist/static/v0.1.1/replay.js +1 -0
- package/dist/static/v0.1.1/toolbar.js +4 -0
- package/dist/static/v0.1.1/validation-HGJXZ553.js +1 -0
- package/dist/static/v0.1.1/webmcp.js +1 -0
- package/dist/toolbar.d.ts +193 -0
- package/dist/toolbar.js +4 -0
- package/dist/types-BtvrrgrR.d.ts +932 -0
- package/dist/types-CLEZS45j.d.ts +1109 -0
- package/dist/validation-HGJXZ553.js +1 -0
- package/dist/webmcp.d.ts +21 -0
- package/dist/webmcp.js +1 -0
- package/package.json +104 -3
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 [yyyy] [name of copyright owner]
|
|
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/README.md
CHANGED
|
@@ -1,3 +1,233 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lucida-analytics/browser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Browser SDK: core client plus opt-in modules (each its own entry, tree-shakeable).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createClient, autocapture } from "@lucida-analytics/browser";
|
|
7
|
+
import { replay } from "@lucida-analytics/browser/replay"; // loader only; rrweb loads lazily
|
|
8
|
+
import { heatmaps } from "@lucida-analytics/browser/heatmaps";
|
|
9
|
+
import { forms } from "@lucida-analytics/browser/forms";
|
|
10
|
+
createClient("lc_pk_...", { apiHost: "https://ingest.example.com" }, [autocapture, heatmaps, forms, replay]);
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Privacy defaults: inputs masked in replay, no form values ever collected, consent respected
|
|
14
|
+
before any storage write. `[data-lc-ignore]` hides a subtree from every module,
|
|
15
|
+
`[data-lc-mask]` masks text in replay, `[data-lc-block]` replaces an element with a placeholder.
|
|
16
|
+
`replay: { mask_all_text: true, unmask_selectors: [".menu"] }` masks every text node and text attribute in the browser except
|
|
17
|
+
inside `[data-lc-unmask]` or the unmask list (a mask selector inside still wins); the project setting `replay_mask_all_text` forces it on.
|
|
18
|
+
|
|
19
|
+
## Wire contract
|
|
20
|
+
|
|
21
|
+
- **Replay**: `POST /v1/replay?compression=gzip`, body `{api_key, session_id, window_id, seq, events}`;
|
|
22
|
+
`seq` is monotonic per window and resets when the session rotates. The gateway accepts up to
|
|
23
|
+
10 MB decompressed (full DOM snapshots); the SDK drops a single event above that. A custom
|
|
24
|
+
rrweb event `page_height` carries the document height for scroll-depth math.
|
|
25
|
+
- **Clicks** (`$autocapture`): `$selector`, `$el_interactive`, `$click_x/$click_y` (page px),
|
|
26
|
+
`$click_el_x/$click_el_y`, `$el_width/$el_height`, `$viewport_bucket`. `$rageclick`,
|
|
27
|
+
`$deadclick` and `$frustration` are derived server-side (`selector`, `x_ratio`, `y_px`,
|
|
28
|
+
`viewport_bucket`, `$pathname`); the browser never emits them.
|
|
29
|
+
- **Scroll depth**: `$pageleave` carries `$scroll_depth` (%) and `$scroll_depth_px`.
|
|
30
|
+
- **Forms**: `$form_start {form}`, `$form_field_interact {form, field, interaction_ms,
|
|
31
|
+
refill_count, error}`, `$form_submit {form}`, `$form_abandon {form, last_field}`. `form` and
|
|
32
|
+
`field` are 12-hex hashes of name/id/label; values are never read.
|
|
33
|
+
- **Toolbar**: opens on `?__lc_toolbar=<token>`; the token is stripped from the URL and exchanged
|
|
34
|
+
once at `POST /v1/toolbar/exchange` with `{token, origin}`, returning
|
|
35
|
+
`{token, project_id, scopes, origin, expires_at}`. The returned token is the bearer for
|
|
36
|
+
project-scoped calls (`/v1/projects/{id}/actions`, `/heatmaps`). Rejected token: nothing mounts.
|
|
37
|
+
Launch it from the app (Settings > Toolbar: authorized origins, Launch, bookmarklet) or from code with
|
|
38
|
+
`client.loadToolbar(token)` when your framework rewrites the URL first; `#__lc_toolbar=<token>` in the hash also works.
|
|
39
|
+
Behind a reverse proxy that only forwards capture, set `uiHost` to the Lucida API host the toolbar should call.
|
|
40
|
+
Panels: multi-element **actions** (each picked element is an OR alternative with editable selector, text, link and
|
|
41
|
+
page conditions; `toolbar.dataAttributes` sets the selector's attribute preference) and an overlay of existing
|
|
42
|
+
actions (numbered boxes, counts, edit, delete); **heatmap** (click, rage, dead, move, scrollmap; numbered element
|
|
43
|
+
boxes with click and rage counts, "Create action" from a box, Load more / Load all, match links by URL); **flag
|
|
44
|
+
overrides** (search, on/off or any variant, reload prompt); **event debugger** (local only: search or `/regex/`,
|
|
45
|
+
category, pause, pin, copy, export JSON, relative time). A toolbar `read` member gets a view-only session.
|
|
46
|
+
**CSP**: allow the API host (or `uiHost`) in `connect-src`; the toolbar needs no extra `script-src` (its panels are
|
|
47
|
+
bundled chunks of this SDK) and renders in a shadow root, so `style-src` must permit inline style attributes
|
|
48
|
+
(`'unsafe-inline'` for attributes, or `style-src-attr 'unsafe-inline'`). The in-app heatmap viewer renders a
|
|
49
|
+
recording, not your live site, so it needs no `frame-ancestors` change on your site.
|
|
50
|
+
The **Guide builder** (lazy chunk, LC-ENG-7) picks elements with the inspector (selector preference: `data-lc-id`,
|
|
51
|
+
`data-testid`/`data-test`/`data-cy`/`data-qa`, `#id`, structural), previews with the SDK renderer (no events), and saves via
|
|
52
|
+
`POST/PUT /v1/projects/{id}/guides`. Toolbar sessions carry `guides:write`. All guide kinds are offered, plus an image URL and alt text.
|
|
53
|
+
- **Experiment editor** (lazy chunk, LC-EXT-37): opens on `?__lc_toolbar=<token>&__lc_edit=<experiment id>` (scope `experiments:write`). It picks a variant, records point-and-click changes (optionally for this page only), saves them to a draft experiment and adds click goals. `?lc_preview=<flag>:<variant>` forces a variant for QA without recording exposure.
|
|
54
|
+
- **Banners and changelog** (LC-ENG-8): `banner` guides render top or bottom (`steps[0].placement: "bottom"`), dismissible,
|
|
55
|
+
one engagement at a time via the arbiter. `client.guides.showChangelog()` lists banner guides (returns the count, 0 = none).
|
|
56
|
+
- **Guides depth** (LC-ENG-10 to 18, `@lucida-analytics/browser/guides`): `hotspot`, `beacon`, `badge` and `launcher` guides stay on the
|
|
57
|
+
page (lazy `persistent` chunk). Step `buttons[].goto` / `branch` rules (person properties) jump forward; a step with `url`
|
|
58
|
+
pauses a tour until that page, and tours / checklists resume on the next page (consent-gated storage). Targeting adds
|
|
59
|
+
`devices`, `person_filters`, `group_filters` (from `group(type, key, props)`), `seen_guides` / `not_seen_guides`, `schedule`
|
|
60
|
+
(window, weekdays, local hours), `frequency` and gateway-resolved `cohort_ids` / `exclude_cohort_ids`. Guides sharing `ab_group`
|
|
61
|
+
are A/B variants (`ab_weight`); `holdout_pct` people get `$guide_holdout` and no guide, the control for goal impact.
|
|
62
|
+
`steps[].i18n` picks text by `config.guides.locale`, person property `locale`, then the browser language. Checklist items
|
|
63
|
+
with `complete_on: {event, props?}` tick themselves from captured events, also when the list is not on screen.
|
|
64
|
+
- **Guide behaviour extras** (W11): `branch[].op` also `element_present` / `element_absent` (CSS selector, checked when Next is
|
|
65
|
+
pressed) and `flag_on` / `flag_off` (evaluated flags). Buttons `action: "snooze"` (`snooze_hours` 1..720, kept with the guide
|
|
66
|
+
state and synced across devices), step `advance: "input"` (moves on when the target field fires `change`; the value is never
|
|
67
|
+
read), `auto_close_s` (dismissed with `reason: "auto_close"`), `confetti` on the last step (skipped under reduced motion) and
|
|
68
|
+
`automation: {action: click|focus|fill, selector, value?}` (never on `input[type=password]`, `[data-lc-mask]`, `.lc-mask`,
|
|
69
|
+
`[autocomplete^=cc-]`; values never read). Kinds `carousel` (dot pager, Back / Next, arrow keys, swipe) and `form_validation`
|
|
70
|
+
(`validation: {selector, rules}` checked on blur and submit; a failing submit is held back and only
|
|
71
|
+
`$guide_validation_failed {rule}` is sent, never a value). `appearance.theme_mode` (auto / light / dark) with
|
|
72
|
+
`appearance.dark.tokens` and the gateway-resolved theme `font_family`. Anchored steps that never find their target send
|
|
73
|
+
`$guide_target_missing {step_id, selector}`.
|
|
74
|
+
- **Guide permalinks**: `?lc_guide=<id>` opens that guide at once (no delay) when the gateway served it and its targeting
|
|
75
|
+
passes; the param is stripped with `history.replaceState`, and nothing runs before consent.
|
|
76
|
+
- **Resource-center AI answers**: a `search` module asks `POST /v1/guides/answer` (publishable key; 503 = no LLM, the box hides
|
|
77
|
+
and plain search stays), shows the answer, https citations, suggested guides and Helpful / Not helpful. Each search sends
|
|
78
|
+
`$guide_search {query_length, results, answered, feedback?}`; the query text only with the project setting
|
|
79
|
+
`guide_search_capture_query`.
|
|
80
|
+
- **Guides in iframes**: in a child frame set `guides.renderInTop: "https://app.example.com"` (the top origin); in the top
|
|
81
|
+
window set `guides.frameOrigins: ["https://embed.example.com"]`. The child keeps targeting, state and events and posts its
|
|
82
|
+
guides to the top window, which draws them over the whole page with target rects mapped through the iframe position.
|
|
83
|
+
Messages go to one exact origin and are accepted only from the expected window and origin.
|
|
84
|
+
- **Toolbar guide tools**: "Record clicks" turns a click path (across page loads in the tab) into tour steps with stable
|
|
85
|
+
selectors and step urls, then `POST /v1/projects/{id}/guides/draft` writes the copy (a plain recorded tour when the route
|
|
86
|
+
fails); "Draft from prompt" asks the same route; "Derive theme from this page" reads computed body / primary-button styles
|
|
87
|
+
and saves `POST /guide-themes`. Automation targets and form-validation fields are checked in the page before saving.
|
|
88
|
+
|
|
89
|
+
## Experiments and early access
|
|
90
|
+
|
|
91
|
+
- **Split URL** (`splitUrl` from `@lucida-analytics/browser/experiments`): a variant payload `{"lc_split_url": {"url": "/pricing-b"}}`
|
|
92
|
+
sends visitors assigned that variant there with `location.replace`, before paint when `splitUrl.antiFlickerMs` hides the page.
|
|
93
|
+
Query and hash are kept (the variant URL's own params win), the target gets `__lc_split=<flag>` (stripped on arrival; it
|
|
94
|
+
prevents loops), only same-origin or `splitUrl.allowedOrigins` targets are followed, and `$exposure` is flushed first.
|
|
95
|
+
- **Early access** (`earlyAccess` from `@lucida-analytics/browser/early-access`): `client.earlyAccess.list()` reads
|
|
96
|
+
`GET /v1/early-access?api_key=` (`{features: [{flag_key, name, description, stage}]}`, a gateway endpoint that does not
|
|
97
|
+
exist yet) and marks local enrolment; `optIn(key)`/`optOut(key)` capture `$early_access_opt_in {$feature_flag, $enrolled}`
|
|
98
|
+
with the person property `$feature_enrollment/<key>` and reload flags.
|
|
99
|
+
|
|
100
|
+
## Link, search, privacy and identity options
|
|
101
|
+
|
|
102
|
+
- **Outbound / downloads / site search** (autocapture config, each on by default): `outboundLinks` emits `$outbound_click
|
|
103
|
+
{$url, $outbound_host}`; `fileDownloads` (`false`, or your own extension list; default pdf, zip, office, csv, dmg, exe, mp3,
|
|
104
|
+
mp4 ...) emits `$file_download {$url, $file_name, $file_extension}`; `siteSearch` (`false`, or `{params: [...]}`, default
|
|
105
|
+
`q`, `s`, `search`, `query`) emits `$site_search {$search_term, $search_param}` after each `$pageview` that carries a
|
|
106
|
+
query param. Reported URLs drop query and hash. `[data-lc-ignore]` subtrees are skipped. `tag404(client)` (from
|
|
107
|
+
`@lucida-analytics/browser`) on a 404 page captures `$page_not_found {$status: 404}`.
|
|
108
|
+
- **DNT / GPC**: `respectDnt` (default false) and `respectGpc` (default false). When set and the browser sends the signal,
|
|
109
|
+
an `opt_out` project starts with consent denied, so nothing is stored or sent until `setConsent`. An explicit stored
|
|
110
|
+
decision still wins. (`consent.respectDnt` is kept and enables both.)
|
|
111
|
+
- **Cookie Munch**: `import { cookieMunchConsent } from "@lucida-analytics/browser/consent"` and pass it as a module; it follows
|
|
112
|
+
`CookieMunch.consent` after the visitor's decision (`statistics` -> analytics + replay, `marketing` -> marketing). See `docs/guides/cookie-munch.md`.
|
|
113
|
+
- **Consent state**: `client.getConsent()` returns the current decision per category; `client.getConsentStatus(category?)`
|
|
114
|
+
is `pending` until the visitor chose (stored or `setConsent`), then `granted` or `denied`, so a banner can show only
|
|
115
|
+
while pending. `consent.storageKey` (default `lc_consent`) names the stored decision; `cookie: { domain: ".example.com" }`
|
|
116
|
+
(or `crossSubdomain: true`) shares identity, session and the decision across subdomains. While `pending` no `lc_*` cookie or
|
|
117
|
+
storage item is written; on a denial the SDK removes the `lc_*` items stored earlier **except the decision itself** (`lc_consent_<suffix>`).
|
|
118
|
+
- **Cross-domain**: `crossDomains: ["shop.example.com"]` (exact host or subdomains; list the other site on both sides). While
|
|
119
|
+
analytics consent is held, clicks on links to those hosts get `_lcid=<distinct_id>.<base36 ms>_<session id>`. On landing the
|
|
120
|
+
SDK strips `_lcid` from the address bar and, if it is under 2 minutes old and the referrer (when sent) is a configured
|
|
121
|
+
domain, adopts that id and session for a first-time visitor (an existing id or session is kept). Links from older SDKs
|
|
122
|
+
(no session part) still work, and older SDKs read new links. The value is unsigned by design: treat it as identity
|
|
123
|
+
continuity, not authentication.
|
|
124
|
+
- **Internal traffic**: `client.optOutInternal()` stores an exclude-me flag (consent-gated) and adds `$internal: true` to
|
|
125
|
+
every event from that browser; `optOutInternal(false)` undoes it. The toolbar has a toggle. `$lc_*` properties are stripped
|
|
126
|
+
at the gateway, hence `$internal`: lc-worker must drop or flag these events.
|
|
127
|
+
|
|
128
|
+
## Snapshot properties, page privacy rules and agent actions
|
|
129
|
+
|
|
130
|
+
- **Snapshot properties** (no code, set in project settings or picked in the toolbar): each rule reads an element's visible
|
|
131
|
+
text (whitespace collapsed, at most 255 characters) or one attribute onto `$autocapture` clicks and/or `$pageview` as
|
|
132
|
+
`<name>`. `scope: "target"` reads the match nearest the clicked element, `url` limits the rule to matching pages. Form
|
|
133
|
+
fields, editable or masked elements, `value`/`password`/`on*` attributes and card-like digit runs are never read. SPA
|
|
134
|
+
pageviews wait one tick so the new page renders; the first pageview of a hard load can miss values the page renders later.
|
|
135
|
+
- **Page privacy rules** (`replay.url_privacy_rules`, or `replay_url_privacy_rules` from the remote config): `[{url,
|
|
136
|
+
mask_all_text?, mask_selectors?, block_selectors?}]`. On matching pages the recorder adds those masks on top of the global
|
|
137
|
+
policy and restarts recording with a fresh full snapshot when the rule set changes on navigation. Patterns use the URL
|
|
138
|
+
blocklist syntax (`*` wildcard, `re:` regex).
|
|
139
|
+
- **WebMCP agent actions** (`import { webmcp } from "@lucida-analytics/browser/webmcp"`, add it to `modules`): wraps
|
|
140
|
+
`navigator.modelContext.provideContext` / `registerTool` so each tool call an AI agent makes on the page captures
|
|
141
|
+
`$agent_action {tool, status: ok|error, duration_ms, $agent_protocol: "webmcp"}`. Tool arguments and results are never
|
|
142
|
+
sent. From the first call the session is marked: every later event carries `$agent_session: true`, and the enricher sets
|
|
143
|
+
`$agent_source = webmcp` so replays and insights can filter agent-driven sessions.
|
|
144
|
+
|
|
145
|
+
## Event hooks, person modes and request controls
|
|
146
|
+
|
|
147
|
+
- **`beforeSend`** (one hook or an array): runs on every event right before it is queued, in order, each on the previous
|
|
148
|
+
output. Return the (amended) event, or `null` to drop it. A hook that throws is logged and skipped. `sampleRate: 0.1` keeps
|
|
149
|
+
10% and stamps `$sample_rate` (the `sampleHook(rate)` helper is exported to compose with your own filter);
|
|
150
|
+
`propertyDenylist: ["email"]` removes those keys from properties, `$set` and `$set_once`. They run before your hooks.
|
|
151
|
+
- **`personProfiles`**: `"always"` (default), `"identified_only"` (events carry `$process_person_profile: false` until
|
|
152
|
+
`identify`, `alias`, `group` or `setPersonProperties`; the state is stored after consent and cleared by `reset()`), or
|
|
153
|
+
`"never"` (always personless; `identify`/`alias`/`setPersonProperties` do nothing). `$identify`, `$create_alias` and
|
|
154
|
+
`$groupidentify` are always processed. Person writes riding on a personless event are not sent, except `$set_once`
|
|
155
|
+
values (initial referrer, campaign, click ids): those are kept (first value wins, consent-gated) and sent with the first
|
|
156
|
+
person-processed event. `createPersonProfile()` switches an `identified_only` visitor to a person without `identify`.
|
|
157
|
+
`reuseAnonymousId: true` makes `reset()` keep this device's first anonymous id.
|
|
158
|
+
- **Methods**: `setPersonProperties(set, setOnce)` / `unsetPersonProperties(keys)` (send a `$set` event),
|
|
159
|
+
`getSessionId()`, `onSessionId(cb)` (now and on every rotation), `getProperty(key)`, `hasOptedOut()`,
|
|
160
|
+
`reset(resetDeviceId)`, `getReplayUrl({withTimestamp, timestampLookBackSeconds})` (uses `uiHost`, else `apiHost`; the classic script sets `uiHost` to its own host when it is Lucida-hosted),
|
|
161
|
+
`debug(on)` (also `?__lucida_debug=1`), `featureView(flag)` / `featureInteraction(flag)` (`$feature_view` /
|
|
162
|
+
`$feature_interaction`, marking the person `$feature_view/<flag>`), `updateFlags(flags, payloads, {merge})`.
|
|
163
|
+
- **`capture(event, props, options)`**: `timestamp` (epoch ms, ISO string or Date), `sendInstantly` (flush now),
|
|
164
|
+
`transport: "beacon"` (flush with sendBeacon).
|
|
165
|
+
- **`bootstrap`**: `{distinctId, isIdentified, sessionId, flags, payloads}`. A stored identity or session always wins
|
|
166
|
+
over bootstrap values, so a returning browser keeps its own; `isIdentified` means the id is a signed-in user.
|
|
167
|
+
- **Tracing headers**: `tracingHeaders: ["api.example.com", ".example.org"]` (exact host, or a leading-dot suffix) adds
|
|
168
|
+
`X-Lucida-Distinct-Id` and `X-Lucida-Session-Id` to fetch/XHR to those hosts. Opt-in, only while analytics consent is
|
|
169
|
+
held, never sent to the ingest host; cross-origin targets must allow both headers in CORS. Server SDKs read them with
|
|
170
|
+
`requestContext`; they are client-controlled, so never use them for auth.
|
|
171
|
+
- **Limits and sessions**: `rateLimit: {eventsPerSecond: 10, burst: 100}` (off by default) is a client token bucket; drops
|
|
172
|
+
are reported as one `$$client_ingestion_warning {$dropped_count}` per minute. `onCapture` listeners (inspector, replay
|
|
173
|
+
triggers) only see events that passed `beforeSend`, sampling and the limit;
|
|
174
|
+
`session: {idleMs, maxMs}` changes the 30 min idle / 24 h rotation; `customCampaignParams: ["ref_code"]` adds
|
|
175
|
+
`$ref_code` (and `$initial_ref_code`) on pageviews.
|
|
176
|
+
- **Transport**: `disableBeacon`, `requestHeaders` (adds a CORS preflight to the ingest host), `onRequestError({url, status})`,
|
|
177
|
+
`rewritePath: (path) => path` (renames every request path on `apiHost` / `flagsApiHost`, for proxies). Every event carries
|
|
178
|
+
`$lib_custom_api_host` when `apiHost` is not the Lucida default, so proxy coverage is measurable.
|
|
179
|
+
- **Storage**: `persistence: "cookie" | "localStorage" | "sessionStorage" | "localStorage+cookie" | "memory" | "none"`.
|
|
180
|
+
`localStorage+cookie` keeps identity, session, device id and consent in a cookie and localStorage (cookie wins on
|
|
181
|
+
conflict, either fills in for the other) and everything else in localStorage. `persistedProperties: ["plan"]` persists only
|
|
182
|
+
those super properties; `storageWriteDelayMs` coalesces writes (flushed on page hide); `flagPersistence` and
|
|
183
|
+
`consentPersistence` give the flag cache and the consent decision their own store; `cookieless: "always" | "on_reject"`.
|
|
184
|
+
All writes stay behind consent.
|
|
185
|
+
- **Runtime config**: `client.setConfig(partial)` merges options one level deep; per-event options (debug, autocapture
|
|
186
|
+
options, hooks, sampling, denylist, rate limit, persisted properties) apply at once.
|
|
187
|
+
- **URL privacy**: well-known sensitive query params (`password`, `token`, `key`, `code`, `email`, ... see the quickstart) are always masked as `<masked>` in every URL sent and in replay; `urlPrivacy: {maskParams, maskCampaignParams, stripHash}` adds to that.
|
|
188
|
+
- **Delivery**: `assetHost` (default: the host `lucida.js` was loaded from) + `modules: ["replay", ...]` (classic script only) load versioned modules from
|
|
189
|
+
`<assetHost>/static/v<version>/`; `nonce` goes on every injected `<style>`; `extension: true` (auto on extension pages) for
|
|
190
|
+
Manifest V3. See docs/guides/sdk-pinning.md, csp.md and browser-extension.md.
|
|
191
|
+
- **Cookies**: `cookie: {secure, expiryDays, crossSubdomain, domain}`. `crossSubdomain` probes for the broadest parent domain
|
|
192
|
+
the browser accepts (on first write, which is after consent); all cookie writes stay behind consent.
|
|
193
|
+
- **Pageleave**: `capturePageleave: true | false | "if_capture_pageview"` (default).
|
|
194
|
+
- **Autocapture**: `elementAllowlist: ["a", "button"]`, `attributeIgnore: ["data-*", "title", "href"]`,
|
|
195
|
+
`maskAllAttributes` + `attributeAllowlist` (every attribute value in `$elements` reads `***` except the allowlist),
|
|
196
|
+
`urlIgnorelist: ["/admin", /\/checkout\//]` (autocapture off on those pages), `contentEditable` (default on: an edited
|
|
197
|
+
region is reported on blur, chain only), `copyCut` (`$copy_autocapture {$copy_type}`, default off) with
|
|
198
|
+
`captureCopiedText` (`$selected_content`, digits and emails masked, 255 chars), and `data-lc-attr-<name>="v"` on an
|
|
199
|
+
element or ancestor adds `<name>: "v"` to its events.
|
|
200
|
+
`rageClicks: false | {count, radiusPx, windowMs, ignoreSelectors, ignoreTextSelection, suppressSteppers, stepperSelectors}`
|
|
201
|
+
(`.lc-no-rageclick` always opts out; steppers such as number inputs, +/- and carousel arrows never count unless
|
|
202
|
+
`suppressSteppers: false`), `deadClicks: false | {waitMs, ignoreSelectors}` (a scroll or selection change counts as a reaction).
|
|
203
|
+
- **Flags**: `flagsApiHost` (separate origin for `/v1/flags`), `flagOptions: {timeoutMs, refreshMs, keys, evaluationContexts,
|
|
204
|
+
disableRemote}`. `keys` scopes both the request (`flag_keys`) and what the client exposes; `disableRemote` leaves values to
|
|
205
|
+
bootstrap, `localFlags` and `updateFlags`.
|
|
206
|
+
|
|
207
|
+
## Agent analytics
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
const lucida = init("lc_pk_...", { ai: { captureText: false } });
|
|
211
|
+
const convo = lucida.ai.startConversation({ agentName: "support-bot", agentVersion: "3", traceId, topic: "billing" });
|
|
212
|
+
convo.message("user", question);
|
|
213
|
+
convo.message("assistant", answer);
|
|
214
|
+
convo.feedback({ kind: "thumbs", value: -1 });
|
|
215
|
+
convo.end("resolved");
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Events: `$ai_conversation_started`, `$ai_message` (role, auto-incremented index, text length; for user
|
|
219
|
+
messages a simhash `$ai_text_hash` and a lexicon `$ai_sentiment` so rephrases and frustration show without the
|
|
220
|
+
text), `$ai_feedback` (thumbs 1/-1, rating 1..5, comment), `$ai_conversation_ended` and `$ai_outcome`
|
|
221
|
+
(`resolved`, `unresolved`, `escalated`, `abandoned`, `error`). Message text and feedback comments are sent only
|
|
222
|
+
with `ai: { captureText: true }`, after cards, emails and phone numbers are masked. `traceId` (a W3C trace id) links the
|
|
223
|
+
conversation to its trace in Watchtower; tokens, latency, cost and model names are never captured here.
|
|
224
|
+
Events use the normal capture path, so consent and opt-out apply.
|
|
225
|
+
|
|
226
|
+
## Interventions
|
|
227
|
+
|
|
228
|
+
`client.onIntervention((i) => ...)` receives the in-session interventions fired for the current person (`{id, intervention_id, name, event, payload, fired_at}`, each once). The first listener opens `GET /v1/interventions/stream` (after analytics consent); it resumes after the last fire on reconnect and follows `identify` / `reset`. Returns an unsubscribe function. See `docs/guides/interventions.md`.
|
|
229
|
+
|
|
230
|
+
## Develop
|
|
231
|
+
|
|
232
|
+
`pnpm test` (jsdom), `pnpm e2e` (builds, then real Chromium via Playwright against a stub
|
|
233
|
+
ingest server), `pnpm size` (bundle budgets).
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { C as Client, M as Module } from './types-CLEZS45j.js';
|
|
2
|
+
import { Props } from '@lucida-analytics/sdk-core';
|
|
3
|
+
|
|
4
|
+
interface ElementInfo {
|
|
5
|
+
tag_name: string;
|
|
6
|
+
nth_child: number;
|
|
7
|
+
nth_of_type: number;
|
|
8
|
+
classes?: string[];
|
|
9
|
+
attr__id?: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
attrs?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
/** Attribute-value masking: everything but `allow` (same matching as attributeIgnore) reads `***`. */
|
|
15
|
+
interface MaskOptions {
|
|
16
|
+
maskAll?: boolean | undefined;
|
|
17
|
+
allow?: readonly string[] | undefined;
|
|
18
|
+
}
|
|
19
|
+
declare const MASKED = "***";
|
|
20
|
+
/** `data-lc-attr-<name>="v"` on the target or an ancestor becomes event property `<name>: "v"` (nearest wins). */
|
|
21
|
+
declare function attrProps(target: Element): Record<string, string>;
|
|
22
|
+
/** Element chain from the target up to <html> (max depth 10). Text only on the first `textDepth` elements. */
|
|
23
|
+
declare function buildChain(target: Element, captureText: boolean, textUpTo?: Element, ignoreAttrs?: readonly string[], maskOpts?: MaskOptions): ElementInfo[];
|
|
24
|
+
/** Compact single-string form: tag.class:attr__id="x"nth-child="1"..., elements joined by ';'. */
|
|
25
|
+
declare function chainToString(chain: ElementInfo[]): string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Descendant-combinator selector (`body div.card button#buy`) in the subset crates/lc-replay's
|
|
29
|
+
* selector engine understands: tag, #id, .class. Stops at the first id; max 5 levels.
|
|
30
|
+
*/
|
|
31
|
+
declare function cssSelector(el: Element): string;
|
|
32
|
+
|
|
33
|
+
/** Copied text as sent with `captureCopiedText`: digit runs (cards, phones) and emails masked, whitespace folded, cut to 255. */
|
|
34
|
+
declare function maskCopied(t: string): string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Repeated clicks here are the intended use, not frustration: number inputs and spinbuttons, +/- and arrow buttons,
|
|
38
|
+
* and controls whose class, aria-label or title names a stepper, quantity or carousel, plus your `extra` selectors.
|
|
39
|
+
*/
|
|
40
|
+
declare function isStepper(target: Element, extra?: readonly string[]): boolean;
|
|
41
|
+
|
|
42
|
+
declare const DOWNLOAD_EXTENSIONS: string[];
|
|
43
|
+
declare const SEARCH_PARAMS: string[];
|
|
44
|
+
/** Call from the 404 page template: `$page_not_found` lets reports list dead URLs and their referrers. */
|
|
45
|
+
declare function tag404(client: Pick<Client, "capture">, props?: Record<string, string | number | boolean>): void;
|
|
46
|
+
|
|
47
|
+
/** Media URL without query or fragment (signed URLs and tokens stay out of analytics). */
|
|
48
|
+
declare function mediaSrc(el: HTMLMediaElement): string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* No-code snapshot properties (P-M15): remote rules (`snapshot_properties` in GET /v1/config, set in the
|
|
52
|
+
* web app or with the toolbar picker) copy the visible text or one attribute of a matching element onto
|
|
53
|
+
* `$autocapture` clicks and/or `$pageview`s. Form controls, editable and masked elements are never read,
|
|
54
|
+
* nor `value`/event-handler attributes; card-like digit runs are dropped.
|
|
55
|
+
*/
|
|
56
|
+
interface SnapshotRule {
|
|
57
|
+
name: string;
|
|
58
|
+
selector: string;
|
|
59
|
+
source: "text" | "attribute";
|
|
60
|
+
attribute?: string;
|
|
61
|
+
events: Array<"click" | "pageview">;
|
|
62
|
+
/** `target`: the closest match around the clicked element (click rules only). Default `page`: first match in the document. */
|
|
63
|
+
scope?: "page" | "target";
|
|
64
|
+
/** URL pattern (substring, `*` wildcard, `re:` regex). */
|
|
65
|
+
url?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Well-formed rules only (remote config is untrusted input). */
|
|
68
|
+
declare function snapshotRules(v: unknown): SnapshotRule[];
|
|
69
|
+
/** Property values of the rules for `event` on this page (`target`: the clicked element). */
|
|
70
|
+
declare function readSnapshot(rules: SnapshotRule[], event: "click" | "pageview", target?: Element, url?: string): Props;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Autocapture module: click/change/submit, contenteditable edits, copy/cut, outbound/download/site-search, media,
|
|
74
|
+
* SPA pageviews, pageleave + scroll depth. `urlIgnorelist` switches all but pageviews off on matching pages.
|
|
75
|
+
*/
|
|
76
|
+
declare const autocapture: Module;
|
|
77
|
+
|
|
78
|
+
export { DOWNLOAD_EXTENSIONS, type ElementInfo, MASKED, type MaskOptions, SEARCH_PARAMS, type SnapshotRule, attrProps, autocapture, buildChain, chainToString, cssSelector, isStepper, maskCopied, mediaSrc, readSnapshot, snapshotRules, tag404 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ve=(e,t)=>()=>(e&&(t=e(e=0)),t);function Ke(e){return e.startsWith("re:")?e.slice(3):e.split("*").map(t=>t.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")}function j(e,t){return!!e?.some(n=>{try{return new RegExp(Ke(n),"i").test(t)}catch{return!1}})}var pe=ve(()=>{"use strict"});var be='[data-lc-region="article"]';function K(e,t,n){if(t.articles===!1)return()=>{};let o;e.loadConfig().then(f=>{typeof f?.article_selector=="string"&&(o=f.article_selector)});let s=()=>{for(let f of[t.articleSelector,o,be])if(f)try{let _=document.querySelector(f);if(_)return _}catch{}return null},i=location.href,l=location.pathname,c=null,a=0,u=!1,r=()=>{if(c??=s(),!c)return;let f=c.getBoundingClientRect();if(f.height<=0)return;let _=Math.round(Math.min(100,Math.max(0,(window.innerHeight-f.top)/f.height*100)));a=Math.max(a,_);let v=c.querySelector("h1,h2");v&&v.getBoundingClientRect().bottom<0&&(u=!0)},p=()=>{!c||!n()||(r(),e.client.capture("$article_read",{$article_id:(c.getAttribute("data-lc-article-id")??"").trim().slice(0,200)||l,$article_depth:a,$article_finished:a>=90,$article_headline_exit:!u&&a<25}),c=null)},d=()=>{p(),c=null,a=0,u=!1,i=location.href,l=location.pathname},m=()=>location.href!==i?d():r(),g=new MutationObserver(m);return g.observe(document.documentElement,{childList:!0,subtree:!0}),window.addEventListener("scroll",m,{passive:!0}),e.onUnload(p),r(),()=>{g.disconnect(),window.removeEventListener("scroll",m)}}var T="data-lc-content",Ee="data-lc-content-piece",we="data-lc-content-target";var H=(e,t)=>(e.getAttribute(t)??"").trim().slice(0,200);function G(e,t,n){if(t.contentBlocks===!1||typeof IntersectionObserver>"u")return()=>{};let o=new WeakSet,s=r=>{let p={$content_name:H(r,T)},d=H(r,Ee),m=H(r,we);return d&&(p.$content_piece=d),m&&(p.$content_target=m),p},i=location.href,l=new IntersectionObserver(r=>{for(let p of r)!p.isIntersecting||o.has(p.target)||!n()||(o.add(p.target),e.client.capture("$content_impression",s(p.target)))},{threshold:.5}),c=r=>r.querySelectorAll(`[${T}]`).forEach(p=>l.observe(p));c(document);let a=new MutationObserver(()=>{location.href!==i&&(i=location.href,l.disconnect(),document.querySelectorAll(`[${T}]`).forEach(r=>o.delete(r))),c(document)});a.observe(document.documentElement,{childList:!0,subtree:!0});let u=r=>{let p=r.target?.closest?.(`[${T}]`);p&&n()&&e.client.capture("$content_interaction",{...s(p),$content_interaction_type:"click"})};return document.addEventListener("click",u,!0),()=>{l.disconnect(),a.disconnect(),document.removeEventListener("click",u,!0)}}var ke=new Set(["input","textarea","select","option"]),xe=["name","type","role","aria-label","title","alt","placeholder"],Re=/(?:\d[ -]?){9,}/;function Ce(e){if(ke.has(e.tagName.toLowerCase())||e.isContentEditable)return;let t="";for(let n of Array.from(e.childNodes))n.nodeType===3&&(t+=n.textContent??"");if(t=t.replace(/\s+/g," ").trim(),!(!t||Re.test(t)))return t.slice(0,255)}function Y(e){if(!e?.length)return()=>!1;let t=e.map(n=>n.toLowerCase());return n=>t.some(o=>o.endsWith("*")?n.startsWith(o.slice(0,-1)):n===o)}var B="***";function w(e){let t={};for(let n=e,o=0;n&&o<10;n=n.parentElement,o++)for(let s of Array.from(n.attributes)){let i=s.name.startsWith("data-lc-attr-")?s.name.slice(13):"";i&&!(i in t)&&!i.startsWith("$")&&(t[i]=s.value.slice(0,255))}return t}function Se(e,t,n,o){let s=e.parentElement,i=s?Array.from(s.children):[e],l={tag_name:e.tagName.toLowerCase(),nth_child:i.indexOf(e)+1,nth_of_type:i.filter(r=>r.tagName===e.tagName).indexOf(e)+1},c=(e.getAttribute("class")??"").split(/\s+/).filter(Boolean);c.length&&!n("class")&&(l.classes=c),e.id&&!n("id")&&(l.attr__id=o("id",e.id));let a=e.getAttribute("href");a&&!n("href")&&(l.href=o("href",a.slice(0,1024)));let u={};for(let r of Array.from(e.attributes))(r.name.startsWith("data-lc-")||xe.includes(r.name))&&!n(r.name)&&(u[r.name]=o(r.name,r.value.slice(0,255)));if(Object.keys(u).length&&(l.attrs=u),t){let r=Ce(e);r&&(l.text=r)}return l}function k(e,t,n,o,s={}){let i=[],l=Y(o),c=Y(s.allow),a=s.maskAll?(r,p)=>c(r)?p:B:(r,p)=>p,u=t;for(let r=e;r&&i.length<10;r=r.parentElement)i.push(Se(r,u,l,a)),(r===n||!n)&&(u=!1);return i}var $=e=>e.replace(/(["\\])/g,"\\$1");function x(e){return e.map(t=>{let n=t.tag_name+(t.classes?"."+t.classes.join("."):"")+":";t.attr__id&&(n+=`attr__id="${$(t.attr__id)}"`),t.href&&(n+=`href="${$(t.href)}"`),t.text&&(n+=`text="${$(t.text)}"`);for(let[o,s]of Object.entries(t.attrs??{}))n+=`attr__${o}="${$(s)}"`;return n+`nth-child="${t.nth_child}"nth-of-type="${t.nth_of_type}"`}).join(";")}var b=[],Ae=/^[+\-−–‹›<>«»←→↑↓▲▼▶◀^ˇ˄˅]$/,Me=/\b(increase|decrease|increment|decrement|plus|minus|add one|remove one|next|prev|previous|scroll (left|right))\b/i,Te=/(^|[-_\s])(stepper|spinner|quantity|qty|increment|decrement|inc|dec|plus|minus|carousel|slider|swiper|slick|glide|splide|arrow|next|prev)([-_\s]|$)/i,$e="button,[role=button],a,input[type=button],input[type=submit],[role=spinbutton]";function z(e,t=[]){if(t.length&&e.closest(t.join(","))||e.closest("input[type=number],[role=spinbutton],[role=slider]"))return!0;let n=e.closest($e)??e,o=`${n.getAttribute("aria-label")??""} ${n.getAttribute("title")??""}`;if(Ae.test((n.textContent??"").trim())||Me.test(o))return!0;for(let s=n,i=0;s&&i<3;s=s.parentElement,i++)if(Te.test(s.getAttribute("class")??""))return!0;return!1}var Le=()=>typeof getSelection=="function"?(getSelection()?.toString()??"")!=="":!1;function V(e,t=Date.now(),n={},o){if(o&&n.ignoreSelectors?.length&&o.closest(n.ignoreSelectors.join(",")))return{};if(o&&n.suppressSteppers!==!1&&z(o,n.stepperSelectors))return{};if(n.ignoreTextSelection!==!1&&Le())return{};let s=n.windowMs??1e3,i=n.radiusPx??30;for(b.length&&t<b[b.length-1].t&&(b.length=0),b.push({t,x:e.clientX,y:e.clientY});b.length&&t-b[0].t>s;)b.shift();let l=b.filter(c=>Math.hypot(c.x-e.clientX,c.y-e.clientY)<=i).length;return l>=(n.count??3)?{$rageclick:!0,$rageclick_count:l}:{}}function Q(e,t,n=700){if(typeof MutationObserver>"u")return;let o=!1,s=new MutationObserver(()=>o=!0);s.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let i=()=>{o=!0};window.addEventListener("scroll",i,{capture:!0,passive:!0}),document.addEventListener("selectionchange",i);let l=()=>{s.disconnect(),window.removeEventListener("scroll",i,{capture:!0}),document.removeEventListener("selectionchange",i)},c=setTimeout(()=>{l(),!o&&document.visibilityState!=="hidden"&&e.client.capture("$deadclick_hint",{$selector:t,$no_mutation_ms:n})},n);e.onUnload(()=>{clearTimeout(c),l()})}var Z=/^[A-Za-z_][\w-]*$/,He=5;function J(e){let t=[];for(let n=e;n&&t.length<He;n=n.parentElement){let o=n.tagName.toLowerCase();if(n.id&&Z.test(n.id)){t.unshift(`${o}#${n.id}`);break}let s=(n.getAttribute("class")??"").split(/\s+/).filter(i=>Z.test(i)).slice(0,2);t.unshift(o+s.map(i=>`.${i}`).join(""))}return t.join(" ")}function ee(e,t,n,o,s={}){let i={$selector:J(n),$el_interactive:o};(t.clientX||t.clientY||t.detail)&&(i.$click_x=Math.round(t.clientX+(window.scrollX||0)),i.$click_y=Math.round(t.clientY+(window.scrollY||0))),s.rageClicks!==!1&&!n.closest(".lc-no-rageclick,[data-lc-no-rageclick]")&&Object.assign(i,V(t,Date.now(),s.rageClicks||{},n));let l=s.deadClicks;!o&&t.isTrusted&&l!==!1&&!(l?.ignoreSelectors?.length&&n.closest(l.ignoreSelectors.join(",")))&&Q(e,i.$selector,l?.waitMs);for(let c of e.clickExtras)Object.assign(i,c(t,n));return i}var Oe="a,button,input,select,textarea,label,summary,[role=button],[role=link],[data-lc-capture]",Ie="[data-lc-ignore]",O=e=>e.some(t=>typeof t=="string"?location.href.includes(t):t.test(location.href)),Pe=e=>!e?.length||O(e),I=e=>({maskAll:e.maskAllAttributes,allow:e.attributeAllowlist}),R=(e,t)=>!!e.closest(Ie)||!!(t.denySelectors?.length&&e.closest(t.denySelectors.join(",")));function te(e,t,n){let o=t.events??["click","change","submit"],s=0,i=a=>{let u=a.target;!n()||a.isComposing||!(u instanceof Element)||R(u,t)||u instanceof HTMLInputElement&&u.type==="password"||(s+=1)},l=a=>u=>{if(!n())return;let r=u.target;if(!(r instanceof Element)||R(r,t)||t.allowSelectors?.length&&!r.closest(t.allowSelectors.join(","))||t.elementAllowlist?.length&&!r.closest(t.elementAllowlist.join(","))||!Pe(t.urlAllowlist)||a==="change"&&!/^(input|select|textarea)$/i.test(r.tagName)||r instanceof HTMLInputElement&&r.type==="password")return;let p=r.closest(Oe);if(a==="click"&&!p&&!t.allowSelectors?.length)return;let d=k(r,t.captureText??!0,p??void 0,t.attributeIgnore,I(t)),m=d.find(f=>f.text)?.text,g=s;s=0,e.client.capture("$autocapture",{...w(r),$event_type:a,...g>0?{$keystroke_count:g}:{},$elements:d,$elements_chain:x(d),...m?{$el_text:m}:{},...a==="click"?ee(e,u,r,!!p,t):{}})};e.autocaptureClicks=o.includes("click");let c=o.map(a=>[a,l(a)]);for(let[a,u]of c)document.addEventListener(a,u,!0);return document.addEventListener("keydown",i,!0),()=>{for(let[a,u]of c)document.removeEventListener(a,u,!0);document.removeEventListener("keydown",i,!0)}}var je='[contenteditable]:not([contenteditable="false"])',ne="input,textarea,select",We=255;function re(e){return e.replace(/\d(?:[ -]?\d){5,}/g,"***").replace(/[^\s@]+@[^\s@]+\.[^\s@]+/g,"***").replace(/\s+/g," ").trim().slice(0,We)}var De=e=>e?e instanceof Element?e:e.parentElement:null;function oe(e,t,n){let o=t.events??["click","change","submit"],s=t.contentEditable!==!1&&o.includes("change"),i=new WeakSet,l=p=>{let d=k(p,!1,p,t.attributeIgnore,I(t));return{...w(p),$elements:d,$elements_chain:x(d)}},c=p=>{let d=p instanceof Element?p.closest(je):null;return d&&!R(d,t)?d:null},a=p=>{let d=n()?c(p.target):null;d&&i.add(d)},u=p=>{let d=c(p.target);!d||!i.has(d)||p.relatedTarget instanceof Node&&d.contains(p.relatedTarget)||(i.delete(d),n()&&e.client.capture("$autocapture",{$event_type:"change",$el_contenteditable:!0,...l(d)}))},r=p=>{if(!n()||!t.copyCut)return;let d=typeof getSelection=="function"?getSelection():null,m=p.target instanceof Element?p.target:null,g=De(d?.anchorNode)??m;if(!g||R(g,t)||g.closest(ne)||m?.closest(ne))return;let f=t.captureCopiedText?re(d?.toString()??""):"";e.client.capture("$copy_autocapture",{$copy_type:p.type,...l(g),...f?{$selected_content:f}:{}})};return s&&(document.addEventListener("input",a,!0),document.addEventListener("focusout",u,!0)),document.addEventListener("copy",r,!0),document.addEventListener("cut",r,!0),()=>{document.removeEventListener("input",a,!0),document.removeEventListener("focusout",u,!0),document.removeEventListener("copy",r,!0),document.removeEventListener("cut",r,!0)}}var Ne="[data-lc-ignore]",ie=["pdf","zip","gz","tar","rar","7z","doc","docx","xls","xlsx","ppt","pptx","csv","epub","dmg","exe","msi","pkg","apk","iso","mp3","mp4","mov"],ae=["q","s","search","query"],se=e=>e.origin+e.pathname;function le(e,t,n){let o=Array.isArray(t.fileDownloads)?t.fileDownloads.map(i=>i.toLowerCase()):ie,s=[];if(t.outboundLinks!==!1||t.fileDownloads!==!1){let i=l=>{let c=l.target instanceof Element?l.target.closest("a[href]"):null;if(!c||!n()||c.closest(Ne))return;let a;try{a=new URL(c.href,location.href)}catch{return}if(a.protocol!=="http:"&&a.protocol!=="https:")return;let u=decodeURIComponent(a.pathname.split("/").pop()??""),r=u.includes(".")?u.split(".").pop().toLowerCase():"";t.fileDownloads!==!1&&(c.hasAttribute("download")||o.includes(r))?e.client.capture("$file_download",{$url:se(a),$file_name:u,$file_extension:r}):t.outboundLinks!==!1&&a.host!==location.host&&e.client.capture("$outbound_click",{$url:se(a),$outbound_host:a.host})};document.addEventListener("click",i,!0),s.push(()=>document.removeEventListener("click",i,!0))}if(t.siteSearch!==!1){let i=typeof t.siteSearch=="object"&&t.siteSearch.params?t.siteSearch.params:ae,l=!0;s.push(()=>{l=!1}),e.onCapture(c=>{if(!l||c.event!=="$pageview"||!n())return;let a=new URLSearchParams(location.search);for(let u of i){let r=a.get(u)?.trim();if(r)return void e.client.capture("$site_search",{$search_term:r.slice(0,200),$search_param:u})}})}return()=>s.forEach(i=>i())}function Ue(e,t={}){e.capture("$page_not_found",{$status:404,...t})}var Xe=[25,50,75],Fe="data-lc-media-title";function P(e){let t=e.currentSrc||e.src;if(!t||t.startsWith("blob:")||t.startsWith("data:"))return"";try{let n=new URL(t,location.href);return`${n.origin}${n.pathname}`}catch{return""}}var qe=e=>(e.getAttribute(Fe)??e.getAttribute("title")??e.getAttribute("aria-label")??"").trim().slice(0,200);function ce(e,t,n){if(t.media===!1)return()=>{};let o=new WeakMap,s=a=>{let u={$media_type:a instanceof HTMLVideoElement?"video":"audio",$media_src:P(a)},r=qe(a);return r&&(u.$media_title=r),Number.isFinite(a.duration)&&(u.$media_duration=Math.round(a.duration)),u},i=a=>{let u=P(a);if(!u)return null;let r=o.get(a);return(!r||r.src!==u)&&o.set(a,r={src:u,played:!1,reached:new Set,done:!1}),r},l=a=>{let u=a.target;if(!(u instanceof HTMLMediaElement)||!n())return;let r=i(u);if(r)if(a.type==="play"){if(r.done&&Object.assign(r,{played:!1,reached:new Set,done:!1}),r.played)return;r.played=!0,e.client.capture("$media_play",s(u))}else if(a.type==="timeupdate"){if(!r.played||r.done||!Number.isFinite(u.duration)||u.duration<=0)return;let p=u.currentTime/u.duration*100;for(let d of Xe)p>=d&&!r.reached.has(d)&&(r.reached.add(d),e.client.capture("$media_progress",{...s(u),$media_progress:d}))}else a.type==="ended"&&r.played&&!r.done&&(r.done=!0,e.client.capture("$media_complete",s(u)))},c=["play","timeupdate","ended"];return c.forEach(a=>document.addEventListener(a,l,!0)),()=>c.forEach(a=>document.removeEventListener(a,l,!0))}function ue(e=()=>performance.now()){let t=()=>document.visibilityState!=="hidden",n=0,o=t()?e():null,s=()=>{t()?o===null&&(o=e()):(o!==null&&(n+=e()-o),o=null)};return document.addEventListener("visibilitychange",s),{read:()=>Math.round(n+(o===null?0:e()-o)),reset:()=>{n=0,o=t()?e():null},stop:()=>document.removeEventListener("visibilitychange",s)}}pe();var de=255,Ge=new Set(["input","textarea","select","option"]),Ye="[data-lc-mask],.lc-mask,[data-lc-no-capture],.lc-no-capture,[data-lc-block]",Be=new Set(["value","password","autocomplete"]),ze=/(?:\d[ -]?){9,}/,C=new WeakMap,W=new WeakMap;function fe(e,t){let n=W.get(e);if(n)return new Promise(o=>{let s=setTimeout(o,t);n.then(()=>(clearTimeout(s),o()))})}function me(e){return Array.isArray(e)?e.filter(t=>{if(!t||typeof t!="object")return!1;let n=t;return typeof n.name=="string"&&n.name!==""&&!n.name.startsWith("$")&&typeof n.selector=="string"&&(n.source==="text"||n.source==="attribute"&&typeof n.attribute=="string")&&Array.isArray(n.events)}):[]}function Ve(e){if(!e||Ge.has(e.tagName.toLowerCase())||e.isContentEditable)return!1;try{return!e.closest(Ye)}catch{return!1}}function Qe(e,t){if(e.source==="attribute"){let o=(e.attribute??"").toLowerCase();if(!o||Be.has(o)||o.startsWith("on"))return;let s=t.getAttribute(o);return s===null?void 0:s.slice(0,de)}let n=(t.textContent??"").replace(/\s+/g," ").trim();if(!(!n||ze.test(n)))return n.slice(0,de)}function D(e,t,n,o=location.href){let s={};for(let i of e){if(!i.events.includes(t)||i.url&&!j([i.url],o))continue;let l=null;try{l=i.scope==="target"?t==="click"&&n?n.closest(i.selector):null:document.querySelector(i.selector)}catch{continue}if(!Ve(l))continue;let c=Qe(i,l);c!==void 0&&(s[i.name]=c)}return s}function ge(e){let t=!0,n=e.loadConfig().then(o=>{t&&C.set(e,me(o?.snapshot_properties)),W.delete(e)});return W.set(e,n),e.clickExtras.push((o,s)=>t?D(C.get(e)??[],"click",s):{}),()=>{t=!1,C.delete(e)}}function he(e){let t=C.get(e);return t?.length?D(t,"pageview"):{}}function ye(e){return!!C.get(e)?.some(t=>t.events.includes("pageview"))}var Ze=e=>{try{return new URL(e).pathname}catch{return e}};function Je(e){for(let t of e===void 0?[]:Array.isArray(e)?e:[e])try{let n=document.querySelector(t);if(n)return n}catch{}}function _e(e){let t=0,n=0,o=()=>{let s=Je(e),i=document.documentElement,l=s?s.scrollHeight:Math.max(i.scrollHeight,document.body?.scrollHeight??0),c=s?s.scrollTop:window.scrollY||window.pageYOffset||0,a=Math.min(l,c+(s?s.clientHeight:window.innerHeight));a>t&&(t=a,n=l>0?Math.min(100,Math.round(a/l*100)):0)};return o(),window.addEventListener("scroll",o,{passive:!0,capture:!0}),window.addEventListener("resize",o,{passive:!0}),{read:()=>({pct:n,px:t}),stop:()=>{window.removeEventListener("scroll",o,{capture:!0}),window.removeEventListener("resize",o)}}}var et=800,tt=e=>e.core.hasConsent("analytics");function nt(e){return e==="history"?{path:!0,search:!0}:e==="hash"?{path:!0,search:!0,hash:!0}:typeof e=="object"?e:void 0}function rt(e,t,n){try{let o=new URL(e),s=new URL(t);return!!(n.path&&o.pathname!==s.pathname||n.search&&o.search!==s.search||n.hash&&o.hash!==s.hash)}catch{return e!==t}}function L(e,t,n={}){let o=n.views??!0,s=n.leave??!0,i=nt(t),l=e.config.scrollRoot,c=location.href,a=c,u=Date.now(),r=_e(l),p=ue(),d,m=()=>{if(!s||d===c)return;d=c;let{pct:h,px:E}=r.read();e.client.capture("$pageleave",{$current_url:c,$scroll_depth:h,$scroll_depth_px:E,$engagement_time_ms:p.read()})},g=!1,f=(h,E={})=>{if(!o)return;let{core:y}=e;if(!y.hasConsent("analytics")&&!y.anonymousOnReject&&!(y.consent.pending&&y.consent.queueBeforeConsent)){if(!g){g=!0;let A=()=>{g&&(g=!1,f())};e.whenConsented(A),y.onChange(M=>{M==="consent"&&y.anonymousOnReject&&A()})}return}e.client.capture("$pageview",{...he(e),...h===void 0?{}:{$referrer:h},...E})},_,v=()=>{let h=_;_=void 0,h?.()},S=h=>{if(location.href===a)return;let E=a;if(a=location.href,!i||!rt(E,a,i))return;let y=c;m(),r.stop();let A=new Date(u);c=location.href,u=Date.now(),r=_e(l),p.reset();let M={$navigation_type:h,$prev_pageview_pathname:Ze(y),$prev_pageview_duration:Math.round((u-A.getTime())/100)/10};ye(e)?setTimeout(()=>f(y,M),0):(v(),_=()=>f(y,M),queueMicrotask(v))};e.onUnload(m);let N=tt(e)?fe(e,et):void 0;if(N?(_=()=>f(),e.onUnload(v),N.then(v)):f(),!i)return()=>(r.stop(),p.stop());let{pushState:U,replaceState:X}=history;history.pushState=function(...h){v(),U.apply(this,h),S("pushState")},history.replaceState=function(...h){v(),X.apply(this,h),S("replaceState")};let F=()=>S("popstate"),q=()=>S("hashchange");return window.addEventListener("popstate",F),i.hash&&window.addEventListener("hashchange",q),()=>{window.removeEventListener("hashchange",q),history.pushState=U,history.replaceState=X,window.removeEventListener("popstate",F),r.stop(),p.stop()}}var Dt=e=>{let t=[],n=e.config.autocapture,o=!1;if(n!==!1){let l=typeof n=="object"?n:{},c=()=>!o&&!(l.urlIgnorelist?.length&&O(l.urlIgnorelist));t.push(te(e,l,c),oe(e,l,c),le(e,l,c),G(e,l,c),K(e,l,c),ce(e,l,c),ge(e)),n===void 0&&e.loadConfig().then(a=>o=a?.autocapture===!1)}let s=e.config.capturePageview??"history",i=e.config.capturePageleave??"if_capture_pageview";return s!==!1&&i!==!1?t.push(L(e,s)):s!==!1?t.push(L(e,s,{leave:!1})):i===!0&&t.push(L(e,"history",{views:!1})),()=>t.forEach(l=>l())};export{ie as DOWNLOAD_EXTENSIONS,B as MASKED,ae as SEARCH_PARAMS,w as attrProps,Dt as autocapture,k as buildChain,x as chainToString,J as cssSelector,z as isStepper,re as maskCopied,P as mediaSrc,D as readSnapshot,me as snapshotRules,Ue as tag404};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as A}from"./chunk-32K5P5GN.js";import"./chunk-O4W7SZ2X.js";var C={title:"Your privacy",body:"We use cookies and similar technologies to measure and improve this site. Choose what you allow.",acceptAll:"Accept all",rejectAll:"Reject all",save:"Save choices",categories:{analytics:"Analytics",replay:"Session replay",marketing:"Marketing"}},j=["analytics","replay","marketing"],O="button, input, [href], [tabindex]:not([tabindex='-1'])",w={bottom:{left:"0",right:"0",bottom:"0"},top:{left:"0",right:"0",top:"0"},center:{top:"50%",left:"50%",transform:"translate(-50%,-50%)","max-width":"28rem"},"bottom-left":{left:"1rem",bottom:"1rem","max-width":"24rem"},"bottom-right":{right:"1rem",bottom:"1rem","max-width":"24rem"}},l=(e,t={},...s)=>{let c=Object.assign(document.createElement(e),t);return c.append(...s),c},h;function P(){h?.close()}function S(e){if(!e)return{};let t=(e.categories??[]).filter(a=>!a.required&&j.includes(a.id)),s=Object.fromEntries(t.map(a=>[a.id,a.label])),c={title:e.title,body:e.body,acceptAll:e.accept_label,rejectAll:e.decline_label,save:e.customize_label,categories:s},d=e.position?.replace("_","-");return{texts:Object.fromEntries(Object.entries(c).filter(([,a])=>a!==void 0)),...t.length?{categories:t.map(a=>a.id)}:{},...d&&d in w?{position:d}:{}}}async function H(e){try{let t=await e.fetch(`${e.config.apiHost}/v1/config?api_key=${encodeURIComponent(e.apiKey)}`,{credentials:"omit"});return t.ok?S((await t.json()).consent_banner):{}}catch{return{}}}async function _(e,t={}){if(!t.remote)return B(e,t);let s=await H(e);return B(e,{...s,...t,texts:{...s.texts,...t.texts,categories:{...s.texts?.categories,...t.texts?.categories}}})}function B(e,t){P();let s={...C,...t.texts,categories:{...C.categories,...t.texts?.categories}},c=t.categories??j,d=e.core.getConsent(),a=t.position??"bottom",m=`lc-consent-${Math.random().toString(36).slice(2,8)}`,L=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,M=document.activeElement,v=c.map(o=>{let i=l("input",{type:"checkbox",id:`${m}-${o}`,checked:d[o]});return{c:o,input:i,row:l("label",{htmlFor:i.id},i,document.createTextNode(` ${s.categories[o]}`))}}),p=(o,i)=>{let u=l("button",{type:"button",textContent:o});return u.style.cssText=`padding:.5rem 1rem;margin:.25rem .5rem .25rem 0;border:1px solid #1f2937;border-radius:.375rem;cursor:pointer;font:inherit;background:${i?"#1f2937":"#fff"};color:${i?"#fff":"#1f2937"}`,u},g=p(s.acceptAll,!0),k=p(s.rejectAll,!0),T=p(s.save,!1),n=l("div",{role:"dialog",id:m},l("h2",{id:`${m}-t`,textContent:s.title}),l("p",{id:`${m}-d`,textContent:s.body}),...c.length>1?v.map(o=>o.row):[],l("div",{},g,k,...c.length>1?[T]:[]));n.setAttribute("aria-modal","true"),n.setAttribute("aria-labelledby",`${m}-t`),n.setAttribute("aria-describedby",`${m}-d`),n.setAttribute("data-lc-ignore",""),n.style.cssText="position:fixed;z-index:2147483000;box-sizing:border-box;padding:1rem 1.25rem;background:#fff;color:#111827;font:14px/1.4 system-ui,sans-serif;box-shadow:0 0 .75rem rgba(0,0,0,.3);display:block";for(let[o,i]of Object.entries(w[a]))n.style.setProperty(o,i);for(let o of n.querySelectorAll("h2"))o.style.cssText="margin:0 0 .5rem;font-size:1.1rem";for(let o of n.querySelectorAll("label"))o.style.cssText="display:block;margin:.25rem 0";return L||(n.style.opacity="0",n.style.transition="opacity .2s",requestAnimationFrame(()=>n.style.opacity="1")),new Promise(o=>{let i=r=>{document.removeEventListener("keydown",E,!0),n.remove(),h=void 0,M?.focus?.(),r&&A(e,r,"banner",t.version?{version:t.version}:{}),o(r?e.core.getConsent():null)},u=r=>Object.fromEntries(c.map(f=>[f,r])),E=r=>{if(r.key==="Escape")return void i(null);if(r.key!=="Tab")return;let f=[...n.querySelectorAll(O)],y=f[0],b=f[f.length-1],x=document.activeElement;if(!n.contains(x))(r.shiftKey?b:y).focus();else if(r.shiftKey&&x===y)b.focus();else if(!r.shiftKey&&x===b)y.focus();else return;r.preventDefault()};g.onclick=()=>i(u(!0)),k.onclick=()=>i(u(!1)),T.onclick=()=>i(Object.fromEntries(v.map(r=>[r.c,r.input.checked]))),document.addEventListener("keydown",E,!0),document.body.append(n),h={root:n,close:()=>i(null)},g.focus()})}export{S as fromRemote,P as hideBanner,_ as showBanner};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-O4W7SZ2X.js";var r="$consent_updated";function l(e,s,a,n={}){let c=JSON.stringify(e.core.getConsent());e.client.setConsent(s);let t=e.core.getConsent();if(n.onlyIfChanged&&JSON.stringify(t)===c)return;let o={categories:t,source:a,version:n.version??e.config.consent?.policyVersion??"1"};if(e.core.hasConsent("analytics"))e.client.capture(r,o);else if(e.config.consent?.logBeacon&&!e.config.disabled){let p=JSON.stringify({api_key:e.apiKey,batch:[{uuid:i(Date.now()),event:r,timestamp:new Date().toISOString(),properties:{...o,$lib:"lucida-browser"}}],sent_at:new Date().toISOString()});e.fetch(`${e.config.apiHost}/v1/batch`,{method:"POST",body:p,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{})}}export{r as a,l as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=!1;function t(){if(e)return null;e=!0;let r=!1;return()=>{r||(r=!0,e=!1)}}export{t as a};
|