@datadog/mobile-react-native-code-push 1.5.2 → 1.6.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.
@@ -1,4 +1,5 @@
1
1
  import { SdkVerbosity } from './SdkVerbosity';
2
+ export declare const DATADOG_MESSAGE_PREFIX = "DATADOG:";
2
3
  /**
3
4
  * /!\ DO NOT USE THIS IN YOUR APP /!\\
4
5
  *
@@ -1,5 +1,6 @@
1
1
  export declare const EMPTY_MESSAGE = "Unknown Error";
2
2
  export declare const EMPTY_STACK_TRACE = "";
3
+ export declare const DEFAULT_ERROR_NAME = "Error";
3
4
  export declare const getErrorMessage: (error: any | undefined) => string;
4
5
  /**
5
6
  * Will extract the stack from the error, taking the first key found among:
@@ -10,3 +11,4 @@ export declare const getErrorMessage: (error: any | undefined) => string;
10
11
  * generate a stack from this information.
11
12
  */
12
13
  export declare const getErrorStackTrace: (error: any | undefined) => string;
14
+ export declare const getErrorName: (error: unknown) => string;
@@ -1,12 +1,20 @@
1
- import type { DdLogsType, LogEventMapper } from './types';
1
+ import type { DdLogsType, LogArguments, LogEventMapper, LogWithErrorArguments } from './types';
2
2
  declare class DdLogsWrapper implements DdLogsType {
3
3
  private nativeLogs;
4
4
  private logEventMapper;
5
- debug(message: string, context?: object): Promise<void>;
6
- info(message: string, context?: object): Promise<void>;
7
- warn(message: string, context?: object): Promise<void>;
8
- error(message: string, context?: object): Promise<void>;
5
+ debug(...args: LogArguments | LogWithErrorArguments): Promise<void>;
6
+ info(...args: LogArguments | LogWithErrorArguments): Promise<void>;
7
+ warn(...args: LogArguments | LogWithErrorArguments): Promise<void>;
8
+ error(...args: LogArguments | LogWithErrorArguments): Promise<void>;
9
+ /**
10
+ * Since the InternalLog does not have a verbosity set yet in this case,
11
+ * we use console.warn to warn the user in dev mode.
12
+ */
13
+ private printLogDroppedSdkNotInitialized;
14
+ private printlogDroppedByMapper;
15
+ private printLogTracked;
9
16
  private log;
17
+ private logWithError;
10
18
  registerLogEventMapper(logEventMapper: LogEventMapper): void;
11
19
  unregisterLogEventMapper(): void;
12
20
  }
@@ -1,11 +1,11 @@
1
1
  import type { Attributes } from '../sdk/AttributesSingleton/types';
2
2
  import { EventMapper } from '../sdk/EventMappers/EventMapper';
3
3
  import type { UserInfo } from '../sdk/UserInfoSingleton/types';
