@kubesense/kubesense-browser-logs 0.0.0-stage → 2.0.0-beta.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 +201 -0
- package/README.md +90 -2
- package/bundle/kubesense-logs.js +1 -0
- package/cjs/boot/logsPublicApi.d.ts +231 -0
- package/cjs/boot/logsPublicApi.js +75 -0
- package/cjs/boot/logsPublicApi.js.map +1 -0
- package/cjs/boot/preStartLogs.d.ts +8 -0
- package/cjs/boot/preStartLogs.js +105 -0
- package/cjs/boot/preStartLogs.js.map +1 -0
- package/cjs/boot/startLogs.d.ts +35 -0
- package/cjs/boot/startLogs.js +54 -0
- package/cjs/boot/startLogs.js.map +1 -0
- package/cjs/domain/assembly.d.ts +5 -0
- package/cjs/domain/assembly.js +35 -0
- package/cjs/domain/assembly.js.map +1 -0
- package/cjs/domain/configuration.d.ts +306 -0
- package/cjs/domain/configuration.js +86 -0
- package/cjs/domain/configuration.js.map +1 -0
- package/cjs/domain/console/consoleCollection.d.ts +20 -0
- package/cjs/domain/console/consoleCollection.js +37 -0
- package/cjs/domain/console/consoleCollection.js.map +1 -0
- package/cjs/domain/contexts/commonContext.d.ts +2 -0
- package/cjs/domain/contexts/commonContext.js +13 -0
- package/cjs/domain/contexts/commonContext.js.map +1 -0
- package/cjs/domain/contexts/internalContext.d.ts +7 -0
- package/cjs/domain/contexts/internalContext.js +11 -0
- package/cjs/domain/contexts/internalContext.js.map +1 -0
- package/cjs/domain/contexts/rumInternalContext.d.ts +2 -0
- package/cjs/domain/contexts/rumInternalContext.js +32 -0
- package/cjs/domain/contexts/rumInternalContext.js.map +1 -0
- package/cjs/domain/contexts/sessionContext.d.ts +4 -0
- package/cjs/domain/contexts/sessionContext.js +20 -0
- package/cjs/domain/contexts/sessionContext.js.map +1 -0
- package/cjs/domain/contexts/trackingConsentContext.d.ts +3 -0
- package/cjs/domain/contexts/trackingConsentContext.js +14 -0
- package/cjs/domain/contexts/trackingConsentContext.js.map +1 -0
- package/cjs/domain/createErrorFieldFromRawError.d.ts +10 -0
- package/cjs/domain/createErrorFieldFromRawError.js +15 -0
- package/cjs/domain/createErrorFieldFromRawError.js.map +1 -0
- package/cjs/domain/hooks.d.ts +28 -0
- package/cjs/domain/hooks.js +13 -0
- package/cjs/domain/hooks.js.map +1 -0
- package/cjs/domain/lifeCycle.d.ts +24 -0
- package/cjs/domain/lifeCycle.js +6 -0
- package/cjs/domain/lifeCycle.js.map +1 -0
- package/cjs/domain/logger/isAuthorized.d.ts +17 -0
- package/cjs/domain/logger/isAuthorized.js +34 -0
- package/cjs/domain/logger/isAuthorized.js.map +1 -0
- package/cjs/domain/logger/loggerCollection.d.ts +7 -0
- package/cjs/domain/logger/loggerCollection.js +47 -0
- package/cjs/domain/logger/loggerCollection.js.map +1 -0
- package/cjs/domain/logger.d.ts +48 -0
- package/cjs/domain/logger.js +112 -0
- package/cjs/domain/logger.js.map +1 -0
- package/cjs/domain/networkError/networkErrorCollection.d.ts +9 -0
- package/cjs/domain/networkError/networkErrorCollection.js +57 -0
- package/cjs/domain/networkError/networkErrorCollection.js.map +1 -0
- package/cjs/domain/plugins.d.ts +49 -0
- package/cjs/domain/plugins.js +12 -0
- package/cjs/domain/plugins.js.map +1 -0
- package/cjs/domain/remoteSdkConfiguration.d.ts +26 -0
- package/cjs/domain/remoteSdkConfiguration.js +67 -0
- package/cjs/domain/remoteSdkConfiguration.js.map +1 -0
- package/cjs/domain/report/reportCollection.d.ts +13 -0
- package/cjs/domain/report/reportCollection.js +30 -0
- package/cjs/domain/report/reportCollection.js.map +1 -0
- package/cjs/domain/reportError.d.ts +2 -0
- package/cjs/domain/reportError.js +20 -0
- package/cjs/domain/reportError.js.map +1 -0
- package/cjs/domain/runtimeError/runtimeErrorCollection.d.ts +14 -0
- package/cjs/domain/runtimeError/runtimeErrorCollection.js +29 -0
- package/cjs/domain/runtimeError/runtimeErrorCollection.js.map +1 -0
- package/cjs/domainContext.types.d.ts +11 -0
- package/cjs/entries/main.d.ts +33 -0
- package/cjs/entries/main.js +31 -0
- package/cjs/entries/main.js.map +1 -0
- package/cjs/logsEvent.types.d.ts +192 -0
- package/cjs/rawLogsEvent.types.d.ts +59 -0
- package/cjs/transport/startLogsBatch.d.ts +4 -0
- package/cjs/transport/startLogsBatch.js +22 -0
- package/cjs/transport/startLogsBatch.js.map +1 -0
- package/cjs/transport/startLogsBridge.d.ts +2 -0
- package/cjs/transport/startLogsBridge.js +13 -0
- package/cjs/transport/startLogsBridge.js.map +1 -0
- package/esm/boot/logsPublicApi.mjs +75 -0
- package/esm/boot/logsPublicApi.mjs.map +1 -0
- package/esm/boot/preStartLogs.mjs +105 -0
- package/esm/boot/preStartLogs.mjs.map +1 -0
- package/esm/boot/startLogs.mjs +54 -0
- package/esm/boot/startLogs.mjs.map +1 -0
- package/esm/domain/assembly.mjs +35 -0
- package/esm/domain/assembly.mjs.map +1 -0
- package/esm/domain/configuration.mjs +84 -0
- package/esm/domain/configuration.mjs.map +1 -0
- package/esm/domain/console/consoleCollection.mjs +36 -0
- package/esm/domain/console/consoleCollection.mjs.map +1 -0
- package/esm/domain/contexts/commonContext.mjs +13 -0
- package/esm/domain/contexts/commonContext.mjs.map +1 -0
- package/esm/domain/contexts/internalContext.mjs +11 -0
- package/esm/domain/contexts/internalContext.mjs.map +1 -0
- package/esm/domain/contexts/rumInternalContext.mjs +32 -0
- package/esm/domain/contexts/rumInternalContext.mjs.map +1 -0
- package/esm/domain/contexts/sessionContext.mjs +20 -0
- package/esm/domain/contexts/sessionContext.mjs.map +1 -0
- package/esm/domain/contexts/trackingConsentContext.mjs +14 -0
- package/esm/domain/contexts/trackingConsentContext.mjs.map +1 -0
- package/esm/domain/createErrorFieldFromRawError.mjs +15 -0
- package/esm/domain/createErrorFieldFromRawError.mjs.map +1 -0
- package/esm/domain/hooks.mjs +13 -0
- package/esm/domain/hooks.mjs.map +1 -0
- package/esm/domain/lifeCycle.mjs +7 -0
- package/esm/domain/lifeCycle.mjs.map +1 -0
- package/esm/domain/logger/isAuthorized.mjs +32 -0
- package/esm/domain/logger/isAuthorized.mjs.map +1 -0
- package/esm/domain/logger/loggerCollection.mjs +47 -0
- package/esm/domain/logger/loggerCollection.mjs.map +1 -0
- package/esm/domain/logger.mjs +110 -0
- package/esm/domain/logger.mjs.map +1 -0
- package/esm/domain/networkError/networkErrorCollection.mjs +56 -0
- package/esm/domain/networkError/networkErrorCollection.mjs.map +1 -0
- package/esm/domain/plugins.mjs +12 -0
- package/esm/domain/plugins.mjs.map +1 -0
- package/esm/domain/remoteSdkConfiguration.mjs +65 -0
- package/esm/domain/remoteSdkConfiguration.mjs.map +1 -0
- package/esm/domain/report/reportCollection.mjs +30 -0
- package/esm/domain/report/reportCollection.mjs.map +1 -0
- package/esm/domain/reportError.mjs +20 -0
- package/esm/domain/reportError.mjs.map +1 -0
- package/esm/domain/runtimeError/runtimeErrorCollection.mjs +29 -0
- package/esm/domain/runtimeError/runtimeErrorCollection.mjs.map +1 -0
- package/esm/entries/main.mjs +27 -0
- package/esm/entries/main.mjs.map +1 -0
- package/esm/transport/startLogsBatch.mjs +22 -0
- package/esm/transport/startLogsBatch.mjs.map +1 -0
- package/esm/transport/startLogsBridge.mjs +13 -0
- package/esm/transport/startLogsBridge.mjs.map +1 -0
- package/package.json +53 -3
- package/src/boot/logsPublicApi.ts +427 -0
- package/src/boot/preStartLogs.ts +192 -0
- package/src/boot/startLogs.ts +83 -0
- package/src/domain/assembly.ts +73 -0
- package/src/domain/configuration.ts +176 -0
- package/src/domain/console/consoleCollection.ts +58 -0
- package/src/domain/contexts/commonContext.ts +15 -0
- package/src/domain/contexts/internalContext.ts +19 -0
- package/src/domain/contexts/rumInternalContext.ts +60 -0
- package/src/domain/contexts/sessionContext.ts +34 -0
- package/src/domain/contexts/trackingConsentContext.ts +18 -0
- package/src/domain/createErrorFieldFromRawError.ts +22 -0
- package/src/domain/hooks.ts +40 -0
- package/src/domain/lifeCycle.ts +25 -0
- package/src/domain/logger/isAuthorized.ts +33 -0
- package/src/domain/logger/loggerCollection.ts +69 -0
- package/src/domain/logger.ts +202 -0
- package/src/domain/networkError/networkErrorCollection.ts +104 -0
- package/src/domain/plugins.ts +72 -0
- package/src/domain/remoteSdkConfiguration.ts +105 -0
- package/src/domain/report/reportCollection.ts +47 -0
- package/src/domain/reportError.ts +20 -0
- package/src/domain/runtimeError/runtimeErrorCollection.ts +51 -0
- package/src/domainContext.types.ts +21 -0
- package/src/entries/main.ts +65 -0
- package/src/logsEvent.types.ts +198 -0
- package/src/rawLogsEvent.types.ts +74 -0
- package/src/transport/startLogsBatch.ts +29 -0
- package/src/transport/startLogsBridge.ts +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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 2019-Present KubeSense, Inc.
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Kubesense Browser Logs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Send logs to Kubesense from your browser pages. The Logs SDK forwards console
|
|
4
|
+
errors and uncaught exceptions, and lets you send your own structured log entries
|
|
5
|
+
with severity levels and custom context.
|
|
6
|
+
|
|
7
|
+
It can run standalone or alongside [`@kubesense/kubesense-browser-rum`][rum] — when
|
|
8
|
+
both are present, logs are automatically correlated with the active RUM session
|
|
9
|
+
and view.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @kubesense/kubesense-browser-logs
|
|
15
|
+
# or
|
|
16
|
+
yarn add @kubesense/kubesense-browser-logs
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Initialize the SDK as early as possible in your application's lifecycle:
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { kubesenseLogs } from '@kubesense/kubesense-browser-logs'
|
|
25
|
+
|
|
26
|
+
kubesenseLogs.init({
|
|
27
|
+
clientToken: '<KUBESENSE_CLIENT_TOKEN>',
|
|
28
|
+
kubesenseRumEndpoint: '<KUBESENSE_RUM_ENDPOINT>',
|
|
29
|
+
forwardErrorsToLogs: true,
|
|
30
|
+
sessionSampleRate: 100,
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Sending logs
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
import { kubesenseLogs } from '@kubesense/kubesense-browser-logs'
|
|
38
|
+
|
|
39
|
+
kubesenseLogs.logger.info('Button clicked', { name: 'buttonName', id: 123 })
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
throw new Error('Wrong behavior')
|
|
43
|
+
} catch (error) {
|
|
44
|
+
kubesenseLogs.logger.error('Error occurred', { team: 'myTeam' }, error)
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The logger exposes `debug`, `info`, `warn`, and `error` methods. Each accepts a
|
|
49
|
+
message, an optional context object, and an optional `Error`.
|
|
50
|
+
|
|
51
|
+
### Identifying the user
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
kubesenseLogs.setUser({ id: 'u-123', name: 'Jane Doe', email: 'jane@example.com', mobile: '+919876543210' })
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`id`, `name`, `email`, `mobile` and any custom properties are attached to every
|
|
58
|
+
log as `usr.*`. Changing the user id ends the current session and starts a new
|
|
59
|
+
one, so one user's logs never land in another user's session — call `setUser()`
|
|
60
|
+
only when the identity actually changes.
|
|
61
|
+
|
|
62
|
+
### Dashboard-managed configuration
|
|
63
|
+
|
|
64
|
+
The Logs SDK opts into remote configuration independently of RUM:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
kubesenseLogs.init({
|
|
68
|
+
clientToken: '<KUBESENSE_CLIENT_TOKEN>',
|
|
69
|
+
kubesenseRumEndpoint: '<KUBESENSE_RUM_ENDPOINT>',
|
|
70
|
+
enableRemoteSdkConfiguration: true,
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Sampling and forwarding settings can then be managed from the Kubesense dashboard
|
|
75
|
+
without a redeploy. The SDK reads its cached document during `init()` and
|
|
76
|
+
refreshes it in the background, so changes apply from the next page load. It is
|
|
77
|
+
off by default, and any missing or invalid remote value falls back to your local
|
|
78
|
+
`init()` value. See [Remote SDK Configuration][remote-config].
|
|
79
|
+
|
|
80
|
+
## Documentation
|
|
81
|
+
|
|
82
|
+
See the [dedicated Kubesense documentation][docs] for configuration options,
|
|
83
|
+
custom loggers, and log filtering.
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
[Apache-2.0](https://github.com/kubesense-ai/kubesense-browser-sdk/blob/main/LICENSE)
|
|
88
|
+
|
|
89
|
+
[rum]: https://www.npmjs.com/package/@kubesense/kubesense-browser-rum
|
|
90
|
+
[docs]: https://docs.kubesense.ai/logs/log_collection/javascript
|
|
91
|
+
[remote-config]: https://github.com/kubesense-ai/kubesense-browser-sdk/blob/main/docs/REMOTE_SDK_CONFIG.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{const e=globalThis,t="WorkerGlobalScope"in e;let n=!1;function r(e){n=e}function o(){return n}const s="https://docs.kubesense.ai",i="More details:",a={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},c=console,u={log:c.log,debug:c.debug,info:c.info,warn:c.warn,error:c.error};function l(e){return{debug:u.debug.bind(c,e),log:u.log.bind(c,e),info:u.info.bind(c,e),warn:u.warn.bind(c,e),error:u.error.bind(c,e)}}const f=l("KubeSense Browser SDK:"),d=s+"/rum/browser/troubleshooting";function p(e,t){return(...n)=>{try{return e(...n)}catch(e){f.error(t,e)}}}let g;const m=function(e,t){function n(e){return function(...t){return r(e,this,t)}}function r(e,t,n){try{return e.apply(t,n)}catch(e){s(e)}}function s(n){const r=t=>{o()&&e.error("[MONITOR]",t)};r(n);try{t(n)}catch(n){r(n)}}return{monitored(e,t,r){r.value=n(r.value)},monitor:n,callMonitored:r,monitorError:s}}(l("KubeSense SDK:"),e=>g?.(e)),b=m.monitor,y=m.callMonitored,h=m.monitorError;function v(t){const n=e.queueMicrotask;"function"==typeof n?n(b(t)):Promise.resolve().then(b(t))}class k{constructor(e){this.onFirstSubscribe=e,this.observers=[]}subscribe(e){return this.addObserver(e),{unsubscribe:()=>this.removeObserver(e)}}notify(e){this.observers.forEach(t=>t(e))}addObserver(e){this.observers.push(e),1===this.observers.length&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe(this)||void 0)}removeObserver(e){this.observers=this.observers.filter(t=>e!==t),!this.observers.length&&this.onLastUnsubscribe&&this.onLastUnsubscribe()}}function S(...e){return new k(t=>{const n=e.map(e=>e.subscribe(e=>t.notify(e)));return()=>n.forEach(e=>e.unsubscribe())})}class w extends k{constructor(e,t){super(),this.maxBufferSize=e,this.onDrop=t,this.buffer=[],this.droppedCount=0}notify(e){this.buffer.push(e),this.buffer.length>this.maxBufferSize&&(this.buffer.shift(),this.droppedCount++),super.notify(e)}subscribe(e){let t=!1;const n={unsubscribe:()=>{t=!0,this.removeObserver(e)}};return v(()=>{for(const n of this.buffer){if(t)return;e(n)}t||this.addObserver(e)}),n}unbuffer(){v(()=>{this.droppedCount>0&&this.onDrop&&this.onDrop(this.droppedCount),this.maxBufferSize=this.buffer.length=0})}}function x(){return(new Date).getTime()}function E(){return x()}function C(e,t){return t-e}function _(e,t){return e+t}function A(){return performance.now()}function T(){return{relative:A(),timeStamp:E()}}function O(){return{relative:0,timeStamp:L()}}function R(e){return e-L()}let I,$,P;function L(){return void 0===I&&(I=performance.timing?.navigationStart??performance.timeOrigin),I}function q(t){return M(t,e.document?.baseURI??e.location?.href).href}function M(t,n){const r=function(){if(!$){let t=!1;try{t="http://a/b"===new e.URL("b","http://a").href}catch{}$=t?e.URL:function(){if(!P){let t,n;try{t=document.createElement("iframe"),t.style.display="none",document.body.appendChild(t),n=t.contentWindow??e}catch{n=e}P={URL:n.URL},t?.remove()}return P}().URL}return $}();try{return void 0!==n?new r(t,n):new r(t)}catch(e){throw Error("Failed to construct URL: "+e)}}function N(t,n){const r=e;let o;return r.Zone&&"function"==typeof r.Zone.__symbol__&&(o=t[r.Zone.__symbol__(n)]),o||(o=t[n]),o}function U(t,n){return N(e,"setTimeout")(b(t),n)}function j(t){N(e,"clearTimeout")(t)}function D(t,n){return N(e,"setInterval")(b(t),n)}function B(t){N(e,"clearInterval")(t)}function F(){}function z(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function G(e){return"object"===z(e)}new Map;const K="?";function H(e){const t=[];let n=te(e,"stack");const r=e+"";if(n?.startsWith(r)&&(n=n.slice(r.length)),n&&n.split("\n").forEach(e=>{const n=function(e){const t=V.exec(e);if(!t)return;const n=0===t[2]?.indexOf("native"),r=0===t[2]?.indexOf("eval"),o=Z.exec(t[2]);return r&&o&&(t[2]=o[1],t[3]=o[2],t[4]=o[3]),{args:n?[t[2]]:[],column:t[4]?+t[4]:void 0,func:t[1]||K,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){const t=X.exec(e);if(t)return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||K,line:t[3]?+t[3]:void 0,url:t[2]}}(e)||function(e){const t=Q.exec(e);if(t)return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||K,line:+t[3],url:t[2]}}(e)||function(e){const t=Y.exec(e);if(!t)return;const n=t[3]&&t[3].indexOf(" > eval")>-1,r=ee.exec(t[3]);return n&&r&&(t[3]=r[1],t[4]=r[2],t[5]=void 0),{args:t[2]?t[2].split(","):[],column:t[5]?+t[5]:void 0,func:t[1]||K,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=K),t.push(n))}),t.length>0&&function(){if(void 0!==oe)return oe;const[e,t]=[class extends Error{constructor(){super(),this.name="Error"}},Error].map(e=>new e);return oe=re(Object.getPrototypeOf(e))&&t.stack!==e.stack,oe}()&&e instanceof Error){const n=[];let r=e;for(;(r=Object.getPrototypeOf(r))&&re(r);){const e=r.constructor?.name||K;n.push(e)}for(let e=n.length-1;e>=0&&t[0]?.func===n[e];e--)t.shift()}return{message:te(e,"message"),name:te(e,"name"),stack:t}}const W="((?:blob|native|eval|<anonymous>|[a-zA-Z][a-zA-Z0-9+.-]*:\\/\\/|\\w+\\.|\\/).*?)",J="(?::(\\d+))",V=RegExp(`^\\s*at (.*?) ?\\(${W}${J}?${J}?\\)?\\s*$`,"i"),Z=RegExp(`\\((\\S*)${J}${J}\\)`),X=RegExp(`^\\s*at\\s*(?:(.*)?(?: @))?\\s*${W}${J}?${J}??\\s*$`,"i"),Q=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Y=/^\s*(.*?)(?:\((.*?)\))?(?:(?:(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle|\[wasm code\])(?::(\d+))?(?::(\d+))?)|@)\s*$/i,ee=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function te(e,t){return G(e)&&"string"==typeof e[t]?e[t]:void 0}const ne=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;function re(e){return(e.constructor+"").startsWith("class ")}let oe;function se(e){const t=Error(e);let n;return t.name="HandlingStack",y(()=>{const e=H(t);e.stack=e.stack.slice(2),n=ie(e)}),n}function ie(e){let t=ae(e);return e.stack.forEach(e=>{const n="?"===e.func?"<anonymous>":e.func,r=e.args&&e.args.length>0?`(${e.args.join(", ")})`:"",o=e.line?":"+e.line:"",s=e.line&&e.column?":"+e.column:"";t+=`\n at ${n}${r} @ ${e.url}${o}${s}`}),t}function ae(e){return`${e.name||"Error"}: ${e.message}`}function ce(e,t,n,{computeHandlingStack:r}={}){let o=e[t];if("function"!=typeof o){if(!(t in e)||"string"!=typeof t||!t.startsWith("on"))return{stop:F};o=F}let s=!1;const{stop:i}=function(e,t,n,r){return e[t]=r,{stop(){e[t]===r&&(e[t]=n)}}}(e,t,o,function(){if(s)return o.apply(this,arguments);const e=Array.from(arguments);return function(e,t,n){let r;y(e,null,[{...t,onPostCall(e){r=e}}]);const o=n();return r&&y(r,null,[o]),o}(n,{target:this,parameters:e,handlingStack:r?se("instrumented method"):void 0},()=>o.apply(this,e))});return{stop(){s=!0,i()}}}const ue=/[^\u0000-\u007F]/;function le(e){return ue.test(e)?(new TextEncoder).encode(e).length:e.length}function fe(e){return e>=500}let de;const pe=[];function ge({responseBodyAction:t}={}){return t&&pe.push(t),de||(de=new k(t=>{if(!e.fetch)return;const{stop:n}=ce(e,"fetch",e=>function({parameters:e,onPostCall:t,handlingStack:n},r){const[o,s]=e;let i=s?.method;void 0===i&&o instanceof Request&&(i=o.method);const a=void 0!==i?(i+"").toUpperCase():"GET",c=o instanceof Request?o.url:q(o+""),u={state:"start",init:s,input:o,method:a,startClocks:T(),url:c,handlingStack:n,isAbortedOnStart:o instanceof Request&&o.signal?.aborted||s?.signal?.aborted||!1};r.notify(u),e[0]=u.input,e[1]=u.init,t(e=>{(async function(e,t,n){const r=n;let o;try{o=await t}catch(t){return void e.notify({...r,state:"resolve",status:0,isAborted:r.init?.signal?.aborted||t instanceof DOMException&&t.code===DOMException.ABORT_ERR,error:t})}if(r.response=o,r.status=o.status,r.responseType=o.type,r.isAborted=!1,1===pe.reduce((e,t)=>Math.max(e,t(r)),0)){const e=function(e){try{return e.clone()}catch{return}}(o);if(e?.body)try{const t=await async function(e){const t=e.getReader(),n=[];for(;;){const e=await t.read();if(e.done)break;n.push(e.value)}return t.cancel().catch(F),function(e){if(1===e.length)return e[0];const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(n)}(e.body);r.responseBody=(new TextDecoder).decode(t)}catch{}}e.notify({...r,state:"resolve"})})(r,e,u).catch(h)})}(e,t),{computeHandlingStack:!0});return n})),de}function me(e,t,n,r){return be(e,[t],n,r)}function be(e,t,n,{once:r,capture:o,passive:s}={}){const i=b(e=>{(e.isTrusted||e.__kubesenseIsTrusted||!1!==he)&&(r&&l(),n(e))}),a=s?{capture:o,passive:s}:o,c=window.EventTarget&&e instanceof EventTarget?window.EventTarget.prototype:e,u=N(c,"addEventListener");function l(){const n=N(c,"removeEventListener");t.forEach(t=>n.call(e,t,i,a))}return t.forEach(t=>u.call(e,t,i,a)),{stop:l}}function ye(e,t){if(!e)return!1;try{return me(e,t,F).stop(),!0}catch{return!1}}let he,ve;const ke=new WeakMap;function Se({target:e,parameters:[t,n]}){ke.set(e,{state:"open",method:(t+"").toUpperCase(),url:q(n+"")})}function we({target:e}){const t=ke.get(e);t&&(t.isAborted=!0)}function xe(e,t){return Ee(e,t,function(){const e=new WeakSet;return{hasAlreadyBeenSeen(t){const n=e.has(t);return n||e.add(t),n}}}())}function Ee(e,t,n){if(void 0===t)return e;if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return RegExp(t.source,t.flags);if(n.hasAlreadyBeenSeen(t))return;if(Array.isArray(t)){const r=Array.isArray(e)?e:[];for(let e=0;e<t.length;++e)r[e]=Ee(r[e],t[e],n);return r}const r="object"===z(e)?e:{};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&"__proto__"!==e&&(r[e]=Ee(r[e],t[e],n));return r}function Ce(e){return xe(void 0,e)}function _e(...e){let t;for(const n of e)null!=n&&(t=xe(t,n));return t}function Ae(){let e=[];return{register(t){return e.push(t),{unregister(){e=e.filter(e=>e!==t)}}},trigger(t){const n=[];for(const r of e){const e=r(t);if(e===Te)return Te;e!==Oe&&n.push(e)}return _e(...n)}}}const Te="DISCARDED",Oe="SKIPPED";function Re(e){return 0!==e&&100*Math.random()<=e}const Ie="rum.tyke.ai",$e="us2.kubesense.ai",Pe=["ksource","kubesense-api-key","kubesense-request-id"];function Le(e,t,n){return{build(r,o){return function({proxy:e,kubesenseRumEndpoint:t=$e,path:n,parameters:r="",subdomain:o}){let s=n;if(r&&(s+="?"+r),"string"==typeof e){let t=`${q(e)}?kubesense-forward=${encodeURIComponent(s)}`;return o&&(t+="&kubesense-forward-subdomain="+o),t}if("function"==typeof e)return e({path:n,parameters:r,subdomain:o});let i=t;return o&&(i=`${o}.${i}`),`https://${i}${s}`}({proxy:e.proxy,kubesenseRumEndpoint:e.kubesenseRumEndpoint,path:"/rum/api/v1/"+t,parameters:Me(e,t,r,o,n)})},trackType:t}}function qe({replica:e,proxy:t,source:n},r){if(e)return Le({clientToken:e.clientToken,proxy:t,source:n,kubesenseRumEndpoint:$e},r,"rum"===r?["application.id="+e.applicationId]:void 0)}function Me({clientToken:e,source:t="browser"},n,r,{retry:o,encoding:s},i=[]){const a=["ksource="+t,"kubesense-api-key="+e,"kubesense-evp-origin-version="+encodeURIComponent("2.0.0"),"kubesense-evp-origin=browser","kubesense-request-id="+Ne()].concat(i);return s&&a.push("kubesense-evp-encoding="+s),"rum"===n&&(a.push("batch_time="+E(),"_kubesense.api="+r),o&&a.push("_kubesense.retry_count="+o.count,"_kubesense.retry_after="+o.lastFailureStatus)),a.join("&")}function Ne(e){return e?(parseInt(e,10)^16*Math.random()>>parseInt(e,10)/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,Ne)}const Ue="No stack, consider using an instance of Error";function je(e){try{return e instanceof Error||"[object Error]"===Object.prototype.toString.call(e)}catch{return!1}}const De=(e,t)=>"__proto__"===e?void 0:t;function Be(e){return 0===Object.keys(e).length}var Fe;!function(e){e.TRACK_INTAKE_REQUESTS="track_intake_requests",e.TRACK_WEBSOCKETS="track_websockets"}(Fe||(Fe={}));const ze=new Set;function Ge(e){const{env:t,service:n,version:r,datacenter:o,sdkVersion:s,variant:i}=e,a=[Ke("sdk_version",s??"2.0.0")];return t&&a.push(Ke("env",t)),n&&a.push(Ke("service",n)),r&&a.push(Ke("version",r)),o&&a.push(Ke("datacenter",o)),i&&a.push(Ke("variant",i)),a}function Ke(e,t){const n=t?`${e}:${t}`:e;return(n.length>200||function(e){return RegExp("[^\\p{Ll}\\p{Lo}0-9_:./-]","u").test(e)}(n))&&f.warn(`Tag ${n} doesn't meet tag requirements and will be sanitized. ${i} ${s}/getting_started/tagging/#defining-tags`),He(n)}function He(e){return e.replace(/,/g,"_")}function We(t,n){const r=e.__kubesenseBrowserSdkExtensionCallback;r&&r({type:t,payload:n})}function Je(e,t,n){if("object"!=typeof e||null===e)return JSON.stringify(e);const r=Ve(Object.prototype),o=Ve(Array.prototype),s=Ve(Object.getPrototypeOf(e)),i=Ve(e);try{return JSON.stringify(e,t,n)}catch{return"<error: unable to serialize object>"}finally{r(),o(),s(),i()}}function Ve(e){const t=e,n=t.toJSON;return n?(delete t.toJSON,()=>{t.toJSON=n}):F}function Ze(){const{navigator:t}=e;return{status:t?.onLine?"connected":"not_connected",interfaces:t?.connection?.type?[t.connection.type]:["unknown"],effective_type:t?.connection?.effectiveType,rtt:t?.connection?.rtt,downlink:t?.connection?.downlink}}function Xe(){const t=e.KubeSenseEventBridge;if(t)return{getCapabilities(){return JSON.parse(t.getCapabilities?.()||"[]")},getPrivacyLevel(){return t.getPrivacyLevel?.()},getIsTraceSampled(){return JSON.parse(t.getIsTraceSampled?.()||"null")},getAllowedWebViewHosts(){return JSON.parse(t.getAllowedWebViewHosts())},send(e,n,r){const o=r?{id:r}:void 0;t.send(JSON.stringify({eventType:e,event:n,view:o}))}}}function Qe(t=e.location?.hostname){const n=Xe();return n?.getAllowedWebViewHosts().some(e=>function(e,t){if(!t.includes("*"))return e===t||e.endsWith("."+t);const n=t.split("*");if(2!==n.length)return f.error(`Invalid WebView host pattern "${t}": only one wildcard (*) is supported.`),!1;const[r,o]=n;return e.length>r.length+o.length&&e.startsWith(r)&&e.endsWith(o)}(t,e))??!1}function Ye(e){return Object.values(e)}const et={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};function tt(){let e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write(n,r){const o=le(n);t+=o,e+=n,r&&r(o)},finish(e){e(this.finishSync())},finishSync(){const n={output:e,outputBytesCount:t,rawBytesCount:t,pendingData:""};return e="",t=0,n},estimateEncodedBytesCount(e){return e.length}}}function nt(t,n){return N(e,"fetch")(t,n)}function rt(e,t,n,r,o,s){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?st(e,t,n,s,{onSuccess:()=>it(0,t,n,r,o,s),onFailure(){t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e}),ot(t,n,r,o,s)}}):t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e})}function ot(e,t,n,r,o){2===e.transportStatus&&U(()=>{st(e.queuedPayloads.first(),e,t,o,{onSuccess(){e.queuedPayloads.dequeue(),e.currentBackoffTime=1e3,it(1,e,t,n,r,o)},onFailure(){e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),ot(e,t,n,r,o)}})},e.currentBackoffTime)}function st(e,t,n,r,{onSuccess:o,onFailure:s}){t.bandwidthMonitor.add(e),n(e,n=>{t.bandwidthMonitor.remove(e),function(e,t,n){return"opaque"!==e.type&&(0===e.status&&(!navigator.onLine||(t.retry?.count??0)<n)||408===e.status||429===e.status||fe(e.status))}(n,e,t.networkErrorRetries)?(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:n.status},r.notify({type:"failure",bandwidth:t.bandwidthMonitor.stats(),payload:e}),s()):(t.transportStatus=0,r.notify(function(e){return"opaque"===e.type||e.status>=200&&e.status<400}(n)?{type:"success",bandwidth:t.bandwidthMonitor.stats(),payload:e}:{type:"dropped",bandwidth:t.bandwidthMonitor.stats(),payload:e,status:n.status}),o())})}function it(e,t,n,r,o,s){0===e&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(o(`Reached max ${r} events size queued for upload: 20MiB`),t.queueFullReported=!0);const i=t.queuedPayloads;for(t.queuedPayloads=at();i.size()>0;)rt(i.dequeue(),t,n,r,o,s)}function at(){const e=[];return{bytesCount:0,enqueue(t){return!this.isFull()&&(e.push(t),this.bytesCount+=t.bytesCount,!0)},first(){return e[0]},dequeue(){const t=e.shift();return t&&(this.bytesCount-=t.bytesCount),t},size(){return e.length},isFull(){return this.bytesCount>=20971520}}}function ct(e,t,n){if(n.bytesCount<t)try{const t=e.build("beacon",n);if(navigator.sendBeacon(t,n.data))return}catch(e){!function(e){ut||(ut=!0,h(e))}(e)}lt(e,n)}let ut=!1;function lt(e,t,n){nt(e.build("fetch",t),{method:"POST",body:t.data,mode:"cors"}).then(b(e=>n?.({status:e.status,type:e.type}))).catch(b(()=>n?.({status:0})))}const ft=t?1:50;function dt({encoder:t=tt(),endpoints:n,reportError:r}){const o=function(e,t,n=16384,r=0){const o=new k,s=function(e=0){return{transportStatus:0,currentBackoffTime:1e3,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle(e){return 0===this.ongoingRequestCount||this.ongoingByteCount+e.bytesCount<=81920&&this.ongoingRequestCount<32},add(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount},stats(){return{ongoingByteCount:this.ongoingByteCount,ongoingRequestCount:this.ongoingRequestCount}}},queuedPayloads:at(),queueFullReported:!1,networkErrorRetries:e}}(r);return{observable:o,send(n){for(const r of e)rt(n,s,(e,t)=>{lt(r,e,t)},r.trackType,t,o)},sendOnExit(t){for(const r of e)ct(r,n,t)},sendQueuedOnExit(){let t;for(;void 0!==(t=s.queuedPayloads.dequeue());)for(const r of e)ct(r,n,t)}}}(n,r),s=new k(t=>{const n=e.window;if(!n)return;const{stop:r}=be(n,["visibilitychange","freeze"],e=>{"visibilitychange"===e.type&&"hidden"===document.visibilityState?t.notify({reason:et.HIDDEN}):"freeze"===e.type&&t.notify({reason:et.FROZEN})},{capture:!0}),o=me(n,"beforeunload",()=>{t.notify({reason:et.UNLOADING})}).stop,s=me(n,"pagehide",()=>{t.notify({reason:et.PAGEHIDE})}).stop;return()=>{r(),o(),s()}}),a=function({pageMayExitObservable:e}){let t;const n=new k,r=e.subscribe(e=>{t=e.reason;try{n.notify(e.reason)}finally{t=void 0}c(e.reason)}),o=new k(()=>()=>{r.unsubscribe()});let s,i=0,a=0;function c(e){if(0===a)return;const t=a,n=i;a=0,i=0,j(s),s=void 0,o.notify({reason:e,messagesCount:t,bytesCount:n})}return{flushObservable:o,prepareUrgentFlushObservable:n,forceFlush:c,get messagesCount(){return a},notifyBeforeAddMessage(e){i+e>=16384&&c(t??"bytes_limit"),a+=1,i+=e,void 0===s&&(s=U(()=>{c("duration_limit")},3e4))},notifyAfterAddMessage(e=0){i+=e,a>=ft?c(t??"messages_limit"):i>=16384&&c(t??"bytes_limit")}}}({pageMayExitObservable:s});let c={};const u=a.flushObservable.subscribe(e=>function(e){const n=Ye(c).join("\n");c={};const r=(i=e.reason,Ye(et).includes(i)),s=r?o.sendOnExit:o.send;var i;if(r&&t.isAsync){const e=t.finishSync();e.outputBytesCount&&s(pt(e));const r=[e.pendingData,n].filter(Boolean).join("\n");r&&s({data:r,bytesCount:le(r)})}else n&&t.write(t.isEmpty?n:"\n"+n),t.finish(e=>{s(pt(e))})}(e)),l=s.subscribe(()=>{o.sendQueuedOnExit()});function p(e,n){const r=Je(e),o=t.estimateEncodedBytesCount(r);o>=262144?f.warn(`Discarded a message whose size was bigger than the maximum allowed size 256KiB. ${i} ${d}/#technical-limitations`):function(e,n,r){if(void 0!==r){let o;void 0!==c[r]?o=n-t.estimateEncodedBytesCount(c[r]):(a.notifyBeforeAddMessage(n),o=0),c[r]=e,a.notifyAfterAddMessage(o)}else a.notifyBeforeAddMessage(n),t.write(t.isEmpty?e:"\n"+e,e=>{a.notifyAfterAddMessage(e-n)})}(r,o,n)}return{get isEmpty(){return 0===a.messagesCount},add:p,upsert:p,prepareUrgentFlushObservable:a.prepareUrgentFlushObservable,forceFlush:a.forceFlush,flushObservable:a.flushObservable,stop(){u.unsubscribe(),l.unsubscribe()}}}function pt(e){let t;return t="string"==typeof e.output?e.output:new Blob([e.output],{type:"text/plain"}),{data:t,bytesCount:e.outputBytesCount,encoding:e.encoding}}const gt="log",mt="configuration",bt="usage",yt=["https://rum.kubesense.ai","https://rum.tyke.ai","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],ht=[Ie];let vt;function kt(){return vt||(vt=new w(100)),vt}function St(e,t){o()&&f.debug("[Telemetry]",e,t),kt().notify({rawEvent:{type:gt,message:e,status:"debug",...t}})}function wt(e,t){kt().notify({rawEvent:{type:gt,status:"error",...Et(e),...t}})}function xt(e){kt().notify({rawEvent:{type:bt,usage:e}})}function Et(e){if(je(e)){const t=H(e);return{error:{kind:t.name,stack:ie(Ct(t))},message:t.message}}return{error:{stack:Ue},message:"Uncaught "+Je(e)}}function Ct(e){return e.stack=e.stack.filter(e=>!e.url||yt.some(t=>e.url.startsWith(t))),e}function _t(e,t=225280){const n=Ve(Object.prototype),r=Ve(Array.prototype);try{const n=[],r=new WeakMap,o=At(e,"$",void 0,n,r),s=JSON.stringify(o);let i=s?s.length:0;if(i>t)return void Ot(t,"discarded",e);for(;n.length>0&&i<t;){const o=n.shift();let s=0;if(Array.isArray(o.source))for(let a=0;a<o.source.length;a++){const c=At(o.source[a],o.path,a,n,r);if(i+=void 0!==c?JSON.stringify(c).length:4,i+=s,s=1,i>t){Ot(t,"truncated",e);break}o.target[a]=c}else for(const a in o.source)if(Object.prototype.hasOwnProperty.call(o.source,a)){const c=At(o.source[a],o.path,a,n,r);if(void 0!==c&&(i+=JSON.stringify(c).length+s+a.length+3,s=1),i>t){Ot(t,"truncated",e);break}o.target[a]=c}}return o}finally{n(),r()}}function At(e,t,n,r,o){const s=function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)return e;const t=e;if("function"==typeof t.toJSON)try{return t.toJSON()}catch{}return e}(e);if(!s||"object"!=typeof s)return"bigint"==typeof(i=s)?"[BigInt] "+i.toString():"function"==typeof i?"[Function] "+(i.name||"unknown"):"symbol"==typeof i?"[Symbol] "+(i.description||i.toString()):i;var i;const a=Tt(s);if("[Object]"!==a&&"[Array]"!==a&&"[Error]"!==a)return a;const c=e;if(o.has(c))return`[Reference seen at ${o.get(c)}]`;const u=void 0!==n?`${t}.${n}`:t,l=Array.isArray(s)?[]:{};return o.set(c,u),r.push({source:s,target:l,path:u}),l}function Tt(e){try{if(e instanceof Event)return{type:(t=e).type,isTrusted:t.isTrusted,currentTarget:t.currentTarget?Tt(t.currentTarget):null,target:t.target?Tt(t.target):null};if(e instanceof RegExp)return"[RegExp] "+e.toString();const n=Object.prototype.toString.call(e).match(/\[object (.*)\]/);if(n?.[1])return`[${n[1]}]`}catch{}var t;return"[Unserializable]"}function Ot(e,t,n){f.warn(`The data provided has been ${t} as it is over the limit of ${e} characters:`,n)}const Rt=new Map,It=new Set;let $t=!1;function Pt(t){!function(){const t=e.window?.KUBESENSE_SOURCE_CODE_CONTEXT;if(!t)return;let n=!1,r=!1,o=!1;for(const[e,s]of Object.entries(t)){if(n=n||void 0!==s.ddDebugId,r=r||void 0!==s.service,o=o||void 0!==s.version,It.has(e))continue;It.add(e);const t=H({stack:e}).stack[0]?.url;t&&!Rt.has(t)&&Rt.set(t,s)}$t||($t=!0,xt({feature:"source-code-context",use_debug_id:n,use_service:r,use_version:o}))}();const n=new Set,r=[];for(const e of t){if(n.has(e))continue;n.add(e);const t=Rt.get(e)?.ddDebugId;void 0!==t&&r.push({url:e,id:t})}return r.length?r:void 0}const Lt="Error";function qt({originalError:e,stackTrace:t,source:n,useFallbackStack:r=!0,nonErrorPrefix:o}){const s=je(e);return{source:n,type:Mt(t,e),message:Dt(t,s,o,e),stack:t?ie(t):r?Ue:void 0}}function Mt(e,t){return e?e.name||Lt:/\[object (\w+)\]/.exec(Object.prototype.toString.call(t))?.[1]??Lt}function Nt(e){return e?.stack.map(e=>e.url).filter(e=>!!e)??[]}function Ut(e,t){const n=t.flatMap(({stackTrace:e})=>Nt(e));return Pt(Nt(e).concat(n))}function jt({stackTrace:e,originalError:t,handlingStack:n,componentStack:r,startClocks:o,nonErrorPrefix:s,useFallbackStack:i=!0,source:a,handling:c}){const u=e??(je(t)?H(t):void 0),l=je(t)?function(e){const t=[];let n=e.cause;for(;null!=n&&t.length<10;){const e=je(n),r=e?H(n):void 0;t.push({originalError:n,stackTrace:r}),n=e?n.cause:void 0}return t}(t):[],f=qt({originalError:t,stackTrace:u,source:a,useFallbackStack:i,nonErrorPrefix:s}),d=l.map(({originalError:e,stackTrace:t})=>qt({originalError:e,stackTrace:t,source:a,useFallbackStack:!1}));return{startClocks:o,handling:c,handlingStack:n,componentStack:r,originalError:t,...f,debugIds:Ut(u,l),causes:d.length?d:void 0,fingerprint:Bt(t),context:Ft(t)}}function Dt(e,t,n,r){return e?.message&&e?.name?e.message:t?"Empty message":n?`${n} ${Je(_t(r))}`:Je(_t(r))}function Bt(e){return je(e)&&"kubesense_fingerprint"in e?e.kubesense_fingerprint+"":void 0}function Ft(e){if(G(e))return e.kubesense_context}const zt="agent",Gt="console",Kt="logger",Ht="source",Wt="report";let Jt={};function Vt(e,t,n,r){return b((...o)=>(r&&xt({feature:r}),e()[t][n](...o)))}function Zt(e,t,n){e.changeObservable.subscribe(()=>{const r=e.getContext();n.notify(e=>e[t].setContext(r))})}const Xt="userContext",Qt="globalContext",Yt="accountContext",en="getContext",tn="setContext",nn="setContextProperty",rn="removeContextProperty",on="clearContext";function sn(e,t){t.silentMultipleInit||f.error(e+" is already initialized.")}function an(e,t,n){const r={...e};for(const[e,{required:o,type:s}]of Object.entries(t))"string"!==s||cn(r[e])||(r[e]=r[e]+""),o&&cn(r[e])&&f.warn(`The property ${e} of ${n} is required; context will not be sent to the intake.`);return r}function cn(e){return null==e||""===e}function un(e="",{propertiesConfig:t={}}={}){let n={};const r=new k,o={getContext:()=>Ce(n),setContext(s){!function(e){const t="object"===z(e);return t||f.error("Unsupported context:",e),t}(s)?o.clearContext():n=_t(an(s,t,e)),r.notify()},setContextProperty(o,s){n=_t(an({...n,[o]:s},t,e)),r.notify()},removeContextProperty(o){delete n[o],an(n,t,e),r.notify()},clearContext(){n={},r.notify()},changeObservable:r};return o}function ln(e,t,n){const r=n.getHandler(),o=Array.isArray(r)?r:[r];return dn[e]>=dn[n.getLevel()]&&o.includes(t)}const fn={ok:"ok",debug:"debug",info:"info",notice:"notice",warn:"warn",error:"error",critical:"critical",alert:"alert",emerg:"emerg"},dn={[fn.ok]:0,[fn.debug]:1,[fn.info]:2,[fn.notice]:4,[fn.warn]:5,[fn.error]:6,[fn.critical]:7,[fn.alert]:8,[fn.emerg]:9};function pn(e,{includeMessage:t=!1}={}){return{stack:e.stack,kind:e.type,message:t?e.message:void 0,causes:e.causes,fingerprint:e.fingerprint,handling:e.handling}}const gn="http",mn=Object.keys(fn);class bn{constructor(e,t,n=gn,r=fn.debug,o={}){this.handleLogStrategy=e,this.handlerType=n,this.level=r,this.contextManager=un("logger"),this.tags=[],this.contextManager.setContext(o),t&&this.contextManager.setContextProperty("logger",{name:t})}logImplementation(e,t,n=fn.info,r,o){y(()=>{const s=_t(t);let i,a;if(null!=r){const e=jt({originalError:r,nonErrorPrefix:"Provided",source:Kt,handling:"handled",startClocks:T()});a=e.debugIds,i=_e({error:pn(e,{includeMessage:!0})},e.context,s)}else i=s;this.handleLogStrategy({message:_t(e),context:i,status:n,...a?{debugIds:a}:{}},this,o)})}log(e,t,n=fn.info,r){let o;ln(n,gn,this)&&(o=se("log")),this.logImplementation(e,t,n,r,o)}setContext(e){this.contextManager.setContext(e)}getContext(){return this.contextManager.getContext()}setContextProperty(e,t){this.contextManager.setContextProperty(e,t)}removeContextProperty(e){this.contextManager.removeContextProperty(e)}clearContext(){this.contextManager.clearContext()}addTag(e,t){this.tags.push(Ke(e,t))}removeTagsWithKey(e){const t=He(e);this.tags=this.tags.filter(e=>e!==t&&!e.startsWith(t+":"))}getTags(){return this.tags.slice()}setHandler(e){this.handlerType=e}getHandler(){return this.handlerType}setLevel(e){this.level=e}getLevel(){return this.level}}function yn(e){return function(t,n,r){let o;ln(e,gn,this)&&(o=se("log")),this.logImplementation(t,n,e,r,o)}}function hn(){return t?{}:{view:{referrer:document.referrer,url:window.location.href}}}function vn(e,t,n){if(e)for(const r of e){const e=r[t];e&&e(n)}}bn.prototype.ok=yn(fn.ok),bn.prototype.debug=yn(fn.debug),bn.prototype.info=yn(fn.info),bn.prototype.notice=yn(fn.notice),bn.prototype.warn=yn(fn.warn),bn.prototype.error=yn(fn.error),bn.prototype.critical=yn(fn.critical),bn.prototype.alert=yn(fn.alert),bn.prototype.emerg=yn(fn.emerg);const kn=[];function Sn(e,t,n){if("undefined"==typeof window||"undefined"==typeof localStorage)return;const r=function(e,t){return`_kubesense_c_${e}_${t}`}(t,n);kn.push(me(window,"storage",({key:t})=>{r===t&&e.setContext(s())})),e.changeObservable.subscribe(function(){localStorage.setItem(r,JSON.stringify(e.getContext()))});const o=_e(s(),e.getContext());function s(){const e=localStorage.getItem(r);return e?function(e){try{return JSON.parse(e,De)}catch{}}(e)??{}:{}}Be(o)||e.setContext(o)}function wn(){return un("account",{propertiesConfig:{id:{type:"string",required:!0},name:{type:"string"}}})}const xn=1/0;let En;const Cn=new Set;function _n({expireDelay:e,maxEntries:t}){let n=[];const r=()=>{if(!e)return;const t=A()-e;for(;n.length>0&&n[n.length-1].endTime<t;)n.pop()};return e&&(En||(En=D(()=>{Cn.forEach(e=>e())},6e4)),Cn.add(r)),{add(e,r){const o={value:e,startTime:r,endTime:xn,remove(){!function(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}(n,o)},close(e){o.endTime=e}};return t&&n.length>=t&&n.pop(),n.unshift(o),o},find(e=1/0,t={returnInactive:!1}){for(const r of n)if(r.startTime<=e){if(t.returnInactive||e<=r.endTime)return r.value;break}},closeActive(e){const t=n[0];t?.endTime===xn&&t.close(e)},findAll(e=1/0,t=0){const r=_(e,t);return n.filter(t=>t.startTime<=r&&e<=t.endTime).map(e=>e.value)},findAllEntries(e=1/0,t=0){const r=_(e,t);return n.filter(t=>t.startTime<=r&&e<=t.endTime)},getEntries:e=>n.filter(t=>t.startTime===e),reset(){n=[]},stop(){Cn.delete(r),0===Cn.size&&En&&(B(En),En=void 0)}}}const An=144e5,Tn="cookie",On="memory",Rn="local-storage";function In(e){return"string"==typeof e?e:void 0===e?void 0:Je(e)}function $n(e){return"_kubesense_session_user_"+e}function Pn(e,t){try{const n=$n(e);t?localStorage.setItem(n,t):localStorage.removeItem(n)}catch{}}function Ln(){return un("user",{propertiesConfig:{id:{type:"string"},name:{type:"string"},email:{type:"string"},mobile:{type:"string"}}})}function qn(){return un("global context")}function Mn(e){return e?(parseInt(e,10)^16*Math.random()>>parseInt(e,10)/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,Mn)}const Nn=/(\S+?)\s*=\s*(.*?)(?:;|$)/g;function Un(e,t,n=""){const r=e.charCodeAt(t-1),o=r>=55296&&r<=56319?t+1:t;return e.length<=o?e:`${e.slice(0,o)}${n}`}const jn="_kubesense_tab_id";let Dn;const Bn={[a.log]:fn.info,[a.debug]:fn.debug,[a.info]:fn.info,[a.warn]:fn.warn,[a.error]:fn.error},Fn={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function zn(e){return{startClocks:T(),source:Wt,handling:"unhandled",...e}}function Gn(e,t,n,r,o){return n?ie({name:e,message:t,stack:[{func:"?",url:n,line:r??void 0,column:o??void 0}]}):void 0}function Kn(e){return"xhr"===e?"XHR":"Fetch"}const Hn=class{constructor(){this.callbacks={}}notify(e,t){const n=this.callbacks[e];n&&n.forEach(e=>e(t))}subscribe(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),{unsubscribe:()=>{this.callbacks[e]=this.callbacks[e].filter(e=>t!==e)}}}},Wn={[fn.ok]:a.debug,[fn.debug]:a.debug,[fn.info]:a.info,[fn.notice]:a.info,[fn.warn]:a.warn,[fn.error]:a.error,[fn.critical]:a.error,[fn.alert]:a.error,[fn.emerg]:a.error};function Jn(e,t,n=0,r){const o=new Date;o.setTime(o.getTime()+n);const s="expires="+o.toUTCString(),i=r?.crossSite?"none":"strict",a=r?.domain?";domain="+r.domain:"",c=r?.secure?";secure":"",u=r?.partitioned?";partitioned":"";document.cookie=`${e}=${t};${s};path=/;samesite=${i}${a}${c}${u}`}function Vn(e){const t=function(e,t){for(Nn.lastIndex=0;;){const n=Nn.exec(e);if(!n)break;if(n[1]===t)return n[2]}}(document.cookie,e);if(""!==t)return t}function Zn(e){return function(e){const t=new Map;for(Nn.lastIndex=0;;){const n=Nn.exec(e);if(!n)break;{const e=n[1],r=n[2];t.has(e)?t.get(e).push(r):t.set(e,[r])}}return t}(document.cookie).get(e)||[]}let Xn,Qn;function Yn(e,t){Jn(e,"",0,t)}const er="logs";const tr=["chrome-extension://","moz-extension://"];function nr(e){return tr.some(t=>e.includes(t))}const rr=new Map,or=/^([a-zA-Z]+)=([a-z0-9-]+)$/;function sr(e){return e.created?Number(e.created):void 0}function ir(e){const t=e.expire&&Number(e.expire),n=sr(e);if(t&&n)return Math.min(t,n+An)}function ar(e,t){const n={isExpired:"1"};return t.trackAnonymousUser&&(n.anonymousId=Mn()),n}function cr(e){return Be(e)}function ur(e){return void 0!==e.isExpired||!function(e){const t=ir(e);return!!t&&x()<t}(e)}function lr(e){e.expire=x()+9e5+""}function fr(e){return(t=e,Object.entries(t)).map(([e,t])=>"anonymousId"===e?"aid="+t:`${e}=${t}`).join("&");var t}function dr(e){const t={};return function(e){return!!e&&(-1!==e.indexOf("&")||or.test(e))}(e)&&e.split("&").forEach(e=>{const n=or.exec(e);if(null!==n){const[,e,r]=n;"aid"===e?t.anonymousId=r:t[e]=r}}),t}function pr(e,t){return cr(e)?(t.trackAnonymousUser&&(e.anonymousId=Mn()),ar(0,t)):e}function gr(e,t){if(cr(e))return e;let n=e;return ur(e)&&(n=ar(0,t)),n.id||(n.id=Mn(),n.created=x()+""),t.trackAnonymousUser&&!n.anonymousId&&(n.anonymousId=Mn()),delete n.isExpired,lr(n),n}const mr="kubesense_cookie_test_";async function br(e,t){const n=`${mr}${Mn()}`,r="test",o=e(n,t);try{return await o.getAllAndSet(()=>({value:r,expireDelay:6e4})),(await o.getAll()).includes(r)}catch(e){return f.error(e),!1}finally{try{await o.delete()}catch{}}}function yr(t,n){const r=e.cookieStore,o=new k(()=>me(r,"change",e=>{(e.changed.some(e=>e.name===t)||e.deleted.some(e=>e.name===t))&&o.notify()}).stop);return{async getAll(){return(await r.getAll(t)).map(e=>e.value)},delete(){return r.delete({name:t,domain:n.domain,path:"/",partitioned:n.partitioned})},async getAllAndSet(e){const o=await r.getAll(t),s=o.map(e=>e.value),{value:i,expireDelay:a}=e(s);try{await r.set({name:t,value:i,expires:x()+a,path:"/",sameSite:n.crossSite?"none":"strict",domain:n.domain,secure:n.secure,partitioned:n.partitioned})}catch(e){if(!t.startsWith(mr)){const r=Zn(t);St("Failed to set cookie using Cookie Store API",{"error.message":e.message,newValue:i,cookieOptions:{...n},cookies:o.map(e=>({...e})),cookieCount:o.length,documentCookies:r})}}},observable:o}}function hr(e,t){let n=Zn(e);const r=new k(()=>{const t=D(()=>{o(Zn(e))},1e3);return()=>{B(t)}});function o(e){e+""!=n+""&&(n=e,r.notify())}return{getAll(){return Promise.resolve(Zn(e))},async getAllAndSet(n){const r=Zn(e),{value:s,expireDelay:i}=n(r);Jn(e,s,i,t),await Promise.resolve(),o([s])},async delete(){Yn(e,t),await Promise.resolve(),o([])},observable:r}}const vr="_kubesense_s_v2",kr="_kubesense_s";let Sr;function wr(e,t){let n;for(const r of e.slice().reverse())if(n=dr(r),n.c===t)break;return delete n?.c,n??{}}function xr(e){let t=0;return t|=0,t|=(e.domain?e.domain.split(".").length-1:0)<<1,t|=e.crossSite?1:0,t.toString(16)}const Er="_KUBESENSE_SESSION";function Cr(t,n){switch(t){case Tn:return async function(t){const n=function(t){const n={};if(n.secure=t.useSecureSessionCookie||t.usePartitionedCrossSiteSessionCookie,n.crossSite=t.usePartitionedCrossSiteSessionCookie,n.partitioned=t.usePartitionedCrossSiteSessionCookie,t.trackSessionAcrossSubdomains){const t=function(t=e.location?.hostname??"",n=("undefined"!=typeof document?document.referrer:"")){if("undefined"!=typeof document){if(void 0===Qn){const e=function(e,t){try{return e||M(t).hostname}catch{}}(t,n);if(e){const t="kubesense_site_test_"+Mn(),n="test",r=e.split(".");let o=r.pop();for(;r.length&&!Vn(t);)o=`${r.pop()}.${o}`,Jn(t,n,1e3,{domain:o});Yn(t,{domain:o}),Qn=o}}return Qn}}();if(!t)return;n.domain=t}return n}(t);if(n)return function(){const t=e.cookieStore;return!(!t||!ye(t,"change"))}()&&await br(yr,n)?{type:Tn,cookieOptions:n,cookieApi:1}:await br(hr,n)?{type:Tn,cookieOptions:n,cookieApi:0}:void 0}(n);case Rn:return function(){try{const e=Mn(),t="_kubesense_test_"+e;localStorage.setItem(t,e);const n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:Rn}:void 0}catch{return}}();case On:return{type:On};default:return void f.error(`Invalid session persistence '${t+""}'`)}}let _r=[];function Ar(e){return e.createdAt+An}function Tr(e,t){switch(t.type){case"string":return`"${e}" must be a non-empty string`;case"number":return void 0!==t.min&&void 0!==t.max?`"${e}" must be a number between ${t.min} and ${t.max}`:void 0!==t.min?`"${e}" must be a number greater than or equal to ${t.min}`:void 0!==t.max?`"${e}" must be a number less than or equal to ${t.max}`:`"${e}" must be a finite number`;case"percentage":return`"${e}" must be a number between 0 and 100`;case"boolean":return`"${e}" must be a boolean`;case"site":return`"${e}" must be a non-empty intake host, for example "us2.kubesense.ai"`;case"match-option":return`"${e}" must be a string, RegExp, or function`;case"enum":return`"${e}" must be one of: "${$r(t.values).join('", "')}"`;case"union":return`"${e}" does not match any expected type`;case"schema":return`"${e}" is not a valid object`;case"function":return`"${e}" must be a function`}}function Or(e,t,n){const r={};for(const[o,s]of Object.entries(e)){const e=t[o],i=s.multiple?Rr(s,e,n):Ir(s,e,n);if(void 0===i){if(null!=e&&""!==e){if(n.error(Tr(o,s)),s.required||!1!==s.strict)return}else if(s.required)return void n.error(`"${o}" is required`);r[o]="default"in s?Ce(s.default):void 0}else r[o]=i}return r}function Rr(e,t,n){if(null==t)return;if("enum"===e.type&&e.allowAll&&"all"===t)return $r(e.values).slice();const r=Array.isArray(t)?t:[t],o=[];for(const t of r){const r=Ir(e,t,n);if(void 0===r){if(!1!==e.strict)return}else o.push(r)}return!1===e.strict&&0===o.length&&r.length>0?void 0:o}function Ir(e,t,n){if("schema"===e.type){if("object"!=typeof t||null===t)return;return Or(e.schema,t,n)}if("union"!==e.type){if(null!=t)switch(e.type){case"function":return"function"==typeof t?t:void 0;case"string":return"string"==typeof t&&t.length>0?t:void 0;case"number":return"number"==typeof t&&Number.isFinite(t)&&(void 0===e.min||t>=e.min)&&(void 0===e.max||t<=e.max)?t:void 0;case"percentage":return function(e){return"number"==typeof e&&e>=0&&e<=100}(t)?t:void 0;case"boolean":return"boolean"==typeof t?t:!1===e.strict?!!t:void 0;case"site":if("string"!=typeof t||""===t.trim())return;return t;case"match-option":return function(e){return"string"==typeof e||e instanceof RegExp||"function"==typeof e}(t)?t:void 0;case"enum":return"string"==typeof t&&$r(e.values).includes(t)?t:void 0}}else{if(null==t)return;for(const r of e.variants){const e=Ir(r,t,n);if(void 0!==e)return e}}}function $r(e){return Array.isArray(e)?e:Object.values(e)}const Pr={clientToken:{type:"string",required:!0},service:{type:"string"},env:{type:"string"},version:{type:"string"},kubesenseRumEndpoint:{type:"site",default:$e},proxy:{type:"union",variants:[{type:"string"},{type:"function",signature:void 0}]},sessionSampleRate:{type:"percentage",default:100},telemetrySampleRate:{type:"percentage",default:20},telemetryConfigurationSampleRate:{type:"percentage",default:5},telemetryUsageSampleRate:{type:"percentage",default:5},silentMultipleInit:{type:"boolean",default:!1,strict:!1},storeContextsAcrossPages:{type:"boolean",default:!1,strict:!1},trackAnonymousUser:{type:"boolean",default:!0,strict:!1},useSecureSessionCookie:{type:"boolean",default:!1,strict:!1},usePartitionedCrossSiteSessionCookie:{type:"boolean",default:!1,strict:!1},trackSessionAcrossSubdomains:{type:"boolean",default:!1,strict:!1},allowedTrackingOrigins:{type:"match-option",multiple:!0,strict:!1},trackingConsent:{type:"enum",values:{GRANTED:"granted",NOT_GRANTED:"not-granted"},default:"granted"},beforeSend:{type:"function",signature:void 0},source:{type:"enum",values:["browser","flutter","unity"],default:"browser",strict:!1},sessionPersistence:{type:"enum",values:["cookie","local-storage","memory"],multiple:!0,strict:!1},replica:{type:"schema",schema:{clientToken:{type:"string",required:!0},applicationId:{type:"string"}}},datacenter:{type:"string"},sdkVersion:{type:"string"},variant:{type:"string"},forwardErrorsToLogs:{type:"boolean",default:!0,strict:!1},enableRemoteSdkConfiguration:{type:"boolean",default:!1,strict:!1},forwardConsoleLogs:{type:"enum",values:a,multiple:!0,allowAll:!0,default:[]},forwardReports:{type:"enum",values:Fn,multiple:!0,allowAll:!0,default:[]},plugins:{type:"schema",multiple:!0,strict:!1,default:[],schema:{name:{type:"string",required:!0},getConfigurationTelemetry:{type:"function",strict:!1,signature:void 0},onInit:{type:"function",strict:!1,signature:void 0},onLogsStart:{type:"function",strict:!1,signature:void 0}}}},Lr="_kubesense_sdk_config";function qr(e){return`${Lr}_${e}`}function Mr(e){try{localStorage.removeItem(qr(e))}catch{}}function Nr(e){try{const t=JSON.parse(e);if(!t||"object"!=typeof t||Array.isArray(t))return;return t}catch{return}}function Ur(e){if("undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.timeout)return AbortSignal.timeout(e)}function jr(e,t){const n=e?.[t];return"boolean"==typeof n?n:void 0}function Dr(e,t){const n=e?.[t];return"number"==typeof n&&isFinite(n)&&n>=0&&n<=100?n:void 0}function Br(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length>0?t:void 0}function Fr(e,t){const n=e?.[t];return"string"==typeof n&&n.length>0?n:void 0}function zr(e,t){if("all"===e)return"all";const n=Br(e)?.filter(e=>t.includes(e));return n?.length?n:void 0}function Gr(e,t,n){void 0!==n&&(e[t]=n)}function Kr(n,r,o,s){const i=new w(500,e=>{St("preStartLogs buffer data lost",{count:e})}),c=qn();Zt(c,Qt,i);const u=wn();Zt(u,Yt,i);const l=Ln();let d,m,b;Zt(l,Xt,i);const y={assembleEventDefaults:Ae(),assembleTelemetry:Ae(),assembleEvent:Ae()},v=r.observable.subscribe(S);function S(){if(!m||!d||!b)return;v.unsubscribe();const e=o(m,b,y);i.subscribe(t=>t(e)),i.unbuffer()}return{init(n,o,i){if(!n)return void f.error("Missing configuration");var c,u;u=n.enableExperimentalFeatures,Array.isArray(u)&&u.filter(e=>{return n=e,Object.keys(t=Fe).some(e=>t[e]===n);var t,n}).forEach(e=>{ze.add(e)}),c=n.allowUntrustedEvents,!0!==he&&(he=c??!1),Qe()&&(n=function(e){return{...e,clientToken:"empty"}}(n));const l=!!n.enableRemoteSdkConfiguration,v=()=>{l&&function(t){return function(t){if(!("fetch"in e))return Promise.resolve();let n;try{n=function(e){return`https://${e.kubesenseRumEndpoint??$e}/rum/api/v1/sdk-config?${["ksource=browser","kubesense-api-key="+encodeURIComponent(e.clientToken),"kubesense-request-id="+Mn()].join("&")}`}(t)}catch(e){return h(e),Promise.resolve()}return nt(n,{method:"GET",credentials:"omit",mode:"cors",cache:"no-store",signal:Ur(1e4)}).then(e=>{if(404!==e.status){if(e.ok)return e.text()}else Mr(t.clientToken)}).then(e=>{void 0!==e&&(Nr(e)?function(e,t){try{localStorage.setItem(qr(e),t)}catch{}}(t.clientToken,e):f.warn("Remote SDK configuration is not a valid JSON object, ignoring it."))}).catch(()=>{})}(t)}(n).catch(F)};if(l){const e=function(e){const t=function(e){let t;try{localStorage.removeItem(Lr),t=localStorage.getItem(qr(e))}catch{return}if(!t)return;const n=Nr(t);return n||Mr(e),n}(e.clientToken);return t?function(e,t){if(!1===jr(t.features,"logs"))return{initConfiguration:e,logsEnabled:!1};const n=t.logs;if(!n)return{initConfiguration:e,logsEnabled:!0};const r={...e};return Gr(r,"sessionSampleRate",Dr(n,"sessionSampleRate")),Gr(r,"telemetrySampleRate",Dr(n,"telemetrySampleRate")),Gr(r,"forwardErrorsToLogs",jr(n,"forwardErrorsToLogs")),Gr(r,"trackAnonymousUser",jr(n,"trackAnonymousUser")),Gr(r,"trackSessionAcrossSubdomains",jr(n,"trackSessionAcrossSubdomains")),Gr(r,"allowedTrackingOrigins",Br(n.allowedTrackingOrigins)),Gr(r,"forwardConsoleLogs",zr(n.forwardConsoleLogs,Ye(a))),Gr(r,"forwardReports",zr(n.forwardReports,Ye(Fn))),Gr(r,"service",Fr(n,"service")),Gr(r,"env",Fr(n,"env")),Gr(r,"version",Fr(n,"version")),{initConfiguration:r,logsEnabled:!0}}(e,t):{initConfiguration:e,logsEnabled:!0}}(n);if(n=e.initConfiguration,!e.logsEnabled)return d=n,void v()}if(d=n,m)return void sn("KUBESENSE_LOGS",n);vn(n.plugins,"onInit",{initConfiguration:n,publicApi:o,registerAssembleEventHook:y.assembleEvent.register});const w=function(e){const t=function(e,t,n){if(e&&"object"==typeof e)return Or(t,e,n);n.error("Configuration must be an object")}(e,Pr,f);if(t)return{...t,beforeSend:t.beforeSend?p(t.beforeSend,"beforeSend threw an error:"):void 0}}(n);w&&function(t,n){const r=e.location,o=r?r.origin:"",s=t.allowedTrackingOrigins;if(!s)return!function(e,t=""){return!nr(e)&&nr(t.split("\n").filter(e=>{const t=e.trim();return t.length&&/^at\s+|@/.test(t)})[1]||"")}(o,n)||(f.error("Running the Browser SDK in a Web extension content script is forbidden unless the `allowedTrackingOrigins` option is provided."),!1);const i=function(e,t,n=!1){return e.some(e=>{try{if("function"==typeof e)return e(t);if(e instanceof RegExp)return e.lastIndex=0,e.test(t);if("string"==typeof e)return n?t.startsWith(e):e===t}catch(e){f.error(e)}return!1})}(s,o);return i||f.error("SDK initialized on a non-allowed domain."),i}(w,i??"")?(m=w,r.tryToInit(w.trackingConsent),r.onGrantedOnce(()=>{!function(e,t){function n(){return t.isGranted()?Oe:Te}e.assembleEventDefaults.register(n),e.assembleTelemetry.register(n)}(y,r),function(n,r,o,s){const i=new k,{enabled:a,metricsEnabled:c}=function(n,r,o,s,i,a=1,c=15){const u={},l=!ht.includes(r.kubesenseRumEndpoint)&&Re(r.telemetrySampleRate),f={[gt]:l,[mt]:l&&Re(r.telemetryConfigurationSampleRate),[bt]:l&&Re(r.telemetryUsageSampleRate),metric:l&&Re(a)},d={is_local_file:"file:"===e.location?.protocol,is_worker:t},p=kt();return p.subscribe(({rawEvent:e,metricName:t})=>{if(t&&!f.metric||!f[e.type])return;const a=t||e.status||e.type;let l=u[a];if(l||(l=u[a]=new Set),l.size>=c)return;const p=Je(e);if(l.has(p))return;const g=o.trigger({startTime:T().relative});if(g===Te)return;const m=function(e,t,n,o){const s={type:"telemetry",date:T().timeStamp,service:t,version:"2.0.0",source:"browser",_kubesense:{format_version:2},telemetry:_e(n,{runtime_env:o,connectivity:Ze(),sdk_setup:"cdn",sdk_name:i}),ktags:Ge(r).join(","),experimental_features:Array.from(ze)};return _e(s,e)}(g,n,e,d);s.notify(m),We("telemetry",m),l.add(p)}),p.unbuffer(),!g&&(g=wt),{enabled:l,metricsEnabled:f.metric}}("kubesense-browser-logs-sdk",r,o,i,s),{stop:u}=function(e,t){const n=[];if(Qe()){const e=Xe(),r=t.subscribe(t=>e.send("internal_telemetry",t));n.push(r.unsubscribe)}else{const r=[Le(e,"rum")],o=qe(e,"rum");o&&function(e){return e.kubesenseRumEndpoint===Ie}(e)&&r.push(o);const s=dt({endpoints:r,reportError:F});n.push(s.stop);const i=t.subscribe(s.add);n.push(i.unsubscribe)}return{stop(){return n.forEach(e=>e())}}}(r,i)}(0,w,y.assembleTelemetry,s),(Qe()?function(){let e={id:Mn(),isReplayForced:!1,anonymousId:void 0,createdAt:E()};return Promise.resolve({findSession(){return e},findTrackedSession(){return e},renewObservable:new k,expireObservable:new k,expire:F,updateSessionState(t){e={...e,...t}}})}():async function(n,r){const o=A(),s=new k,i=new k,a=await async function(e){const n=void 0!==(r=e.sessionPersistence)?r:t?[On]:[Tn];var r;for(const t of n){const n=await Cr(t,e);if(void 0!==n)return n}}(n);if(!a)return void f.warn("No storage available for session. We will not send any data.");const c=function(t,n){switch(t.type){case Tn:return function(e,t){const{cookieOptions:n,cookieApi:r}=e,o=new k,s=!!t.trackAnonymousUser,i=xr(n),a=function(e,t){return 1===e?yr(vr,t):hr(vr,t)}(r,n);let c=!0;function u(e){return a.getAllAndSet(t=>{let r=wr(t,i);c&&Be(r)&&(r=wr(Zn(kr),i)),c=!1;const o=function(e,t){return fr(Be(e)?e:{...e,c:xr(t)})}(e(r),n);return{value:o,expireDelay:s?31536e6:An}})}return a.observable.subscribe(()=>{a.getAll().then(e=>{o.notify(wr(e,i))}).catch(e=>h(Error("Error while reading session cookies on change: "+e)))}),{async setSessionState(e,t){"undefined"!=typeof navigator&&navigator.locks?await navigator.locks.request(vr,()=>u(e)).catch(e=>{if(!function(e){return e instanceof Error&&("AbortError"===e.name||e.message.includes("no longer runnable"))}(e))throw e}):(Sr=(Sr??Promise.resolve()).then(()=>u(e)),await Sr)},sessionObservable:o}}(t,n);case Rn:return function(){const e=new k(e=>me(window,"storage",t=>{t.key===vr&&t.storageArea===localStorage&&e.notify(dr(t.newValue))}).stop);let t=!0;return{async setSessionState(n,r){let o=dr(localStorage.getItem(vr));t&&cr(o)&&(o=dr(localStorage.getItem(kr))),t=!1;const s=n(o);localStorage.setItem(vr,fr(s)),await Promise.resolve(),e.notify(s)},sessionObservable:e}}();case On:return function(){const t=e;t[Er]||(t[Er]={});const n=t[Er],r=new k,o=n.onChange;return n.onChange=e=>{o?.(e),r.notify(e)},{async setSessionState(e,t){const r=(o=e(n.state??{}),{...o});var o;n.state=r,await Promise.resolve(),n.onChange?.(r)},sessionObservable:r}}()}}(a,n),u=_n({maxEntries:1e3});_r.push(()=>u.stop());let l=!1;const{throttled:d,cancel:p}=function(e){let t,n,r=!1;return{throttled(...o){r?t=o:(e(...o),r=!0,n=U(()=>{t&&e(...t),r=!1,t=void 0},1e3))},cancel(){j(n),r=!1,t=void 0}}}(()=>{!function(){const e=u.find();e&&E()>=Ar(e)&&I(ar(0,n))}(),l=!1,c.setSessionState(e=>gr(e,n),"expandOrRenewOnActivity").catch(h)});let g;_r.push(p),_r.push(()=>j(g));let m=!1;_r.push(()=>{m=!0});let b=await S().catch(e=>h(Error("Error while resolving initial session state: "+e)));if(b&&!m){for(;!r.isGranted();){if($(),await new Promise(e=>r.onGrantedOnce(e)),m)return;if(b=await S().catch(h),!b||m)return}var y,v;return u.add(P(b),O().relative),w(b),function(){const e=c.sessionObservable.subscribe(e=>{w(e),I(e)});_r.push(()=>e.unsubscribe())}(),r.observable.subscribe(()=>{r.isGranted()?(l=!1,c.setSessionState(e=>gr(e,n),"expandOrRenewOnConsent").catch(h)):$()}),t||(function(){const{stop:e}=be(window,["click","touchstart","keydown","scroll"],()=>{r.isGranted()&&d()},{capture:!0,passive:!0});_r.push(e)}(),function(){const e=()=>{"visible"===document.visibilityState&&(l||c.setSessionState(e=>function(e){return ur(e)||cr(e)||!e.id||lr(e),e}(e),"expandOnVisibility").catch(h))},{stop:t}=me(document,"visibilitychange",e);_r.push(t);const n=D(e,6e4);_r.push(()=>{B(n)})}(),function(){const{stop:e}=me(window,"resume",()=>{c.setSessionState(e=>pr(e,n),"initializeOnResume").catch(h)},{capture:!0});_r.push(e)}()),y="Session manager init metrics",v={metrics:{duration:C(o,A())}},kt().notify({rawEvent:{type:gt,message:y,status:"debug",...v},metricName:y}),{findSession:(e,t)=>u.find(e,t),findTrackedSession(e,{returnInactive:t=!1,maxAge:r=432e5}={}){const o=u.find(e,{returnInactive:t});if(o&&"invalid"!==o.id&&function(e,t){if(100===t)return!0;if(0===t)return!1;const n=rr.get(t);if(e===n?.sessionId)return n.decision;const r=function(e,t){const n=1n<<64n;return Number(1111111111111111111n*e%n)<=t/100*Number(n)}(BigInt("0x"+e.split("-")[4]),t);return rr.set(t,{sessionId:e,decision:r}),r}(o.id,n.sessionSampleRate)&&!(x()-o.createdAt>r)&&(t||!(function(e){return void 0===e?E():(t=e,Math.round(_(L(),t)));var t}(e)>=Ar(o))))return o},renewObservable:s,expireObservable:i,expire:$,updateSessionState(e){c.setSessionState(t=>({...t,...e}),"updateState").catch(h)}}}async function S(){let e={};return await c.setSessionState(t=>{const r=pr(t,n);return e=gr(r,n),e},"initialize"),e}function w(e){j(g);const t=ir(e);if(t){const e=t-x();g=U(()=>{c.setSessionState(e=>{if(ur(e)){const e=ar(0,n);return r.isGranted()||delete e.anonymousId,e}return e},"expireOnTimeout").catch(h)},e)}}function I(e){const t=u.find(),n=void 0!==t?.id,r=void 0!==e.id,o=n&&r&&t.id!==e.id;if(!n||r&&!o||(l=!0,i.notify(),u.closeActive(function(e){const t=T();if(!e)return t;const n=Ar(e);return n<t.timeStamp?{relative:R(r=n),timeStamp:r}:t;var r}(t).relative)),!r||n&&!o)n&&r&&!o&&(t.isReplayForced=!!e.forcedReplay);else{if(l)return;u.add(P(e),A()),s.notify()}}function $(){p();const e=ar(u.find(),n);r.isGranted()||delete e.anonymousId,I(e),c.setSessionState(e=>{const t=ar(0,n);return r.isGranted()||delete t.anonymousId,t},"expire").catch(h)}function P(e){const t=sr(e)??E();return e.id?{id:e.id,isReplayForced:!!e.forcedReplay,anonymousId:e.anonymousId,createdAt:t}:{id:"invalid",isReplayForced:!1,anonymousId:void 0,createdAt:t}}}(w,r)).then(e=>{e&&(b=e,function(e,t){e.register(({startTime:e})=>{const n=t.findTrackedSession(e);return n?{session:{id:n.id},anonymous_id:n.anonymousId}:Oe})}(y.assembleTelemetry,b),function(e){kt().notify({rawEvent:{type:mt,configuration:e}})}(function(e){const t={session_sample_rate:(n=e).sessionSampleRate,telemetry_sample_rate:n.telemetrySampleRate,telemetry_configuration_sample_rate:n.telemetryConfigurationSampleRate,telemetry_usage_sample_rate:n.telemetryUsageSampleRate,use_before_send:!!n.beforeSend,use_partitioned_cross_site_session_cookie:n.usePartitionedCrossSiteSessionCookie,use_secure_session_cookie:n.useSecureSessionCookie,use_proxy:!!n.proxy,silent_multiple_init:n.silentMultipleInit,track_session_across_subdomains:n.trackSessionAcrossSubdomains,track_anonymous_user:n.trackAnonymousUser,session_persistence:Array.isArray(n.sessionPersistence)?n.sessionPersistence[0]:n.sessionPersistence,store_contexts_across_pages:!!n.storeContextsAcrossPages,allow_untrusted_events:!!n.allowUntrustedEvents,tracking_consent:n.trackingConsent,use_allowed_tracking_origins:Array.isArray(n.allowedTrackingOrigins),source:n.source,sdk_version:n.sdkVersion,variant:n.variant};var n;return{forward_errors_to_logs:e.forwardErrorsToLogs,enable_remote_sdk_configuration:!!e.enableRemoteSdkConfiguration,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports,plugins:e.plugins?.map(e=>({name:e.name,...e.getConfigurationTelemetry?.()})),...t}}(n)),S(),v())}).catch(h)})):v()},get initConfiguration(){return d},globalContext:c,accountContext:u,userContext:l,getInternalContext:F,handleLog(e,t,r,o=n(),s=E()){i.notify(n=>n.handleLog(e,t,r,o,s))}}}const Hr=function(n={}){const o=function(e){const t=new k;function n(){return"granted"===e}return{tryToInit(t){e||(e=t)},onGrantedOnce(e){if(n())e();else{const r=t.subscribe(()=>{n()&&(e(),r.unsubscribe())})}},update(n){e=n,t.notify()},isGranted:n,observable:t}}(),s=function(){const t=new w(500,e=>{St("Early data collection dropped data on unbuffer",{count:e})}),n=[];function r(e,r){n.push(r.subscribe(n=>{t.notify({type:e,data:n})}))}return r(0,new k(t=>{const n=(e,n)=>{const r=jt({stackTrace:n,originalError:e,startClocks:T(),nonErrorPrefix:"Uncaught",source:Ht,handling:"unhandled"});t.notify(r)},{stop:r}=(o=n,ce(e,"onerror",({parameters:[e,t,n,r,s]})=>{let i;je(s)||(i=function(e,t,n,r){if(void 0===t)return;const{name:o,message:s}=function(e){let t,n;return"[object String]"==={}.toString.call(e)&&([,t,n]=ne.exec(e)),{name:t,message:n}}(e);return{name:o,message:s,stack:[{url:t,column:r,line:n}]}}(e,t,n,r)),o(s??e,i)}));var o;const{stop:s}=function(t){return ye(e.window,"unhandledrejection")?ce(e,"onunhandledrejection",({parameters:[e]})=>{t(e.reason||"Empty reason")}):{stop:F}}(n);return()=>{r(),s()}})),r(1,ge()),r(2,(ve||(ve="XMLHttpRequest"in e?new k(e=>{const{stop:t}=ce(XMLHttpRequest.prototype,"open",Se),{stop:n}=ce(XMLHttpRequest.prototype,"send",t=>{!function({target:e,parameters:[t],handlingStack:n},r){const o=ke.get(e);if(!o)return;const s=o;s.state="start",s.startClocks=T(),s.isAborted=!1,s.xhr=e,s.handlingStack=n,s.requestBody=t;let i=!1;const{stop:a}=ce(e,"onreadystatechange",()=>{e.readyState===XMLHttpRequest.DONE&&c()}),c=()=>{if(u(),a(),i)return;i=!0;const t=o;t.duration=C(s.startClocks.timeStamp,E()),t.status=e.status,"string"==typeof e.response&&(t.responseBody=e.response),r.notify({...t,state:"complete"})},{stop:u}=me(e,"loadend",c);r.notify(s)}(t,e)},{computeHandlingStack:!0}),{stop:r}=ce(XMLHttpRequest.prototype,"abort",we);return()=>{t(),n(),r()}}):new k),ve)),r(3,S(...Object.values(a).map(e=>(Jt[e]||(Jt[e]=function(e){return new k(t=>{const n=c[e];return c[e]=(...r)=>{n.apply(console,r);const o=se("console error");y(()=>{t.notify(function(e,t,n){const r=e.map(e=>function(e){return"string"==typeof e?_t(e):je(e)?ae(H(e)):Je(_t(e),void 0,2)}(e)).join(" ");if(t===a.error){const o=jt({originalError:e.find(je)??e[0],handlingStack:n,startClocks:T(),source:Gt,handling:"handled",nonErrorPrefix:"Provided",useFallbackStack:!1});return o.message=r,{api:t,message:r,handlingStack:n,error:o}}return{api:t,message:r,error:void 0,handlingStack:n}}(r,e,o))})},()=>{c[e]=n}})}(e)),Jt[e])))),{observable:t,stop(){return n.forEach(e=>e.unsubscribe())}}}().observable;let i=Kr(hn,o,(n,r,o)=>{const a=function(n,r,o,s,i){const a=new Hn,l=[];a.subscribe(1,e=>We("logs",e));const f=function(e){return t=>{e.notify(0,{rawLogsEvent:{message:t,date:E(),origin:zt,status:fn.error}}),St("Error reported to customer",{"error.message":t})}}(a),{assembleEventDefaults:d}=i;!function(e,t,n){e.register(({startTime:e})=>{const r=n.findTrackedSession(e);return n.findTrackedSession(e,{returnInactive:!0,maxAge:1/0})?{service:t.service,session_id:r?r.id:void 0,session:r?{id:r.id}:void 0}:Te})}(d,n,r);const p=function(e,t,n){const r=wn();return t.storeContextsAcrossPages&&Sn(r,n,4),e.register(()=>{const e=r.getContext();return Be(e)||!e.id?Oe:{account:e}}),r}(d,n,er),g=function(e,t,n,r){const o=Ln();if(t.storeContextsAcrossPages&&Sn(o,r,1),n.expire){const e=o.getContext().id,t=function(e){try{return localStorage.getItem($n(e))||void 0}catch{return}}(r),s=In(e);void 0!==t&&void 0!==s&&t!==s&&n.expire(),Pn(r,s??t);let i=s??t;o.changeObservable.subscribe(()=>{const e=In(o.getContext().id);e!==i&&(n.expire(),Pn(r,e)),i=e})}const s=_n({expireDelay:An});return s.add(o.getContext(),O().relative),o.changeObservable.subscribe(()=>{const e=A();s.closeActive(e),s.add(o.getContext(),e)}),e.register(({eventType:e,startTime:r})=>{const i=s.find(r),a=i?Ce(i):o.getContext(),c=n.findTrackedSession(r);return c?.anonymousId&&!a.anonymous_id&&t.trackAnonymousUser&&(a.anonymous_id=c.anonymousId),Be(a)?Oe:{type:e,usr:a}}),o}(d,n,r,er),m=function(e,t,n){const r=qn();return t.storeContextsAcrossPages&&Sn(r,n,2),e.register(()=>r.getContext()),r}(d,n,er);(function(n){const r=e;function o(n){const o=function(e,t){if(t?.getInternalContext)return t.getInternalContext(e)}(n,t||!e._KUBESENSE_SYNTHETICS_INJECTS_RUM&&(Xn||(Xn=function(e){const t=new Map;for(Nn.lastIndex=0;;){const n=Nn.exec(e);if(!n)break;t.set(n[1],n[2])}return t}(document.cookie)),!Xn.get("kubesense-synthetics-injects-rum"))?r.KUBESENSE_SDK:r.KUBESENSE_SDK_SYNTHETICS);if(o)return o}n.assembleEventDefaults.register(({startTime:e})=>o(e)||Oe),n.assembleTelemetry.register(({startTime:e})=>{const t=o(e);return t?{application:{id:t.application_id},view:{id:t.view?.id},action:{id:t.user_action?.id}}:Oe})})(i),function(e){const t=(Dn||(Dn=function(){try{const e=sessionStorage.getItem(jn);if(e)return e;const t=Mn();return sessionStorage.setItem(jn,t),t}catch{return}}()??Mn()),Dn);e.register(()=>({tab:{id:t}}))}(d),function(e,t,n){if(!e.forwardErrorsToLogs)return{stop:F};function r(e){return t=e.url,!Pe.every(e=>t.includes(e))&&!e.isAborted&&(function(e){return 0===e.status&&"opaque"!==e.responseType}(e)||fe(e.status));var t}function o(e,n){if(!r(n))return;const o="error"in n&&n.error?H(n.error):void 0,s=o?ie(o):n.responseBody||"Failed to load",i=o?Pt(Nt(o)):void 0,a={handlingStack:n.handlingStack};t.notify(0,{rawLogsEvent:{message:`${Kn(e)} error ${n.method} ${n.url}`,date:n.startClocks.timeStamp,error:{stack:Un(s,32768,"..."),handling:void 0},_kubesense:{debug_ids:i},http:{method:n.method,status_code:n.status,url:n.url},status:fn.error,origin:"network"},domainContext:a})}ge({responseBodyAction:e=>r(e)?1:0}),n.subscribe(({data:e,type:t})=>{1===t&&"resolve"===e.state?o("fetch",e):2===t&&"complete"===e.state&&o("xhr",e)})}(n,a,s),function(e,t,n){if(!e.forwardErrorsToLogs)return{stop:F};n.subscribe(e=>{if(0===e.type){const n=e.data;t.notify(0,{rawLogsEvent:_e({message:n.message,date:n.startClocks.timeStamp,error:pn(n),_kubesense:{debug_ids:n.debugIds},origin:Ht,status:fn.error},n.context)})}})}(n,a,s),function(e,t,n){n.subscribe(({data:n,type:r})=>{if(3!==r||!e.forwardConsoleLogs.includes(n.api))return;const o={rawLogsEvent:_e({date:E(),message:n.message,origin:Gt,error:n.error&&pn(n.error),_kubesense:n.error&&{debug_ids:n.error.debugIds},status:Bn[n.api]},n.error?.context),domainContext:{handlingStack:n.handlingStack}};t.notify(0,o)})}(n,a,s),s.unbuffer(),function(e,t){(function(e){const t=[];e.includes(Fn.cspViolation)&&t.push(new k(e=>{if(!ye(document,"securitypolicyviolation"))return;const{stop:t}=me(document,"securitypolicyviolation",t=>{e.notify(function(e){const t=`'${e.blockedURI}' blocked by '${e.effectiveDirective}' directive`;return zn({type:e.effectiveDirective,message:`${Fn.cspViolation}: ${t}`,originalError:e,csp:{disposition:e.disposition},stack:Gn(e.effectiveDirective,e.originalPolicy?`${t} of the policy "${Un(e.originalPolicy,100,"...")}"`:"no policy",e.sourceFile,e.lineNumber,e.columnNumber),debugIds:e.sourceFile?Pt([e.sourceFile]):void 0})}(t))});return t}));const n=e.filter(e=>e!==Fn.cspViolation);return n.length&&t.push(function(e){return new k(t=>{if(!window.ReportingObserver)return;const n=b((e,n)=>e.forEach(e=>t.notify(function(e){const{type:t,body:n}=e;return zn({type:n.id,message:`${t}: ${n.message}`,originalError:e,stack:Gn(n.id,n.message,n.sourceFile,n.lineNumber,n.columnNumber),debugIds:n.sourceFile?Pt([n.sourceFile]):void 0})}(e)))),r=new window.ReportingObserver(n,{types:e,buffered:!0});return r.observe(),()=>{r.disconnect()}})}(n)),S(...t)})(e.forwardReports).subscribe(e=>{let n,r=e.message;const o="deprecation"===e.originalError.type?fn.warn:fn.error;var s;o===fn.error?n=pn(e):e.stack&&(r+=" Found in "+(s=e.stack,/@ (.+)/.exec(s)?.[1])),t.notify(0,{rawLogsEvent:{date:E(),message:r,origin:Wt,error:n,_kubesense:{debug_ids:e.debugIds},status:o}})})}(n,a);const{handleLog:y}=function(e){return{handleLog(t,n,r,o,s){const i=_e(n.getContext(),t.context);if(ln(t.status,"console",n)&&function({status:e,message:t},n){u[Wn[e]].call(c,t,n)}(t,i),ln(t.status,gn,n)){const a={rawLogsEvent:_e({date:s||E(),message:t.message,status:t.status,origin:Kt,_kubesense:{debug_ids:t.debugIds}},i),savedCommonContext:o,ktags:n.getTags()};r&&(a.domainContext={handlingStack:r}),e.notify(0,a)}}}}(a);if(function(e,t,n,r,o){const s=mn.concat(["custom"]),i={};s.forEach(e=>{i[e]=function(e,t,n=3e3){let r=0,o=!1;return{isLimitReached(){if(0===r&&U(()=>{r=0},6e4),r+=1,r<=n||o)return o=!1,!1;if(r===n+1){o=!0;try{t(`Reached max number of ${e}s by minute: ${n}`)}finally{o=!1}}return!0}}}(e,o,void 0)}),t.subscribe(0,({rawLogsEvent:o,savedCommonContext:s,domainContext:a,ktags:c=[]})=>{const u=R(o.date),l=s||r(),f={startTime:u,rawLogsEvent:o,domainContext:a},d=n.assembleEventDefaults.trigger(f);if(d===Te)return;const p=n.assembleEvent.trigger(f);if(p===Te)return;const g=Ge(e),m=_e({view:l.view},d,o,p,{ktags:g.concat(c).join(",")});!1===e.beforeSend?.(m,a)||m.origin!==zt&&(i[m.status]??i.custom).isLimitReached()||t.notify(1,m)})}(n,a,i,o,f),Qe())!function(e){const t=Xe();e.subscribe(1,e=>{t.send("log",e)})}(a);else{const{stop:e}=function(e,t,n,r){const o=[Le(e,"logs")],s=qe(e,"logs");s&&o.push(s);const i=dt({endpoints:o,reportError:n});return r.expireObservable.subscribe(()=>i.forceFlush("session_expire")),t.subscribe(1,e=>{i.add(e)}),i}(n,a,f,r);l.push(()=>e())}const h=function(e){return{get(t){const n=e.findTrackedSession(t);if(n)return{session_id:n.id}}}}(r);return{handleLog:y,getInternalContext:h.get,accountContext:p,globalContext:m,userContext:g,stop(){l.forEach(e=>e())}}}(n,r,hn,s,o);return i=function(e,t){return{...e,init(e){sn("KUBESENSE_LOGS",e)},getInternalContext:t.getInternalContext,globalContext:t.globalContext,userContext:t.userContext,accountContext:t.accountContext}}(i,a),vn(n.plugins,"onLogsStart",{handleLog:a.handleLog}),a},n.sdkName);const l=()=>i,f={},d=function(e){const t={version:"2.0.0",onReady(e){e()},...e};return Object.defineProperty(t,"_setDebug",{get:()=>r,enumerable:!1}),t}({logger:new bn((...e)=>i.handleLog(...e)),init(e){const t=Error().stack;y(()=>i.init(e,d,t))},setTrackingConsent:b(e=>{o.update(e),xt({feature:"set-tracking-consent",tracking_consent:e})}),getGlobalContext:Vt(l,Qt,en),setGlobalContext:Vt(l,Qt,tn),setGlobalContextProperty:Vt(l,Qt,nn),removeGlobalContextProperty:Vt(l,Qt,rn),clearGlobalContext:Vt(l,Qt,on),createLogger:b((e,t={})=>(f[e]=new bn((...e)=>i.handleLog(...e),_t(e),t.handler,t.level,_t(t.context)),f[e])),getLogger:b(e=>f[e]),getInitConfiguration:b(()=>Ce(i.initConfiguration)),getInternalContext:b(e=>i.getInternalContext(e)),setUser:Vt(l,Xt,tn),getUser:Vt(l,Xt,en),setUserProperty:Vt(l,Xt,nn),removeUserProperty:Vt(l,Xt,rn),clearUser:Vt(l,Xt,on),setAccount:Vt(l,Yt,tn),getAccount:Vt(l,Yt,en),setAccountProperty:Vt(l,Yt,nn),removeAccountProperty:Vt(l,Yt,rn),clearAccount:Vt(l,Yt,on)});return d}({sdkName:"logs"});!function(e,t,n){const r=e[t];r&&!r.q&&r.version&&f.warn("SDK is loaded more than once. This is unsupported and might have unexpected behavior."),e[t]=n,r?.q&&r.q.forEach(e=>p(e,"onReady callback threw an error:")())}(e,"KUBESENSE_LOGS",Hr)})();
|