@datadog/mobile-react-native-code-push 1.3.0 → 1.4.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.
@@ -5,12 +5,20 @@ import type { LogEventMapper } from './logs/types';
5
5
  import type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';
6
6
  import type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';
7
7
  import type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';
8
+ import type { FirstPartyHost } from './rum/types';
8
9
  export declare enum VitalsUpdateFrequency {
9
10
  FREQUENT = "FREQUENT",
10
11
  AVERAGE = "AVERAGE",
11
12
  RARE = "RARE",
12
13
  NEVER = "NEVER"
13
14
  }
15
+ export declare type FirstPartyHostsConfiguration = (FirstPartyHost | LegacyFirstPartyHost)[];
16
+ export declare type LegacyFirstPartyHost = string;
17
+ /**
18
+ * Defaults legacy first party hosts format to Datadog first party hosts to keep
19
+ * retro-compatibility before OTel support was introduced.
20
+ */
21
+ export declare const formatFirstPartyHosts: (firstPartyHosts: FirstPartyHostsConfiguration) => FirstPartyHost[];
14
22
  /**
15
23
  * The SDK configuration class.
16
24
  * It will be used to configure the SDK functionality at initialization.
@@ -63,7 +71,7 @@ export declare class DdSdkReactNativeConfiguration {
63
71
  *
64
72
  * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.
65
73
  */
66
- firstPartyHosts: string[];
74
+ firstPartyHosts: FirstPartyHostsConfiguration;
67
75
  /**
68
76
  * Overrides the reported version of the app.
69
77
  * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.
@@ -134,7 +142,7 @@ export declare class DdSdkReactNativeConfiguration {
134
142
  export declare type AutoInstrumentationConfiguration = {
135
143
  readonly trackInteractions: boolean;
136
144
  readonly trackResources: boolean;
137
- readonly firstPartyHosts?: string[];
145
+ readonly firstPartyHosts?: FirstPartyHostsConfiguration;
138
146
  readonly resourceTracingSamplingRate?: number;
139
147
  readonly trackErrors: boolean;
140
148
  readonly logEventMapper?: LogEventMapper | null;
@@ -148,7 +156,7 @@ export declare type AutoInstrumentationConfiguration = {
148
156
  export declare type AutoInstrumentationParameters = {
149
157
  readonly trackInteractions: boolean;
150
158
  readonly trackResources: boolean;
151
- readonly firstPartyHosts: string[];
159
+ readonly firstPartyHosts: FirstPartyHostsConfiguration;
152
160
  readonly resourceTracingSamplingRate: number;
153
161
  readonly trackErrors: boolean;
154
162
  readonly logEventMapper: LogEventMapper | null;
@@ -1,4 +1,4 @@
1
- import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode } from './DdSdkReactNativeConfiguration';
1
+ import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode, VitalsUpdateFrequency } from './DdSdkReactNativeConfiguration';
2
2
  import { DdSdkReactNative } from './DdSdkReactNative';
3
3
  import { InternalLog } from './InternalLog';
4
4
  import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
@@ -7,6 +7,6 @@ import { TrackingConsent } from './TrackingConsent';
7
7
  import { DdTrace } from './foundation';
8
8
  import { DdLogs } from './logs/DdLogs';
9
9
  import { DdRum } from './rum/DdRum';
10
- import { RumActionType, ErrorSource } from './rum/types';
10
+ import { RumActionType, ErrorSource, PropagatorType } from './rum/types';
11
11
  import { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';
12
- export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
12
+ export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType };
@@ -1,4 +1,3 @@
1
- /// <reference types="react-native" />
2
1
  import type { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';
3
2
  import { EventMapper } from '../../sdk/EventMappers/EventMapper';
4
3
  import type { ResourceKind } from '../types';
@@ -7,6 +7,7 @@ export declare class DdRumUserInteractionTracking {
7
7
  private static eventsInterceptor;
8
8
  private static originalCreateElement;
9
9
  private static originalMemo;
10
+ private static originalJsx;
10
11
  private static patchCreateElementFunction;
11
12
  /**
12
13
  * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.
@@ -1,3 +1,4 @@
1
+ import type { FirstPartyHost } from '../../types';
1
2
  /**
2
3
  * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
3
4
  */
