1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-08 14:15:14 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

feat: add logger

This commit is contained in:
sunnylqm
2024-02-24 11:36:58 +08:00
parent 4f9e1495c8
commit f01716bcb2
2 changed files with 51 additions and 52 deletions

View File

@@ -1,5 +1,4 @@
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
import { EventType, UpdateEventsLogger } from './type';
import { log } from './utils';
const {
version: v,
@@ -58,44 +57,6 @@ if (!uuid) {
PushyModule.setUuid(uuid);
}
const noop = () => {};
let reporter: UpdateEventsLogger = noop;
export function onPushyEvents(customReporter: UpdateEventsLogger) {
reporter = customReporter;
if (isRolledBack) {
report({
type: 'rollback',
data: {
rolledBackVersion,
},
});
}
}
export function report({
type,
message = '',
data = {},
}: {
type: EventType;
message?: string;
data?: Record<string, string | number>;
}) {
log(type + ' ' + message);
reporter({
type,
data: {
currentVersion,
cInfo,
packageVersion,
buildTime,
message,
...data,
},
});
}
log('uuid: ' + uuid);
export const cInfo = {