4
- import type { LogEvent, LogEventMapper, NativeLog, RawLog } from './types';
5
- export declare const formatLogEventToNativeLog: (logEvent: LogEvent) => NativeLog;
6
- export declare const formatRawLogToNativeEvent: (rawLog: RawLog) => NativeLog;
7
- export declare const formatRawLogToLogEvent: (rawLog: RawLog, additionalInformation: {
4
+ import type { LogEvent, LogEventMapper, NativeLog, NativeLogWithError, RawLog, RawLogWithError } from './types';
5
+ export declare const formatLogEventToNativeLog: (logEvent: LogEvent) => NativeLog | NativeLogWithError;
6
+ export declare const formatRawLogToNativeEvent: (rawLog: RawLog | RawLogWithError) => NativeLog | NativeLogWithError;
7
+ export declare const formatRawLogToLogEvent: (rawLog: RawLog | RawLogWithError, additionalInformation: {
8
8
  userInfo: UserInfo;
9
9
  attributes: Attributes;
10
10
  }) => LogEvent;
11
- export declare const generateEventMapper: (logEventMapper: LogEventMapper | undefined) => EventMapper<RawLog, LogEvent, NativeLog>;
11
+ export declare const generateEventMapper: (logEventMapper: LogEventMapper | undefined) => EventMapper<RawLog | RawLogWithError, LogEvent, NativeLog | NativeLogWithError>;
@@ -4,29 +4,29 @@ import type { UserInfo } from '../sdk/UserInfoSingleton/types';
4
4
  */
5
5
  export declare type DdLogsType = {
6
6
  /**
7
- * Send a log with level debug.
7
+ * Send a log with debug level.
8
8
  * @param message: The message to send.
9
9
  * @param context: The additional context to send.
10
10
  */
11
- debug(message: string, context?: object): Promise<void>;
11
+ debug(...args: LogArguments | LogWithErrorArguments): Promise<void>;
12
12
  /**
13
- * Send a log with level info.
13
+ * Send a log with info level.
14
14
  * @param message: The message to send.
15
15
  * @param context: The additional context to send.
16
16
  */
17
- info(message: string, context?: object): Promise<void>;
17
+ info(...args: LogArguments | LogWithErrorArguments): Promise<void>;
18
18
  /**
19
- * Send a log with level warn.
19
+ * Send a log with warn level.
20
20
  * @param message: The message to send.
21
21
  * @param context: The additional context to send.
22
22
  */
23
- warn(message: string, context?: object): Promise<void>;
23
+ warn(...args: LogArguments | LogWithErrorArguments): Promise<void>;
24
24
  /**
25
- * Send a log with level error.
25
+ * Send a log with error level.
26
26
  * @param message: The message to send.
27
27
  * @param context: The additional context to send.
28
28
  */
29
- error(message: string, context?: object): Promise<void>;
29
+ error(...args: LogArguments | LogWithErrorArguments): Promise<void>;
30
30
  };
31
31
  /**
32
32
  * Log input from developers
@@ -36,6 +36,14 @@ export declare type RawLog = {
36
36
  context: object;
37
37
  status: LogStatus;
38
38
  };
39
+ export declare type RawLogWithError = {
40
+ message: string;
41
+ errorKind: string;
42
+ errorMessage: string;
43
+ stacktrace: string;
44
+ context: object;
45
+ status: LogStatus;
46
+ };
39
47
  /**
40
48
  * Log input for native SDKs
41
49
  */
@@ -43,12 +51,30 @@ export declare type NativeLog = {
43
51
  message: string;
44
52
  context: object;
45
53
  };
54
+ export declare type NativeLogWithError = {
55
+ message: string;
56
+ errorKind: string;
57
+ errorMessage: string;
58
+ stacktrace: string;
59
+ context: object;
60
+ };
46
61
  export declare type LogStatus = 'debug' | 'info' | 'warn' | 'error';
47
62
  export declare type LogEvent = {
48
63
  message: string;
49
64
  context: object;
65
+ errorKind?: string;
66
+ errorMessage?: string;
67
+ stacktrace?: string;
50
68
  readonly status: LogStatus;
51
69
  readonly userInfo: UserInfo;
52
70
  readonly attributes?: object;
53
71
  };
54
72
  export declare type LogEventMapper = (logEvent: LogEvent) => LogEvent | null;
73
+ export declare type LogArguments = [message: string, context?: object];
74
+ export declare type LogWithErrorArguments = [
75
+ message: string,
76
+ errorKind?: string,
77
+ errorMessage?: string,
78
+ stacktrace?: string,
79
+ context?: object
80
+ ];
@@ -59,29 +59,65 @@ export declare type DdNativeSdkType = {
59
59
  */
60
60
  export declare type DdNativeLogsType = {
61
61
  /**
62
- * Send a log with level debug.
62
+ * Send a log with DEBUG level.
63
63
  * @param message: The message to send.
64
64
  * @param context: The additional context to send.
65
65
  */
66
66
  debug(message: string, context?: object): Promise<void>;
67
67
  /**
68
- * Send a log with level info.
68
+ * Send a log with INFO level.
69
69
  * @param message: The message to send.
70
70
  * @param context: The additional context to send.
71
71
  */
72
72
  info(message: string, context?: object): Promise<void>;
73
73
  /**
74
- * Send a log with level warn.
74
+ * Send a log with WARN level.
75
75
  * @param message: The message to send.
76
76
  * @param context: The additional context to send.
77
77
  */
78
78
  warn(message: string, context?: object): Promise<void>;
79
79
  /**
80
- * Send a log with level error.
80
+ * Send a log with ERROR level.
81
81
  * @param message: The message to send.
82
82
  * @param context: The additional context to send.
83
83
  */
84
84
  error(message: string, context?: object): Promise<void>;
85
+ /**
86
+ * Send a log containing an error with DEBUG level.
87
+ * @param message: The message to send.
88
+ * @param errorKind: The error kind to send.
89
+ * @param errorMessage: The error message to send.
90
+ * @param stacktrace: The stack trace to send.
91
+ * @param context: The additional context to send.
92
+ */
93
+ debugWithError(message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: object): Promise<void>;
94
+ /**
95
+ * Send a log containing an error with INDO level.
96
+ * @param message: The message to send.
97
+ * @param errorKind: The error kind to send.
98
+ * @param errorMessage: The error message to send.
99
+ * @param stacktrace: The stack trace to send.
100
+ * @param context: The additional context to send.
101
+ */
102
+ infoWithError(message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: object): Promise<void>;
103
+ /**
104
+ * Send a log containing an error with WARN level.
105
+ * @param message: The message to send.
106
+ * @param errorKind: The error kind to send.
107
+ * @param errorMessage: The error message to send.
108
+ * @param stacktrace: The stack trace to send.
109
+ * @param context: The additional context to send.
110
+ */
111
+ warnWithError(message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: object): Promise<void>;
112
+ /**
113
+ * Send a log containing an error with ERROR level.
114
+ * @param message: The message to send.
115
+ * @param errorKind: The error kind to send.
116
+ * @param errorMessage: The error message to send.
117
+ * @param stacktrace: The stack trace to send.
118
+ * @param context: The additional context to send.
119
+ */
120
+ errorWithError(message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: object): Promise<void>;
85
121
  };
86
122
  /**
87
123
  * The entry point to use Datadog's Trace feature.
@@ -178,6 +214,10 @@ export declare type DdNativeRumType = {
178
214
  * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
179
215
  */
180
216
  addTiming(name: string): Promise<void>;
217
+ /**
218
+ * Stops the current RUM Session.
219
+ */
220
+ stopSession(): Promise<void>;
181
221
  };
182
222
  declare type ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';
183
223
  declare type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
@@ -25,6 +25,7 @@ declare class DdRumWrapper implements DdRumType {
25
25
  stopResource(key: string, statusCode: number, kind: ResourceKind, size?: number, context?: object, timestampMs?: number, resourceContext?: XMLHttpRequest): Promise<void>;
26
26
  addError(message: string, source: ErrorSource, stacktrace: string, context?: object, timestampMs?: number): Promise<void>;
27
27
  addTiming(name: string): Promise<void>;
28
+ stopSession(): Promise<void>;
28
29
  registerErrorEventMapper(errorEventMapper: ErrorEventMapper): void;
29
30
  unregisterErrorEventMapper(): void;
30
31
  registerResourceEventMapper(resourceEventMapper: ResourceEventMapper): void;
@@ -10,6 +10,7 @@ export declare class DdRumErrorTracking {
10
10
  * Starts tracking errors and sends a RUM Error event every time an error is detected.
11
11
  */
12
12
  static startTracking(): void;
13
- static onGlobalError(error: any, isFatal?: boolean): void;
14
- static onConsoleError(...params: unknown[]): void;
13
+ static onGlobalError: (error: any, isFatal?: boolean) => void;
14
+ static onConsoleError: (...params: unknown[]) => void;
15
+ private static reportError;
15
16
  }
@@ -1,7 +1,7 @@
1
1
  import type EventsInterceptor from './EventsInterceptor';
2
2
  export declare const UNKNOWN_TARGET_NAME = "unknown_target";
3
3
  export declare class DdEventsInterceptor implements EventsInterceptor {
4
- static ACTION_EVENT_DROPPED_WARN_MESSAGE: string;
4
+ static ACTION_EVENT_DROPPED_DEBUG_MESSAGE: string;
5
5
  private debouncingStartedTimestamp;
6
6
  interceptOnPress(...args: any[]): void;
7
7
  private handleTargetEvent;
@@ -1,4 +1,7 @@
1
1
  /**
2
- * Does a shallow comparison between 2 objects
2
+ * Does a shallow comparison between 2 objects.
3
+ *
4
+ * In some rare cases, one of the objects can be `undefined` or `null`.
5
+ * This is documented in https://github.com/DataDog/dd-sdk-reactnative/issues/419.
3
6
  */
4
- export declare const areObjectShallowEqual: (objectA: Record<string, unknown>, objectB: Record<string, unknown>) => boolean;
7
+ export declare const areObjectShallowEqual: (objectA: Record<string, unknown> | undefined | null, objectB: Record<string, unknown> | undefined | null) => boolean;
@@ -84,6 +84,10 @@ export declare type DdRumType = {
84
84
  * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
85
85
  */
86
86
  addTiming(name: string): Promise<void>;
87
+ /**
88
+ * Stops the current RUM Session.
89
+ */
90
+ stopSession(): Promise<void>;
87
91
  };
88
92
  /**
89
93
  * Describe the type of a RUM Action.
@@ -20,12 +20,16 @@ export declare class DdSdkConfiguration {
20
20
  trackErrors: boolean;
21
21
  trackInteractions: boolean;
22
22
  trackNetworkRequests: boolean;
23
+ reactVersion: string;
24
+ reactNativeVersion: string;
23
25
  };
24
26
  constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, nativeLongTaskThresholdMs: number, longTaskThresholdMs: number, sampleRate: number, site: string, trackingConsent: string, additionalConfig: object, telemetrySampleRate: number, vitalsUpdateFrequency: string, trackFrustrations: boolean, configurationForTelemetry: {
25
27
  initializationType: string;
26
28
  trackErrors: boolean;
27
29
  trackInteractions: boolean;
28
30
  trackNetworkRequests: boolean;
31
+ reactVersion: string;
32
+ reactNativeVersion: string;
29
33
  });
30
34
  }
31
35
  /**
@@ -1 +1 @@
1
- export declare const version = "1.5.2";
1
+ export declare const version = "1.6.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native-code-push",
3
- "version": "1.5.2",
3
+ "version": "1.6.0",
4
4
  "description": "A client-side React Native module to interact with Appcenter Codepush and Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -38,7 +38,7 @@
38
38
  "prepare": "rm -rf lib && yarn bob build"
39
39
  },
40
40
  "devDependencies": {
41
- "@datadog/mobile-react-native": "^1.5.2",
41
+ "@datadog/mobile-react-native": "^1.6.0",
42
42
  "@testing-library/react-native": "7.0.2",
43
43
  "react-native-code-push": "7.0.5"
44
44
  },
@@ -72,5 +72,5 @@
72
72
  ]
73
73
  ]
74
74
  },
75
- "gitHead": "2987dffcc3f438771e7a33fab8d4609a17070a78"
75
+ "gitHead": "b95779b45f4917992f898f426a6640472b77cc3d"
76
76
  }