@@ -9,7 +10,7 @@ export declare class DdRumResourceTracking {
9
10
  */
10
11
  static startTracking({ tracingSamplingRate, firstPartyHosts }: {
11
12
  tracingSamplingRate: number;
12
- firstPartyHosts: string[];
13
+ firstPartyHosts: FirstPartyHost[];
13
14
  }): void;
14
15
  static stopTracking(): void;
15
16
  }
@@ -1,19 +1,45 @@
1
+ import type { PropagatorType } from '../../../types';
1
2
  import type { Hostname } from './firstPartyHosts';
3
+ import type { RegexMap } from './interfaces/RequestProxy';
2
4
  export declare type DdRumResourceTracingAttributes = {
3
5
  tracingStrategy: 'KEEP';
4
- traceId: string;
5
- spanId: string;
6
- samplingPriorityHeader: '1';
6
+ traceId: TraceId;
7
+ spanId: SpanId;
8
+ samplingPriorityHeader: '1' | '0';
7
9
  rulePsr: number;
10
+ propagatorTypes: PropagatorType[];
8
11
  } | {
9
12
  tracingStrategy: 'DISCARD';
10
13
  traceId?: void;
11
14
  spanId?: void;
12
15
  samplingPriorityHeader: '0';
13
16
  };
14
- export declare const getTracingAttributes: ({ hostname, firstPartyHostsRegex, tracingSamplingRate }: {
17
+ export declare const getTracingAttributes: ({ hostname, firstPartyHostsRegexMap, tracingSamplingRate }: {
15
18
  hostname: Hostname | null;
16
- firstPartyHostsRegex: RegExp;
19
+ firstPartyHostsRegexMap: RegexMap;
17
20
  tracingSamplingRate: number;
18
21
  }) => DdRumResourceTracingAttributes;
19
- export declare function generateTraceId(): string;
22
+ /**
23
+ * Using branded types will ensure we don't accidentally use
24
+ * traceId for spanId when generating headers.
25
+ */
26
+ export declare type TraceId = TraceIdentifier & {
27
+ _brand: 'traceId';
28
+ };
29
+ export declare type SpanId = TraceIdentifier & {
30
+ _brand: 'spanId';
31
+ };
32
+ export declare class TraceIdentifier {
33
+ private low;
34
+ private high;
35
+ constructor();
36
+ toString: (radix: number) => string;
37
+ /**
38
+ * This function pads the trace with `0`.
39
+ * It should not be used with a `length` lower than the trace, as we return the full trace in this case.
40
+ * @param radix radix for the trace
41
+ * @param length minimum length
42
+ * @returns padded string
43
+ */
44
+ toPaddedString: (radix: number, length: number) => string;
45
+ }
@@ -0,0 +1,21 @@
1
+ import type { DdRumResourceTracingAttributes } from './distributedTracing';
2
+ export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
3
+ /**
4
+ * Datadog headers
5
+ */
6
+ export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
7
+ export declare const ORIGIN_RUM = "rum";
8
+ export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
9
+ export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
10
+ /**
11
+ * OTel headers
12
+ */
13
+ export declare const TRACECONTEXT_HEADER_KEY = "traceparent";
14
+ export declare const B3_HEADER_KEY = "b3";
15
+ export declare const B3_MULTI_TRACE_ID_HEADER_KEY = "X-B3-TraceId";
16
+ export declare const B3_MULTI_SPAN_ID_HEADER_KEY = "X-B3-SpanId";
17
+ export declare const B3_MULTI_SAMPLED_HEADER_KEY = "X-B3-Sampled";
18
+ export declare const getTracingHeaders: (tracingAttributes: DdRumResourceTracingAttributes) => {
19
+ header: string;
20
+ value: string;
21
+ }[];
@@ -1,6 +1,8 @@
1
+ import type { FirstPartyHost, PropagatorType } from '../../../types';
2
+ import type { RegexMap } from './interfaces/RequestProxy';
1
3
  export declare type Hostname = {
2
4
  _type: 'Hostname';
3
5
  } & string;
4
6
  export declare const NO_MATCH_REGEX: RegExp;
5
- export declare const firstPartyHostsRegexBuilder: (firstPartyHosts: string[]) => RegExp;
6
- export declare const isHostFirstParty: (hostname: Hostname, firstPartyHostsRegex: RegExp) => boolean;
7
+ export declare const firstPartyHostsRegexMapBuilder: (firstPartyHosts: FirstPartyHost[]) => RegexMap;
8
+ export declare const getPropagatorsForHost: (hostname: Hostname, firstPartyHostsRegexMap: RegexMap) => PropagatorType[] | null;
@@ -1,7 +1,12 @@
1
+ import type { PropagatorType } from '../../../../types';
1
2
  export interface RequestProxyOptions {
2
3
  tracingSamplingRate: number;
3
- firstPartyHostsRegex: RegExp;
4
+ firstPartyHostsRegexMap: RegexMap;
4
5
  }
6
+ export declare type RegexMap = {
7
+ regex: RegExp;
8
+ propagatorType: PropagatorType;
9
+ }[];
5
10
  export declare abstract class RequestProxy {
6
11
  abstract onTrackingStart: (context: RequestProxyOptions) => void;
7
12
  abstract onTrackingStop: () => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react-native" />
2
1
  import type { ResourceKind } from '../../../../types';
3
2
  import type { DdRumResourceTracingAttributes } from '../distributedTracing';
4
3
  export interface RUMResource {
@@ -1,12 +1,6 @@
1
- /// <reference types="react-native" />
2
1
  import type { RequestProxyOptions } from '../domain/interfaces/RequestProxy';
3
2
  import { RequestProxy } from '../domain/interfaces/RequestProxy';
4
3
  import type { ResourceReporter } from './DatadogRumResource/ResourceReporter';
5
- export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
6
- export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
7
- export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
8
- export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
9
- export declare const ORIGIN_RUM = "rum";
10
4
  interface XHRProxyProviders {
11
5
  xhrType: typeof XMLHttpRequest;
12
6
  resourceReporter: ResourceReporter;
@@ -1,3 +1,2 @@
1
- /// <reference types="react-native" />
2
1
  export declare const RESOURCE_SIZE_ERROR_MESSAGE = "Couldn't get resource size, because an error occured: ";
3
2
  export declare function calculateResponseSize(xhr: XMLHttpRequest): number;
@@ -108,3 +108,20 @@ export declare enum ErrorSource {
108
108
  WEBVIEW = "WEBVIEW",
109
109
  CUSTOM = "CUSTOM"
110
110
  }
111
+ /**
112
+ * Type of instrumentation on the host.
113
+ * - DATADOG: Datadog’s propagator (`x-datadog-*`)
114
+ * - TRACECONTEXT: W3C Trace Context (`traceparent`)
115
+ * - B3: B3 single header (`b3`)
116
+ * - B3MULTI: B3 multiple headers (`X-B3-*`)
117
+ */
118
+ export declare enum PropagatorType {
119
+ DATADOG = "datadog",
120
+ TRACECONTEXT = "tracecontext",
121
+ B3 = "b3",
122
+ B3MULTI = "b3multi"
123
+ }
124
+ export declare type FirstPartyHost = {
125
+ match: string;
126
+ propagatorTypes: PropagatorType[];
127
+ };
@@ -1 +1 @@
1
- export declare const version = "1.3.0";
1
+ export declare const version = "1.4.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native-code-push",
3
- "version": "1.3.0",
3
+ "version": "1.4.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.3.0",
41
+ "@datadog/mobile-react-native": "^1.4.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": "16a9d318f9882dc85339b9b59045157d1bc62e7b"
75
+ "gitHead": "cc9c7937cecfd48720ec46852c24965f4a00bab4"
76
76
  }
@@ -20,7 +20,8 @@ jest.mock('@datadog/mobile-react-native', () => {
20
20
  return actualPackage;
21
21
  });
22
22
 
23
- const flushPromises = () => new Promise(setImmediate);
23
+ const flushPromises = () =>
24
+ new Promise(jest.requireActual('timers').setImmediate);
24
25
 
25
26
  const createCodepushPackageMock = label => ({
26
27
  label,
@@ -101,7 +102,7 @@ describe('AppCenter Codepush integration', () => {
101
102
  'env',
102
103
  'appId',
103
104
  true,
104
- true,
105
+ false,
105
106
  true
106
107
  );
107
108
  render(<DatadogCodepushProvider configuration={configuration} />);