@wf-financing/ui 1.4.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/index-DgBzPfcG.mjs +76600 -0
  3. package/dist/index.es.js +1 -75797
  4. package/dist/profiler-Dvl3kCjE.mjs +240 -0
  5. package/dist/startRecording-C7EyZWpe.mjs +1225 -0
  6. package/package.json +2 -2
  7. package/sdk/index.ts +12 -19
  8. package/src/App.tsx +9 -8
  9. package/src/api/continueHostedApplication.ts +3 -3
  10. package/src/api/ctaBanner.ts +3 -3
  11. package/src/api/dismissCta.ts +4 -6
  12. package/src/api/fetchCtaBanner.test.ts +5 -6
  13. package/src/api/getHeadlessSdkInstance.test.ts +6 -7
  14. package/src/api/getHeadlessSdkInstance.ts +6 -9
  15. package/src/api/startHostedApplication.test.ts +5 -6
  16. package/src/api/startHostedApplication.ts +3 -3
  17. package/src/components/banner/CtaBanner.snapshot.stories.tsx +7 -40
  18. package/src/components/modal/ConsentModal.snapshot.stories.tsx +1 -3
  19. package/src/config/index.ts +2 -0
  20. package/src/config/url.ts +1 -1
  21. package/src/config/whitelistedPartnerIds.ts +14 -0
  22. package/src/hooks/useContinueHostedApplication.ts +2 -2
  23. package/src/hooks/useCtaBanner.ts +3 -3
  24. package/src/hooks/useDismissCta.ts +2 -2
  25. package/src/hooks/useStartHostedApplication.ts +2 -2
  26. package/src/main.tsx +8 -8
  27. package/src/utils/applyFont.ts +4 -7
  28. package/src/utils/getPartnerIdFromToken.ts +9 -0
  29. package/src/utils/getPartnerThemeById.ts +9 -0
  30. package/src/utils/index.ts +4 -2
  31. package/src/utils/initializeHeadlessSdk.ts +4 -8
  32. package/src/utils/loadScriptAndInitializeSdk.ts +3 -3
  33. package/src/utils/parseJwt.ts +12 -0
  34. package/src/utils/partnerContext.ts +2 -3
  35. package/vitest.shims.d.ts +0 -1
