@applicaster/zapp-react-native-utils
Version:
Applicaster Zapp React Native utilities package
93 lines (73 loc) • 1.98 kB
text/typescript
enum XRayLogLevel {
verbose = 0,
debug = 1,
info = 2,
warning = 3,
warn = 3,
error = 4,
off = 100,
}
const wrapInObject = (_ctx: unknown, _key: string) => {};
const applyConditions = (_fn: unknown) => {};
/**
* This is the mocked version of XRayLogger
* It was created as a part of our dynamically imported usage of Xray
* Otherwise we would have to add optional conditions to every use of xray
* This may not be the solution we are looking for
* */
export default class XRayLogger {
private category: string;
private subsystem: string;
private context: {};
private parent: XRayLogger;
static mock: boolean = true;
static logLevels = XRayLogLevel;
constructor(category: string, subsystem: string, parent?: XRayLogger) {
this.category = category;
this.subsystem = subsystem;
this.context = {};
this.parent = parent || null;
this.addContext({});
this.addSubsystem = this.addSubsystem.bind(this);
}
addSubsystem = (subsystem: string): XRayLogger => {
// @ts-ignore
return new XRayLogger(
this.category,
`${this.subsystem}/${subsystem}`,
this
);
};
log = (_event) => {};
debug = (_event) => {};
info = (_event) => {};
warning = (_event) => {};
warn = (_event) => {
this.warning(event);
};
error = (_event) => {};
sendEvent = (_event, _eventData) => {};
// To be used by QuickBrick Hook events
sendAudienceEvent = (event, eventData = null) => {
this.sendEvent(event, eventData);
};
getContext = () => {
return Object.assign({}, this.parent?.getContext() || {}, this.context);
};
addContext = (context): this => {
try {
const newContext = Object.assign(
{},
this.getContext(),
applyConditions(wrapInObject(context, "context"))
);
this.context = newContext;
} catch (e) {
// Failed to add context
}
return this;
};
createEvent = () => {
return () => {};
};
}