@p-r-d-i-f-y/monitor 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 +26 -6
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +3 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +114 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/replay.d.ts +1 -0
- package/dist/replay.d.ts.map +1 -1
- package/dist/replay.js +25 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# f you want to keep going, the next logical items are the Engineering shared shell/subnav or trace correlation (x-trace-id).f you want to keep going, the next logical items are the Engineering shared shell/subnav or trace correlation (x-trace-id).@p-r-d-i-f-y/monitor
|
|
2
2
|
|
|
3
3
|
Lightweight SDK for PRDify Engineering monitoring: error capture, distributed tracing, and session replay.
|
|
4
4
|
|
|
@@ -10,6 +10,21 @@ npm install @p-r-d-i-f-y/monitor
|
|
|
10
10
|
|
|
11
11
|
Copy your project DSN from **Engineering → Monitoring** in PRDify.
|
|
12
12
|
|
|
13
|
+
## Universal setup
|
|
14
|
+
|
|
15
|
+
Use `initMonitor` when you want the SDK to auto-detect browser vs Node.js.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { initMonitor } from '@p-r-d-i-f-y/monitor';
|
|
19
|
+
|
|
20
|
+
initMonitor({
|
|
21
|
+
dsn: process.env.NEXT_PUBLIC_PRDIFY_MONITOR_DSN ?? process.env.PRDIFY_MONITOR_DSN!,
|
|
22
|
+
apiUrl: process.env.NEXT_PUBLIC_API_BASE_URL ?? process.env.PRDIFY_MONITOR_API_URL,
|
|
23
|
+
environment: process.env.NODE_ENV,
|
|
24
|
+
release: '1.0.0',
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
13
28
|
## Browser
|
|
14
29
|
|
|
15
30
|
```ts
|
|
@@ -23,7 +38,7 @@ initBrowserMonitor({
|
|
|
23
38
|
});
|
|
24
39
|
```
|
|
25
40
|
|
|
26
|
-
Browser init automatically records page spans and enables session replay (clicks, inputs with masked values, navigation).
|
|
41
|
+
Browser init automatically records page spans, instruments `fetch` with `x-trace-id` / `x-span-id` headers, and enables session replay (clicks, inputs with masked values, navigation). Password fields, hidden inputs, and `[data-sensitive]` fields are skipped. Set `enableReplay: false` to disable replay or `traceFetch: false` to disable fetch instrumentation.
|
|
27
42
|
|
|
28
43
|
## Node / NestJS
|
|
29
44
|
|
|
@@ -37,6 +52,8 @@ initNodeMonitor({
|
|
|
37
52
|
});
|
|
38
53
|
```
|
|
39
54
|
|
|
55
|
+
Node init captures process-level exceptions and instruments global `fetch` when available. Downstream services receive `x-trace-id` and `x-span-id`, and PRDify records the request span automatically.
|
|
56
|
+
|
|
40
57
|
## Manual spans
|
|
41
58
|
|
|
42
59
|
```ts
|
|
@@ -50,11 +67,13 @@ await span.end('ok');
|
|
|
50
67
|
|
|
51
68
|
## Ingest endpoints
|
|
52
69
|
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
|
|
71
|
+
| Endpoint | Purpose |
|
|
72
|
+
| ----------------------------------- | ---------------------- |
|
|
55
73
|
| `POST /developer/monitoring/ingest` | Errors and breadcrumbs |
|
|
56
|
-
| `POST /developer/monitoring/spans`
|
|
57
|
-
| `POST /developer/monitoring/replay` | Session replay events
|
|
74
|
+
| `POST /developer/monitoring/spans` | Trace spans |
|
|
75
|
+
| `POST /developer/monitoring/replay` | Session replay events |
|
|
76
|
+
|
|
58
77
|
|
|
59
78
|
Send `X-PRDify-DSN: <public-key>` on every request.
|
|
60
79
|
|
|
@@ -65,3 +84,4 @@ cd packages/monitor
|
|
|
65
84
|
npm run build
|
|
66
85
|
npm publish --access public
|
|
67
86
|
```
|
|
87
|
+
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAKxE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAKxE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAsD/D;AAED,wBAAgB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAEhC;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM;;;;;;;;GAMrE;AAED,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
package/dist/browser.js
CHANGED
|
@@ -47,7 +47,9 @@ export function initBrowserMonitor(options) {
|
|
|
47
47
|
durationMs: 0,
|
|
48
48
|
startedAt: new Date().toISOString(),
|
|
49
49
|
}).catch(function () { return undefined; });
|
|
50
|
-
|
|
50
|
+
if (options.enableReplay !== false) {
|
|
51
|
+
enableSessionReplay(client, options);
|
|
52
|
+
}
|
|
51
53
|
return client;
|
|
52
54
|
}
|
|
53
55
|
export function getBrowserMonitor() {
|
package/dist/core.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export type MonitorClientOptions = {
|
|
|
23
23
|
environment?: string;
|
|
24
24
|
release?: string;
|
|
25
25
|
traceId?: string;
|
|
26
|
+
enableReplay?: boolean;
|
|
27
|
+
traceFetch?: boolean;
|
|
26
28
|
};
|
|
27
29
|
export declare function parsePublicKeyFromDsn(dsn: string): string | null;
|
|
28
30
|
export declare function resolveIngestUrl(dsn: string, apiUrl?: string): string;
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQhE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOrE;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAwHF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB;2BAOjC,iBAAiB;4BAKV,mBAAmB;;;;;;;8BAyBjB,OAAO,UAAU,OAAO,CAAC,mBAAmB,CAAC;;;;;;;uBAYpD,WAAW;;;;;;;gCAkBR,MAAM,UAAU,MAAM,iBAAiB,MAAM;;;uBAOxD,MAAM,aAAoB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;EAkC1E;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/core.js
CHANGED
|
@@ -82,6 +82,113 @@ function randomSpanId() {
|
|
|
82
82
|
function randomTraceId() {
|
|
83
83
|
return "".concat(Date.now().toString(16)).concat(Math.random().toString(16).slice(2, 10));
|
|
84
84
|
}
|
|
85
|
+
var fetchTraceContext = null;
|
|
86
|
+
var originalFetch = null;
|
|
87
|
+
function requestUrl(input) {
|
|
88
|
+
if (typeof input === 'string')
|
|
89
|
+
return input;
|
|
90
|
+
if (input instanceof URL)
|
|
91
|
+
return input.toString();
|
|
92
|
+
return input.url;
|
|
93
|
+
}
|
|
94
|
+
function requestMethod(input, init) {
|
|
95
|
+
if (init === null || init === void 0 ? void 0 : init.method)
|
|
96
|
+
return init.method.toUpperCase();
|
|
97
|
+
if (typeof input !== 'string' && !(input instanceof URL) && input.method) {
|
|
98
|
+
return input.method.toUpperCase();
|
|
99
|
+
}
|
|
100
|
+
return 'GET';
|
|
101
|
+
}
|
|
102
|
+
function routeFromUrl(url) {
|
|
103
|
+
try {
|
|
104
|
+
var parsed = new URL(url, typeof window !== 'undefined' ? window.location.origin : undefined);
|
|
105
|
+
return "".concat(parsed.pathname).concat(parsed.search);
|
|
106
|
+
}
|
|
107
|
+
catch (_a) {
|
|
108
|
+
return url;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function shouldSkipFetchTrace(url, ingestUrls) {
|
|
112
|
+
return ingestUrls.some(function (ingestUrl) { return url.startsWith(ingestUrl); });
|
|
113
|
+
}
|
|
114
|
+
function withTraceHeaders(input, init, traceId, spanId) {
|
|
115
|
+
var _a;
|
|
116
|
+
var sourceHeaders = (_a = init === null || init === void 0 ? void 0 : init.headers) !== null && _a !== void 0 ? _a : (typeof input !== 'string' && !(input instanceof URL) ? input.headers : undefined);
|
|
117
|
+
var headers = new Headers(sourceHeaders);
|
|
118
|
+
if (!headers.has('x-trace-id'))
|
|
119
|
+
headers.set('x-trace-id', traceId);
|
|
120
|
+
if (!headers.has('x-span-id'))
|
|
121
|
+
headers.set('x-span-id', spanId);
|
|
122
|
+
if (typeof input !== 'string' && !(input instanceof URL)) {
|
|
123
|
+
return [new Request(input, __assign(__assign({}, init), { headers: headers })), undefined];
|
|
124
|
+
}
|
|
125
|
+
return [input, __assign(__assign({}, init), { headers: headers })];
|
|
126
|
+
}
|
|
127
|
+
function installFetchTraceHeaders(context) {
|
|
128
|
+
var _this = this;
|
|
129
|
+
fetchTraceContext = context;
|
|
130
|
+
if (typeof fetch === 'undefined' || originalFetch)
|
|
131
|
+
return;
|
|
132
|
+
originalFetch = fetch.bind(globalThis);
|
|
133
|
+
globalThis.fetch = (function (input, init) { return __awaiter(_this, void 0, void 0, function () {
|
|
134
|
+
var active, url, spanId, method, route, startedAt, startedMs, _a, tracedInput, tracedInit, response, error_1;
|
|
135
|
+
return __generator(this, function (_b) {
|
|
136
|
+
switch (_b.label) {
|
|
137
|
+
case 0:
|
|
138
|
+
active = fetchTraceContext;
|
|
139
|
+
url = requestUrl(input);
|
|
140
|
+
if (!active || !url || shouldSkipFetchTrace(url, active.ingestUrls)) {
|
|
141
|
+
return [2 /*return*/, originalFetch(input, init)];
|
|
142
|
+
}
|
|
143
|
+
spanId = randomSpanId();
|
|
144
|
+
method = requestMethod(input, init);
|
|
145
|
+
route = routeFromUrl(url);
|
|
146
|
+
startedAt = new Date().toISOString();
|
|
147
|
+
startedMs = Date.now();
|
|
148
|
+
_a = withTraceHeaders(input, init, active.traceId, spanId), tracedInput = _a[0], tracedInit = _a[1];
|
|
149
|
+
_b.label = 1;
|
|
150
|
+
case 1:
|
|
151
|
+
_b.trys.push([1, 3, , 4]);
|
|
152
|
+
return [4 /*yield*/, originalFetch(tracedInput, tracedInit)];
|
|
153
|
+
case 2:
|
|
154
|
+
response = _b.sent();
|
|
155
|
+
void active
|
|
156
|
+
.recordSpan({
|
|
157
|
+
traceId: active.traceId,
|
|
158
|
+
spanId: spanId,
|
|
159
|
+
operation: "".concat(method, " ").concat(route),
|
|
160
|
+
route: route,
|
|
161
|
+
status: response.ok ? 'ok' : 'error',
|
|
162
|
+
durationMs: Date.now() - startedMs,
|
|
163
|
+
startedAt: startedAt,
|
|
164
|
+
metadata: {
|
|
165
|
+
status: response.status,
|
|
166
|
+
},
|
|
167
|
+
})
|
|
168
|
+
.catch(function () { return undefined; });
|
|
169
|
+
return [2 /*return*/, response];
|
|
170
|
+
case 3:
|
|
171
|
+
error_1 = _b.sent();
|
|
172
|
+
void active
|
|
173
|
+
.recordSpan({
|
|
174
|
+
traceId: active.traceId,
|
|
175
|
+
spanId: spanId,
|
|
176
|
+
operation: "".concat(method, " ").concat(route),
|
|
177
|
+
route: route,
|
|
178
|
+
status: 'error',
|
|
179
|
+
durationMs: Date.now() - startedMs,
|
|
180
|
+
startedAt: startedAt,
|
|
181
|
+
metadata: {
|
|
182
|
+
error: error_1 instanceof Error ? error_1.message : String(error_1),
|
|
183
|
+
},
|
|
184
|
+
})
|
|
185
|
+
.catch(function () { return undefined; });
|
|
186
|
+
throw error_1;
|
|
187
|
+
case 4: return [2 /*return*/];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}); });
|
|
191
|
+
}
|
|
85
192
|
export function createMonitorClient(options) {
|
|
86
193
|
var _this = this;
|
|
87
194
|
var _a;
|
|
@@ -198,6 +305,13 @@ export function createMonitorClient(options) {
|
|
|
198
305
|
},
|
|
199
306
|
};
|
|
200
307
|
};
|
|
308
|
+
if (options.traceFetch !== false) {
|
|
309
|
+
installFetchTraceHeaders({
|
|
310
|
+
traceId: activeTraceId,
|
|
311
|
+
ingestUrls: [ingestUrl, spansUrl, spansUrl.replace(/\/spans$/, '/replay')],
|
|
312
|
+
recordSpan: recordSpan,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
201
315
|
return {
|
|
202
316
|
addBreadcrumb: addBreadcrumb,
|
|
203
317
|
captureEvent: captureEvent,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
import { type MonitorClientOptions } from './core';
|
|
2
|
+
export declare function initMonitor(options: MonitorClientOptions): {
|
|
3
|
+
addBreadcrumb: (crumb: import("./core").MonitorBreadcrumb) => void;
|
|
4
|
+
captureEvent: (payload: import("./core").MonitorEventPayload) => Promise<{
|
|
5
|
+
ok: false;
|
|
6
|
+
status?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
status: number;
|
|
10
|
+
}>;
|
|
11
|
+
captureException: (error: unknown, extra?: Partial<import("./core").MonitorEventPayload>) => Promise<{
|
|
12
|
+
ok: false;
|
|
13
|
+
status?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
status: number;
|
|
17
|
+
}>;
|
|
18
|
+
recordSpan: (span: import("./core").SpanPayload) => Promise<{
|
|
19
|
+
ok: false;
|
|
20
|
+
status?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
status: number;
|
|
24
|
+
}>;
|
|
25
|
+
startTimedSpan: (operation: string, route?: string, parentSpanId?: string) => {
|
|
26
|
+
spanId: string;
|
|
27
|
+
traceId: string;
|
|
28
|
+
end: (status?: string, metadata?: Record<string, unknown>) => Promise<void>;
|
|
29
|
+
};
|
|
30
|
+
getTraceId: () => string;
|
|
31
|
+
getPublicKey: () => string | null;
|
|
32
|
+
getIngestUrl: () => string;
|
|
33
|
+
} | null;
|
|
1
34
|
export * from './core';
|
|
2
35
|
export * from './browser';
|
|
3
36
|
export * from './node';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAGxE,wBAAgB,WAAW,CAAC,OAAO,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAUxD;AAED,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import { initBrowserMonitor } from './browser';
|
|
2
|
+
import { createMonitorClient } from './core';
|
|
3
|
+
import { initNodeMonitor } from './node';
|
|
4
|
+
export function initMonitor(options) {
|
|
5
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
6
|
+
return initBrowserMonitor(options);
|
|
7
|
+
}
|
|
8
|
+
if (typeof process !== 'undefined' && typeof process.on === 'function') {
|
|
9
|
+
return initNodeMonitor(options);
|
|
10
|
+
}
|
|
11
|
+
return createMonitorClient(options);
|
|
12
|
+
}
|
|
1
13
|
export * from './core';
|
|
2
14
|
export * from './browser';
|
|
3
15
|
export * from './node';
|
package/dist/replay.d.ts
CHANGED
package/dist/replay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAsBF,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,cAiHF"}
|
package/dist/replay.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -46,6 +57,16 @@ function maskValue(value) {
|
|
|
46
57
|
return '**';
|
|
47
58
|
return "".concat(value.slice(0, 1)).concat('*'.repeat(Math.min(value.length - 1, 8)));
|
|
48
59
|
}
|
|
60
|
+
function isSensitiveInput(target) {
|
|
61
|
+
var _a;
|
|
62
|
+
if (target.type === 'password' || target.type === 'hidden')
|
|
63
|
+
return true;
|
|
64
|
+
if ((_a = target.autocomplete) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('password'))
|
|
65
|
+
return true;
|
|
66
|
+
if (target.hasAttribute('data-sensitive'))
|
|
67
|
+
return true;
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
49
70
|
export function enableSessionReplay(client, options) {
|
|
50
71
|
var _this = this;
|
|
51
72
|
var _a, _b;
|
|
@@ -114,17 +135,15 @@ export function enableSessionReplay(client, options) {
|
|
|
114
135
|
timestamp: new Date().toISOString(),
|
|
115
136
|
route: window.location.pathname,
|
|
116
137
|
message: (_b = (_a = target === null || target === void 0 ? void 0 : target.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'element',
|
|
117
|
-
data: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
text: ((_c = target === null || target === void 0 ? void 0 : target.textContent) === null || _c === void 0 ? void 0 : _c.trim().slice(0, 80)) || undefined,
|
|
121
|
-
},
|
|
138
|
+
data: __assign({ id: (target === null || target === void 0 ? void 0 : target.id) || undefined, className: (target === null || target === void 0 ? void 0 : target.className) || undefined }, (options.recordClickText
|
|
139
|
+
? { text: ((_c = target === null || target === void 0 ? void 0 : target.textContent) === null || _c === void 0 ? void 0 : _c.trim().slice(0, 80)) || undefined }
|
|
140
|
+
: {})),
|
|
122
141
|
});
|
|
123
142
|
};
|
|
124
143
|
var onInput = function (event) {
|
|
125
144
|
var _a;
|
|
126
145
|
var target = event.target;
|
|
127
|
-
if (!target)
|
|
146
|
+
if (!target || isSensitiveInput(target))
|
|
128
147
|
return;
|
|
129
148
|
record({
|
|
130
149
|
type: 'input',
|