Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import Client from './core/Client';
import ErrorPlugin from './plugins/ErrorPlugin';
import PerformancePlugin from './plugins/PerformancePlugin';
import NetworkPlugin from './plugins/NetworkPlugin';
import BehaviorPlugin from './plugins/BehaviorPlugin';
import OfflinePlugin from './plugins/OfflinePlugin';
import SamplingPlugin from './plugins/SamplingPlugin';
import RouterPlugin from './plugins/RouterPlugin';
import InteractionPlugin from './plugins/InteractionPlugin';
import { Span as SpanClass, Transaction as TransactionClass, httpStatusToSpanStatus, dbStatusToSpanStatus, statusToSpanStatus } from './utils/tracing';
import { serializeBaggage, parseBaggage, createBaggageFromTransaction } from './utils/baggage';
import type { LightConfig, LightClient, SentryEvent, EventLevel, UserInfo, Breadcrumb, LightPlugin, ErrorEvent, PerformanceEvent, NetworkEvent, BehaviorEvent, DSNInfo, TransactionContext, SpanContext, Transaction, Span, SamplingContext, BaggageFields, SpanStatus } from './types';
import { logDebug, setDebug } from './utils/logger';
import { setAnonymousId as setStoredAnonymousId, clearAnonymousId as clearStoredAnonymousId, getAnonymousId as getStoredAnonymousId } from './utils/identity';
let globalClient: LightClient | null = null;
function init(config: LightConfig): LightClient {
setDebug(config.debug === true);
logDebug('Index', 'init called', { dsn: config.dsn, debug: config.debug });
const client = new Client(config);
const defaultPlugins: LightPlugin[] = [
new OfflinePlugin(),
new SamplingPlugin(),
new ErrorPlugin(),
];
const pluginNames = config.plugins?.filter(p => typeof p === 'string') as string[] || [];
if (pluginNames.includes('performance') || pluginNames.includes('all')) {
defaultPlugins.push(new PerformancePlugin());
}
if (pluginNames.includes('network') || pluginNames.includes('all')) {
defaultPlugins.push(new NetworkPlugin());
}
if (pluginNames.includes('behavior') || pluginNames.includes('all')) {
defaultPlugins.push(new BehaviorPlugin());
}
if (pluginNames.includes('router') || pluginNames.includes('all')) {
defaultPlugins.push(new RouterPlugin());
}
if (pluginNames.includes('interaction') || pluginNames.includes('all')) {
defaultPlugins.push(new InteractionPlugin());
}
logDebug('Index', 'Registering plugins', { count: defaultPlugins.length, plugins: defaultPlugins.map(p => p.name) });
for (const plugin of defaultPlugins) {
client.use(plugin);
}
if (config.plugins) {
for (const plugin of config.plugins) {
if (typeof plugin === 'object' && plugin !== null && 'name' in plugin && 'setup' in plugin) {
client.use(plugin as LightPlugin);
}
}
}
client.init();
globalClient = client;
logDebug('Index', 'init completed, globalClient set');
return client;
}
function getClient(): LightClient | null {
return globalClient;
}
function captureException(error: Error | unknown): void {
logDebug('Index', 'captureException called', { hasClient: !!globalClient });
if (!globalClient) {
console.warn('[LightSDK] SDK not initialized. Call LightSentry.init() first.');
return;
}
globalClient.captureException(error);
}
function captureMessage(message: string, level?: EventLevel): void {
logDebug('Index', 'captureMessage called', { hasClient: !!globalClient });
if (!globalClient) {
console.warn('[LightSDK] SDK not initialized. Call LightSentry.init() first.');
return;
}
globalClient.captureMessage(message, level);
}
function captureEvent(event: Partial<SentryEvent> & { type: string }): void {
logDebug('Index', 'captureEvent called', { hasClient: !!globalClient });
if (!globalClient) {
console.warn('[LightSDK] SDK not initialized. Call LightSentry.init() first.');
return;
}
globalClient.captureEvent(event);
}
function setUser(user: UserInfo | null): void {
globalClient?.setUser(user);
}
function setAnonymousId(id: string): void {
setStoredAnonymousId(id);
}
function clearAnonymousId(): void {
clearStoredAnonymousId();
}
function getAnonymousId(): string | null {
return getStoredAnonymousId();
}
function startTransaction(context: TransactionContext): Transaction | null {
return globalClient?.startTransaction(context) || null;
}
function getCurrentTransaction(): Transaction | null {
return globalClient?.getCurrentTransaction() || null;
}
function getCurrentSpan(): Span | null {
return globalClient?.getCurrentSpan() || null;
}
function setSpan(span: Span | null): void {
globalClient?.setSpan(span);
}
function startSpan(context: SpanContext): Span | null {
return globalClient?.startSpan(context) || null;
}
function setTag(key: string, value: string): void {
globalClient?.setTag(key, value);
}
function setTags(tags: Record<string, string>): void {
globalClient?.setTags(tags);
}
function setExtra(key: string, value: unknown): void {
globalClient?.setExtra(key, value);
}
function addBreadcrumb(breadcrumb: Omit<Breadcrumb, 'timestamp'>): void {
globalClient?.addBreadcrumb(breadcrumb);
}
async function flush(): Promise<void> {
await globalClient?.flush();
}
function disable(): void {
globalClient?.disable();
}
function enable(): void {
globalClient?.enable();
}
export {
init,
getClient,
captureException,
captureMessage,
captureEvent,
setUser,
setAnonymousId,
clearAnonymousId,
getAnonymousId,
startTransaction,
getCurrentTransaction,
getCurrentSpan,
setSpan,
startSpan,
setTag,
setTags,
setExtra,
addBreadcrumb,
flush,
disable,
enable,
Client,
httpStatusToSpanStatus,
dbStatusToSpanStatus,
statusToSpanStatus,
serializeBaggage,
parseBaggage,
createBaggageFromTransaction,
ErrorPlugin,
PerformancePlugin,
NetworkPlugin,
BehaviorPlugin,
OfflinePlugin,
SamplingPlugin,
RouterPlugin,
InteractionPlugin,
};
export { SpanClass as Span, TransactionClass as Transaction };
export type {
LightConfig,
LightClient,
LightPlugin,
SentryEvent,
ErrorEvent,
PerformanceEvent,
NetworkEvent,
BehaviorEvent,
EventLevel,
UserInfo,
Breadcrumb,
DSNInfo,
TransactionContext,
SpanContext,
SamplingContext,
BaggageFields,
SpanStatus,
SpanJSON,
TransactionJSON,
};
export default {
init,
getClient,
captureException,
captureMessage,
captureEvent,
setUser,
setAnonymousId,
clearAnonymousId,
getAnonymousId,
startTransaction,
getCurrentTransaction,
getCurrentSpan,
setSpan,
startSpan,
setTag,
setTags,
setExtra,
addBreadcrumb,
flush,
disable,
enable,
Span: SpanClass,
Transaction: TransactionClass,
httpStatusToSpanStatus,
};
|