@dynatrace/react-native-plugin 2.323.1 → 2.325.1

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.
Files changed (45) hide show
  1. package/README.md +33 -9
  2. package/android/build.gradle +3 -3
  3. package/files/plugin-runtime.gradle +8 -1
  4. package/files/plugin.gradle +1 -1
  5. package/index.js +18 -10
  6. package/instrumentation/DynatraceInstrumentation.js +1 -1
  7. package/instrumentation/jsx/CreateElement.js +10 -7
  8. package/instrumentation/jsx/ElementHelper.js +0 -5
  9. package/instrumentation/libs/react-native/Switch.js +55 -12
  10. package/instrumentation/libs/withOnPressMonitoring.js +1 -1
  11. package/instrumentation/model/Types.js +0 -1
  12. package/internal.js +7 -0
  13. package/lib/core/Dynatrace.js +4 -1
  14. package/lib/core/DynatraceAction.js +3 -2
  15. package/lib/core/DynatraceWebRequestTiming.js +5 -5
  16. package/lib/core/ErrorHandler.js +18 -34
  17. package/lib/core/NullWebRequestTiming.js +1 -0
  18. package/lib/core/configuration/Configuration.js +2 -2
  19. package/lib/core/configuration/ConfigurationBuilder.js +3 -2
  20. package/lib/core/configuration/ManualStartupConfiguration.js +6 -3
  21. package/lib/core/interface/IWebRequestTiming.js +1 -0
  22. package/lib/core/logging/LogLevel.js +1 -10
  23. package/lib/core/logging/LogLevelUtil.js +13 -0
  24. package/lib/next/Dynatrace.js +29 -19
  25. package/lib/next/appstart/AppStartObserver.js +1 -1
  26. package/lib/next/events/EventCreator.js +2 -1
  27. package/lib/next/events/EventPipeline.js +14 -6
  28. package/lib/next/events/HttpRequestEventBuilder.js +196 -0
  29. package/lib/next/events/IHttpRequestEventBuilder.js +2 -0
  30. package/lib/next/events/ViewInfoCreator.js +1 -1
  31. package/lib/next/events/modifier/BaseDataEventModifier.js +6 -0
  32. package/lib/next/events/modifier/EventModifierUtil.js +34 -1
  33. package/lib/next/events/modifier/ModifyEventValidation.js +18 -5
  34. package/lib/next/events/modifier/SendEventValidation.js +23 -10
  35. package/lib/next/events/spec/EventSpecContstants.js +2 -1
  36. package/package.json +12 -6
  37. package/public.js +22 -0
  38. package/react-augmentation.js +3 -0
  39. package/react-native-dynatrace.podspec +1 -1
  40. package/scripts/core/LineOffsetAnalyzeCall.js +3 -3
  41. package/types.d.ts +1969 -0
  42. package/instrumentation/jsx/components/Switch.js +0 -57
  43. package/instrumentation/model/TypesUtil.js +0 -21
  44. package/src/instrumentation/jsx/IDynatraceProperties.ts +0 -15
  45. package/typings/react-native-dynatrace.d.ts +0 -1729