@@ -0,0 +1,240 @@
1
+ import { R as z, p as K, Z as Q, _ as X, $ as Z, a0 as $, a1 as b, w as P, a2 as q, a3 as g, a4 as W, Q as Y, O as x, l as ee, a5 as te, a6 as ne } from "./index-DgBzPfcG.mjs";
2
+ function se(e) {
3
+ let n = 0;
4
+ for (const i of e)
5
+ i.stackId !== void 0 && n++;
6
+ return n;
7
+ }
8
+ const h = /* @__PURE__ */ new Map();
9
+ function re(e, n) {
10
+ h.set(n, e);
11
+ }
12
+ function oe(e) {
13
+ return h.get(e);
14
+ }
15
+ function _(e) {
16
+ for (const n of h.keys())
17
+ n < e && h.delete(n);
18
+ }
19
+ function ae({ rawRumEvent: e, startTime: n }) {
20
+ if (e.type !== z.LONG_TASK)
21
+ return;
22
+ const i = e.long_task.id;
23
+ re(i, n);
24
+ }
25
+ const ie = (e, n, i) => {
26
+ const { profilingEndpointBuilder: r, applicationId: l } = n, p = le(e, n, i), c = ue(e, p), m = r.build("fetch", c);
27
+ return K("Sending profile to public profiling intake", { profilingIntakeURL: m, applicationId: l, sessionId: i }), fetch(m, {
28
+ body: c.data,
29
+ method: "POST"
30
+ });
31
+ };
32
+ function le(e, n, i) {
33
+ const r = Q(n), l = de(e, n.applicationId, i), p = ce(r);
34
+ return {
35
+ ...l,
36
+ attachments: ["wall-time.json"],
37
+ start: new Date(e.startClocks.timeStamp).toISOString(),
38
+ end: new Date(e.endClocks.timeStamp).toISOString(),
39
+ family: "chrome",
40
+ runtime: "chrome",
41
+ format: "json",
42
+ version: 4,
43
+ // Ingestion event version (not the version application tag)
44
+ tags_profiler: p.join(","),
45
+ _dd: {
46
+ clock_drift: X()
47
+ }
48
+ };
49
+ }
50
+ function ce(e) {
51
+ return e.concat(["language:javascript", "runtime:chrome", "family:chrome", "host:browser"]);
52
+ }
53
+ function ue(e, n) {
54
+ const i = new Blob([JSON.stringify(e)], {
55
+ type: "application/json"
56
+ }), r = new FormData();
57
+ return r.append("event", new Blob([JSON.stringify(n)], { type: "application/json" }), "event.json"), r.append("wall-time.json", i, "wall-time.json"), { data: r, bytesCount: 0 };
58
+ }
59
+ function de(e, n, i) {
60
+ const r = {
61
+ application: {
62
+ id: n
63
+ }
64
+ };
65
+ i && (r.session = {
66
+ id: i
67
+ });
68
+ const l = Array.from(new Set(e.views.map((c) => c.viewId)));
69
+ l.length && (r.view = {
70
+ id: l
71
+ });
72
+ const p = e.longTasks.map((c) => c.id).filter((c) => c !== void 0);
73
+ return p.length && (r.long_task = { id: p }), r;
74
+ }
75
+ const pe = {
76
+ sendProfile: ie
77
+ }, fe = /\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g;
78
+ function me(e) {
79
+ return e ? e.replace(fe, "/?") : "/";
80
+ }
81
+ const O = (e, n) => e || me(n), ve = {
82
+ sampleIntervalMs: 10,
83
+ // Sample stack trace every 10ms
84
+ collectIntervalMs: 6e4,
85
+ // Collect data every minute
86
+ minProfileDurationMs: 5e3,
87
+ // Require at least 5 seconds of profile data to reduce noise and cost
88
+ minNumberOfSamples: 50
89
+ // Require at least 50 samples (~500 ms) to report a profile to reduce noise and cost
90
+ };
91
+ function ge(e, n, i, r, l = ve) {
92
+ const p = Z($.LONG_ANIMATION_FRAME);
93
+ let c;
94
+ const m = [];
95
+ let o = { state: "stopped" };
96
+ function L(t) {
97
+ o.state !== "running" && (c = t ? {
98
+ startClocks: t.startClocks,
99
+ viewId: t.id,
100
+ viewName: O(t.name, document.location.pathname)
101
+ } : void 0, m.push(P(e, window, "visibilitychange", A).stop, P(e, window, "beforeunload", j).stop), v());
102
+ }
103
+ async function N() {
104
+ await k("stopped"), m.forEach((t) => t()), _(b().relative), r.set({ status: "stopped", error_reason: void 0 });
105
+ }
106
+ function D(t) {
107
+ if (t.state === "running")
108
+ return {
109
+ cleanupTasks: t.cleanupTasks,
110
+ observer: t.observer
111
+ };
112
+ const s = [];
113
+ let a;
114
+ if (e.trackLongTasks) {
115
+ a = new PerformanceObserver(R), a.observe({
116
+ entryTypes: [B()]
117
+ });
118
+ const u = n.subscribe(12, (f) => {
119
+ ae(f);
120
+ });
121
+ s.push(() => a == null ? void 0 : a.disconnect()), s.push(u.unsubscribe);
122
+ }
123
+ const d = n.subscribe(2, (u) => {
124
+ const f = {
125
+ viewId: u.id,
126
+ // Note: `viewName` is only filled when users use manual view creation via `startView` method.
127
+ viewName: O(u.name, document.location.pathname),
128
+ startClocks: u.startClocks
129
+ };
130
+ y(f), c = f;
131
+ });
132
+ return s.push(d.unsubscribe), {
133
+ cleanupTasks: s,
134
+ observer: a
135
+ };
136
+ }
137
+ function v() {
138
+ const t = q().Profiler;
139
+ if (!t)
140
+ throw r.set({ status: "error", error_reason: "not-supported-by-browser" }), new Error("RUM Profiler is not supported in this browser.");
141
+ T(o).catch(g);
142
+ const { cleanupTasks: s, observer: a } = D(o);
143
+ let d;
144
+ try {
145
+ d = new t({
146
+ sampleInterval: l.sampleIntervalMs,
147
+ // Keep buffer size at 1.5 times of minimum required to collect data for a profiling instance
148
+ maxBufferSize: Math.round(l.collectIntervalMs * 1.5 / l.sampleIntervalMs)
149
+ });
150
+ } catch (u) {
151
+ u instanceof Error && u.message.includes("disabled by Document Policy") ? (W.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.", u), r.set({ status: "error", error_reason: "missing-document-policy-header" })) : r.set({ status: "error", error_reason: "unexpected-exception" });
152
+ return;
153
+ }
154
+ r.set({ status: "running", error_reason: void 0 }), o = {
155
+ state: "running",
156
+ startClocks: b(),
157
+ profiler: d,
158
+ timeoutId: Y(v, l.collectIntervalMs),
159
+ longTasks: [],
160
+ views: [],
161
+ cleanupTasks: s,
162
+ observer: a
163
+ }, y(c), d.addEventListener("samplebufferfull", w);
164
+ }
165
+ async function T(t) {
166
+ var s, a;
167
+ if (t.state !== "running")
168
+ return;
169
+ E((a = (s = t.observer) === null || s === void 0 ? void 0 : s.takeRecords()) !== null && a !== void 0 ? a : []), x(t.timeoutId), t.profiler.removeEventListener("samplebufferfull", w);
170
+ const { startClocks: d, longTasks: u, views: f } = t, V = b();
171
+ await t.profiler.stop().then((I) => {
172
+ const S = b(), G = u.length > 0, H = ee(d.timeStamp, S.timeStamp) < l.minProfileDurationMs, J = se(I.samples) < l.minNumberOfSamples;
173
+ !G && (H || J) || (M(
174
+ // Enrich trace with time and instance data
175
+ Object.assign(I, {
176
+ startClocks: d,
177
+ endClocks: S,
178
+ clocksOrigin: te(),
179
+ longTasks: u,
180
+ views: f,
181
+ sampleInterval: l.sampleIntervalMs
182
+ })
183
+ ), _(V.relative));
184
+ }).catch(g);
185
+ }
186
+ async function k(t) {
187
+ o.state === "running" && (o.cleanupTasks.forEach((s) => s()), await T(o), o = { state: t });
188
+ }
189
+ function y(t) {
190
+ o.state !== "running" || !t || o.views.push(t);
191
+ }
192
+ function M(t) {
193
+ var s;
194
+ const a = (s = i.findTrackedSession()) === null || s === void 0 ? void 0 : s.id;
195
+ pe.sendProfile(t, e, a).catch(g);
196
+ }
197
+ function w() {
198
+ v();
199
+ }
200
+ function R(t) {
201
+ E(t.getEntries());
202
+ }
203
+ function E(t) {
204
+ if (o.state === "running")
205
+ for (const s of t) {
206
+ if (s.duration < l.sampleIntervalMs)
207
+ continue;
208
+ const a = ne(s.startTime), d = oe(a.relative);
209
+ o.longTasks.push({
210
+ id: d,
211
+ duration: s.duration,
212
+ entryType: s.entryType,
213
+ startClocks: a
214
+ });
215
+ }
216
+ }
217
+ function A() {
218
+ document.visibilityState === "hidden" && o.state === "running" ? k("paused").catch(g) : document.visibilityState === "visible" && o.state === "paused" && v();
219
+ }
220
+ function j() {
221
+ v();
222
+ }
223
+ function B() {
224
+ return p ? "long-animation-frame" : "longtask";
225
+ }
226
+ function C() {
227
+ return o.state === "stopped";
228
+ }
229
+ function F() {
230
+ return o.state === "running";
231
+ }
232
+ function U() {
233
+ return o.state === "paused";
234
+ }
235
+ return { start: L, stop: N, isStopped: C, isRunning: F, isPaused: U };
236
+ }
237
+ export {
238
+ ve as DEFAULT_RUM_PROFILER_CONFIGURATION,
239
+ ge as createRumProfiler
240
+ };