@astropay/payments-lib 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -11
- package/dist/astropay-payments-lib.es.js +5 -9984
- package/dist/astropay-payments-lib.umd.js +186 -174
- package/dist/main-DcyIcTY7.js +16426 -0
- package/dist/profiler-DOjJT9RY.js +228 -0
- package/dist/public/AstroPayCore/index.d.ts +1 -1
- package/dist/startRecording-CKIy7MKJ.js +1146 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +12 -12
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { p as x, V as z, W as H, w as O, X as W, Y as v, Z as X, O as Y, M as Z } from "./main-DcyIcTY7.js";
|
|
2
|
+
function q(e) {
|
|
3
|
+
let t = 0;
|
|
4
|
+
for (const o of e)
|
|
5
|
+
o.stackId !== void 0 && t++;
|
|
6
|
+
return t;
|
|
7
|
+
}
|
|
8
|
+
const g = /* @__PURE__ */ new Map();
|
|
9
|
+
let m = !1;
|
|
10
|
+
function C() {
|
|
11
|
+
m = performance.now();
|
|
12
|
+
}
|
|
13
|
+
function K() {
|
|
14
|
+
m = !1, g.clear();
|
|
15
|
+
}
|
|
16
|
+
function Q(e, t) {
|
|
17
|
+
g.set(t, e);
|
|
18
|
+
}
|
|
19
|
+
function L(e) {
|
|
20
|
+
if (!(m === !1 || e.startTime < m))
|
|
21
|
+
return g.get(e.startTime);
|
|
22
|
+
}
|
|
23
|
+
function $(e) {
|
|
24
|
+
if (!(m === !1 || e < m))
|
|
25
|
+
for (const t of g.keys())
|
|
26
|
+
t < e && g.delete(t);
|
|
27
|
+
}
|
|
28
|
+
function ee({ rawRumEvent: e, startTime: t }) {
|
|
29
|
+
if (e.type !== "long_task")
|
|
30
|
+
return;
|
|
31
|
+
const o = e.long_task.id;
|
|
32
|
+
Q(o, t);
|
|
33
|
+
}
|
|
34
|
+
const ne = (e, t, o, s) => {
|
|
35
|
+
const f = te(e, t, o, s), c = re(e, f), l = t.build("fetch", c);
|
|
36
|
+
return x("Sending profile to public profiling intake", { profilingIntakeURL: l, applicationId: o, sessionId: s }), fetch(l, {
|
|
37
|
+
body: c.data,
|
|
38
|
+
method: "POST"
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
function te(e, t, o, s) {
|
|
42
|
+
const f = t.tags, c = ie(e, o, s), l = se(f), i = new Date(e.timeOrigin + e.startTime), b = new Date(e.timeOrigin + e.endTime);
|
|
43
|
+
return {
|
|
44
|
+
...c,
|
|
45
|
+
attachments: ["wall-time.json"],
|
|
46
|
+
start: i.toISOString(),
|
|
47
|
+
end: b.toISOString(),
|
|
48
|
+
family: "chrome",
|
|
49
|
+
runtime: "chrome",
|
|
50
|
+
format: "json",
|
|
51
|
+
version: 4,
|
|
52
|
+
// Ingestion event version (not the version application tag)
|
|
53
|
+
tags_profiler: l.join(",")
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function se(e) {
|
|
57
|
+
return e.concat(["language:javascript", "runtime:chrome", "family:chrome", "host:browser"]);
|
|
58
|
+
}
|
|
59
|
+
function re(e, t) {
|
|
60
|
+
const o = new Blob([JSON.stringify(e)], {
|
|
61
|
+
type: "application/json"
|
|
62
|
+
}), s = new FormData();
|
|
63
|
+
return s.append("event", new Blob([JSON.stringify(t)], { type: "application/json" }), "event.json"), s.append("wall-time.json", o, "wall-time.json"), { data: s, bytesCount: 0 };
|
|
64
|
+
}
|
|
65
|
+
function ie(e, t, o) {
|
|
66
|
+
const s = {
|
|
67
|
+
application: {
|
|
68
|
+
id: t
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
o && (s.session = {
|
|
72
|
+
id: o
|
|
73
|
+
});
|
|
74
|
+
const f = Array.from(new Set(e.views.map((l) => l.viewId)));
|
|
75
|
+
f.length && (s.view = {
|
|
76
|
+
id: f
|
|
77
|
+
});
|
|
78
|
+
const c = e.longTasks.map((l) => L(l)).filter((l) => l !== void 0);
|
|
79
|
+
return c.length && (s.long_task = { id: c }), s;
|
|
80
|
+
}
|
|
81
|
+
const oe = {
|
|
82
|
+
sendProfile: ne
|
|
83
|
+
}, ae = {
|
|
84
|
+
sampleIntervalMs: 10,
|
|
85
|
+
// Sample stack trace every 10ms
|
|
86
|
+
collectIntervalMs: 6e4,
|
|
87
|
+
// Collect data every minute
|
|
88
|
+
minProfileDurationMs: 5e3,
|
|
89
|
+
// Require at least 5 seconds of profile data to reduce noise and cost
|
|
90
|
+
minNumberOfSamples: 50
|
|
91
|
+
// Require at least 50 samples (~500 ms) to report a profile to reduce noise and cost
|
|
92
|
+
};
|
|
93
|
+
function ce(e, t, o, s = ae) {
|
|
94
|
+
const f = z(H.LONG_ANIMATION_FRAME);
|
|
95
|
+
let c;
|
|
96
|
+
const l = [];
|
|
97
|
+
let i = { state: "stopped" };
|
|
98
|
+
function b(n) {
|
|
99
|
+
i.state !== "running" && (c = n ? { startTime: n.startClocks.relative, viewId: n.id, viewName: n.name } : void 0, l.push(O(e, window, "visibilitychange", _).stop, O(e, window, "beforeunload", j).stop), p());
|
|
100
|
+
}
|
|
101
|
+
async function h() {
|
|
102
|
+
await y("stopped"), K(), l.forEach((n) => n());
|
|
103
|
+
}
|
|
104
|
+
function M(n) {
|
|
105
|
+
if (n.state === "running")
|
|
106
|
+
return {
|
|
107
|
+
cleanupTasks: n.cleanupTasks,
|
|
108
|
+
observer: n.observer
|
|
109
|
+
};
|
|
110
|
+
const r = [];
|
|
111
|
+
let a;
|
|
112
|
+
if (e.trackLongTasks) {
|
|
113
|
+
a = new PerformanceObserver(R), a.observe({
|
|
114
|
+
entryTypes: [D()]
|
|
115
|
+
});
|
|
116
|
+
const u = t.subscribe(12, (T) => {
|
|
117
|
+
ee(T);
|
|
118
|
+
});
|
|
119
|
+
C(), r.push(() => a == null ? void 0 : a.disconnect()), r.push(u.unsubscribe);
|
|
120
|
+
}
|
|
121
|
+
const d = t.subscribe(2, (u) => {
|
|
122
|
+
k({ viewId: u.id, viewName: u.name, startTime: u.startClocks.relative });
|
|
123
|
+
});
|
|
124
|
+
return r.push(d.unsubscribe), {
|
|
125
|
+
cleanupTasks: r,
|
|
126
|
+
observer: a
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function p() {
|
|
130
|
+
const n = W().Profiler;
|
|
131
|
+
if (!n)
|
|
132
|
+
throw new Error("RUM Profiler is not supported in this browser.");
|
|
133
|
+
w(i).catch(v);
|
|
134
|
+
const { cleanupTasks: r, observer: a } = M(i);
|
|
135
|
+
let d;
|
|
136
|
+
try {
|
|
137
|
+
d = new n({
|
|
138
|
+
sampleInterval: s.sampleIntervalMs,
|
|
139
|
+
// Keep buffer size at 1.5 times of minimum required to collect data for a profiling instance
|
|
140
|
+
maxBufferSize: Math.round(s.collectIntervalMs * 1.5 / s.sampleIntervalMs)
|
|
141
|
+
});
|
|
142
|
+
} catch (u) {
|
|
143
|
+
X.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.", u);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
i = {
|
|
147
|
+
state: "running",
|
|
148
|
+
startTime: performance.now(),
|
|
149
|
+
profiler: d,
|
|
150
|
+
timeoutId: Y(p, s.collectIntervalMs),
|
|
151
|
+
longTasks: [],
|
|
152
|
+
views: [],
|
|
153
|
+
cleanupTasks: r,
|
|
154
|
+
observer: a
|
|
155
|
+
}, k(c), d.addEventListener("samplebufferfull", P);
|
|
156
|
+
}
|
|
157
|
+
async function w(n) {
|
|
158
|
+
var r, a;
|
|
159
|
+
if (n.state !== "running")
|
|
160
|
+
return;
|
|
161
|
+
I((a = (r = n.observer) === null || r === void 0 ? void 0 : r.takeRecords()) !== null && a !== void 0 ? a : []), Z(n.timeoutId), n.profiler.removeEventListener("samplebufferfull", P);
|
|
162
|
+
const { startTime: d, longTasks: u, views: T } = n, U = performance.now();
|
|
163
|
+
await n.profiler.stop().then((E) => {
|
|
164
|
+
const S = performance.now(), V = u.length > 0, G = S - d < s.minProfileDurationMs, J = q(E.samples) < s.minNumberOfSamples;
|
|
165
|
+
!V && (G || J) || (N(
|
|
166
|
+
// Enrich trace with time and instance data
|
|
167
|
+
Object.assign(E, {
|
|
168
|
+
startTime: d,
|
|
169
|
+
endTime: S,
|
|
170
|
+
timeOrigin: performance.timeOrigin,
|
|
171
|
+
longTasks: u,
|
|
172
|
+
views: T,
|
|
173
|
+
sampleInterval: s.sampleIntervalMs
|
|
174
|
+
})
|
|
175
|
+
), $(U));
|
|
176
|
+
}).catch(v);
|
|
177
|
+
}
|
|
178
|
+
async function y(n) {
|
|
179
|
+
i.state === "running" && (i.cleanupTasks.forEach((r) => r()), await w(i), i = { state: n });
|
|
180
|
+
}
|
|
181
|
+
function k(n) {
|
|
182
|
+
i.state !== "running" || !n || i.views.push(n);
|
|
183
|
+
}
|
|
184
|
+
function N(n) {
|
|
185
|
+
var r;
|
|
186
|
+
const a = (r = o.findTrackedSession()) === null || r === void 0 ? void 0 : r.id;
|
|
187
|
+
oe.sendProfile(n, e.profilingEndpointBuilder, e.applicationId, a).catch(v);
|
|
188
|
+
}
|
|
189
|
+
function P() {
|
|
190
|
+
p();
|
|
191
|
+
}
|
|
192
|
+
function R(n) {
|
|
193
|
+
I(n.getEntries());
|
|
194
|
+
}
|
|
195
|
+
function I(n) {
|
|
196
|
+
if (i.state === "running")
|
|
197
|
+
for (const r of n)
|
|
198
|
+
r.duration < s.sampleIntervalMs || i.longTasks.push({
|
|
199
|
+
id: L(r),
|
|
200
|
+
duration: r.duration,
|
|
201
|
+
entryType: r.entryType,
|
|
202
|
+
startTime: r.startTime
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function _() {
|
|
206
|
+
document.visibilityState === "hidden" && i.state === "running" ? y("paused").catch(v) : document.visibilityState === "visible" && i.state === "paused" && p();
|
|
207
|
+
}
|
|
208
|
+
function j() {
|
|
209
|
+
p();
|
|
210
|
+
}
|
|
211
|
+
function D() {
|
|
212
|
+
return f ? "long-animation-frame" : "longtask";
|
|
213
|
+
}
|
|
214
|
+
function A() {
|
|
215
|
+
return i.state === "stopped";
|
|
216
|
+
}
|
|
217
|
+
function B() {
|
|
218
|
+
return i.state === "running";
|
|
219
|
+
}
|
|
220
|
+
function F() {
|
|
221
|
+
return i.state === "paused";
|
|
222
|
+
}
|
|
223
|
+
return { start: b, stop: h, isStopped: A, isRunning: B, isPaused: F };
|
|
224
|
+
}
|
|
225
|
+
export {
|
|
226
|
+
ae as DEFAULT_RUM_PROFILER_CONFIGURATION,
|
|
227
|
+
ce as createRumProfiler
|
|
228
|
+
};
|
|
@@ -17,7 +17,6 @@ export declare class AstroPayCore {
|
|
|
17
17
|
private static isInitialized;
|
|
18
18
|
private static token;
|
|
19
19
|
private static components;
|
|
20
|
-
private constructor();
|
|
21
20
|
/**
|
|
22
21
|
* Initializes the AstroPay Payments Library.
|
|
23
22
|
*
|
|
@@ -29,6 +28,7 @@ export declare class AstroPayCore {
|
|
|
29
28
|
* theme: 'light' // or 'dark'
|
|
30
29
|
* language: 'en' // or 'es'/'pt'
|
|
31
30
|
* currencyMode: 'iso' // or 'symbol'
|
|
31
|
+
* tracking: true // or false to disable tracking
|
|
32
32
|
* styles: {
|
|
33
33
|
* primaryColor: '#000000',
|
|
34
34
|
* }
|