package/types.d.ts ADDED
@@ -0,0 +1,1969 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Platform enum for targeting specific mobile platforms.
4
+ * Use this when you want platform-specific behavior, ensuring commands are only sent to Android or iOS.
5
+ */
6
+ declare enum Platform {
7
+ /**
8
+ * Restricts the command to the Android platform only.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { Dynatrace, Platform } from '@dynatrace/react-native-plugin';
13
+ *
14
+ * // This action will only be tracked on Android devices
15
+ * const myAction = Dynatrace.enterAutoAction('MyButton tapped', Platform.Android);
16
+ * // Perform the action and whatever else is needed
17
+ * myAction.leaveAction();
18
+ * ```
19
+ */
20
+ Android,
21
+ /**
22
+ * Restricts the command to the iOS platform only.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { Dynatrace, Platform } from '@dynatrace/react-native-plugin';
27
+ *
28
+ * // This action will only be tracked on iOS devices
29
+ * const myAction = Dynatrace.enterAutoAction('MyButton tapped', Platform.Ios);
30
+ * // Perform the action and whatever else is needed
31
+ * myAction.leaveAction();
32
+ * ```
33
+ */
34
+ Ios
35
+ }
36
+
37
+ /**
38
+ * Enum representing different data collection and privacy levels. Each level determines
39
+ * the amount of monitoring data collected and sent by the Dynatrace agent.
40
+ *
41
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
42
+ * @see https://docs.dynatrace.com/docs/platform-modules/digital-experience/mobile-applications/additional-configuration/configure-rum-privacy-mobile#data-collection-levels
43
+ */
44
+ declare enum DataCollectionLevel {
45
+ /**
46
+ * No monitoring data is sent to Dynatrace.
47
+ *
48
+ * **Characteristics:**
49
+ * - No personal data is sent
50
+ * - All identifiers are randomized on every app launch
51
+ * - A single "Loading <App>" event is sent to track the number of users who opted out
52
+ *
53
+ * Use this level when users have not consented to any data collection.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
58
+ *
59
+ * const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Off, false);
60
+ * Dynatrace.applyUserPrivacyOptions(privacyConfig);
61
+ * ```
62
+ *
63
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
64
+ * @see https://docs.dynatrace.com/docs/platform-modules/digital-experience/mobile-applications/additional-configuration/configure-rum-privacy-mobile#data-collection-levels
65
+ */
66
+ Off,
67
+ /**
68
+ * Only performance and automatically captured data is sent to Dynatrace.
69
+ *
70
+ * **Characteristics:**
71
+ * - No personal data is sent
72
+ * - All identifiers are randomized on every app launch
73
+ * - Performance metrics and crash data are collected
74
+ * - User-specific data and custom events are not tracked
75
+ *
76
+ * Use this level when users consent to performance monitoring but not personal data collection.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
81
+ *
82
+ * const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Performance, true);
83
+ * Dynatrace.applyUserPrivacyOptions(privacyConfig);
84
+ * ```
85
+ *
86
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
87
+ * @see https://docs.dynatrace.com/docs/platform-modules/digital-experience/mobile-applications/additional-configuration/configure-rum-privacy-mobile#data-collection-levels
88
+ */
89
+ Performance,
90
+ /**
91
+ * @deprecated Replaced by `DataCollectionLevel.UserBehavior`
92
+ */
93
+ User,
94
+ /**
95
+ * Both performance data and user behavior data are sent to Dynatrace.
96
+ *
97
+ * **Characteristics:**
98
+ * - Personal data may be sent (depending on configuration)
99
+ * - OneAgent recognizes and tracks returning users across sessions
100
+ * - User tagging, custom events, and custom values are enabled
101
+ * - Full monitoring capabilities are available
102
+ *
103
+ * **Note:** If you haven't configured user tagging or custom event/value reporting,
104
+ * this level functions similarly to the Performance level.
105
+ *
106
+ * Use this level when users have consented to full monitoring and analytics.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
111
+ *
112
+ * const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true);
113
+ * Dynatrace.applyUserPrivacyOptions(privacyConfig);
114
+ * ```
115
+ *
116
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
117
+ * @see https://docs.dynatrace.com/docs/platform-modules/digital-experience/mobile-applications/additional-configuration/configure-rum-privacy-mobile#data-collection-levels
118
+ */
119
+ UserBehavior
120
+ }
121
+
122
+ /**
123
+ * Represents user privacy settings for data collection and crash reporting.
124
+ * Use this class to configure privacy options and apply them via `Dynatrace.applyUserPrivacyOptions(userPrivacyOptions)`.
125
+ */
126
+ declare class UserPrivacyOptions {
127
+ private _dataCollectionLevel;
128
+ private _crashReportingOptedIn;
129
+ /**
130
+ * Creates a new UserPrivacyOptions instance with the specified privacy settings.
131
+ *
132
+ * @param {DataCollectionLevel} dataCollectionLevel The level of data collection to allow
133
+ * @param {boolean} crashReportingOptedIn Whether crash reporting should be enabled
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
138
+ *
139
+ * // Create privacy options with no data collection
140
+ * const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Off, false);
141
+ * Dynatrace.applyUserPrivacyOptions(privacyConfig);
142
+ *
143
+ * // Create privacy options with full monitoring
144
+ * const fullPrivacyConfig = new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true);
145
+ * Dynatrace.applyUserPrivacyOptions(fullPrivacyConfig);
146
+ * ```
147
+ *
148
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
149
+ */
150
+ constructor(dataCollectionLevel: DataCollectionLevel, crashReportingOptedIn: boolean);
151
+ /**
152
+ * Gets the current data collection level.
153
+ *
154
+ * @returns {DataCollectionLevel} The configured data collection level
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * import { DataCollectionLevel, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
159
+ *
160
+ * const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Performance, false);
161
+ * const level = privacyConfig.dataCollectionLevel;
162
+ * console.log(level); // DataCollectionLevel.Performance
163
+ * ```
164
+ *
165
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
166
+ */
167
+ get dataCollectionLevel(): DataCollectionLevel;
168
+ /**
169
+ * Returns the opt-in value for crash reporting.
170
+ *
171
+ * @return {boolean} the opt-in value for crash reporting
172
+ *
173
+ * Usage:
174
+ *
175
+ * ```ts
176
+ * import { DataCollectionLevel, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
177
+ *
178
+ * const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Off, false);
179
+ * const crashReporting = privacyConfig.crashReportingOptedIn;
180
+ * ```
181
+ *
182
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
183
+ */
184
+ get crashReportingOptedIn(): boolean;
185
+ /**
186
+ * Sets the crash reporting opt-in preference.
187
+ *
188
+ * @param {boolean} crashReportingOptedIn Set to `true` to enable crash reporting, `false` to disable it
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
193
+ *
194
+ * const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Performance, false);
195
+ * privacyConfig.crashReportingOptedIn = true; // Enable crash reporting
196
+ * Dynatrace.applyUserPrivacyOptions(privacyConfig);
197
+ * ```
198
+ *
199
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
200
+ */
201
+ set crashReportingOptedIn(crashReportingOptedIn: boolean);
202
+ /**
203
+ * Sets the data collection level.
204
+ *
205
+ * @param {DataCollectionLevel} dataCollectionLevel The data collection level to apply
206
+ *
207
+ * @example
208
+ * ```ts
209
+ * import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
210
+ *
211
+ * const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Off, false);
212
+ * privacyConfig.dataCollectionLevel = DataCollectionLevel.Performance; // Change to Performance level
213
+ * Dynatrace.applyUserPrivacyOptions(privacyConfig);
214
+ * ```
215
+ *
216
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
217
+ */
218
+ set dataCollectionLevel(dataCollectionLevel: DataCollectionLevel);
219
+ }
220
+
221
+ /**
222
+ * Interface for Action
223
+ */
224
+ interface IDynatraceAction {
225
+ /**
226
+ * Reports an error event with an error code. The key-value pair is marked as an error type.
227
+ *
228
+ * **Note:** The error will not be reported if the action is already closed or if the errorName
229
+ * is null or empty.
230
+ *
231
+ * @param {string} errorName Name of the error event
232
+ * @param {number} errorCode The error code to report
233
+ * @param {Platform} platform Optional platform filter. Defaults to both Android and iOS.
234
+ *
235
+ * @example
236
+ * ```ts
237
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
238
+ *
239
+ * const action = Dynatrace.enterAutoAction('User Login');
240
+ * action.reportError('Page Not Found', 404);
241
+ * action.leaveAction();
242
+ *
243
+ * // With platform-specific error
244
+ * const platformAction = Dynatrace.enterAutoAction('API Call');
245
+ * platformAction.reportError('Connection Failed', 500, Platform.Android);
246
+ * platformAction.leaveAction();
247
+ * ```
248
+ *
249
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
250
+ */
251
+ reportError(errorName: string, errorCode: number, platform?: Platform): void;
252
+ /**
253
+ * Reports a timestamped event to track when a user passes through a specific part of your application.
254
+ * This method provides a simple way to monitor user behavior and application flow.
255
+ *
256
+ * **Note:** The event will not be reported if the action is already closed or if the eventName
257
+ * is null or empty.
258
+ *
259
+ * @param eventName Name of the event to report
260
+ * @param platform Optional platform filter. Defaults to both Android and iOS.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
265
+ *
266
+ * const action = Dynatrace.enterAutoAction('Checkout Process');
267
+ * action.reportEvent('Payment Method Selected');
268
+ * action.reportEvent('Order Confirmed');
269
+ * action.leaveAction();
270
+ * ```
271
+ *
272
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
273
+ */
274
+ reportEvent(eventName: string, platform?: Platform): void;
275
+ /**
276
+ * Reports a timestamped string key-value pair for tracking important measurement data.
277
+ *
278
+ * **Note:** The event will not be reported if the action is already closed, or if either
279
+ * valueName or value is null or empty.
280
+ *
281
+ * @param valueName Name of the value being reported
282
+ * @param value String value to report
283
+ * @param platform Optional platform filter. Defaults to both Android and iOS.
284
+ *
285
+ * @example
286
+ * ```ts
287
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
288
+ *
289
+ * const action = Dynatrace.enterAutoAction('User Profile Update');
290
+ * action.reportStringValue('User Tier', 'Premium');
291
+ * action.reportStringValue('Selected Theme', 'Dark Mode');
292
+ * action.leaveAction();
293
+ * ```
294
+ *
295
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
296
+ */
297
+ reportStringValue(valueName: string, value: string, platform?: Platform): void;
298
+ /**
299
+ * Reports a timestamped integer key-value pair for tracking important measurement data.
300
+ *
301
+ * **Note:** The event will not be reported if the action is already closed or if
302
+ * valueName is null or empty.
303
+ *
304
+ * @param valueName Name of the value being reported
305
+ * @param value Integer value to report
306
+ * @param platform Optional platform filter. Defaults to both Android and iOS.
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
311
+ *
312
+ * const action = Dynatrace.enterAutoAction('Shopping Cart');
313
+ * action.reportIntValue('Items Count', 5);
314
+ * action.reportIntValue('Total Quantity', 12);
315
+ * action.leaveAction();
316
+ * ```
317
+ *
318
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
319
+ */
320
+ reportIntValue(valueName: string, value: number, platform?: Platform): void;
321
+ /**
322
+ * Reports a timestamped double (floating-point) key-value pair for tracking important measurement data.
323
+ *
324
+ * **Note:** The event will not be reported if the action is already closed or if
325
+ * valueName is null or empty.
326
+ *
327
+ * @param valueName Name of the value being reported
328
+ * @param value Double (floating-point) value to report
329
+ * @param platform Optional platform filter. Defaults to both Android and iOS.
330
+ *
331
+ * @example
332
+ * ```ts
333
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
334
+ *
335
+ * const action = Dynatrace.enterAutoAction('Purchase Transaction');
336
+ * action.reportDoubleValue('Transaction Amount', 99.99);
337
+ * action.reportDoubleValue('Tax Amount', 8.50);
338
+ * action.leaveAction();
339
+ * ```
340
+ *
341
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
342
+ */
343
+ reportDoubleValue(valueName: string, value: number, platform?: Platform): void;
344
+ /**
345
+ * Completes this action and prepares the collected data for transmission in the next sending interval.
346
+ *
347
+ * **Note:** When a parent action is exited, all nested child actions are automatically closed.
348
+ *
349
+ * @param platform Optional platform filter. Defaults to both Android and iOS.
350
+ *
351
+ * @example
352
+ * ```ts
353
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
354
+ *
355
+ * const action = Dynatrace.enterAutoAction('User Login');
356
+ * action.reportEvent('Credentials Validated');
357
+ * action.reportIntValue('Login Attempts', 1);
358
+ * action.leaveAction();
359
+ * ```
360
+ *
361
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
362
+ */
363
+ leaveAction(platform?: Platform): void;
364
+ /**
365
+ * Cancels this action and discards all collected data. Similar to `leaveAction()`, but the data
366
+ * and all unfinished child actions are discarded instead of being sent to Dynatrace.
367
+ *
368
+ * Use this when an action was started incorrectly or should not contribute to monitoring data
369
+ * (e.g., test actions, debug sessions, pre-production validation).
370
+ *
371
+ * @param platform Optional platform filter. Defaults to both Android and iOS.
372
+ *
373
+ * @example
374
+ * ```ts
375
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
376
+ *
377
+ * const action = Dynatrace.enterAutoAction('Data Processing');
378
+ * action.reportEvent('Processing Started');
379
+ *
380
+ * // Cancel if running in development or test mode
381
+ * if (__DEV__ || isTestEnvironment) {
382
+ * action.cancel(); // Don't send test data to production monitoring
383
+ * } else {
384
+ * action.leaveAction(); // Send the action data
385
+ * }
386
+ * ```
387
+ *
388
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#cancel-actions
389
+ */
390
+ cancel(platform?: Platform): void;
391
+ /**
392
+ * Generates a Dynatrace request tag for manual web request tagging. This tag must be added as an
393
+ * HTTP header to link the web request with this mobile action. The header key can be obtained
394
+ * using `getRequestTagHeader()`.
395
+ *
396
+ * The tag value is evaluated by the Dynatrace web server agent, which links server-side PurePath
397
+ * data with this mobile user action for end-to-end tracing.
398
+ *
399
+ * **Note:** The returned string may be empty if the Dynatrace agent is disabled or not started yet,
400
+ * if communication with the Dynatrace server fails, or if privacy settings do not allow monitoring of requests.
401
+ *
402
+ * @param {string} url The URL of the request you want to track
403
+ * @returns {Promise<string>} The request tag value to be used as the HTTP header value
404
+ *
405
+ * @example
406
+ * ```ts
407
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
408
+ *
409
+ * const action = Dynatrace.enterAutoAction('API Request');
410
+ * const requestTag = await action.getRequestTag('https://api.example.com/data');
411
+ * const headerName = action.getRequestTagHeader();
412
+ *
413
+ * // Attach to your HTTP request
414
+ * fetch('https://api.example.com/data', {
415
+ * headers: {
416
+ * [headerName]: requestTag,
417
+ * 'Content-Type': 'application/json'
418
+ * }
419
+ * });
420
+ *
421
+ * action.leaveAction();
422
+ * ```
423
+ *
424
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
425
+ */
426
+ getRequestTag(url: string): Promise<string>;
427
+ /**
428
+ * Returns the HTTP header name required for manual web request tagging. Use this in combination
429
+ * with `getRequestTag()` to link web requests with mobile actions.
430
+ *
431
+ * @returns {string} The name of the HTTP header to use for request tagging
432
+ *
433
+ * @example
434
+ * ```ts
435
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
436
+ *
437
+ * const action = Dynatrace.enterAutoAction('Data Fetch');
438
+ * const headerName = action.getRequestTagHeader();
439
+ * const headerValue = await action.getRequestTag('https://api.example.com/users');
440
+ *
441
+ * // Use in your HTTP client
442
+ * const response = await fetch('https://api.example.com/users', {
443
+ * headers: {
444
+ * [headerName]: headerValue
445
+ * }
446
+ * });
447
+ *
448
+ * action.leaveAction();
449
+ * ```
450
+ *
451
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
452
+ */
453
+ getRequestTagHeader(): string;
454
+ }
455
+
456
+ type Primitive = string | number | boolean;
457
+ type JSONArray = JSONValue[];
458
+ type JSONValue = Primitive | JSONArray | JSONObject;
459
+ /**
460
+ * JSON Object which can be used for sendEvent API
461
+ */
462
+ interface JSONObject {
463
+ [key: string]: JSONValue;
464
+ }
465
+
466
+ /**
467
+ * Log level enum to control the verbosity of plugin logging.
468
+ */
469
+ declare enum LogLevel {
470
+ /**
471
+ * Enables verbose diagnostic logging. Use this level when troubleshooting issues or during development.
472
+ *
473
+ * **Configuration options:**
474
+ * - Via `dynatrace.config.js`: Set `react.debug` to `true`
475
+ * - Via code (manual startup): Use the `ConfigurationBuilder`
476
+ *
477
+ * @example
478
+ * ```ts
479
+ * import { ConfigurationBuilder, Dynatrace, LogLevel } from '@dynatrace/react-native-plugin';
480
+ *
481
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
482
+ * .withLogLevel(LogLevel.Debug);
483
+ * await Dynatrace.start(config.buildConfiguration());
484
+ * ```
485
+ */
486
+ Debug = 0,
487
+ /**
488
+ * Enables standard informational logging. This is the default log level and provides essential information
489
+ * without excessive detail.
490
+ *
491
+ * **Note:** Since this is the default, explicit configuration is not required.
492
+ *
493
+ * **Configuration options:**
494
+ * - Via `dynatrace.config.js`: Set `react.debug` to `false`
495
+ * - Via code (manual startup): Use the `ConfigurationBuilder`
496
+ *
497
+ * @example
498
+ * ```ts
499
+ * import { ConfigurationBuilder, Dynatrace, LogLevel } from '@dynatrace/react-native-plugin';
500
+ *
501
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
502
+ * .withLogLevel(LogLevel.Info);
503
+ * await Dynatrace.start(config.buildConfiguration());
504
+ * ```
505
+ */
506
+ Info = 1
507
+ }
508
+
509
+ /**
510
+ * Configuration interface for Dynatrace agent startup.
511
+ * Use this interface when configuring the agent programmatically instead of using auto-startup.
512
+ */
513
+ interface IConfiguration {
514
+ /**
515
+ * The beacon URL used to communicate with the Dynatrace beacon endpoint. This value is mandatory.
516
+ *
517
+ * **Note:** This value is only used for manual startup. For auto-startup, configure this through
518
+ * the native agent configuration.
519
+ */
520
+ readonly beaconUrl: string;
521
+ /**
522
+ * The application ID used to identify and report data for this application. This value is mandatory.
523
+ *
524
+ * **Note:** This value is only used for manual startup. For auto-startup, configure this through
525
+ * the native agent configuration.
526
+ */
527
+ readonly applicationId: string;
528
+ /**
529
+ * Enables crash reporting. Defaults to `true` if not specified.
530
+ *
531
+ * **Note:** This value is only used for manual startup. For auto-startup, configure this through
532
+ * the native agent configuration.
533
+ */
534
+ readonly reportCrash: boolean;
535
+ /**
536
+ * Enables the React Native error/crash handler. Defaults to `true` if not specified.
537
+ *
538
+ * **Note:** This value is only used for manual startup. For auto-startup, configure this through
539
+ * the `react` configuration block in the `dynatrace.config.js` file.
540
+ */
541
+ readonly errorHandler: boolean;
542
+ /**
543
+ * Determines whether fatal errors are reported as crashes or errors.
544
+ *
545
+ * - When `true` (default): Unhandled fatal errors are reported as crashes and end the current session
546
+ * - When `false`: Unhandled fatal errors are reported as errors and the current session continues
547
+ *
548
+ * **Note:** This value is only used for manual startup. For auto-startup, configure this through
549
+ * the `react` configuration block in the `dynatrace.config.js` file.
550
+ */
551
+ readonly reportFatalErrorAsCrash: boolean;
552
+ /**
553
+ * The log level for the Dynatrace plugin during application runtime. Defaults to `LogLevel.Info` if not specified.
554
+ */
555
+ readonly logLevel: LogLevel;
556
+ /**
557
+ * Enables tracking of component update cycles in lifecycle actions. Defaults to `false` if not specified.
558
+ *
559
+ * **Warning:** Enabling this option generates significantly more monitoring data.
560
+ */
561
+ readonly lifecycleUpdate: boolean;
562
+ /**
563
+ * Activates privacy mode when set to `true`. User consent must be queried and configured separately.
564
+ * Privacy settings for data collection and crash reporting can be changed by calling
565
+ * `Dynatrace.applyUserPrivacyOptions(userPrivacyOptions)`. Defaults to `false` if not specified.
566
+ *
567
+ * **Note:** This value is only used for manual startup. For auto-startup, configure this through
568
+ * the native agent configuration.
569
+ *
570
+ * @see Data privacy documentation for more details on privacy settings
571
+ */
572
+ readonly userOptIn: boolean;
573
+ /**
574
+ * Activates privacy mode for Touchables and Buttons. When set to `true`, specific control names
575
+ * are hidden and replaced with generic component types (e.g., "Touch on Login" becomes "Touch on Button").
576
+ *
577
+ * **Note:** This setting is ignored when a `dtActionName` prop is explicitly set on the component.
578
+ * Defaults to `false` if not specified.
579
+ */
580
+ readonly actionNamePrivacy: boolean;
581
+ /**
582
+ * The bundle name used as a prefix for internal action IDs. Optional.
583
+ */
584
+ readonly bundleName?: string;
585
+ /**
586
+ * The bundle version used for events. This is mandatory for proper crash reporting and source map symbolication.
587
+ *
588
+ * **Important:** Without a bundle version, source maps cannot be applied to crash reports.
589
+ */
590
+ readonly bundleVersion?: string;
591
+ /**
592
+ * Returns a string representation of the configuration.
593
+ *
594
+ * @returns A formatted string containing the configuration details
595
+ */
596
+ toString(): string;
597
+ }
598
+
599
+ /**
600
+ * Interface which declares event modification through modifyEvent
601
+ * Implement this interface and register it via Dynatrace.addEventModifier(IEventModifier) to modify events.
602
+ */
603
+ interface IEventModifier {
604
+ /**
605
+ * Event as JSONObject is received and can be modified.
606
+ *
607
+ * Returning null discards this event and prevents future mutator functions to be executed.
608
+ *
609
+ * Certain reserved fields and namespaces can't be modified in any way (added, removed or overridden),
610
+ * while others are open for modification. See the public documentation for a detailed list of reserved/open fields.
611
+ * @param event Event as JSONObject
612
+ * @returns Either the modified event or null if you want to cancel the event
613
+ *
614
+ * @example
615
+ * ```ts
616
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
617
+ *
618
+ * Dynatrace.addEventModifier({ modifyEvent(event) {
619
+ * event['event_properties.modified'] = 'modified';
620
+ * return event;
621
+ * }});
622
+ * ```
623
+ *
624
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
625
+ */
626
+ modifyEvent(event: JSONObject): JSONObject | null;
627
+ }
628
+
629
+ interface IHttpRequestEventBuilder {
630
+ /**
631
+ * Sets the duration of the HTTP request in milliseconds.
632
+ *
633
+ * @param duration The request duration in milliseconds. Only positive numbers are valid.
634
+ * @returns The builder instance for method chaining
635
+ *
636
+ * @example
637
+ * ```ts
638
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
639
+ *
640
+ * const requestEvent = new HttpRequestEventBuilder('https://api.example.com/data', 'GET')
641
+ * .withDuration(250);
642
+ * Dynatrace.sendHttpRequestEvent(requestEvent);
643
+ * ```
644
+ *
645
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
646
+ */
647
+ withDuration(duration: number): this;
648
+ /**
649
+ * Sets the HTTP response status code.
650
+ *
651
+ * @param statusCode The HTTP status code (e.g., 200, 404, 500). Only positive numbers are valid.
652
+ * @returns The builder instance for method chaining
653
+ *
654
+ * @example
655
+ * ```ts
656
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
657
+ *
658
+ * const requestEvent = new HttpRequestEventBuilder('https://api.example.com/data', 'GET')
659
+ * .withStatusCode(200);
660
+ * Dynatrace.sendHttpRequestEvent(requestEvent);
661
+ * ```
662
+ *
663
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
664
+ */
665
+ withStatusCode(statusCode: number): this;
666
+ /**
667
+ * Sets the HTTP response reason phrase.
668
+ *
669
+ * @param reasonPhrase The reason phrase (e.g., "OK", "Not Found"). Maximum 5000 characters; longer values will be trimmed.
670
+ * @returns The builder instance for method chaining
671
+ *
672
+ * @example
673
+ * ```ts
674
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
675
+ *
676
+ * const requestEvent = new HttpRequestEventBuilder('https://api.example.com/data', 'GET')
677
+ * .withReasonPhrase('OK');
678
+ * Dynatrace.sendHttpRequestEvent(requestEvent);
679
+ * ```
680
+ *
681
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
682
+ */
683
+ withReasonPhrase(reasonPhrase: string): this;
684
+ /**
685
+ * Associates an error with the HTTP request event.
686
+ *
687
+ * @param error A standard JavaScript Error object representing the request failure
688
+ * @returns The builder instance for method chaining
689
+ *
690
+ * @example
691
+ * ```ts
692
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
693
+ *
694
+ * try {
695
+ * // Request code
696
+ * } catch (error) {
697
+ * const requestEvent = new HttpRequestEventBuilder('https://api.example.com/data', 'GET')
698
+ * .withError(error);
699
+ * Dynatrace.sendHttpRequestEvent(requestEvent);
700
+ * }
701
+ * ```
702
+ *
703
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
704
+ */
705
+ withError(error: Error): this;
706
+ /**
707
+ * Sets the number of bytes sent in the request.
708
+ *
709
+ * @param bytesSent The number of bytes sent in the request payload. Only positive numbers are valid.
710
+ * @returns The builder instance for method chaining
711
+ *
712
+ * @example
713
+ * ```ts
714
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
715
+ *
716
+ * const requestEvent = new HttpRequestEventBuilder('https://api.example.com/data', 'POST')
717
+ * .withBytesSent(1024);
718
+ * Dynatrace.sendHttpRequestEvent(requestEvent);
719
+ * ```
720
+ *
721
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
722
+ */
723
+ withBytesSent(bytesSent: number): this;
724
+ /**
725
+ * Sets the number of bytes received in the response.
726
+ *
727
+ * @param bytesReceived The number of bytes received in the response payload. Only positive numbers are valid.
728
+ * @returns The builder instance for method chaining
729
+ *
730
+ * @example
731
+ * ```ts
732
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
733
+ *
734
+ * const requestEvent = new HttpRequestEventBuilder('https://api.example.com/data', 'GET')
735
+ * .withBytesReceived(2048);
736
+ * Dynatrace.sendHttpRequestEvent(requestEvent);
737
+ * ```
738
+ *
739
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
740
+ */
741
+ withBytesReceived(bytesReceived: number): this;
742
+ /**
743
+ * Adds a W3C traceparent header for distributed tracing.
744
+ *
745
+ * @param traceparentHeader A valid traceparent header according to the W3C Trace Context specification.
746
+ * Format: `00-<trace-id>-<parent-id>-<trace-flags>` where trace-id is 32 hex digits, parent-id is 16 hex digits.
747
+ * @returns The builder instance for method chaining
748
+ *
749
+ * @example
750
+ * ```ts
751
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
752
+ *
753
+ * const requestEvent = new HttpRequestEventBuilder('https://api.example.com/data', 'GET')
754
+ * .withTraceparentHeader('00-80e1afed08e019fc1110464cfa66635c-7a085853722dc6d2-01');
755
+ * Dynatrace.sendHttpRequestEvent(requestEvent);
756
+ * ```
757
+ *
758
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
759
+ */
760
+ withTraceparentHeader(traceparentHeader: TraceparentHeader): this;
761
+ /**
762
+ * Adds a custom event property to the request event.
763
+ * @param key The property key. See property requirements below.
764
+ * @param value The property value. Cannot contain functions, undefined, Infinity, or NaN (they will be replaced with null).
765
+ *
766
+ * **Property Requirements:**
767
+ * - Only properties prefixed with `event_properties.*` are allowed
768
+ * - Maximum of 50 custom properties per event
769
+ * - String properties are limited to 5000 characters (exceeding characters are truncated)
770
+ * - Field names must contain only alphabetic characters, numbers, underscores, and dots
771
+ * - Each dot must be followed by an alphabetic character
772
+ * - Each underscore must be followed by an alphabetic character or number
773
+ *
774
+ * @returns The builder instance for method chaining
775
+ *
776
+ * @example
777
+ * ```ts
778
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
779
+ *
780
+ * const requestEvent = new HttpRequestEventBuilder('https://api.example.com/data', 'GET')
781
+ * .addEventProperty('event_properties.user_id', '12345')
782
+ * .addEventProperty('event_properties.api_version', 'v2');
783
+ * Dynatrace.sendHttpRequestEvent(requestEvent);
784
+ * ```
785
+ *
786
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
787
+ */
788
+ addEventProperty(key: `event_properties.${string}`, value: EventProperty): this;
789
+ }
790
+
791
+ type EventProperty = string | number | boolean;
792
+ type TraceparentHeader = `00-${string}-${string}-0${'0' | '1'}`;
793
+ type AllowedRequestMethods = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH' | 'get' | 'head' | 'post' | 'put' | 'delete' | 'connect' | 'options' | 'trace' | 'patch';
794
+ declare class HttpRequestEventBuilder implements IHttpRequestEventBuilder {
795
+ private url;
796
+ private requestMethod;
797
+ private static readonly allowedRequestMethods;
798
+ private static readonly maxReasonPhraseLength;
799
+ private duration;
800
+ private statusCode?;
801
+ private reasonPhrase?;
802
+ private bytesReceived?;
803
+ private bytesSent?;
804
+ private error?;
805
+ private traceparentHeader?;
806
+ private rawEventProperties;
807
+ private hasDroppedTraceparent;
808
+ private hasDroppedCustomProperties;
809
+ private hasNfnValues;
810
+ private triedToOverwriteDuration;
811
+ /**
812
+ * Creates a new HTTP request event builder.
813
+ *
814
+ * @param url The request URL. Must be a valid URL according to the WHATWG URL Standard, starting with `http://` or `https://`.
815
+ * @param requestMethod The HTTP request method. Allowed values: GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS,
816
+ * TRACE, PATCH (case-insensitive).
817
+ *
818
+ * @example
819
+ * ```ts
820
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
821
+ *
822
+ * const requestEvent = new HttpRequestEventBuilder('https://api.example.com/data', 'GET');
823
+ * Dynatrace.sendHttpRequestEvent(requestEvent);
824
+ * ```
825
+ *
826
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
827
+ */
828
+ constructor(url: `http://${string}` | `https://${string}`, requestMethod: AllowedRequestMethods);
829
+ withDuration(duration: number): this;
830
+ withStatusCode(statusCode: number): this;
831
+ withReasonPhrase(reasonPhrase: string): this;
832
+ withError(error: Error): this;
833
+ withBytesSent(bytesSent: number): this;
834
+ withBytesReceived(bytesReceived: number): this;
835
+ withTraceparentHeader(traceparentHeader: TraceparentHeader): this;
836
+ addEventProperty(key: `event_properties.${string}`, value: EventProperty): this;
837
+ build(): JSONObject | null;
838
+ private hasValidMandatoryAttriutes;
839
+ private isInvalidUrl;
840
+ private sanitizeStatusCode;
841
+ private sanitizeReasonPhrase;
842
+ private sanitizeDuration;
843
+ private sanitizeBytesSent;
844
+ private sanitizeBytesReceived;
845
+ private isStatusCodeError;
846
+ private isEventPropertyKey;
847
+ private includeIfDefined;
848
+ private includeIfTrue;
849
+ private parseTraceparent;
850
+ private allZeros;
851
+ }
852
+
853
+ interface IDynatrace$1 {
854
+ /**
855
+ * Adds an event modifier that is executed just before the event is transferred.
856
+ * This allows you to modify the event to some extent.
857
+ *
858
+ * Returning null discards the event and prevents future modifier functions from being executed.
859
+ *
860
+ * Certain reserved fields and namespaces cannot be modified in any way (added, removed, or overridden),
861
+ * while others are open for modification.
862
+ *
863
+ * See the public documentation for a detailed list of reserved/open fields.
864
+ *
865
+ * @param eventModifier The modifier function to modify a given JSONObject
866
+ * @returns The registered event modifier instance
867
+ *
868
+ * @example
869
+ * ```ts
870
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
871
+ *
872
+ * const modifier = Dynatrace.addEventModifier({
873
+ * modifyEvent(event) {
874
+ * event['event_properties.modified'] = 'modified';
875
+ * return event;
876
+ * }
877
+ * });
878
+ * ```
879
+ *
880
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
881
+ */
882
+ addEventModifier(eventModifier: IEventModifier): IEventModifier;
883
+ /**
884
+ * Removes an event modifier so it will no longer modify events.
885
+ *
886
+ * @param eventModifier The modifier function to be removed
887
+ * @returns True if the modifier was successfully removed, false otherwise
888
+ *
889
+ * @example
890
+ * ```ts
891
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
892
+ *
893
+ * const modifier = Dynatrace.addEventModifier({ modifyEvent: (event) => event });
894
+ * const removed = Dynatrace.removeEventModifier(modifier);
895
+ * ```
896
+ *
897
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
898
+ */
899
+ removeEventModifier(eventModifier: IEventModifier): boolean;
900
+ /**
901
+ * Sends an exception event for error tracking and monitoring.
902
+ *
903
+ * @param {Error} error The error object containing exception information
904
+ * @param {JSONObject} properties Optional custom properties for the exception event. Must be a valid JSON object
905
+ * and cannot contain functions, undefined, Infinity, or NaN as values (they will be replaced with null).
906
+ *
907
+ * **Property Requirements:**
908
+ * - Only properties prefixed with `event_properties.*` are allowed
909
+ * - Additionally, `duration` and `start_time` properties are allowed
910
+ * - Maximum of 50 custom properties per event
911
+ * - String properties are limited to 5000 characters (exceeding characters are truncated)
912
+ * - Field names must contain only alphabetic characters, numbers, underscores, and dots
913
+ * - Each dot must be followed by an alphabetic character
914
+ * - Each underscore must be followed by an alphabetic character or number
915
+ *
916
+ * @example
917
+ * ```ts
918
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
919
+ *
920
+ * try {
921
+ * // Code that may throw an error
922
+ * throw new Error('Something went wrong');
923
+ * } catch (error) {
924
+ * Dynatrace.sendExceptionEvent(error, {
925
+ * 'event_properties.custom_key': 'custom_value',
926
+ * 'event_properties.error_context': 'user_action'
927
+ * });
928
+ * }
929
+ * ```
930
+ *
931
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
932
+ */
933
+ sendExceptionEvent(error: Error, fields?: JSONObject): void;
934
+ /**
935
+ * Sends a custom event with properties in JSON format.
936
+ *
937
+ * @param {JSONObject} properties Event properties as a valid JSON object. Cannot contain functions, undefined,
938
+ * Infinity, or NaN as values (they will be replaced with null). Empty objects are valid.
939
+ *
940
+ * **Property Requirements:**
941
+ * - Only properties prefixed with `event_properties.*` are allowed
942
+ * - Additionally, `duration` and `start_time` properties are allowed
943
+ * - Maximum of 50 custom properties per event
944
+ * - String properties are limited to 5000 characters (exceeding characters are truncated)
945
+ * - Field names must contain only alphabetic characters, numbers, underscores, and dots
946
+ * - Each dot must be followed by an alphabetic character
947
+ * - Each underscore must be followed by an alphabetic character or number
948
+ *
949
+ * @example
950
+ * ```ts
951
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
952
+ *
953
+ * Dynatrace.sendEvent({'event_properties.custom_key':'custom_value'});
954
+ * ```
955
+ *
956
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
957
+ */
958
+ sendEvent(properties: JSONObject): void;
959
+ /**
960
+ * Starts a new view context. All events reported after this call will be associated
961
+ * with this view until `stopView()` is called or a new view is started.
962
+ *
963
+ * **Note:** Only one view context can be active at a time. Starting a new view will
964
+ * automatically stop any currently active view context.
965
+ *
966
+ * @param name Name of the view (e.g., screen name, page title)
967
+ *
968
+ * @example
969
+ * ```ts
970
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
971
+ *
972
+ * // Start tracking a specific screen
973
+ * Dynatrace.startView('HomeScreen');
974
+ * ```
975
+ *
976
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
977
+ */
978
+ startView(name: string): void;
979
+ /**
980
+ * Stops the current view context. Events reported after this call will not be
981
+ * associated with any view until a new view is started.
982
+ *
983
+ * @example
984
+ * ```ts
985
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
986
+ *
987
+ * Dynatrace.startView('HomeScreen');
988
+ * // ... user interactions ...
989
+ * Dynatrace.stopView();
990
+ * ```
991
+ *
992
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
993
+ */
994
+ stopView(): void;
995
+ /**
996
+ * Sends a session properties event. Session properties apply to all events in the current session.
997
+ *
998
+ * **Note:** While you can send multiple session properties at once, if you report the same
999
+ * property multiple times, session aggregation will only use one of the values (first or last).
1000
+ *
1001
+ * @param {JSONObject} properties Session properties as a valid JSON object. Cannot contain functions,
1002
+ * undefined, Infinity, or NaN as values (they will be replaced with null). Empty objects are valid.
1003
+ *
1004
+ * **Property Requirements:**
1005
+ * - Only properties prefixed with `session_properties.*` are allowed
1006
+ * - Additionally, `duration` and `start_time` properties are allowed
1007
+ * - Maximum of 50 custom properties per event
1008
+ * - String properties are limited to 5000 characters (exceeding characters are truncated)
1009
+ * - Field names must contain only alphabetic characters, numbers, underscores, and dots
1010
+ * - Each dot must be followed by an alphabetic character
1011
+ * - Each underscore must be followed by an alphabetic character or number
1012
+ *
1013
+ * @example
1014
+ * ```ts
1015
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1016
+ *
1017
+ * // Set session-level properties
1018
+ * Dynatrace.sendSessionPropertyEvent({
1019
+ * 'session_properties.user_tier': 'premium',
1020
+ * 'session_properties.app_version': '2.1.0',
1021
+ * 'session_properties.device_type': 'mobile'
1022
+ * });
1023
+ * ```
1024
+ *
1025
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
1026
+ */
1027
+ sendSessionPropertyEvent(properties: JSONObject): void;
1028
+ /**
1029
+ * Sends an HTTP request event for network activity monitoring.
1030
+ *
1031
+ * @param {HttpRequestEventBuilder} httpRequestEventBuilder Builder object containing the HTTP request details
1032
+ *
1033
+ * @example
1034
+ * ```ts
1035
+ * import { Dynatrace, HttpRequestEventBuilder } from '@dynatrace/react-native-plugin';
1036
+ *
1037
+ * // Basic HTTP request event
1038
+ * const requestBuilder = new HttpRequestEventBuilder('https://api.example.com/users', 'GET');
1039
+ * Dynatrace.sendHttpRequestEvent(requestBuilder);
1040
+ *
1041
+ * // HTTP request with additional details
1042
+ * const detailedBuilder = new HttpRequestEventBuilder('https://api.example.com/data', 'POST')
1043
+ * .setResponseCode(200)
1044
+ * .setRequestHeaders({ 'Content-Type': 'application/json' });
1045
+ * Dynatrace.sendHttpRequestEvent(detailedBuilder);
1046
+ * ```
1047
+ *
1048
+ * @see https://docs.dynatrace.com/docs/observe/digital-experience/new-rum-experience/api
1049
+ */
1050
+ sendHttpRequestEvent(httpRequestEventBuilder: HttpRequestEventBuilder): void;
1051
+ }
1052
+
1053
+ /**
1054
+ * Root action that extends the standard IDynatraceAction with the ability to create
1055
+ * nested child actions for hierarchical action tracking.
1056
+ */
1057
+ interface IDynatraceRootAction extends IDynatraceAction {
1058
+ /**
1059
+ * Creates a child action nested under this root action. Child actions allow you to track
1060
+ * sub-tasks or operations within a larger workflow, providing hierarchical visibility
1061
+ * into user interactions and application behavior.
1062
+ *
1063
+ * **Note:** When the parent action is closed with `leaveAction()` or `cancel()`, all
1064
+ * child actions are automatically closed as well.
1065
+ *
1066
+ * @param {string} name Name of the child action
1067
+ * @param {Platform} platform Optional platform filter. Defaults to both Android and iOS.
1068
+ * @returns {IDynatraceAction} The created child action instance
1069
+ *
1070
+ * @example
1071
+ * ```ts
1072
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1073
+ *
1074
+ * const parentAction = Dynatrace.enterManualAction('User Registration');
1075
+ *
1076
+ * const validationAction = parentAction.enterAction('Validate Input');
1077
+ * validationAction.reportEvent('Email Validated');
1078
+ * validationAction.leaveAction();
1079
+ *
1080
+ * const submitAction = parentAction.enterAction('Submit Form');
1081
+ * submitAction.reportIntValue('Retry Attempts', 1);
1082
+ * submitAction.leaveAction();
1083
+ *
1084
+ * parentAction.leaveAction();
1085
+ * ```
1086
+ *
1087
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#create-custom-sub-actions
1088
+ */
1089
+ enterAction(name: string, platform?: Platform): IDynatraceAction;
1090
+ }
1091
+
1092
+ interface IDynatrace extends IDynatrace$1 {
1093
+ /**
1094
+ * Starting the React Native plugin and OneAgent for Android or iOS. This method is only necessary
1095
+ * in case of manual startup and should be ignored in auto startup scenarios. The start method will
1096
+ * set the error handler for reporting crashes and will apply the provided configuration globally.
1097
+ *
1098
+ * @param {IConfiguration} configuration Configuration for a manual startup of the plugin
1099
+ *
1100
+ * @example
1101
+ * ```ts
1102
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1103
+ *
1104
+ * const configurationBuilder = new ConfigurationBuilder("beaconUrl", "applicationId");
1105
+ * // Use several configuration options like withLogLevel(LogLevel.Debug)
1106
+ * await Dynatrace.start(configurationBuilder.buildConfiguration());
1107
+ * ```
1108
+ *
1109
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1110
+ */
1111
+ start(configuration: IConfiguration): Promise<void>;
1112
+ /**
1113
+ * This call allows to monitor the passed in component. Depending on the type of the component
1114
+ * (Function Component or Class Component), it will be wrapped and data of renderings will be
1115
+ * automatically reported.
1116
+ *
1117
+ * The name of the Component, which can be passed as parameter, is important because the build
1118
+ * process will remove the name of a Functional Component. Still this parameter is optional as
1119
+ * other properties can be used at runtime as well (e.g. dtActionName).
1120
+ *
1121
+ * @param Component Functional or Class Component
1122
+ * @param {string} name The name of the Component
1123
+ * @returns The Component which was wrapped to be monitored
1124
+ *
1125
+ * @example
1126
+ * ```ts
1127
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1128
+ *
1129
+ * export function MyFunctionalComponent(){
1130
+ * // Content of component
1131
+ * }
1132
+ *
1133
+ * Dynatrace.withMonitoring(MyFunctionalComponent, "MyFunctionalComponent");
1134
+ * ```
1135
+ *
1136
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#monitor-a-component
1137
+ */
1138
+ withMonitoring(Component: React.FunctionComponent | React.ComponentClass, name?: string): React.FunctionComponent | React.ComponentClass;
1139
+ /**
1140
+ * Reroutes to `Dynatrace.enterAutoAction`
1141
+ *
1142
+ * @deprecated Please use either {@link enterAutoAction}, which is doing the same or alternatively {@link enterManualAction}.
1143
+ */
1144
+ enterAction(name: string, platform?: Platform): IDynatraceAction;
1145
+ /**
1146
+ * Creates an Action which will be automatically handled by the plugin. This means that the
1147
+ * plugin decides about the hierarchy of this action. If there is no open action, the following
1148
+ * action will be a root action. All other actions created by this method, while a root action
1149
+ * is open, will be automatically inserted as a child action. Furthermore the plugin will automatically
1150
+ * link webrequest (if they are not tagged manually) to the open root action.
1151
+ *
1152
+ * @param {string} name Name of the action, which will be created. This name must not be empty.
1153
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1154
+ * @returns {IDynatraceAction} Action that is created. If name was empty a NullAction will be provided,
1155
+ * which will act as normal action, but has no functionality.
1156
+ *
1157
+ * @example
1158
+ * ```ts
1159
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1160
+ *
1161
+ * let myAction = Dynatrace.enterAutoAction("MyButton tapped");
1162
+ * // Perform the action and whatever else is needed.
1163
+ * myAction.leaveAction();
1164
+ * ```
1165
+ *
1166
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#create-custom-actions
1167
+ */
1168
+ enterAutoAction(name: string, platform?: Platform): IDynatraceAction;
1169
+ /**
1170
+ * Creates an Action which will NOT be handled by the plugin. This means that you have full control
1171
+ * about the hierarchy of your actions. This function will create a {@link IDynatraceRootAction} for you,
1172
+ * which has the ability to create child actions via {@link IDynatraceRootAction.enterAction}. Be aware,
1173
+ * because of the full manual approach the plugin will not link webrequest automatically. Webrequest
1174
+ * have to be manually tagged by using the tag provided by the action via {@link IDynatraceAction.getRequestTag}.
1175
+ *
1176
+ * @param {string} name Name of the action, which will be created. This name must not be empty.
1177
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1178
+ * @returns {IDynatraceRootAction} Action that is created. If name was empty a NullRootAction will be provided,
1179
+ * which will act as normal root action, but has no functionality.
1180
+ *
1181
+ * @example
1182
+ * ```ts
1183
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1184
+ *
1185
+ * let myAction = Dynatrace.enterManualAction("MyButton tapped");
1186
+ * // Perform the action and whatever else is needed.
1187
+ * myAction.leaveAction();
1188
+ * ```
1189
+ *
1190
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#create-custom-actions
1191
+ */
1192
+ enterManualAction(name: string, platform?: Platform): IDynatraceRootAction;
1193
+ /**
1194
+ * Similar to {@link IDynatraceAction.reportError}. But the error event is reported as root action.
1195
+ *
1196
+ * @param {string} errorName Name of the error event
1197
+ * @param {number} errorCode The code of the error
1198
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1199
+ *
1200
+ * @example
1201
+ * ```ts
1202
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1203
+ *
1204
+ * Dynatrace.reportError("Page not found", 404);
1205
+ * ```
1206
+ *
1207
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
1208
+ */
1209
+ reportError(errorName: string, errorCode: number, platform?: Platform): void;
1210
+ /**
1211
+ * Reports a stacktrace
1212
+ *
1213
+ * @deprecated Please use {@link reportErrorStacktrace} instead.
1214
+ *
1215
+ * @param {String} errorName Name of the Error - SyntaxError
1216
+ * @param {String} reason Reason for the Error
1217
+ * @param {String} stacktrace Whole Stacktrace
1218
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1219
+ */
1220
+ reportErrorWithStacktrace(errorName: string, reason: string, stacktrace: string, platform?: Platform): void;
1221
+ /**
1222
+ * Reports a stacktrace
1223
+ *
1224
+ * @param {string} errorName Name of the error
1225
+ * @param {string} errorValue Value of the error
1226
+ * @param {string} reason Reason for the error
1227
+ * @param {string} stacktrace Whole stacktrace
1228
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1229
+ *
1230
+ * @example
1231
+ * ```ts
1232
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1233
+ *
1234
+ * Dynatrace.reportErrorStacktrace("Error Name", "Error Value", "Reason", "Stacktrace");
1235
+ * ```
1236
+ *
1237
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-an-error-stacktrace
1238
+ */
1239
+ reportErrorStacktrace(errorName: string, errorValue: string, reason: string, stacktrace: string, platform?: Platform): void;
1240
+ /**
1241
+ * Reports a custom crash
1242
+ *
1243
+ * @param {string} crashName Name of the crash
1244
+ * @param {string} reason Reason for the crash
1245
+ * @param {string} stacktrace Whole stacktrace
1246
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1247
+ *
1248
+ * @example
1249
+ * ```ts
1250
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1251
+ *
1252
+ * Dynatrace.reportCrash("Crash Name", "Reason", "Stacktrace");
1253
+ * ```
1254
+ *
1255
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manually-report-a-crash
1256
+ */
1257
+ reportCrash(crashName: string, reason: string, stacktrace: string, platform?: Platform): void;
1258
+ /**
1259
+ * Reports a crash with an error object (which needs to contain a stacktrace)
1260
+ *
1261
+ * @param {string} crashName Name of the crash
1262
+ * @param {Error} crash error object
1263
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1264
+ *
1265
+ * @example
1266
+ * ```ts
1267
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1268
+ *
1269
+ * Dynatrace.reportCrashWithException("Crash Name", error);
1270
+ * ```
1271
+ *
1272
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manually-report-a-crash
1273
+ */
1274
+ reportCrashWithException(crashName: string, crash: Error): void;
1275
+ /**
1276
+ * Send a Business Event
1277
+ *
1278
+ * With sendBizEvent, you can report a business event. These standalone events are being sent
1279
+ * detached from user actions or sessions.
1280
+ *
1281
+ * Note: The 'dt' key, as well as all 'dt.' prefixed keys are considered reserved by Dynatrace
1282
+ * and will be stripped from the passed in attributes.
1283
+ *
1284
+ * Note: Business events are only supported on Dynatrace SaaS deployments currently.
1285
+ *
1286
+ * @param {string} type Mandatory event type
1287
+ * @param {JSONObject} attributes Must be a valid JSON object and cannot contain functions,
1288
+ * undefined, Infinity and NaN as values, otherwise they will be removed.
1289
+ * Attributes need to be serializable using JSON.stringify.
1290
+ * The resulting event will be populated with attributes parameter,
1291
+ * and enriched with additional properties, thus also empty objects are valid.
1292
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1293
+ *
1294
+ * Usage:
1295
+ *
1296
+ * ```ts
1297
+ * import { Dynatrace, JSONObject } from '@dynatrace/react-native-plugin';
1298
+ *
1299
+ * Dynatrace.sendBizEvent('type', { custom : 123 });
1300
+ * ```
1301
+ *
1302
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#business-event-capturing
1303
+ */
1304
+ sendBizEvent(type: string, attributes?: JSONObject, platform?: Platform): void;
1305
+ /**
1306
+ * Can be called to end the current visit and start a new visit. All current actions are
1307
+ * closed and sent to the server.
1308
+ *
1309
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1310
+ *
1311
+ * @example
1312
+ * ```ts
1313
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1314
+ *
1315
+ * Dynatrace.endSession();
1316
+ * ```
1317
+ *
1318
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#end-the-current-user-session
1319
+ */
1320
+ endSession(platform?: Platform): void;
1321
+ /**
1322
+ * The current visit/session will be tagged with the provided user id.
1323
+ * The value will not be stored and has to be renewed for every new session.
1324
+ *
1325
+ * @param {string} user a unique id that allows you to identify the current user.
1326
+ * If user is null or empty, then the user tag will be removed from the session.
1327
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1328
+ *
1329
+ * @example
1330
+ * ```ts
1331
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1332
+ *
1333
+ * Dynatrace.identifyUser('User');
1334
+ * ```
1335
+ *
1336
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#identify-a-user
1337
+ */
1338
+ identifyUser(user: string, platform?: Platform): void;
1339
+ /**
1340
+ * Saves the given GPS location for reporting along with the captured data.
1341
+ *
1342
+ * @param {Number} latitude latitude data of the position
1343
+ * @param {Number} longitude longitude data of the position
1344
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1345
+ *
1346
+ * @example
1347
+ * ```ts
1348
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1349
+ *
1350
+ * Dynatrace.setGPSLocation(48.31518732698596, 14.305245274594471);
1351
+ * ```
1352
+ *
1353
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-gps-location
1354
+ */
1355
+ setGPSLocation(latitude: number, longitude: number, platform?: Platform): void;
1356
+ /**
1357
+ * Tells you if you opted into crash reporting. If this value is false, which means off,
1358
+ * the native agent will not report a single crash that is happening within the application.
1359
+ * This method will always return true, when the user opt-in feature is not used.
1360
+ *
1361
+ * @deprecated Please use {@link getUserPrivacyOptions} to get the crash reporting opt-in value.
1362
+ *
1363
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1364
+ * @returns {Promise<boolean>} Promise which resolves true if crash reporting is opted in.
1365
+ */
1366
+ isCrashReportingOptedIn(platform?: Platform): Promise<boolean>;
1367
+ /**
1368
+ * Allows the user to activate/deactivate crash reporting and stores the users decisions for future sessions.
1369
+ * This method can only be used, when the configuration (dynatrace.config.js) for android or iOS is using the userOptIn mode.
1370
+ *
1371
+ * @deprecated Please use {@link applyUserPrivacyOptions} to set crash reporting opt-in.
1372
+ *
1373
+ * @param {boolean} crashReporting Pass true, if you want to enable crash reporting
1374
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1375
+ */
1376
+ setCrashReportingOptedIn(crashReporting: boolean, platform?: Platform): void;
1377
+ /**
1378
+ * Returns the current {@link DataCollectionLevel} which is used by the plugin. This method will always
1379
+ * return {@link DataCollectionLevel.UserBehavior}, when the user opt-in feature is not used.
1380
+ *
1381
+ * @deprecated Please use {@link getUserPrivacyOptions} to get the current data collection level value.
1382
+ *
1383
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1384
+ * @returns promise which resolve a data collection level string
1385
+ */
1386
+ getDataCollectionLevel(platform?: Platform): Promise<DataCollectionLevel>;
1387
+ /**
1388
+ * Allows the user to set the {@link DataCollectionLevel} and stores the users decisions for future sessions.
1389
+ * This method can only be used, when the configuration for android or iOS is using the userOptIn mode.
1390
+ * When the user changes the {@link DataCollectionLevel} a new session will be started.
1391
+ *
1392
+ * @deprecated Please use {@link applyUserPrivacyOptions} to apply the current data collection level value.
1393
+ *
1394
+ * @param {DataCollectionLevel} dataCollectionLevel New data collection level
1395
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1396
+ */
1397
+ setDataCollectionLevel(dataCollectionLevel: DataCollectionLevel, platform?: Platform): void;
1398
+ /**
1399
+ * Get the current user privacy options including data collection level (Off, Performance, UserBehavior)
1400
+ * and if crash reporting opt-in is enabled
1401
+ *
1402
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1403
+ * @returns {Promise<UserPrivacyOptions>} current user privacy options
1404
+ *
1405
+ * @example
1406
+ * ```ts
1407
+ * import { Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
1408
+ *
1409
+ * let privacyOptions = await Dynatrace.getUserPrivacyOptions();
1410
+ * ```
1411
+ *
1412
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
1413
+ */
1414
+ getUserPrivacyOptions(platform?: Platform): Promise<UserPrivacyOptions>;
1415
+ /**
1416
+ * Creates a new session with the specified privacy settings and stores the privacy settings for future sessions.
1417
+ * This method can only be used, when user opt-in feature is enabled. This method call has no effect,
1418
+ * if the given privacy settings are identical to the previously specified privacy settings.
1419
+ *
1420
+ * @param {UserPrivacyOptions} userPrivacyOptions the new privacy settings from the user
1421
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1422
+ *
1423
+ * @example
1424
+ * ```ts
1425
+ * import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
1426
+ *
1427
+ * Dynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.Performance, true));
1428
+ * ```
1429
+ *
1430
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
1431
+ */
1432
+ applyUserPrivacyOptions(userPrivacyOptions: UserPrivacyOptions, platform?: Platform): void;
1433
+ /**
1434
+ * Call this function to flush all collected events immediately. To reduce network chatter, the collected events are usually
1435
+ * sent in packages where the oldest event has an age of up to 2 minutes (the default; the maximum age can be configured).
1436
+ * Using this function, you can force sending of all collected events regardless of their age.
1437
+ *
1438
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1439
+ *
1440
+ * @example
1441
+ * ```ts
1442
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1443
+ *
1444
+ * Dynatrace.flushEvents();
1445
+ * ```
1446
+ *
1447
+ */
1448
+ flushEvents(platform?: Platform): void;
1449
+ /**
1450
+ * Puts a set of http headers on every agent http request (eg. the Authorization header). It also triggers the agent to
1451
+ * reconnect to the beacon endpoint with the new headers. To clear the previous headers,
1452
+ * call the method with a null or empty value.
1453
+ *
1454
+ * @param {Map<string, string>} headers a set of http headers
1455
+ * @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
1456
+ *
1457
+ * @example
1458
+ * ```ts
1459
+ * import { Dynatrace } from '@dynatrace/react-native-plugin';
1460
+ *
1461
+ * const beaconHeaders = new Map<string, string>();
1462
+ * beaconHeaders.set('headerName', 'headerValue');
1463
+ * Dynatrace.setBeaconHeaders(beaconHeaders);
1464
+ * ```
1465
+ *
1466
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#setting-beacon-headers
1467
+ */
1468
+ setBeaconHeaders(headers?: Map<string, string> | null, platform?: Platform): void;
1469
+ }
1470
+
1471
+ declare const Dynatrace: IDynatrace;
1472
+
1473
+ /**
1474
+ * Manual startup configuration which is used for Dynatrace.start()
1475
+ * @deprecated Use ConfigurationBuilder and IConfiguration instead
1476
+ */
1477
+ declare class ManualStartupConfiguration implements IConfiguration {
1478
+ readonly beaconUrl: string;
1479
+ readonly applicationId: string;
1480
+ readonly logLevel: LogLevel;
1481
+ readonly lifecycleUpdate: boolean;
1482
+ readonly actionNamePrivacy: boolean;
1483
+ readonly bundleName?: string;
1484
+ readonly errorHandler: boolean;
1485
+ readonly reportFatalErrorAsCrash: boolean;
1486
+ readonly reportCrash: boolean;
1487
+ readonly userOptIn: boolean;
1488
+ readonly bundleVersion?: string;
1489
+ /**
1490
+ * Creates a Manual Startup configuration instance
1491
+ *
1492
+ * @param {string} beaconUrl Identifies your environment within Dynatrace. This property is mandatory for manual startup
1493
+ * @param {string} applicationId Identifies your mobile app. This property is mandatory for manual startup
1494
+ * @param {boolean} reportCrash Allows reporting React Native crashes.
1495
+ * @param {LogLevel} logLevel Allows you to choose between `LogLevel.Info` and `LogLevel.Debug`. Debug returns more logs. This is especially important when something is not functioning correctly.
1496
+ * @param {boolean} lifecycleUpdate Decide if you want to see update cycles on lifecycle actions as well. This is per default false as it creates a lot more actions.
1497
+ * @param {boolean} userOptIn Activates the privacy mode when set to `true`. User consent must be queried and set.
1498
+ * @param {boolean} actionNamePrivacy Activates a privacy mode especially for Touchables and Buttons. Setting this option to true means that a name for the control will no longer be shown, e.g. "Touch on Button". When setting a dtActionName onto the component this setting will be ignored.
1499
+ * @param {string} bundleName Will define the bundle name which will prefix internal action ids.
1500
+ * @param {string} bundleVersion Will define the bundle version which will extend bundleName signature.
1501
+ *
1502
+ * @deprecated Use ConfigurationBuilder and IConfiguration instead
1503
+ */
1504
+ constructor(beaconUrl: string, applicationId: string, reportCrash?: boolean, logLevel?: LogLevel, lifecycleUpdate?: boolean, userOptIn?: boolean, actionNamePrivacy?: boolean, bundleName?: string, bundleVersion?: string);
1505
+ toString(): string;
1506
+ }
1507
+
1508
+ /**
1509
+ * Builder for manual startup configuration used with `Dynatrace.start()`.
1510
+ */
1511
+ declare class ConfigurationBuilder {
1512
+ private beaconUrl;
1513
+ private applicationId;
1514
+ private reportCrash;
1515
+ private errorHandler;
1516
+ private reportFatalErrorAsCrash;
1517
+ private logLevel;
1518
+ private lifecycleUpdate;
1519
+ private userOptIn;
1520
+ private actionNamePrivacy;
1521
+ private bundleName;
1522
+ private bundleVersion;
1523
+ private autoStartup;
1524
+ /**
1525
+ * Creates a builder for manual startup configuration.
1526
+ *
1527
+ * @param {string} beaconUrl The beacon URL that identifies your Dynatrace environment. Mandatory for manual startup.
1528
+ * @param {string} applicationId The application ID that identifies your mobile app. Mandatory for manual startup.
1529
+ *
1530
+ * @example
1531
+ * ```ts
1532
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1533
+ *
1534
+ * const configurationBuilder = new ConfigurationBuilder("beaconUrl", "applicationId");
1535
+ * Dynatrace.start(configurationBuilder.buildConfiguration());
1536
+ * ```
1537
+ *
1538
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1539
+ */
1540
+ constructor(beaconUrl: string, applicationId: string);
1541
+ /**
1542
+ * Configures crash reporting. Defaults to `true`.
1543
+ *
1544
+ * @param {boolean} reportCrash Set to `true` to enable React Native crash reporting, `false` to disable it.
1545
+ * @returns {ConfigurationBuilder} The builder instance for method chaining
1546
+ *
1547
+ * @example
1548
+ * ```ts
1549
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1550
+ *
1551
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1552
+ * .withCrashReporting(false); // Disable crash reporting
1553
+ * await Dynatrace.start(config.buildConfiguration());
1554
+ * ```
1555
+ *
1556
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1557
+ */
1558
+ withCrashReporting(reportCrash: boolean): ConfigurationBuilder;
1559
+ /**
1560
+ * Configures the React Native error handler. Defaults to `true`.
1561
+ *
1562
+ * @param {boolean} errorHandler Set to `true` to enable the Dynatrace React Native error handler, `false` to disable it.
1563
+ * @returns {ConfigurationBuilder} The builder instance for method chaining
1564
+ *
1565
+ * @example
1566
+ * ```ts
1567
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1568
+ *
1569
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1570
+ * .withErrorHandler(false); // Disable error handler
1571
+ * await Dynatrace.start(config.buildConfiguration());
1572
+ * ```
1573
+ *
1574
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1575
+ */
1576
+ withErrorHandler(errorHandler: boolean): ConfigurationBuilder;
1577
+ /**
1578
+ * Configures how fatal errors are reported. Defaults to `true`.
1579
+ *
1580
+ * @param {boolean} reportFatalErrorAsCrash Set to `true` to report fatal errors as crashes (ends session),
1581
+ * `false` to report them as errors (session continues).
1582
+ * @returns {ConfigurationBuilder} The builder instance for method chaining
1583
+ *
1584
+ * @example
1585
+ * ```ts
1586
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1587
+ *
1588
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1589
+ * .withReportFatalErrorAsCrash(false); // Report as errors, not crashes
1590
+ * await Dynatrace.start(config.buildConfiguration());
1591
+ * ```
1592
+ *
1593
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1594
+ */
1595
+ withReportFatalErrorAsCrash(reportFatalErrorAsCrash: boolean): ConfigurationBuilder;
1596
+ /**
1597
+ * Configures the log level for the Dynatrace plugin. Defaults to `LogLevel.Info`.
1598
+ *
1599
+ * @param {LogLevel} logLevel The log level to use. Choose `LogLevel.Debug` for verbose logging when troubleshooting,
1600
+ * or `LogLevel.Info` for standard operation.
1601
+ * @returns {ConfigurationBuilder} The builder instance for method chaining
1602
+ *
1603
+ * @example
1604
+ * ```ts
1605
+ * import { ConfigurationBuilder, Dynatrace, LogLevel } from '@dynatrace/react-native-plugin';
1606
+ *
1607
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1608
+ * .withLogLevel(LogLevel.Debug); // Enable debug logging
1609
+ * await Dynatrace.start(config.buildConfiguration());
1610
+ * ```
1611
+ *
1612
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1613
+ */
1614
+ withLogLevel(logLevel: LogLevel): ConfigurationBuilder;
1615
+ /**
1616
+ * Configures tracking of component update cycles in lifecycle actions. Defaults to `false`.
1617
+ *
1618
+ * @param {boolean} lifecycleUpdate Set to `true` to track component update cycles.
1619
+ * **Warning:** This generates significantly more monitoring data.
1620
+ * @returns {ConfigurationBuilder} The builder instance for method chaining
1621
+ *
1622
+ * @example
1623
+ * ```ts
1624
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1625
+ *
1626
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1627
+ * .withLifecycleUpdate(true); // Enable lifecycle updates
1628
+ * await Dynatrace.start(config.buildConfiguration());
1629
+ * ```
1630
+ *
1631
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1632
+ */
1633
+ withLifecycleUpdate(lifecycleUpdate: boolean): ConfigurationBuilder;
1634
+ /**
1635
+ * Configures privacy mode and user opt-in. Defaults to `false`.
1636
+ *
1637
+ * @param {boolean} userOptIn Set to `true` to activate privacy mode. User consent must be queried separately
1638
+ * and configured using `Dynatrace.applyUserPrivacyOptions(userPrivacyOptions)`.
1639
+ * @returns {ConfigurationBuilder} The builder instance for method chaining
1640
+ *
1641
+ * @example
1642
+ * ```ts
1643
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1644
+ *
1645
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1646
+ * .withUserOptIn(true); // Enable privacy mode
1647
+ * await Dynatrace.start(config.buildConfiguration());
1648
+ * ```
1649
+ *
1650
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1651
+ */
1652
+ withUserOptIn(userOptIn: boolean): ConfigurationBuilder;
1653
+ /**
1654
+ * Configures action name privacy for Touchables and Buttons. Defaults to `false`.
1655
+ *
1656
+ * @param {boolean} actionNamePrivacy Set to `true` to hide specific control names and replace them with
1657
+ * generic component types (e.g., "Touch on Login" becomes "Touch on Button").
1658
+ * **Note:** This setting is ignored when a `dtActionName` prop is explicitly set on the component.
1659
+ * @returns {ConfigurationBuilder} The builder instance for method chaining
1660
+ *
1661
+ * @example
1662
+ * ```ts
1663
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1664
+ *
1665
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1666
+ * .withActionNamePrivacy(true); // Enable action name privacy
1667
+ * await Dynatrace.start(config.buildConfiguration());
1668
+ * ```
1669
+ *
1670
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1671
+ */
1672
+ withActionNamePrivacy(actionNamePrivacy: boolean): ConfigurationBuilder;
1673
+ /**
1674
+ * Configures the bundle name used as a prefix for internal action IDs.
1675
+ *
1676
+ * @param {string} bundleName The bundle name to use as a prefix for action IDs.
1677
+ * @returns {ConfigurationBuilder} The builder instance for method chaining
1678
+ *
1679
+ * @example
1680
+ * ```ts
1681
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1682
+ *
1683
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1684
+ * .withBundleName('myapp.bundle');
1685
+ * await Dynatrace.start(config.buildConfiguration());
1686
+ * ```
1687
+ *
1688
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1689
+ */
1690
+ withBundleName(bundleName: string): ConfigurationBuilder;
1691
+ /**
1692
+ * Configures the bundle version for events. This is mandatory for proper crash reporting.
1693
+ *
1694
+ * @param {string} bundleVersion The bundle version to use.
1695
+ * **Important:** Without a bundle version, source map symbolication will not work for crash reports.
1696
+ * @returns {ConfigurationBuilder} The builder instance for method chaining
1697
+ *
1698
+ * @example
1699
+ * ```ts
1700
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1701
+ *
1702
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1703
+ * .withBundleVersion('1.0.0');
1704
+ * await Dynatrace.start(config.buildConfiguration());
1705
+ * ```
1706
+ *
1707
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1708
+ */
1709
+ withBundleVersion(bundleVersion: string): ConfigurationBuilder;
1710
+ /**
1711
+ * Builds the configuration object for Dynatrace agent startup.
1712
+ *
1713
+ * @returns {IConfiguration} The built configuration object
1714
+ * @throws {Error} If beaconUrl or applicationId is empty during manual startup
1715
+ *
1716
+ * @example
1717
+ * ```ts
1718
+ * import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
1719
+ *
1720
+ * const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
1721
+ * .withLogLevel(LogLevel.Debug)
1722
+ * .withCrashReporting(true);
1723
+ * await Dynatrace.start(config.buildConfiguration());
1724
+ * ```
1725
+ *
1726
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
1727
+ */
1728
+ buildConfiguration(): IConfiguration;
1729
+ }
1730
+
1731
+ /**
1732
+ * Interface for manually measuring web request timing and performance metrics.
1733
+ * Use this to track custom HTTP requests that are not automatically instrumented.
1734
+ */
1735
+ interface IDynatraceWebRequestTiming {
1736
+ /**
1737
+ * Starts the measurement of the web request timing. Call this method immediately before
1738
+ * initiating the HTTP request.
1739
+ *
1740
+ * @example
1741
+ * ```ts
1742
+ * import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
1743
+ *
1744
+ * const action = Dynatrace.enterManualAction('API Data Fetch');
1745
+ * const url = 'https://api.example.com/data';
1746
+ * const tag = await action.getRequestTag(url);
1747
+ * const timing = new DynatraceWebRequestTiming(url, tag);
1748
+ *
1749
+ * try {
1750
+ * timing.startWebRequestTiming();
1751
+ * const axiosResponse = await axios.get(url, {
1752
+ * headers: {
1753
+ * [timing.getRequestTagHeader()]: tag
1754
+ * }
1755
+ * });
1756
+ * timing.stopWebRequestTiming(axiosResponse.status, axiosResponse.data);
1757
+ * } catch (error) {
1758
+ * timing.stopWebRequestTiming(-1, error.message);
1759
+ * } finally {
1760
+ * action.leaveAction();
1761
+ * }
1762
+ * ```
1763
+ *
1764
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
1765
+ */
1766
+ startWebRequestTiming(): void;
1767
+ /**
1768
+ * Stops the measurement of the web request timing. Call this method after the request
1769
+ * completes (either successfully or with an error). The response code and message will be
1770
+ * transferred to Dynatrace and displayed in the web UI.
1771
+ *
1772
+ * @param {number} responseCode HTTP status code of the response (e.g., 200, 404, 500)
1773
+ * @param {string} responseMessage Response message or error description
1774
+ *
1775
+ * @example
1776
+ * ```ts
1777
+ * import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
1778
+ *
1779
+ * const action = Dynatrace.enterManualAction('API Data Fetch');
1780
+ * const url = 'https://api.example.com/data';
1781
+ * const tag = await action.getRequestTag(url);
1782
+ * const timing = new DynatraceWebRequestTiming(url, tag);
1783
+ *
1784
+ * try {
1785
+ * timing.startWebRequestTiming();
1786
+ * const axiosResponse = await axios.get(url, {
1787
+ * headers: {
1788
+ * [timing.getRequestTagHeader()]: tag
1789
+ * }
1790
+ * });
1791
+ * timing.stopWebRequestTiming(axiosResponse.status, axiosResponse.statusText);
1792
+ * } catch (error) {
1793
+ * timing.stopWebRequestTiming(-1, error.message);
1794
+ * } finally {
1795
+ * action.leaveAction();
1796
+ * }
1797
+ * ```
1798
+ *
1799
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
1800
+ */
1801
+ stopWebRequestTiming(responseCode: number, responseMessage: string): void;
1802
+ /**
1803
+ * Stops the measurement of the web request timing with additional size information. Call this
1804
+ * method after the request completes to track both timing and payload sizes. The response code,
1805
+ * message, and size metrics will be transferred to Dynatrace and displayed in the web UI.
1806
+ *
1807
+ * @param {number} responseCode HTTP status code of the response (e.g., 200, 404, 500)
1808
+ * @param {string} responseMessage Response message or error description
1809
+ * @param {number} requestSize Size of the request payload in bytes
1810
+ * @param {number} responseSize Size of the response payload in bytes
1811
+ *
1812
+ * @example
1813
+ * ```ts
1814
+ * import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
1815
+ *
1816
+ * const action = Dynatrace.enterManualAction('API Data Upload');
1817
+ * const url = 'https://api.example.com/upload';
1818
+ * const tag = await action.getRequestTag(url);
1819
+ * const timing = new DynatraceWebRequestTiming(url, tag);
1820
+ * const requestData = JSON.stringify({ key: 'value' });
1821
+ *
1822
+ * try {
1823
+ * timing.startWebRequestTiming();
1824
+ * const axiosResponse = await axios.post(url, requestData, {
1825
+ * headers: {
1826
+ * [timing.getRequestTagHeader()]: tag,
1827
+ * 'Content-Type': 'application/json'
1828
+ * }
1829
+ * });
1830
+ * const responseData = JSON.stringify(axiosResponse.data);
1831
+ * timing.stopWebRequestTimingWithSize(
1832
+ * axiosResponse.status,
1833
+ * axiosResponse.statusText,
1834
+ * requestData.length,
1835
+ * responseData.length
1836
+ * );
1837
+ * } catch (error) {
1838
+ * timing.stopWebRequestTiming(-1, error.message);
1839
+ * } finally {
1840
+ * action.leaveAction();
1841
+ * }
1842
+ * ```
1843
+ *
1844
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
1845
+ */
1846
+ stopWebRequestTimingWithSize(responseCode: number, responseMessage: string, requestSize: number, responseSize: number): void;
1847
+ /**
1848
+ * Returns the request tag value that should be used as the HTTP header value for tracking.
1849
+ * This is the same tag that was provided when constructing the DynatraceWebRequestTiming instance.
1850
+ *
1851
+ * @returns {string} The request tag value to be used as the HTTP header value
1852
+ *
1853
+ * @example
1854
+ * ```ts
1855
+ * import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
1856
+ *
1857
+ * const action = Dynatrace.enterManualAction('Manual Web Request');
1858
+ * const url = 'https://api.example.com/data';
1859
+ * const tag = await action.getRequestTag(url);
1860
+ * const timing = new DynatraceWebRequestTiming(url, tag);
1861
+ *
1862
+ * // Retrieve the tag value (same as the one used during construction)
1863
+ * console.log(timing.getRequestTag());
1864
+ * ```
1865
+ *
1866
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
1867
+ */
1868
+ getRequestTag(): string;
1869
+ /**
1870
+ * Returns the HTTP header name required for request tagging. Use this header name in
1871
+ * combination with `getRequestTag()` to properly tag HTTP requests for tracking.
1872
+ *
1873
+ * @returns {string} The name of the HTTP header to use for request tagging
1874
+ *
1875
+ * @example
1876
+ * ```ts
1877
+ * import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
1878
+ *
1879
+ * const action = Dynatrace.enterManualAction('Manual Web Request');
1880
+ * const url = 'https://api.example.com/data';
1881
+ * const tag = await action.getRequestTag(url);
1882
+ * const timing = new DynatraceWebRequestTiming(url, tag);
1883
+ *
1884
+ * // Get the header name to use in HTTP requests
1885
+ * const headerName = timing.getRequestTagHeader();
1886
+ * console.log(headerName); // typically outputs: 'x-dynatrace'
1887
+ * ```
1888
+ *
1889
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
1890
+ */
1891
+ getRequestTagHeader(): string;
1892
+ }
1893
+
1894
+ /**
1895
+ * Class which gives you the option to measure a web request
1896
+ */
1897
+ declare class DynatraceWebRequestTiming implements IDynatraceWebRequestTiming {
1898
+ /**
1899
+ * The request which should be used for tagging
1900
+ */
1901
+ private readonly requestTag;
1902
+ /**
1903
+ * The URL of the request that is timed
1904
+ */
1905
+ private readonly url;
1906
+ /**
1907
+ * Constructor for creating a DynatraceWebRequestTiming
1908
+ *
1909
+ * @param {string} requestTag Request Tag for the action to be linked to
1910
+ * @param {string} url URL that should be linked
1911
+ *
1912
+ * Usage (with Axios example):
1913
+ *
1914
+ * ```ts
1915
+ * import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin'
1916
+ *
1917
+ * const action = Dynatrace.enterManualAction("Manual Web Request");
1918
+ * const tag = await action.getRequestTag(url);
1919
+ * const timing = new DynatraceWebRequestTiming(url, tag);
1920
+ *
1921
+ * try {
1922
+ * timing.startWebRequestTiming();
1923
+ * const axiosResponse = await axios.get(url, {
1924
+ * headers: {
1925
+ * timing.getRequestTagHeader(): tag
1926
+ * }
1927
+ * });
1928
+ * timing.stopWebRequestTiming(axiosResponse.status, axiosResponse.data);
1929
+ * } catch (error) {
1930
+ * timing.stopWebRequestTiming(-1, error);
1931
+ * } finally {
1932
+ * action.leaveAction();
1933
+ * }
1934
+ * ```
1935
+ *
1936
+ * @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
1937
+ */
1938
+ constructor(requestTag: string, url: string);
1939
+ startWebRequestTiming(): void;
1940
+ stopWebRequestTiming(responseCode: number, responseMessage: string): void;
1941
+ stopWebRequestTimingWithSize(responseCode: number, responseMessage: string, requestSize: number, responseSize: number): void;
1942
+ getRequestTag(): string;
1943
+ getRequestTagHeader(): string;
1944
+ }
1945
+
1946
+ /**
1947
+ * Interface which is containing the additional properties available for instrumentation.
1948
+ */
1949
+ interface IDynatraceProperties {
1950
+ /**
1951
+ * This string is changing the name of the action. So it is possible to override the action naming.
1952
+ */
1953
+ dtActionName?: string;
1954
+ /**
1955
+ * If true is passed the auto instrumentation will skip the action creation. We allow both string
1956
+ * and boolean.
1957
+ */
1958
+ dtActionIgnore?: boolean | 'true' | 'false';
1959
+ }
1960
+
1961
+ declare module 'react' {
1962
+ namespace JSX {
1963
+ interface IntrinsicAttributes extends IDynatraceProperties {
1964
+ }
1965
+ }
1966
+ }
1967
+
1968
+ export { ConfigurationBuilder, DataCollectionLevel, Dynatrace, DynatraceWebRequestTiming, HttpRequestEventBuilder, LogLevel, ManualStartupConfiguration, Platform, UserPrivacyOptions };
1969
+ export type { IConfiguration, IDynatraceAction, IDynatraceRootAction, IDynatraceWebRequestTiming, IEventModifier, JSONObject };