Skip to content

Commit

Permalink
StackTracing declarations added
Browse files Browse the repository at this point in the history
  • Loading branch information
RNEvok committed Jun 8, 2024
1 parent ca4feb1 commit 02d912c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class Connector {
if (this._socket?.connected) {
const timestamp = moment().valueOf();
const actionId = this._currentInterceptedReduxActionId++;
const _stackTraceData = this._getStackTraceFn ? (await this._getStackTraceFn(new Error(''))) : undefined;
const _stackTraceData = await this._getStackTraceFn?.(new Error(''));
const reduxActionData = {actionId: `RA_${actionId}`, action, timestamp, _stackTraceData};
jsonStringifyKeepMeta(reduxActionData).ok && this._currentReduxActionsBatch.push(reduxActionData);

Expand Down Expand Up @@ -415,7 +415,7 @@ class Connector {
if (this._socket?.connected) {
const timestamp = moment().valueOf();
const storageActionId = this._currentInterceptedStorageActionId++;
const _stackTraceData = this._getStackTraceFn ? (await this._getStackTraceFn(new Error(''))) : undefined;
const _stackTraceData = await this._getStackTraceFn?.(new Error(''));
const storageActionData = {storageActionId: `SA_${storageActionId}`, action, data, timestamp, _stackTraceData};
jsonStringifyKeepMeta(storageActionData).ok && this._currentStorageActionsBatch.push(storageActionData);

Expand Down Expand Up @@ -453,7 +453,7 @@ class Connector {
const timestamp = moment().valueOf();
const capturedEventId = this._currentCapturedEventId++;

const _stackTraceData = this._getStackTraceFn ? (await this._getStackTraceFn(new Error(''))) : undefined;
const _stackTraceData = await this._getStackTraceFn?.(new Error(''));

const encryptedData = this._encryptData({timestamp, capturedEventId: `UCE_${capturedEventId}`, title, data, _stackTraceData});
encryptedData.ok && this._socket?.emit(SOCKET_EVENTS_EMIT.CAPTURE_EVENT, encryptedData.result);
Expand Down Expand Up @@ -540,7 +540,7 @@ class Connector {
if (this._socket?.connected) {
const timestamp = moment().valueOf();
const tanStackQueryEventId = this._currentInterceptedTanStackQueryEventId++;
// const _stackTraceData = this._getStackTraceFn ? (await this._getStackTraceFn(new Error(''))) : undefined;
// const _stackTraceData = await this._getStackTraceFn?.(new Error(''));
const tanStackQueryEventData: T.InterceptedTanStackQueryEventPreparedData = {tanStackQueryEventId: `TQE_${tanStackQueryEventId}`, event, timestamp};
jsonStringifyKeepMeta(tanStackQueryEventData).ok && this._currentTanStackQueryEventsBatch.push(tanStackQueryEventData);

Expand Down
46 changes: 46 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,50 @@ declare module '@appklaar/codebud/rn' {

declare module '@appklaar/codebud/encryption' {
export class EncryptionPlugin {}
}

declare module '@appklaar/codebud/StackTracing/getStackTraceStackTracey' {
export type StackTraceCallData = {
sourceLine?: string;
beforeParse: string;
callee: string;
calleeShort?: string;
native: boolean;
file?: string;
fileRelative?: string;
fileShort?: string;
fileName?: string;
line?: number;
};

export type StackTraceData = {
stack?: StackTraceCallData[];
};

export type GetStackTraceFunction = (errorOrStack: Error | string | undefined) => Promise<StackTraceData>;

export const getStackTraceStackTracey: GetStackTraceFunction;
}

declare module '@appklaar/codebud/StackTracing/getStackTraceSimple' {
export type StackTraceCallData = {
sourceLine?: string;
beforeParse: string;
callee: string;
calleeShort?: string;
native: boolean;
file?: string;
fileRelative?: string;
fileShort?: string;
fileName?: string;
line?: number;
};

export type StackTraceData = {
stack?: StackTraceCallData[];
};

export type GetStackTraceFunction = (errorOrStack: Error | string | undefined) => Promise<StackTraceData>;

export const getStackTraceSimple: GetStackTraceFunction;
}

0 comments on commit 02d912c

Please sign in to comment.