@goliapkg/sentori-react-native 1.2.0 → 1.3.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.
- package/lib/compat/sentry.d.ts +112 -0
- package/lib/compat/sentry.d.ts.map +1 -0
- package/lib/compat/sentry.js +326 -0
- package/lib/compat/sentry.js.map +1 -0
- package/lib/init.d.ts +10 -0
- package/lib/init.d.ts.map +1 -1
- package/lib/init.js +5 -3
- package/lib/init.js.map +1 -1
- package/package.json +12 -1
- package/src/compat/sentry.ts +482 -0
- package/src/init.ts +15 -3
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.3 W6.3 — Sentry-compatible API surface.
|
|
3
|
+
*
|
|
4
|
+
* Drop-in for code (or LLM-generated code) written against
|
|
5
|
+
* `@sentry/react-native`. Every Sentry call maps to exactly one
|
|
6
|
+
* Sentori-native call internally. Translation differences (e.g.
|
|
7
|
+
* `Sentry.setUser({ ip_address })` — Sentori never stores IP) fire
|
|
8
|
+
* a one-shot console hint at `info` level, deduplicated per
|
|
9
|
+
* (api, dropped_field).
|
|
10
|
+
*
|
|
11
|
+
* Why this exists: LLMs have seen a LOT of Sentry code; letting
|
|
12
|
+
* them write the same syntax against Sentori is one less thing
|
|
13
|
+
* Sentori asks the host to think about. Combined with the v2.3
|
|
14
|
+
* "free bonus" stance — host adds Sentori without unlearning
|
|
15
|
+
* anything.
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
*
|
|
19
|
+
* import * as Sentry from '@goliapkg/sentori-react-native/compat'
|
|
20
|
+
*
|
|
21
|
+
* Sentry.init({ dsn: 'https://<token>@<host>/<projectId>', ... })
|
|
22
|
+
* Sentry.captureException(err)
|
|
23
|
+
* Sentry.setUser({ id, email }) // email → linkBy.email (hashed)
|
|
24
|
+
*
|
|
25
|
+
* The compat layer holds NO state of its own — it's a thin shim
|
|
26
|
+
* over the same Sentori internals. Mixing `Sentry.*` and
|
|
27
|
+
* `sentori.*` calls in the same app works fine.
|
|
28
|
+
*
|
|
29
|
+
* See `docs/design/sdk-v2.3-redesign.md` §4 for the full
|
|
30
|
+
* translation table + design rationale.
|
|
31
|
+
*/
|
|
32
|
+
type SentryInitOpts = {
|
|
33
|
+
dsn: string;
|
|
34
|
+
environment?: string;
|
|
35
|
+
release?: string;
|
|
36
|
+
tracesSampleRate?: number;
|
|
37
|
+
sampleRate?: number;
|
|
38
|
+
attachStacktrace?: boolean;
|
|
39
|
+
autoSessionTracking?: boolean;
|
|
40
|
+
/** Sentry's `debug: true` ≈ Sentori's `logLevel: 'debug'`. */
|
|
41
|
+
debug?: boolean;
|
|
42
|
+
/** Catch-all for fields Sentori either ignores or doesn't map yet. */
|
|
43
|
+
[other: string]: unknown;
|
|
44
|
+
};
|
|
45
|
+
export declare function init(opts: SentryInitOpts): void;
|
|
46
|
+
/** Sentry's severity values, surfaced as strings (Sentori only
|
|
47
|
+
* uses 5 levels). `Log` and `Critical` collapse to `'info'` and
|
|
48
|
+
* `'fatal'` respectively. */
|
|
49
|
+
export declare const Severity: {
|
|
50
|
+
Fatal: "fatal";
|
|
51
|
+
Critical: "fatal";
|
|
52
|
+
Error: "error";
|
|
53
|
+
Warning: "warning";
|
|
54
|
+
Log: "info";
|
|
55
|
+
Info: "info";
|
|
56
|
+
Debug: "debug";
|
|
57
|
+
};
|
|
58
|
+
type SentryLevelString = 'critical' | 'debug' | 'error' | 'fatal' | 'info' | 'log' | 'warning';
|
|
59
|
+
type SentryCaptureContext = {
|
|
60
|
+
tags?: Record<string, string>;
|
|
61
|
+
extra?: Record<string, unknown>;
|
|
62
|
+
level?: SentryLevelString;
|
|
63
|
+
fingerprint?: string[];
|
|
64
|
+
user?: SentrySetUserInput;
|
|
65
|
+
};
|
|
66
|
+
export declare function captureException(err: unknown, hint?: {
|
|
67
|
+
captureContext?: SentryCaptureContext;
|
|
68
|
+
} | SentryCaptureContext): void;
|
|
69
|
+
export declare function captureMessage(msg: string, levelOrCtx?: SentryCaptureContext | SentryLevelString): void;
|
|
70
|
+
type SentrySetUserInput = {
|
|
71
|
+
id?: string;
|
|
72
|
+
email?: string;
|
|
73
|
+
username?: string;
|
|
74
|
+
ip_address?: string;
|
|
75
|
+
segment?: string;
|
|
76
|
+
[other: string]: unknown;
|
|
77
|
+
} | null;
|
|
78
|
+
export declare function setUser(user: SentrySetUserInput): void;
|
|
79
|
+
export declare const setTag: (key: string, value: string) => void;
|
|
80
|
+
export declare const setTags: (record: Record<string, string>) => void;
|
|
81
|
+
type SentryBreadcrumb = {
|
|
82
|
+
category?: string;
|
|
83
|
+
message?: string;
|
|
84
|
+
level?: SentryLevelString;
|
|
85
|
+
type?: 'default' | 'error' | 'http' | 'info' | 'navigation' | 'query' | 'user' | string;
|
|
86
|
+
data?: Record<string, unknown>;
|
|
87
|
+
timestamp?: number;
|
|
88
|
+
};
|
|
89
|
+
export declare function addBreadcrumb(crumb: SentryBreadcrumb): void;
|
|
90
|
+
export { close, flush } from '../lifecycle';
|
|
91
|
+
type SentrySpanOpts = {
|
|
92
|
+
op?: string;
|
|
93
|
+
name?: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
tags?: Record<string, string>;
|
|
96
|
+
};
|
|
97
|
+
export declare function startTransaction(opts: SentrySpanOpts): {
|
|
98
|
+
finish: (status?: 'cancelled' | 'error' | 'ok') => void;
|
|
99
|
+
setStatus: (status: 'cancelled' | 'error' | 'ok') => void;
|
|
100
|
+
setTag: (k: string, v: string) => void;
|
|
101
|
+
startChild: (childOpts: SentrySpanOpts) => unknown;
|
|
102
|
+
};
|
|
103
|
+
type ScopeProxy = {
|
|
104
|
+
setTag: (k: string, v: string) => void;
|
|
105
|
+
setTags: (rec: Record<string, string>) => void;
|
|
106
|
+
setUser: (u: SentrySetUserInput) => void;
|
|
107
|
+
setExtra: (k: string, v: unknown) => void;
|
|
108
|
+
setLevel: (l: SentryLevelString) => void;
|
|
109
|
+
};
|
|
110
|
+
export declare function withScope<T>(fn: (scope: ScopeProxy) => T): T;
|
|
111
|
+
export declare function configureScope(fn: (scope: ScopeProxy) => void): void;
|
|
112
|
+
//# sourceMappingURL=sentry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../../src/compat/sentry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAyBH,KAAK,cAAc,GAAG;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,8DAA8D;IAC9D,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,sEAAsE;IACtE,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;CACzB,CAAA;AA4BD,wBAAgB,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CA8C/C;AAsBD;;8BAE8B;AAC9B,eAAO,MAAM,QAAQ;;;;;;;;CAQpB,CAAA;AAED,KAAK,iBAAiB,GAClB,UAAU,GACV,OAAO,GACP,OAAO,GACP,OAAO,GACP,MAAM,GACN,KAAK,GACL,SAAS,CAAA;AA0Bb,KAAK,oBAAoB,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,KAAK,CAAC,EAAE,iBAAiB,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,IAAI,CAAC,EAAE,kBAAkB,CAAA;CAC1B,CAAA;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EA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
4
|
+
* Drop-in for code (or LLM-generated code) written against
|
|
5
|
+
* `@sentry/react-native`. Every Sentry call maps to exactly one
|
|
6
|
+
* Sentori-native call internally. Translation differences (e.g.
|
|
7
|
+
* `Sentry.setUser({ ip_address })` — Sentori never stores IP) fire
|
|
8
|
+
* a one-shot console hint at `info` level, deduplicated per
|
|
9
|
+
* (api, dropped_field).
|
|
10
|
+
*
|
|
11
|
+
* Why this exists: LLMs have seen a LOT of Sentry code; letting
|
|
12
|
+
* them write the same syntax against Sentori is one less thing
|
|
13
|
+
* Sentori asks the host to think about. Combined with the v2.3
|
|
14
|
+
* "free bonus" stance — host adds Sentori without unlearning
|
|
15
|
+
* anything.
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
*
|
|
19
|
+
* import * as Sentry from '@goliapkg/sentori-react-native/compat'
|
|
20
|
+
*
|
|
21
|
+
* Sentry.init({ dsn: 'https://<token>@<host>/<projectId>', ... })
|
|
22
|
+
* Sentry.captureException(err)
|
|
23
|
+
* Sentry.setUser({ id, email }) // email → linkBy.email (hashed)
|
|
24
|
+
*
|
|
25
|
+
* The compat layer holds NO state of its own — it's a thin shim
|
|
26
|
+
* over the same Sentori internals. Mixing `Sentry.*` and
|
|
27
|
+
* `sentori.*` calls in the same app works fine.
|
|
28
|
+
*
|
|
29
|
+
* See `docs/design/sdk-v2.3-redesign.md` §4 for the full
|
|
30
|
+
* translation table + design rationale.
|
|
31
|
+
*/
|
|
32
|
+
import { logger } from '@goliapkg/sentori-core';
|
|
33
|
+
import { addBreadcrumb as nativeAddBreadcrumb } from '../breadcrumbs';
|
|
34
|
+
import { captureException as nativeCaptureException, captureMessage as nativeCaptureMessage, setTag as nativeSetTag, setTags as nativeSetTags, setUser as nativeSetUser, } from '../capture';
|
|
35
|
+
import { init as nativeInit } from '../init';
|
|
36
|
+
// ── one-shot warn dedup ───────────────────────────────────────────────────
|
|
37
|
+
const _warnedOnce = new Set();
|
|
38
|
+
function warnOnce(key, msg) {
|
|
39
|
+
if (_warnedOnce.has(key))
|
|
40
|
+
return;
|
|
41
|
+
_warnedOnce.add(key);
|
|
42
|
+
logger.info('compat', msg);
|
|
43
|
+
}
|
|
44
|
+
function parseDsn(dsn) {
|
|
45
|
+
// Sentry DSN shape: `https://<key>@<host>[:port][/<projectId>]`
|
|
46
|
+
// Sentori cares about `<key>` (must be `st_pk_…`) and `<host>`.
|
|
47
|
+
let url;
|
|
48
|
+
try {
|
|
49
|
+
url = new URL(dsn);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
throw new Error(`Sentory compat: dsn is not a valid URL: ${dsn}`);
|
|
53
|
+
}
|
|
54
|
+
const key = url.username;
|
|
55
|
+
if (!key) {
|
|
56
|
+
throw new Error(`Sentory compat: dsn missing token in user-info component`);
|
|
57
|
+
}
|
|
58
|
+
if (!key.startsWith('st_pk_')) {
|
|
59
|
+
throw new Error(`Sentory compat: dsn token must start with 'st_pk_' (got prefix '${key.slice(0, 8)}…'). ` +
|
|
60
|
+
`Sentori does not parse Sentry-issued tokens — generate a Sentori project token via the dashboard.`);
|
|
61
|
+
}
|
|
62
|
+
// strip user-info to reconstruct the ingest origin
|
|
63
|
+
const ingestUrl = `${url.protocol}//${url.host}`;
|
|
64
|
+
return { token: key, ingestUrl };
|
|
65
|
+
}
|
|
66
|
+
// ── Sentry.init ───────────────────────────────────────────────────────────
|
|
67
|
+
export function init(opts) {
|
|
68
|
+
const { token, ingestUrl } = parseDsn(opts.dsn);
|
|
69
|
+
const sentoriOpts = {
|
|
70
|
+
token,
|
|
71
|
+
release: opts.release ?? '',
|
|
72
|
+
ingestUrl,
|
|
73
|
+
...(opts.environment ? { environment: opts.environment } : {}),
|
|
74
|
+
sample: {
|
|
75
|
+
...(opts.tracesSampleRate !== undefined ? { traces: opts.tracesSampleRate } : {}),
|
|
76
|
+
...(opts.sampleRate !== undefined ? { errors: opts.sampleRate } : {}),
|
|
77
|
+
},
|
|
78
|
+
...(opts.debug ? { logLevel: 'debug' } : {}),
|
|
79
|
+
};
|
|
80
|
+
// Empty release is the most common Sentry-init mistake; warn but
|
|
81
|
+
// continue.
|
|
82
|
+
if (!sentoriOpts.release) {
|
|
83
|
+
warnOnce('init:no-release', 'Sentry.init() with no `release` — Sentori requires release for grouping + drop-down menus to make sense. Set `release: "myapp@1.2.3"` for production cuts.');
|
|
84
|
+
// Sentori's init throws when release is empty; provide a
|
|
85
|
+
// reasonable fallback so the rest of the code path works in dev.
|
|
86
|
+
sentoriOpts.release = `unspecified@${Date.now()}`;
|
|
87
|
+
}
|
|
88
|
+
// Pass-through informational hints for ignored fields.
|
|
89
|
+
for (const ignored of [
|
|
90
|
+
'attachStacktrace',
|
|
91
|
+
'autoSessionTracking',
|
|
92
|
+
'integrations',
|
|
93
|
+
'beforeSend',
|
|
94
|
+
'beforeBreadcrumb',
|
|
95
|
+
'maxBreadcrumbs',
|
|
96
|
+
]) {
|
|
97
|
+
if (ignored in opts) {
|
|
98
|
+
warnOnce(`init:ignored:${ignored}`, `Sentry.init({ ${ignored} }) ignored. ` +
|
|
99
|
+
`${getIgnoredHint(ignored)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
nativeInit(sentoriOpts);
|
|
103
|
+
}
|
|
104
|
+
function getIgnoredHint(field) {
|
|
105
|
+
switch (field) {
|
|
106
|
+
case 'attachStacktrace':
|
|
107
|
+
return 'Sentori always sends stack traces — no toggle.';
|
|
108
|
+
case 'autoSessionTracking':
|
|
109
|
+
return "Sentori sessions are on by default; toggle via `init({ capture: { sessions: true|false } })`.";
|
|
110
|
+
case 'integrations':
|
|
111
|
+
return 'Sentori uses `init({ capture: {...} })` toggles instead of Integration classes — see the docs.';
|
|
112
|
+
case 'beforeSend':
|
|
113
|
+
case 'beforeBreadcrumb':
|
|
114
|
+
return 'Sentori does not support an arbitrary beforeSend hook today. Server-side PII scrubbing is automatic.';
|
|
115
|
+
case 'maxBreadcrumbs':
|
|
116
|
+
return 'Sentori uses a fixed 100-slot ring buffer.';
|
|
117
|
+
default:
|
|
118
|
+
return '';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// ── Severity / level enum ─────────────────────────────────────────────────
|
|
122
|
+
/** Sentry's severity values, surfaced as strings (Sentori only
|
|
123
|
+
* uses 5 levels). `Log` and `Critical` collapse to `'info'` and
|
|
124
|
+
* `'fatal'` respectively. */
|
|
125
|
+
export const Severity = {
|
|
126
|
+
Fatal: 'fatal',
|
|
127
|
+
Critical: 'fatal',
|
|
128
|
+
Error: 'error',
|
|
129
|
+
Warning: 'warning',
|
|
130
|
+
Log: 'info',
|
|
131
|
+
Info: 'info',
|
|
132
|
+
Debug: 'debug',
|
|
133
|
+
};
|
|
134
|
+
function mapLevel(level) {
|
|
135
|
+
if (!level)
|
|
136
|
+
return undefined;
|
|
137
|
+
switch (level) {
|
|
138
|
+
case 'critical':
|
|
139
|
+
warnOnce('severity:critical', "Sentry.Severity.Critical → mapped to 'fatal' (Sentori's 5-level syslog-style scale).");
|
|
140
|
+
return 'fatal';
|
|
141
|
+
case 'log':
|
|
142
|
+
warnOnce('severity:log', "Sentry.Severity.Log → mapped to 'info' (Sentori's 5-level scale has no separate Log).");
|
|
143
|
+
return 'info';
|
|
144
|
+
default:
|
|
145
|
+
return level;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export function captureException(err, hint) {
|
|
149
|
+
// Sentry v8+ takes the context inline (Hint); earlier versions
|
|
150
|
+
// wrapped it in `{ captureContext: {...} }`. Accept both.
|
|
151
|
+
const ctx = (() => {
|
|
152
|
+
if (!hint)
|
|
153
|
+
return undefined;
|
|
154
|
+
if ('captureContext' in hint) {
|
|
155
|
+
return hint.captureContext;
|
|
156
|
+
}
|
|
157
|
+
return hint;
|
|
158
|
+
})();
|
|
159
|
+
if (ctx?.extra) {
|
|
160
|
+
warnOnce('captureException:extra', 'Sentry.captureException(err, { extra }) → `extra` mapped to `tags` (Sentori does not have a separate extra namespace).');
|
|
161
|
+
}
|
|
162
|
+
if (ctx?.user) {
|
|
163
|
+
// Apply the per-call user via setUser (Sentori takes the
|
|
164
|
+
// current scope user automatically).
|
|
165
|
+
setUser(ctx.user);
|
|
166
|
+
}
|
|
167
|
+
const mergedTags = {
|
|
168
|
+
...(ctx?.tags ?? {}),
|
|
169
|
+
...(ctx?.extra
|
|
170
|
+
? Object.fromEntries(Object.entries(ctx.extra).map(([k, v]) => [k, String(v)]))
|
|
171
|
+
: {}),
|
|
172
|
+
};
|
|
173
|
+
nativeCaptureException(err, {
|
|
174
|
+
...(Object.keys(mergedTags).length > 0 ? { tags: mergedTags } : {}),
|
|
175
|
+
...(ctx?.fingerprint ? { fingerprint: ctx.fingerprint } : {}),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
// ── captureMessage ────────────────────────────────────────────────────────
|
|
179
|
+
export function captureMessage(msg, levelOrCtx) {
|
|
180
|
+
let level;
|
|
181
|
+
let tags;
|
|
182
|
+
if (typeof levelOrCtx === 'string') {
|
|
183
|
+
level = mapLevel(levelOrCtx);
|
|
184
|
+
}
|
|
185
|
+
else if (levelOrCtx) {
|
|
186
|
+
level = mapLevel(levelOrCtx.level);
|
|
187
|
+
tags = levelOrCtx.tags;
|
|
188
|
+
}
|
|
189
|
+
nativeCaptureMessage(msg, {
|
|
190
|
+
...(level ? { level } : {}),
|
|
191
|
+
...(tags ? { tags } : {}),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
export function setUser(user) {
|
|
195
|
+
if (user == null) {
|
|
196
|
+
nativeSetUser(null);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const { id, email, username, ip_address, segment, ...rest } = user;
|
|
200
|
+
if (ip_address !== undefined) {
|
|
201
|
+
warnOnce('setUser:ip_address', 'Sentry.setUser({ ip_address }) → dropped. Sentori never stores IP (privacy by design).');
|
|
202
|
+
}
|
|
203
|
+
if (segment !== undefined) {
|
|
204
|
+
warnOnce('setUser:segment', 'Sentry.setUser({ segment }) → mapped to tag `user.segment`. Set via setTag for clarity.');
|
|
205
|
+
if (typeof segment === 'string')
|
|
206
|
+
nativeSetTag('user.segment', segment);
|
|
207
|
+
}
|
|
208
|
+
const linkBy = {};
|
|
209
|
+
if (email)
|
|
210
|
+
linkBy.email = email;
|
|
211
|
+
if (username)
|
|
212
|
+
linkBy.username = username;
|
|
213
|
+
// Surface any other fields the host bolted on (Sentry historically
|
|
214
|
+
// accepted arbitrary keys) — they pass through as tags.
|
|
215
|
+
for (const [k, v] of Object.entries(rest)) {
|
|
216
|
+
if (v !== undefined && v !== null)
|
|
217
|
+
nativeSetTag(`user.${k}`, String(v));
|
|
218
|
+
}
|
|
219
|
+
nativeSetUser({
|
|
220
|
+
...(id ? { id } : {}),
|
|
221
|
+
...(Object.keys(linkBy).length > 0 ? { linkBy } : {}),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
// ── setTag / setTags ──────────────────────────────────────────────────────
|
|
225
|
+
// Re-export Sentori-native semantics; identical signatures.
|
|
226
|
+
export const setTag = nativeSetTag;
|
|
227
|
+
export const setTags = nativeSetTags;
|
|
228
|
+
function mapCategoryToType(category) {
|
|
229
|
+
if (!category)
|
|
230
|
+
return undefined;
|
|
231
|
+
if (['auth', 'click', 'gesture', 'input', 'touch', 'ui'].includes(category))
|
|
232
|
+
return 'user';
|
|
233
|
+
if (['fetch', 'http', 'xhr'].includes(category))
|
|
234
|
+
return 'net';
|
|
235
|
+
if (['nav', 'navigation', 'route'].includes(category))
|
|
236
|
+
return 'nav';
|
|
237
|
+
if (['console', 'log', 'sentry'].includes(category))
|
|
238
|
+
return 'log';
|
|
239
|
+
return 'custom';
|
|
240
|
+
}
|
|
241
|
+
function mapSentryType(t) {
|
|
242
|
+
if (!t)
|
|
243
|
+
return undefined;
|
|
244
|
+
switch (t) {
|
|
245
|
+
case 'http':
|
|
246
|
+
return 'net';
|
|
247
|
+
case 'navigation':
|
|
248
|
+
return 'nav';
|
|
249
|
+
case 'user':
|
|
250
|
+
case 'log':
|
|
251
|
+
case 'custom':
|
|
252
|
+
return t;
|
|
253
|
+
default:
|
|
254
|
+
return 'custom';
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
export function addBreadcrumb(crumb) {
|
|
258
|
+
if (!crumb.message) {
|
|
259
|
+
crumb.message = crumb.category ?? crumb.type ?? '(no message)';
|
|
260
|
+
}
|
|
261
|
+
if (crumb.category && !crumb.type) {
|
|
262
|
+
warnOnce('breadcrumb:category', 'Sentry.addBreadcrumb({ category }) → mapped to `type` via well-known table; the category string itself is preserved under `data.category`.');
|
|
263
|
+
}
|
|
264
|
+
// RN SDK shape: { type, data }. No top-level `message` —
|
|
265
|
+
// Sentry's message goes into data.message.
|
|
266
|
+
nativeAddBreadcrumb({
|
|
267
|
+
type: mapSentryType(crumb.type) ?? mapCategoryToType(crumb.category) ?? 'custom',
|
|
268
|
+
data: {
|
|
269
|
+
message: crumb.message,
|
|
270
|
+
...(crumb.data ?? {}),
|
|
271
|
+
...(crumb.category ? { category: crumb.category } : {}),
|
|
272
|
+
...(crumb.level ? { level: mapLevel(crumb.level) } : {}),
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
// ── flush / close ─────────────────────────────────────────────────────────
|
|
277
|
+
// Re-export Sentori native flush + close — same signatures.
|
|
278
|
+
export { close, flush } from '../lifecycle';
|
|
279
|
+
// ── startTransaction / startSpan / withScope ──────────────────────────────
|
|
280
|
+
// Trace mapping is non-trivial (Sentry's transaction object exposes
|
|
281
|
+
// startChild, etc.). v2.3 ships a minimum-viable Sentry trace
|
|
282
|
+
// surface that supports startTransaction returning a Sentori Span
|
|
283
|
+
// object with a partial Sentry-style API (.startChild, .finish).
|
|
284
|
+
// Anything beyond that throws a clear error directing to the native
|
|
285
|
+
// `sentori.startSpan` / `sentori.withScopedSpan`.
|
|
286
|
+
import { startSpan } from '@goliapkg/sentori-core';
|
|
287
|
+
export function startTransaction(opts) {
|
|
288
|
+
warnOnce('startTransaction', 'Sentry.startTransaction() → mapped to sentori.startSpan() with op as name. Native equivalent: sentori.startTrace(name) or sentori.startSpan({ name }).');
|
|
289
|
+
const name = opts.name ?? opts.op ?? 'transaction';
|
|
290
|
+
const span = startSpan(name, {
|
|
291
|
+
parent: null,
|
|
292
|
+
tags: opts.tags,
|
|
293
|
+
});
|
|
294
|
+
return {
|
|
295
|
+
finish: (status) => span.finish({ status: status === 'ok' ? 'ok' : 'error' }),
|
|
296
|
+
setStatus: (status) => { span.setTag('status', status); },
|
|
297
|
+
setTag: (k, v) => { span.setTag(k, v); },
|
|
298
|
+
startChild: (childOpts) => {
|
|
299
|
+
return startSpan(childOpts.name ?? childOpts.op ?? 'child', {
|
|
300
|
+
tags: childOpts.tags,
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function scopeProxy() {
|
|
306
|
+
return {
|
|
307
|
+
setTag: nativeSetTag,
|
|
308
|
+
setTags: nativeSetTags,
|
|
309
|
+
setUser,
|
|
310
|
+
setExtra: (k, v) => nativeSetTag(`extra.${k}`, String(v)),
|
|
311
|
+
setLevel: () => {
|
|
312
|
+
warnOnce('scope:setLevel', 'Sentry.withScope(s => s.setLevel(…)) → not supported. Sentori levels travel on capture call, not on scope.');
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
export function withScope(fn) {
|
|
317
|
+
// Sentori has no Hub; tags set inside `fn` persist (best-effort
|
|
318
|
+
// approximation of Sentry semantics). For most callers this is
|
|
319
|
+
// fine; tighter isolation needs an actual Hub which we don't ship.
|
|
320
|
+
warnOnce('withScope', 'Sentry.withScope() → tag mutations are NOT auto-reverted on scope exit. Use sentori.setTag/clearTags explicitly for tight isolation.');
|
|
321
|
+
return fn(scopeProxy());
|
|
322
|
+
}
|
|
323
|
+
export function configureScope(fn) {
|
|
324
|
+
fn(scopeProxy());
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=sentry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA,CAAC,CAAC;QACxD,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAC,CAAC;QACvC,UAAU,EAAE,CAAC,SAAS,EAAE,EAAE;YACxB,OAAO,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,EAAE,IAAI,OAAO,EAAE;gBAC1D,IAAI,EAAE,SAAS,CAAC,IAAI;aACrB,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC;AAYD,SAAS,UAAU;IACjB,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE,aAAa;QACtB,OAAO;QACP,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACzD,QAAQ,EAAE,GAAG,EAAE;YACb,QAAQ,CACN,gBAAgB,EAChB,4GAA4G,CAC7G,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,EAA4B;IACvD,gEAAgE;IAChE,+DAA+D;IAC/D,mEAAmE;IACnE,QAAQ,CACN,WAAW,EACX,sIAAsI,CACvI,CAAA;IACD,OAAO,EAAE,CAAC,UAAU,EAAE,CAAC,CAAA;AACzB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAA+B;IAC5D,EAAE,CAAC,UAAU,EAAE,CAAC,CAAA;AAClB,CAAC"}
|
package/lib/init.d.ts
CHANGED
|
@@ -100,6 +100,16 @@ export type InitOptions = {
|
|
|
100
100
|
* via `sentori.captureMessage()`. `null` / absent → keep all. */
|
|
101
101
|
messages?: null | number;
|
|
102
102
|
};
|
|
103
|
+
/** v2.3 — canonical sampling field (renamed from `sampling`).
|
|
104
|
+
* Same shape; if both are passed, `sample` wins. The older
|
|
105
|
+
* `sampling` stays accepted indefinitely as a back-compat alias —
|
|
106
|
+
* this is the kind of rename that's only worth doing if it's
|
|
107
|
+
* also zero-cost for existing callers. */
|
|
108
|
+
sample?: {
|
|
109
|
+
errors?: null | number;
|
|
110
|
+
traces?: null | number;
|
|
111
|
+
messages?: null | number;
|
|
112
|
+
};
|
|
103
113
|
/** v2.3 — Sentori SDK's own console output gate. Default `'warn'`:
|
|
104
114
|
* SDK is silent unless something is genuinely broken (transport
|
|
105
115
|
* sustained failure, native module not found, internal SDK
|
package/lib/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,UAAU,CAAC;AAerD,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpE,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAUnF,OAAO,KAAK,EAAkB,cAAc,EAA2B,MAAM,SAAS,CAAC;AAIvF,MAAM,MAAM,WAAW,GAAG;IACxB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,OAAO,CAAC,EACJ,OAAO,GACP;YACE;;qEAEyD;YACzD,OAAO,CAAC,EAAE,OAAO,CAAC;SACnB,CAAC;QACN;;8DAEsD;QACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB;;;;;;;uBAOe;QACf,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB;;;6C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D,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACrC,CAAC;AAIF,eAAO,MAAM,IAAI,GAAI,SAAS,WAAW,KAAG,IA+N3C,CAAC;AAqBF,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
package/lib/init.js
CHANGED
|
@@ -50,9 +50,11 @@ export const init = (options) => {
|
|
|
50
50
|
ingestUrl: options.ingestUrl ?? DEFAULT_INGEST_URL,
|
|
51
51
|
enabled: true,
|
|
52
52
|
screenshotsEnabled: options.capture?.screenshot === true,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
// v2.3 — `sample` is the canonical name; `sampling` is the
|
|
54
|
+
// back-compat alias. If both are supplied, `sample` wins.
|
|
55
|
+
errorSampleRate: options.sample?.errors ?? options.sampling?.errors ?? null,
|
|
56
|
+
traceSampleRate: options.sample?.traces ?? options.sampling?.traces ?? null,
|
|
57
|
+
messageSampleRate: options.sample?.messages ?? options.sampling?.messages ?? null,
|
|
56
58
|
sessionTrailEnabled: options.capture?.sessionTrail === true,
|
|
57
59
|
});
|
|
58
60
|
// Tell the native crash handler about the config so the JSON it writes
|
package/lib/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAkB,SAAS,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,mB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AAG,EAAE;YACtB,IAAI,CAAC;gBACH,iEAAiE;gBACjE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;gBACvC,MAAM,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC;gBACrB,OAAO,CAAC,IAAI,IAAI,CAAC;YACnB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QACL,MAAM,IAAI,GAAc;YACtB,UAAU,EAAE,WAAW;YACvB,WAAW,EAAE,MAAM,IAAI,SAAS;YAChC,MAAM,EAAE;gBACN,KAAK,EAAE,CAAC,CAAC,SAAS;gBAClB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;aACxD;SACF,CAAC;QACF,IAAI,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;QAChD,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,gEAAgE;AAChE,sDAAsD;AACtD,MAAM,WAAW,GAAG,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goliapkg/sentori-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Sentori SDK for React Native — JS-layer error capture, native crash handlers (iOS / Android), batched transport, fetch + react-navigation tracing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://sentori.golia.jp",
|
|
@@ -22,6 +22,17 @@
|
|
|
22
22
|
],
|
|
23
23
|
"main": "lib/index.js",
|
|
24
24
|
"types": "lib/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./lib/index.d.ts",
|
|
28
|
+
"default": "./lib/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./compat": {
|
|
31
|
+
"types": "./lib/compat/sentry.d.ts",
|
|
32
|
+
"default": "./lib/compat/sentry.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
25
36
|
"bin": {
|
|
26
37
|
"sentori-rn-upload-source-bundle": "bin/sentori-rn-upload-source-bundle.cjs"
|
|
27
38
|
},
|
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.3 W6.3 — Sentry-compatible API surface.
|
|
3
|
+
*
|
|
4
|
+
* Drop-in for code (or LLM-generated code) written against
|
|
5
|
+
* `@sentry/react-native`. Every Sentry call maps to exactly one
|
|
6
|
+
* Sentori-native call internally. Translation differences (e.g.
|
|
7
|
+
* `Sentry.setUser({ ip_address })` — Sentori never stores IP) fire
|
|
8
|
+
* a one-shot console hint at `info` level, deduplicated per
|
|
9
|
+
* (api, dropped_field).
|
|
10
|
+
*
|
|
11
|
+
* Why this exists: LLMs have seen a LOT of Sentry code; letting
|
|
12
|
+
* them write the same syntax against Sentori is one less thing
|
|
13
|
+
* Sentori asks the host to think about. Combined with the v2.3
|
|
14
|
+
* "free bonus" stance — host adds Sentori without unlearning
|
|
15
|
+
* anything.
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
*
|
|
19
|
+
* import * as Sentry from '@goliapkg/sentori-react-native/compat'
|
|
20
|
+
*
|
|
21
|
+
* Sentry.init({ dsn: 'https://<token>@<host>/<projectId>', ... })
|
|
22
|
+
* Sentry.captureException(err)
|
|
23
|
+
* Sentry.setUser({ id, email }) // email → linkBy.email (hashed)
|
|
24
|
+
*
|
|
25
|
+
* The compat layer holds NO state of its own — it's a thin shim
|
|
26
|
+
* over the same Sentori internals. Mixing `Sentry.*` and
|
|
27
|
+
* `sentori.*` calls in the same app works fine.
|
|
28
|
+
*
|
|
29
|
+
* See `docs/design/sdk-v2.3-redesign.md` §4 for the full
|
|
30
|
+
* translation table + design rationale.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import { logger } from '@goliapkg/sentori-core'
|
|
34
|
+
|
|
35
|
+
import { addBreadcrumb as nativeAddBreadcrumb } from '../breadcrumbs'
|
|
36
|
+
import {
|
|
37
|
+
captureException as nativeCaptureException,
|
|
38
|
+
captureMessage as nativeCaptureMessage,
|
|
39
|
+
setTag as nativeSetTag,
|
|
40
|
+
setTags as nativeSetTags,
|
|
41
|
+
setUser as nativeSetUser,
|
|
42
|
+
} from '../capture'
|
|
43
|
+
import { type InitOptions, init as nativeInit } from '../init'
|
|
44
|
+
|
|
45
|
+
// ── one-shot warn dedup ───────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
const _warnedOnce = new Set<string>()
|
|
48
|
+
function warnOnce(key: string, msg: string): void {
|
|
49
|
+
if (_warnedOnce.has(key)) return
|
|
50
|
+
_warnedOnce.add(key)
|
|
51
|
+
logger.info('compat', msg)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ── DSN parsing ───────────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
type SentryInitOpts = {
|
|
57
|
+
dsn: string
|
|
58
|
+
environment?: string
|
|
59
|
+
release?: string
|
|
60
|
+
tracesSampleRate?: number
|
|
61
|
+
sampleRate?: number
|
|
62
|
+
attachStacktrace?: boolean
|
|
63
|
+
autoSessionTracking?: boolean
|
|
64
|
+
/** Sentry's `debug: true` ≈ Sentori's `logLevel: 'debug'`. */
|
|
65
|
+
debug?: boolean
|
|
66
|
+
/** Catch-all for fields Sentori either ignores or doesn't map yet. */
|
|
67
|
+
[other: string]: unknown
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function parseDsn(dsn: string): { token: string; ingestUrl: string } {
|
|
71
|
+
// Sentry DSN shape: `https://<key>@<host>[:port][/<projectId>]`
|
|
72
|
+
// Sentori cares about `<key>` (must be `st_pk_…`) and `<host>`.
|
|
73
|
+
let url: URL
|
|
74
|
+
try {
|
|
75
|
+
url = new URL(dsn)
|
|
76
|
+
} catch {
|
|
77
|
+
throw new Error(`Sentory compat: dsn is not a valid URL: ${dsn}`)
|
|
78
|
+
}
|
|
79
|
+
const key = url.username
|
|
80
|
+
if (!key) {
|
|
81
|
+
throw new Error(`Sentory compat: dsn missing token in user-info component`)
|
|
82
|
+
}
|
|
83
|
+
if (!key.startsWith('st_pk_')) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`Sentory compat: dsn token must start with 'st_pk_' (got prefix '${key.slice(0, 8)}…'). ` +
|
|
86
|
+
`Sentori does not parse Sentry-issued tokens — generate a Sentori project token via the dashboard.`,
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
// strip user-info to reconstruct the ingest origin
|
|
90
|
+
const ingestUrl = `${url.protocol}//${url.host}`
|
|
91
|
+
return { token: key, ingestUrl }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ── Sentry.init ───────────────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
export function init(opts: SentryInitOpts): void {
|
|
97
|
+
const { token, ingestUrl } = parseDsn(opts.dsn)
|
|
98
|
+
|
|
99
|
+
const sentoriOpts: InitOptions = {
|
|
100
|
+
token,
|
|
101
|
+
release: opts.release ?? '',
|
|
102
|
+
ingestUrl,
|
|
103
|
+
...(opts.environment ? { environment: opts.environment } : {}),
|
|
104
|
+
sample: {
|
|
105
|
+
...(opts.tracesSampleRate !== undefined ? { traces: opts.tracesSampleRate } : {}),
|
|
106
|
+
...(opts.sampleRate !== undefined ? { errors: opts.sampleRate } : {}),
|
|
107
|
+
},
|
|
108
|
+
...(opts.debug ? { logLevel: 'debug' as const } : {}),
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Empty release is the most common Sentry-init mistake; warn but
|
|
112
|
+
// continue.
|
|
113
|
+
if (!sentoriOpts.release) {
|
|
114
|
+
warnOnce(
|
|
115
|
+
'init:no-release',
|
|
116
|
+
'Sentry.init() with no `release` — Sentori requires release for grouping + drop-down menus to make sense. Set `release: "myapp@1.2.3"` for production cuts.',
|
|
117
|
+
)
|
|
118
|
+
// Sentori's init throws when release is empty; provide a
|
|
119
|
+
// reasonable fallback so the rest of the code path works in dev.
|
|
120
|
+
sentoriOpts.release = `unspecified@${Date.now()}`
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Pass-through informational hints for ignored fields.
|
|
124
|
+
for (const ignored of [
|
|
125
|
+
'attachStacktrace',
|
|
126
|
+
'autoSessionTracking',
|
|
127
|
+
'integrations',
|
|
128
|
+
'beforeSend',
|
|
129
|
+
'beforeBreadcrumb',
|
|
130
|
+
'maxBreadcrumbs',
|
|
131
|
+
]) {
|
|
132
|
+
if (ignored in opts) {
|
|
133
|
+
warnOnce(
|
|
134
|
+
`init:ignored:${ignored}`,
|
|
135
|
+
`Sentry.init({ ${ignored} }) ignored. ` +
|
|
136
|
+
`${getIgnoredHint(ignored)}`,
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
nativeInit(sentoriOpts)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function getIgnoredHint(field: string): string {
|
|
145
|
+
switch (field) {
|
|
146
|
+
case 'attachStacktrace':
|
|
147
|
+
return 'Sentori always sends stack traces — no toggle.'
|
|
148
|
+
case 'autoSessionTracking':
|
|
149
|
+
return "Sentori sessions are on by default; toggle via `init({ capture: { sessions: true|false } })`."
|
|
150
|
+
case 'integrations':
|
|
151
|
+
return 'Sentori uses `init({ capture: {...} })` toggles instead of Integration classes — see the docs.'
|
|
152
|
+
case 'beforeSend':
|
|
153
|
+
case 'beforeBreadcrumb':
|
|
154
|
+
return 'Sentori does not support an arbitrary beforeSend hook today. Server-side PII scrubbing is automatic.'
|
|
155
|
+
case 'maxBreadcrumbs':
|
|
156
|
+
return 'Sentori uses a fixed 100-slot ring buffer.'
|
|
157
|
+
default:
|
|
158
|
+
return ''
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// ── Severity / level enum ─────────────────────────────────────────────────
|
|
163
|
+
|
|
164
|
+
/** Sentry's severity values, surfaced as strings (Sentori only
|
|
165
|
+
* uses 5 levels). `Log` and `Critical` collapse to `'info'` and
|
|
166
|
+
* `'fatal'` respectively. */
|
|
167
|
+
export const Severity = {
|
|
168
|
+
Fatal: 'fatal' as const,
|
|
169
|
+
Critical: 'fatal' as const,
|
|
170
|
+
Error: 'error' as const,
|
|
171
|
+
Warning: 'warning' as const,
|
|
172
|
+
Log: 'info' as const,
|
|
173
|
+
Info: 'info' as const,
|
|
174
|
+
Debug: 'debug' as const,
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
type SentryLevelString =
|
|
178
|
+
| 'critical'
|
|
179
|
+
| 'debug'
|
|
180
|
+
| 'error'
|
|
181
|
+
| 'fatal'
|
|
182
|
+
| 'info'
|
|
183
|
+
| 'log'
|
|
184
|
+
| 'warning'
|
|
185
|
+
|
|
186
|
+
type SentoriLevel = 'debug' | 'error' | 'fatal' | 'info' | 'warning'
|
|
187
|
+
|
|
188
|
+
function mapLevel(level: SentryLevelString | undefined): SentoriLevel | undefined {
|
|
189
|
+
if (!level) return undefined
|
|
190
|
+
switch (level) {
|
|
191
|
+
case 'critical':
|
|
192
|
+
warnOnce(
|
|
193
|
+
'severity:critical',
|
|
194
|
+
"Sentry.Severity.Critical → mapped to 'fatal' (Sentori's 5-level syslog-style scale).",
|
|
195
|
+
)
|
|
196
|
+
return 'fatal'
|
|
197
|
+
case 'log':
|
|
198
|
+
warnOnce(
|
|
199
|
+
'severity:log',
|
|
200
|
+
"Sentry.Severity.Log → mapped to 'info' (Sentori's 5-level scale has no separate Log).",
|
|
201
|
+
)
|
|
202
|
+
return 'info'
|
|
203
|
+
default:
|
|
204
|
+
return level as SentoriLevel
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// ── captureException ──────────────────────────────────────────────────────
|
|
209
|
+
|
|
210
|
+
type SentryCaptureContext = {
|
|
211
|
+
tags?: Record<string, string>
|
|
212
|
+
extra?: Record<string, unknown>
|
|
213
|
+
level?: SentryLevelString
|
|
214
|
+
fingerprint?: string[]
|
|
215
|
+
user?: SentrySetUserInput
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function captureException(
|
|
219
|
+
err: unknown,
|
|
220
|
+
hint?: { captureContext?: SentryCaptureContext } | SentryCaptureContext,
|
|
221
|
+
): void {
|
|
222
|
+
// Sentry v8+ takes the context inline (Hint); earlier versions
|
|
223
|
+
// wrapped it in `{ captureContext: {...} }`. Accept both.
|
|
224
|
+
const ctx: SentryCaptureContext | undefined = (() => {
|
|
225
|
+
if (!hint) return undefined
|
|
226
|
+
if ('captureContext' in (hint as { captureContext?: unknown })) {
|
|
227
|
+
return (hint as { captureContext?: SentryCaptureContext }).captureContext
|
|
228
|
+
}
|
|
229
|
+
return hint as SentryCaptureContext
|
|
230
|
+
})()
|
|
231
|
+
|
|
232
|
+
if (ctx?.extra) {
|
|
233
|
+
warnOnce(
|
|
234
|
+
'captureException:extra',
|
|
235
|
+
'Sentry.captureException(err, { extra }) → `extra` mapped to `tags` (Sentori does not have a separate extra namespace).',
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
if (ctx?.user) {
|
|
239
|
+
// Apply the per-call user via setUser (Sentori takes the
|
|
240
|
+
// current scope user automatically).
|
|
241
|
+
setUser(ctx.user)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const mergedTags = {
|
|
245
|
+
...(ctx?.tags ?? {}),
|
|
246
|
+
...(ctx?.extra
|
|
247
|
+
? Object.fromEntries(
|
|
248
|
+
Object.entries(ctx.extra).map(([k, v]) => [k, String(v)]),
|
|
249
|
+
)
|
|
250
|
+
: {}),
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
nativeCaptureException(err as Error, {
|
|
254
|
+
...(Object.keys(mergedTags).length > 0 ? { tags: mergedTags } : {}),
|
|
255
|
+
...(ctx?.fingerprint ? { fingerprint: ctx.fingerprint } : {}),
|
|
256
|
+
})
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// ── captureMessage ────────────────────────────────────────────────────────
|
|
260
|
+
|
|
261
|
+
export function captureMessage(
|
|
262
|
+
msg: string,
|
|
263
|
+
levelOrCtx?: SentryCaptureContext | SentryLevelString,
|
|
264
|
+
): void {
|
|
265
|
+
let level: SentoriLevel | undefined
|
|
266
|
+
let tags: Record<string, string> | undefined
|
|
267
|
+
if (typeof levelOrCtx === 'string') {
|
|
268
|
+
level = mapLevel(levelOrCtx)
|
|
269
|
+
} else if (levelOrCtx) {
|
|
270
|
+
level = mapLevel(levelOrCtx.level)
|
|
271
|
+
tags = levelOrCtx.tags
|
|
272
|
+
}
|
|
273
|
+
nativeCaptureMessage(msg, {
|
|
274
|
+
...(level ? { level } : {}),
|
|
275
|
+
...(tags ? { tags } : {}),
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// ── setUser ───────────────────────────────────────────────────────────────
|
|
280
|
+
|
|
281
|
+
type SentrySetUserInput = {
|
|
282
|
+
id?: string
|
|
283
|
+
email?: string
|
|
284
|
+
username?: string
|
|
285
|
+
ip_address?: string
|
|
286
|
+
segment?: string
|
|
287
|
+
[other: string]: unknown
|
|
288
|
+
} | null
|
|
289
|
+
|
|
290
|
+
export function setUser(user: SentrySetUserInput): void {
|
|
291
|
+
if (user == null) {
|
|
292
|
+
nativeSetUser(null)
|
|
293
|
+
return
|
|
294
|
+
}
|
|
295
|
+
const { id, email, username, ip_address, segment, ...rest } = user
|
|
296
|
+
|
|
297
|
+
if (ip_address !== undefined) {
|
|
298
|
+
warnOnce(
|
|
299
|
+
'setUser:ip_address',
|
|
300
|
+
'Sentry.setUser({ ip_address }) → dropped. Sentori never stores IP (privacy by design).',
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
if (segment !== undefined) {
|
|
304
|
+
warnOnce(
|
|
305
|
+
'setUser:segment',
|
|
306
|
+
'Sentry.setUser({ segment }) → mapped to tag `user.segment`. Set via setTag for clarity.',
|
|
307
|
+
)
|
|
308
|
+
if (typeof segment === 'string') nativeSetTag('user.segment', segment)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const linkBy: Record<string, string> = {}
|
|
312
|
+
if (email) linkBy.email = email
|
|
313
|
+
if (username) linkBy.username = username
|
|
314
|
+
|
|
315
|
+
// Surface any other fields the host bolted on (Sentry historically
|
|
316
|
+
// accepted arbitrary keys) — they pass through as tags.
|
|
317
|
+
for (const [k, v] of Object.entries(rest)) {
|
|
318
|
+
if (v !== undefined && v !== null) nativeSetTag(`user.${k}`, String(v))
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
nativeSetUser({
|
|
322
|
+
...(id ? { id } : {}),
|
|
323
|
+
...(Object.keys(linkBy).length > 0 ? { linkBy } : {}),
|
|
324
|
+
})
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// ── setTag / setTags ──────────────────────────────────────────────────────
|
|
328
|
+
|
|
329
|
+
// Re-export Sentori-native semantics; identical signatures.
|
|
330
|
+
export const setTag = nativeSetTag
|
|
331
|
+
export const setTags = nativeSetTags
|
|
332
|
+
|
|
333
|
+
// ── addBreadcrumb ─────────────────────────────────────────────────────────
|
|
334
|
+
|
|
335
|
+
type SentryBreadcrumb = {
|
|
336
|
+
category?: string
|
|
337
|
+
message?: string
|
|
338
|
+
level?: SentryLevelString
|
|
339
|
+
type?: 'default' | 'error' | 'http' | 'info' | 'navigation' | 'query' | 'user' | string
|
|
340
|
+
data?: Record<string, unknown>
|
|
341
|
+
timestamp?: number
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
type SentoriBreadcrumbType = 'custom' | 'log' | 'nav' | 'net' | 'user'
|
|
345
|
+
|
|
346
|
+
function mapCategoryToType(category: string | undefined): SentoriBreadcrumbType | undefined {
|
|
347
|
+
if (!category) return undefined
|
|
348
|
+
if (['auth', 'click', 'gesture', 'input', 'touch', 'ui'].includes(category)) return 'user'
|
|
349
|
+
if (['fetch', 'http', 'xhr'].includes(category)) return 'net'
|
|
350
|
+
if (['nav', 'navigation', 'route'].includes(category)) return 'nav'
|
|
351
|
+
if (['console', 'log', 'sentry'].includes(category)) return 'log'
|
|
352
|
+
return 'custom'
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function mapSentryType(t: string | undefined): SentoriBreadcrumbType | undefined {
|
|
356
|
+
if (!t) return undefined
|
|
357
|
+
switch (t) {
|
|
358
|
+
case 'http':
|
|
359
|
+
return 'net'
|
|
360
|
+
case 'navigation':
|
|
361
|
+
return 'nav'
|
|
362
|
+
case 'user':
|
|
363
|
+
case 'log':
|
|
364
|
+
case 'custom':
|
|
365
|
+
return t
|
|
366
|
+
default:
|
|
367
|
+
return 'custom'
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export function addBreadcrumb(crumb: SentryBreadcrumb): void {
|
|
372
|
+
if (!crumb.message) {
|
|
373
|
+
crumb.message = crumb.category ?? crumb.type ?? '(no message)'
|
|
374
|
+
}
|
|
375
|
+
if (crumb.category && !crumb.type) {
|
|
376
|
+
warnOnce(
|
|
377
|
+
'breadcrumb:category',
|
|
378
|
+
'Sentry.addBreadcrumb({ category }) → mapped to `type` via well-known table; the category string itself is preserved under `data.category`.',
|
|
379
|
+
)
|
|
380
|
+
}
|
|
381
|
+
// RN SDK shape: { type, data }. No top-level `message` —
|
|
382
|
+
// Sentry's message goes into data.message.
|
|
383
|
+
nativeAddBreadcrumb({
|
|
384
|
+
type: mapSentryType(crumb.type) ?? mapCategoryToType(crumb.category) ?? 'custom',
|
|
385
|
+
data: {
|
|
386
|
+
message: crumb.message,
|
|
387
|
+
...(crumb.data ?? {}),
|
|
388
|
+
...(crumb.category ? { category: crumb.category } : {}),
|
|
389
|
+
...(crumb.level ? { level: mapLevel(crumb.level) } : {}),
|
|
390
|
+
},
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// ── flush / close ─────────────────────────────────────────────────────────
|
|
395
|
+
|
|
396
|
+
// Re-export Sentori native flush + close — same signatures.
|
|
397
|
+
export { close, flush } from '../lifecycle'
|
|
398
|
+
|
|
399
|
+
// ── startTransaction / startSpan / withScope ──────────────────────────────
|
|
400
|
+
|
|
401
|
+
// Trace mapping is non-trivial (Sentry's transaction object exposes
|
|
402
|
+
// startChild, etc.). v2.3 ships a minimum-viable Sentry trace
|
|
403
|
+
// surface that supports startTransaction returning a Sentori Span
|
|
404
|
+
// object with a partial Sentry-style API (.startChild, .finish).
|
|
405
|
+
// Anything beyond that throws a clear error directing to the native
|
|
406
|
+
// `sentori.startSpan` / `sentori.withScopedSpan`.
|
|
407
|
+
|
|
408
|
+
import { startSpan } from '@goliapkg/sentori-core'
|
|
409
|
+
|
|
410
|
+
type SentrySpanOpts = {
|
|
411
|
+
op?: string
|
|
412
|
+
name?: string
|
|
413
|
+
description?: string
|
|
414
|
+
tags?: Record<string, string>
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export function startTransaction(opts: SentrySpanOpts): {
|
|
418
|
+
finish: (status?: 'cancelled' | 'error' | 'ok') => void
|
|
419
|
+
setStatus: (status: 'cancelled' | 'error' | 'ok') => void
|
|
420
|
+
setTag: (k: string, v: string) => void
|
|
421
|
+
startChild: (childOpts: SentrySpanOpts) => unknown
|
|
422
|
+
} {
|
|
423
|
+
warnOnce(
|
|
424
|
+
'startTransaction',
|
|
425
|
+
'Sentry.startTransaction() → mapped to sentori.startSpan() with op as name. Native equivalent: sentori.startTrace(name) or sentori.startSpan({ name }).',
|
|
426
|
+
)
|
|
427
|
+
const name = opts.name ?? opts.op ?? 'transaction'
|
|
428
|
+
const span = startSpan(name, {
|
|
429
|
+
parent: null,
|
|
430
|
+
tags: opts.tags,
|
|
431
|
+
})
|
|
432
|
+
return {
|
|
433
|
+
finish: (status) => span.finish({ status: status === 'ok' ? 'ok' : 'error' }),
|
|
434
|
+
setStatus: (status) => { span.setTag('status', status) },
|
|
435
|
+
setTag: (k, v) => { span.setTag(k, v) },
|
|
436
|
+
startChild: (childOpts) => {
|
|
437
|
+
return startSpan(childOpts.name ?? childOpts.op ?? 'child', {
|
|
438
|
+
tags: childOpts.tags,
|
|
439
|
+
})
|
|
440
|
+
},
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// ── withScope / configureScope (no-op scoping; same state as native) ─────
|
|
445
|
+
|
|
446
|
+
type ScopeProxy = {
|
|
447
|
+
setTag: (k: string, v: string) => void
|
|
448
|
+
setTags: (rec: Record<string, string>) => void
|
|
449
|
+
setUser: (u: SentrySetUserInput) => void
|
|
450
|
+
setExtra: (k: string, v: unknown) => void
|
|
451
|
+
setLevel: (l: SentryLevelString) => void
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function scopeProxy(): ScopeProxy {
|
|
455
|
+
return {
|
|
456
|
+
setTag: nativeSetTag,
|
|
457
|
+
setTags: nativeSetTags,
|
|
458
|
+
setUser,
|
|
459
|
+
setExtra: (k, v) => nativeSetTag(`extra.${k}`, String(v)),
|
|
460
|
+
setLevel: () => {
|
|
461
|
+
warnOnce(
|
|
462
|
+
'scope:setLevel',
|
|
463
|
+
'Sentry.withScope(s => s.setLevel(…)) → not supported. Sentori levels travel on capture call, not on scope.',
|
|
464
|
+
)
|
|
465
|
+
},
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export function withScope<T>(fn: (scope: ScopeProxy) => T): T {
|
|
470
|
+
// Sentori has no Hub; tags set inside `fn` persist (best-effort
|
|
471
|
+
// approximation of Sentry semantics). For most callers this is
|
|
472
|
+
// fine; tighter isolation needs an actual Hub which we don't ship.
|
|
473
|
+
warnOnce(
|
|
474
|
+
'withScope',
|
|
475
|
+
'Sentry.withScope() → tag mutations are NOT auto-reverted on scope exit. Use sentori.setTag/clearTags explicitly for tight isolation.',
|
|
476
|
+
)
|
|
477
|
+
return fn(scopeProxy())
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export function configureScope(fn: (scope: ScopeProxy) => void): void {
|
|
481
|
+
fn(scopeProxy())
|
|
482
|
+
}
|
package/src/init.ts
CHANGED
|
@@ -130,6 +130,16 @@ export type InitOptions = {
|
|
|
130
130
|
* via `sentori.captureMessage()`. `null` / absent → keep all. */
|
|
131
131
|
messages?: null | number;
|
|
132
132
|
};
|
|
133
|
+
/** v2.3 — canonical sampling field (renamed from `sampling`).
|
|
134
|
+
* Same shape; if both are passed, `sample` wins. The older
|
|
135
|
+
* `sampling` stays accepted indefinitely as a back-compat alias —
|
|
136
|
+
* this is the kind of rename that's only worth doing if it's
|
|
137
|
+
* also zero-cost for existing callers. */
|
|
138
|
+
sample?: {
|
|
139
|
+
errors?: null | number;
|
|
140
|
+
traces?: null | number;
|
|
141
|
+
messages?: null | number;
|
|
142
|
+
};
|
|
133
143
|
/** v2.3 — Sentori SDK's own console output gate. Default `'warn'`:
|
|
134
144
|
* SDK is silent unless something is genuinely broken (transport
|
|
135
145
|
* sustained failure, native module not found, internal SDK
|
|
@@ -181,9 +191,11 @@ export const init = (options: InitOptions): void => {
|
|
|
181
191
|
ingestUrl: options.ingestUrl ?? DEFAULT_INGEST_URL,
|
|
182
192
|
enabled: true,
|
|
183
193
|
screenshotsEnabled: options.capture?.screenshot === true,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
194
|
+
// v2.3 — `sample` is the canonical name; `sampling` is the
|
|
195
|
+
// back-compat alias. If both are supplied, `sample` wins.
|
|
196
|
+
errorSampleRate: options.sample?.errors ?? options.sampling?.errors ?? null,
|
|
197
|
+
traceSampleRate: options.sample?.traces ?? options.sampling?.traces ?? null,
|
|
198
|
+
messageSampleRate: options.sample?.messages ?? options.sampling?.messages ?? null,
|
|
187
199
|
sessionTrailEnabled: options.capture?.sessionTrail === true,
|
|
188
200
|
});
|
|
189
201
|
|