@datadog/mobile-react-native 1.0.0-rc4 → 1.0.0-rc7

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 (124) hide show
  1. package/DatadogSDKReactNative.podspec +1 -1
  2. package/README.md +47 -16
  3. package/android/build.gradle +1 -1
  4. package/android/gradle.properties +4 -4
  5. package/lib/commonjs/DdSdkReactNative.js +38 -23
  6. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  7. package/lib/commonjs/DdSdkReactNativeConfiguration.js +17 -2
  8. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  9. package/lib/commonjs/InternalLog.js +56 -0
  10. package/lib/commonjs/InternalLog.js.map +1 -0
  11. package/lib/commonjs/ProxyConfiguration.js.map +1 -1
  12. package/lib/commonjs/SdkVerbosity.js +26 -0
  13. package/lib/commonjs/SdkVerbosity.js.map +1 -0
  14. package/lib/commonjs/TimeProvider.js +72 -0
  15. package/lib/commonjs/TimeProvider.js.map +1 -0
  16. package/lib/commonjs/Timer.js +10 -23
  17. package/lib/commonjs/Timer.js.map +1 -1
  18. package/lib/commonjs/TrackingConsent.js.map +1 -1
  19. package/lib/commonjs/foundation.js +51 -11
  20. package/lib/commonjs/foundation.js.map +1 -1
  21. package/lib/commonjs/index.js +34 -18
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +14 -5
  24. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  25. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +34 -23
  26. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  27. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +62 -36
  28. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
  29. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +46 -7
  30. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  31. package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
  32. package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js +34 -0
  33. package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
  34. package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +1 -1
  35. package/lib/commonjs/types.js.map +1 -1
  36. package/lib/commonjs/version.js +1 -1
  37. package/lib/commonjs/version.js.map +1 -1
  38. package/lib/module/DdSdkReactNative.js +31 -23
  39. package/lib/module/DdSdkReactNative.js.map +1 -1
  40. package/lib/module/DdSdkReactNativeConfiguration.js +18 -3
  41. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  42. package/lib/module/InternalLog.js +52 -0
  43. package/lib/module/InternalLog.js.map +1 -0
  44. package/lib/module/ProxyConfiguration.js.map +1 -1
  45. package/lib/module/SdkVerbosity.js +18 -0
  46. package/lib/module/SdkVerbosity.js.map +1 -0
  47. package/lib/module/TimeProvider.js +63 -0
  48. package/lib/module/TimeProvider.js.map +1 -0
  49. package/lib/module/Timer.js +14 -23
  50. package/lib/module/Timer.js.map +1 -1
  51. package/lib/module/TrackingConsent.js.map +1 -1
  52. package/lib/module/foundation.js +31 -11
  53. package/lib/module/foundation.js.map +1 -1
  54. package/lib/module/index.js +4 -2
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/rum/instrumentation/DdEventsInterceptor.js +11 -5
  57. package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  58. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +30 -23
  59. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  60. package/lib/module/rum/instrumentation/DdRumResourceTracking.js +57 -34
  61. package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
  62. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +41 -6
  63. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  64. package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
  65. package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js +25 -0
  66. package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
  67. package/lib/module/rum/instrumentation/TraceIdentifier.js.map +1 -1
  68. package/lib/module/types.js.map +1 -1
  69. package/lib/module/version.js +1 -1
  70. package/lib/module/version.js.map +1 -1
  71. package/lib/typescript/DdSdkReactNative.d.ts +6 -6
  72. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +15 -4
  73. package/lib/typescript/InternalLog.d.ts +11 -0
  74. package/lib/typescript/SdkVerbosity.d.ts +9 -0
  75. package/lib/typescript/TimeProvider.d.ts +20 -0
  76. package/lib/typescript/Timer.d.ts +3 -2
  77. package/lib/typescript/index.d.ts +4 -2
  78. package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +1 -0
  79. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +2 -2
  80. package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +10 -9
  81. package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -3
  82. package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +13 -3
  83. package/lib/typescript/rum/instrumentation/ShallowObjectEqualityChecker.d.ts +4 -0
  84. package/lib/typescript/version.d.ts +1 -1
  85. package/package.json +6 -3
  86. package/src/DdSdkReactNative.tsx +112 -62
  87. package/src/DdSdkReactNativeConfiguration.tsx +22 -14
  88. package/src/InternalLog.tsx +50 -0
  89. package/src/ProxyConfiguration.tsx +5 -5
  90. package/src/{NativeSdkVerbosity.tsx → SdkVerbosity.tsx} +6 -6
  91. package/src/TimeProvider.tsx +64 -0
  92. package/src/Timer.ts +20 -35
  93. package/src/TrackingConsent.tsx +3 -3
  94. package/src/__mocks__/InternalLog.tsx +9 -0
  95. package/src/__tests__/DdRumWrapper.test.tsx +40 -33
  96. package/src/__tests__/DdSdkReactNative.test.tsx +697 -513
  97. package/src/__tests__/InternalLog.test.tsx +379 -0
  98. package/src/__tests__/TimeProvider.test.tsx +75 -0
  99. package/src/__tests__/Timer.test.ts +148 -57
  100. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +151 -92
  101. package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +179 -106
  102. package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +714 -644
  103. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +239 -85
  104. package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +31 -0
  105. package/src/__tests__/rum/instrumentation/TraceIdentifier.test.tsx +13 -15
  106. package/src/__tests__/rum/instrumentation/__utils__/XMLHttpRequestMock.ts +97 -0
  107. package/src/foundation.tsx +80 -61
  108. package/src/index.tsx +15 -3
  109. package/src/rum/instrumentation/DdEventsInterceptor.tsx +51 -35
  110. package/src/rum/instrumentation/DdRumErrorTracking.tsx +61 -49
  111. package/src/rum/instrumentation/DdRumResourceTracking.tsx +307 -233
  112. package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +72 -25
  113. package/src/rum/instrumentation/DdRumXhr.tsx +21 -11
  114. package/src/rum/instrumentation/EventsInterceptor.tsx +3 -3
  115. package/src/rum/instrumentation/NoOpEventsInterceptor.tsx +2 -2
  116. package/src/rum/instrumentation/ShallowObjectEqualityChecker.ts +24 -0
  117. package/src/rum/instrumentation/TraceIdentifier.tsx +19 -19
  118. package/src/types.tsx +199 -158
  119. package/src/version.ts +1 -1
  120. package/lib/commonjs/NativeSdkVerbosity.js +0 -26
  121. package/lib/commonjs/NativeSdkVerbosity.js.map +0 -1
  122. package/lib/module/NativeSdkVerbosity.js +0 -18
  123. package/lib/module/NativeSdkVerbosity.js.map +0 -1
  124. package/lib/typescript/NativeSdkVerbosity.d.ts +0 -9
@@ -4,74 +4,120 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
- import Timer from '../Timer'
7
+ import Timer from '../Timer';
8
+
9
+ function randomInt(): number {
10
+ return Math.floor(Math.random() * 65536) + 512;
11
+ }
12
+ const mockTimeProvider = {
13
+ getTimestamp: jest.fn()
14
+ };
8
15
 
9
16
  beforeEach(() => {
10
- let performanceNowTime = 0;
11
-
12
- // @ts-ignore
13
- global.performance = {
14
- now: (): number => {
15
- const now = performanceNowTime;
16
- performanceNowTime += 6;
17
- return now;
18
- }
19
-
20
- }
21
- // step is different for performance and Date just to differentiate results
22
- // in order to understand which one was used under the hood
23
- let dateNowTime = 1000;
24
- Date.now = (): number => {
25
- const now = dateNowTime;
26
- dateNowTime += 5;
27
- return now;
28
- }
29
- })
17
+ mockTimeProvider.getTimestamp.mockClear();
18
+ });
30
19
 
31
20
  it('M use performance W available', () => {
32
21
  // GIVEN
33
- const timer = new Timer();
22
+ const expectedDuration = randomInt();
23
+ mockTimeProvider.getTimestamp
24
+ .mockReturnValueOnce({ unix: 5.0, react_native: 7.0 })
25
+ .mockReturnValueOnce({
26
+ unix: 6.0,
27
+ react_native: 7.0 + expectedDuration
28
+ });
29
+ const timer = new Timer(mockTimeProvider);
34
30
 
35
31
  // WHEN
36
32
  timer.start();
37
33
  timer.stop();
38
34
 
39
35
  // THEN
40
- expect(timer.startTime).toBe(1000);
41
- expect(timer.stopTime).toBe(1006);
42
- })
36
+ expect(timer.startTime).toBe(5.0);
37
+ expect(timer.stopTime).toBe(5.0 + expectedDuration);
38
+ });
43
39
 
44
- it('M use Date W performance object is not available', () => {
40
+ it('M use Date W performance data is never available', () => {
45
41
  // GIVEN
46
- const timer = new Timer();
47
- delete global.performance;
42
+ const expectedDuration = randomInt();
43
+ mockTimeProvider.getTimestamp
44
+ .mockReturnValueOnce({ unix: 5.0, react_native: null })
45
+ .mockReturnValueOnce({
46
+ unix: 5.0 + expectedDuration,
47
+ react_native: null
48
+ });
49
+ const timer = new Timer(mockTimeProvider);
48
50
 
49
51
  // WHEN
50
52
  timer.start();
51
53
  timer.stop();
52
54
 
53
55
  // THEN
54
- expect(timer.startTime).toBe(1000);
55
- expect(timer.stopTime).toBe(1005);
56
- })
56
+ expect(timer.startTime).toBe(5.0);
57
+ expect(timer.stopTime).toBe(5.0 + expectedDuration);
58
+ });
57
59
 
58
- it('M use Date W performance.now function is not available', () => {
60
+ it('M use Date W performance data is not available on start', () => {
59
61
  // GIVEN
60
- const timer = new Timer();
61
- delete global.performance.now;
62
+ const expectedDuration = randomInt();
63
+ mockTimeProvider.getTimestamp
64
+ .mockReturnValueOnce({ unix: 5.0, react_native: null })
65
+ .mockReturnValueOnce({
66
+ unix: 5.0 + expectedDuration,
67
+ react_native: 13.0
68
+ });
69
+ const timer = new Timer(mockTimeProvider);
70
+
71
+ // WHEN
72
+ timer.start();
73
+ timer.stop();
74
+
75
+ // THEN
76
+ expect(timer.startTime).toBe(5.0);
77
+ expect(timer.stopTime).toBe(5.0 + expectedDuration);
78
+ });
79
+
80
+ it('M use Date W performance data is not available on stop', () => {
81
+ // GIVEN
82
+ const expectedDuration = randomInt();
83
+ mockTimeProvider.getTimestamp
84
+ .mockReturnValueOnce({ unix: 5.0, react_native: 13.0 })
85
+ .mockReturnValueOnce({
86
+ unix: 5.0 + expectedDuration,
87
+ react_native: null
88
+ });
89
+ const timer = new Timer(mockTimeProvider);
62
90
 
63
91
  // WHEN
64
92
  timer.start();
65
93
  timer.stop();
66
94
 
67
95
  // THEN
68
- expect(timer.startTime).toBe(1000);
69
- expect(timer.stopTime).toBe(1005);
70
- })
96
+ expect(timer.startTime).toBe(5.0);
97
+ expect(timer.stopTime).toBe(5.0 + expectedDuration);
98
+ });
71
99
 
72
100
  it('M return duration between two ticks W performance is available', () => {
73
101
  // GIVEN
74
- const timer = new Timer();
102
+ const expectedDuration1 = randomInt();
103
+ const expectedDuration2 = randomInt();
104
+ const expectedDuration3 = randomInt();
105
+ mockTimeProvider.getTimestamp
106
+ .mockReturnValueOnce({ unix: 5.0, react_native: 13.0 })
107
+ .mockReturnValueOnce({
108
+ unix: 6.0,
109
+ react_native: 13.0 + expectedDuration1
110
+ })
111
+ .mockReturnValueOnce({
112
+ unix: 6.0,
113
+ react_native: 13.0 + expectedDuration1 + expectedDuration2
114
+ })
115
+ .mockReturnValueOnce({
116
+ unix: 6.0,
117
+ react_native:
118
+ 13.0 + expectedDuration1 + expectedDuration2 + expectedDuration3
119
+ });
120
+ const timer = new Timer(mockTimeProvider);
75
121
 
76
122
  // WHEN
77
123
  timer.start();
@@ -80,15 +126,34 @@ it('M return duration between two ticks W performance is available', () => {
80
126
  timer.stop();
81
127
 
82
128
  // THEN
83
- expect(timer.startTime).toBe(1000);
84
- expect(timer.durationBetween('first', 'second')).toBe(6);
85
- expect(timer.stopTime).toBe(1018);
86
- })
129
+ expect(timer.startTime).toBe(5.0);
130
+ expect(timer.durationBetween('first', 'second')).toBe(expectedDuration2);
131
+ expect(timer.stopTime).toBe(
132
+ 5 + expectedDuration1 + expectedDuration2 + expectedDuration3
133
+ );
134
+ });
87
135
 
88
136
  it('M return duration between two ticks W performance is not available', () => {
89
137
  // GIVEN
90
- const timer = new Timer();
91
- delete global.performance
138
+ const expectedDuration1 = randomInt();
139
+ const expectedDuration2 = randomInt();
140
+ const expectedDuration3 = randomInt();
141
+ mockTimeProvider.getTimestamp
142
+ .mockReturnValueOnce({ unix: 5.0, react_native: null })
143
+ .mockReturnValueOnce({
144
+ unix: 5.0 + expectedDuration1,
145
+ react_native: null
146
+ })
147
+ .mockReturnValueOnce({
148
+ unix: 5.0 + expectedDuration1 + expectedDuration2,
149
+ react_native: null
150
+ })
151
+ .mockReturnValueOnce({
152
+ unix:
153
+ 5.0 + expectedDuration1 + expectedDuration2 + expectedDuration3,
154
+ react_native: null
155
+ });
156
+ const timer = new Timer(mockTimeProvider);
92
157
 
93
158
  // WHEN
94
159
  timer.start();
@@ -97,15 +162,16 @@ it('M return duration between two ticks W performance is not available', () => {
97
162
  timer.stop();
98
163
 
99
164
  // THEN
100
- expect(timer.startTime).toBe(1000);
101
- expect(timer.durationBetween('first', 'second')).toBe(5);
102
- expect(timer.stopTime).toBe(1015);
103
- })
165
+ expect(timer.startTime).toBe(5.0);
166
+ expect(timer.durationBetween('first', 'second')).toBe(expectedDuration2);
167
+ expect(timer.stopTime).toBe(
168
+ 5 + expectedDuration1 + expectedDuration2 + expectedDuration3
169
+ );
170
+ });
104
171
 
105
172
  it('M record tick labels', () => {
106
173
  // GIVEN
107
174
  const timer = new Timer();
108
- delete global.performance;
109
175
 
110
176
  // WHEN
111
177
  timer.start();
@@ -115,11 +181,24 @@ it('M record tick labels', () => {
115
181
  // THEN
116
182
  expect(timer.hasTickFor('first')).toBe(true);
117
183
  expect(timer.hasTickFor('second')).toBe(false);
118
- })
184
+ });
119
185
 
120
186
  it('M return time for tick W performance is available', () => {
121
187
  // GIVEN
122
- const timer = new Timer();
188
+ const expectedDuration1 = randomInt();
189
+ const expectedDuration2 = randomInt();
190
+
191
+ mockTimeProvider.getTimestamp
192
+ .mockReturnValueOnce({ unix: 5.0, react_native: 13.0 })
193
+ .mockReturnValueOnce({
194
+ unix: 6.0,
195
+ react_native: 13.0 + expectedDuration1
196
+ })
197
+ .mockReturnValueOnce({
198
+ unix: 6.0,
199
+ react_native: 13.0 + expectedDuration1 + expectedDuration2
200
+ });
201
+ const timer = new Timer(mockTimeProvider);
123
202
 
124
203
  // WHEN
125
204
  timer.start();
@@ -127,13 +206,25 @@ it('M return time for tick W performance is available', () => {
127
206
  timer.stop();
128
207
 
129
208
  // THEN
130
- expect(timer.timeAt('first')).toBe(1006);
131
- })
209
+ expect(timer.timeAt('first')).toBe(5.0 + expectedDuration1);
210
+ });
132
211
 
133
212
  it('M return time for tick W performance is not available', () => {
134
213
  // GIVEN
135
- const timer = new Timer();
136
- delete global.performance;
214
+ const expectedDuration1 = randomInt();
215
+ const expectedDuration2 = randomInt();
216
+
217
+ mockTimeProvider.getTimestamp
218
+ .mockReturnValueOnce({ unix: 5.0, react_native: null })
219
+ .mockReturnValueOnce({
220
+ unix: 5.0 + expectedDuration1,
221
+ react_native: null
222
+ })
223
+ .mockReturnValueOnce({
224
+ unix: 5.0 + expectedDuration1 + expectedDuration2,
225
+ react_native: null
226
+ });
227
+ const timer = new Timer(mockTimeProvider);
137
228
 
138
229
  // WHEN
139
230
  timer.start();
@@ -141,5 +232,5 @@ it('M return time for tick W performance is not available', () => {
141
232
  timer.stop();
142
233
 
143
234
  // THEN
144
- expect(timer.timeAt('first')).toBe(1005);
145
- })
235
+ expect(timer.timeAt('first')).toBe(5.0 + expectedDuration1);
236
+ });
@@ -4,56 +4,71 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
- import { DdEventsInterceptor, RumActionType, UNKNOWN_TARGET_NAME } from '../../../rum/instrumentation/DdEventsInterceptor'
7
+ import { InternalLog } from '../../../InternalLog';
8
+ import { SdkVerbosity } from '../../../SdkVerbosity';
8
9
  import { DdRum } from '../../../index';
10
+ import {
11
+ DdEventsInterceptor,
12
+ RumActionType,
13
+ UNKNOWN_TARGET_NAME
14
+ } from '../../../rum/instrumentation/DdEventsInterceptor';
9
15
 
10
16
  jest.mock('../../../foundation', () => {
11
17
  return {
12
18
  DdRum: {
13
19
  // eslint-disable-next-line @typescript-eslint/no-empty-function
14
- addAction: jest.fn().mockImplementation(() => { })
15
- },
20
+ addAction: jest.fn().mockImplementation(() => {})
21
+ }
22
+ };
23
+ });
24
+
25
+ jest.mock('../../../InternalLog', () => {
26
+ return {
27
+ InternalLog: {
28
+ log: jest.fn()
29
+ }
16
30
  };
17
31
  });
18
32
 
19
33
  // Silence the warning https://github.com/facebook/react-native/issues/11094#issuecomment-263240420
20
- jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper')
21
- jest.useFakeTimers()
34
+ jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
35
+ jest.useFakeTimers();
22
36
 
23
- let testedEventsInterceptor: DdEventsInterceptor
37
+ let testedEventsInterceptor: DdEventsInterceptor;
24
38
 
25
39
  beforeEach(() => {
26
- testedEventsInterceptor = new DdEventsInterceptor()
27
- jest.setTimeout(20000)
28
- DdRum.addAction.mockReset()
29
- })
40
+ testedEventsInterceptor = new DdEventsInterceptor();
41
+ jest.setTimeout(20000);
42
+ InternalLog.log.mockReset();
43
+ DdRum.addAction.mockReset();
44
+ });
30
45
 
31
46
  it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name } ', async () => {
32
47
  // GIVEN
33
- const fakeAccessibilityLabel = "target_name"
34
- const fakeDdActionLabel = "DdActionLabel"
48
+ const fakeAccessibilityLabel = 'target_name';
49
+ const fakeDdActionLabel = 'DdActionLabel';
35
50
  const fakeArguments = {
36
51
  _targetInst: {
37
52
  memoizedProps: {
38
53
  accessibilityLabel: fakeAccessibilityLabel,
39
- "dd-action-name": fakeDdActionLabel
54
+ 'dd-action-name': fakeDdActionLabel
40
55
  }
41
56
  }
42
- }
57
+ };
43
58
 
44
59
  // WHEN
45
- testedEventsInterceptor.interceptOnPress(fakeArguments)
60
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
46
61
 
47
62
  // THEN
48
- expect(DdRum.addAction.mock.calls.length).toBe(1)
49
- expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf())
50
- expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeDdActionLabel)
51
- })
63
+ expect(DdRum.addAction.mock.calls.length).toBe(1);
64
+ expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf());
65
+ expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeDdActionLabel);
66
+ });
52
67
 
53
68
  it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name on a parent node} ', async () => {
54
69
  // GIVEN
55
- const fakeAccessibilityLabel = "target_name"
56
- const fakeDdActionLabel = "DdActionLabel"
70
+ const fakeAccessibilityLabel = 'target_name';
71
+ const fakeDdActionLabel = 'DdActionLabel';
57
72
  const fakeArguments = {
58
73
  _targetInst: {
59
74
  memoizedProps: {
@@ -62,161 +77,205 @@ it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name
62
77
  return: {
63
78
  memoizedProps: {
64
79
  accessibilityLabel: fakeAccessibilityLabel,
65
- "dd-action-name": fakeDdActionLabel
80
+ 'dd-action-name': fakeDdActionLabel
66
81
  }
67
82
  }
68
83
  }
69
- }
84
+ };
70
85
 
71
86
  // WHEN
72
- testedEventsInterceptor.interceptOnPress(fakeArguments)
87
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
73
88
 
74
89
  // THEN
75
- expect(DdRum.addAction.mock.calls.length).toBe(1)
76
- expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf())
77
- expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeDdActionLabel)
78
- })
90
+ expect(DdRum.addAction.mock.calls.length).toBe(1);
91
+ expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf());
92
+ expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeDdActionLabel);
93
+ });
79
94
 
80
95
  it('M send a RUM Action event W interceptOnPress { arguments with accessibilityLabel } ', async () => {
81
96
  // GIVEN
82
- const fakeAccessibilityLabel = "target_name"
83
- const fakeArguments = { _targetInst: { memoizedProps: { accessibilityLabel: fakeAccessibilityLabel } } }
97
+ const fakeAccessibilityLabel = 'target_name';
98
+ const fakeArguments = {
99
+ _targetInst: {
100
+ memoizedProps: { accessibilityLabel: fakeAccessibilityLabel }
101
+ }
102
+ };
84
103
 
85
104
  // WHEN
86
- testedEventsInterceptor.interceptOnPress(fakeArguments)
105
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
87
106
 
88
107
  // THEN
89
- expect(DdRum.addAction.mock.calls.length).toBe(1)
90
- expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf())
91
- expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeAccessibilityLabel)
92
- })
108
+ expect(DdRum.addAction.mock.calls.length).toBe(1);
109
+ expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf());
110
+ expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeAccessibilityLabel);
111
+ });
93
112
 
94
113
  it('M send only one RUM Action event W interceptOnPress { called multiple times for same target } ', async () => {
95
114
  // GIVEN
96
- const fakeAccessibilityLabel = "target_name"
97
- const fakeArguments = { _targetInst: { memoizedProps: { accessibilityLabel: fakeAccessibilityLabel } } }
115
+ const fakeAccessibilityLabel = 'target_name';
116
+ const fakeArguments = {
117
+ _targetInst: {
118
+ memoizedProps: { accessibilityLabel: fakeAccessibilityLabel }
119
+ }
120
+ };
98
121
 
99
122
  // WHEN
100
- testedEventsInterceptor.interceptOnPress(fakeArguments)
101
- testedEventsInterceptor.interceptOnPress(fakeArguments)
102
- testedEventsInterceptor.interceptOnPress(fakeArguments)
103
- testedEventsInterceptor.interceptOnPress(fakeArguments)
123
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
124
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
125
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
126
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
104
127
 
105
128
  // THEN
106
- expect(DdRum.addAction.mock.calls.length).toBe(1)
107
- expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf())
108
- expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeAccessibilityLabel)
109
- })
110
-
129
+ expect(DdRum.addAction.mock.calls.length).toBe(1);
130
+ expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf());
131
+ expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeAccessibilityLabel);
132
+ });
111
133
 
112
134
  it('M send a RUM Action event W interceptOnPress { no accessibilityLabel arguments, elementType is string } ', async () => {
113
135
  // GIVEN
114
- const fakeElementType = "element_type"
115
- const fakeArguments = { _targetInst: { elementType: fakeElementType } }
136
+ const fakeElementType = 'element_type';
137
+ const fakeArguments = { _targetInst: { elementType: fakeElementType } };
116
138
 
117
139
  // WHEN
118
- testedEventsInterceptor.interceptOnPress(fakeArguments)
140
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
119
141
 
120
142
  // THEN
121
- expect(DdRum.addAction.mock.calls.length).toBe(1)
122
- expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf())
123
- expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeElementType)
124
- })
143
+ expect(DdRum.addAction.mock.calls.length).toBe(1);
144
+ expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf());
145
+ expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeElementType);
146
+ });
125
147
 
126
148
  it('M send a RUM Action event W interceptOnPress { no accessibilityLabel arguments, elementType is object with name property } ', async () => {
127
149
  // GIVEN
128
- const fakeElementType = "element_type"
129
- const fakeArguments = { _targetInst: { elementType: { name: fakeElementType } } }
150
+ const fakeElementType = 'element_type';
151
+ const fakeArguments = {
152
+ _targetInst: { elementType: { name: fakeElementType } }
153
+ };
130
154
 
131
155
  // WHEN
132
- testedEventsInterceptor.interceptOnPress(fakeArguments)
156
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
133
157
 
134
158
  // THEN
135
- expect(DdRum.addAction.mock.calls.length).toBe(1)
136
- expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf())
137
- expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeElementType)
138
- })
159
+ expect(DdRum.addAction.mock.calls.length).toBe(1);
160
+ expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf());
161
+ expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeElementType);
162
+ });
139
163
 
140
164
  it('M send a RUM Action event W interceptOnPress { no accessibilityLabel, no elementType } ', async () => {
141
165
  // GIVEN
142
- const fakeArguments = { _targetInst: {} }
166
+ const fakeArguments = { _targetInst: {} };
143
167
 
144
168
  // WHEN
145
- testedEventsInterceptor.interceptOnPress(fakeArguments)
169
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
146
170
 
147
171
  // THEN
148
- expect(DdRum.addAction.mock.calls.length).toBe(1)
149
- expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf())
150
- expect(DdRum.addAction.mock.calls[0][1]).toBe(UNKNOWN_TARGET_NAME)
151
- })
172
+ expect(DdRum.addAction.mock.calls.length).toBe(1);
173
+ expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP.valueOf());
174
+ expect(DdRum.addAction.mock.calls[0][1]).toBe(UNKNOWN_TARGET_NAME);
175
+ });
152
176
 
153
177
  it('M do nothing W interceptOnPress { invalid arguments - empty object } ', async () => {
154
178
  // GIVEN
155
- const fakeArguments = {}
179
+ const fakeArguments = {};
156
180
 
157
181
  // WHEN
158
- testedEventsInterceptor.interceptOnPress(fakeArguments)
182
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
159
183
 
160
184
  // THEN
161
- expect(DdRum.addAction.mock.calls.length).toBe(0)
162
- })
185
+ expect(DdRum.addAction.mock.calls.length).toBe(0);
186
+ expect(InternalLog.log.mock.calls.length).toBe(1);
187
+ expect(InternalLog.log.mock.calls[0][0]).toBe(
188
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
189
+ );
190
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
191
+ });
163
192
 
164
193
  it('M do nothing W interceptOnPress { invalid arguments - array } ', async () => {
165
194
  // GIVEN
166
- const fakeArguments = []
195
+ const fakeArguments = [];
167
196
 
168
197
  // WHEN
169
- testedEventsInterceptor.interceptOnPress(fakeArguments)
198
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
170
199
 
171
200
  // THEN
172
- expect(DdRum.addAction.mock.calls.length).toBe(0)
173
- })
201
+ expect(DdRum.addAction.mock.calls.length).toBe(0);
202
+ expect(InternalLog.log.mock.calls.length).toBe(1);
203
+ expect(InternalLog.log.mock.calls[0][0]).toBe(
204
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
205
+ );
206
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
207
+ });
174
208
 
175
209
  it('M do nothing W interceptOnPress { invalid arguments - nested array } ', async () => {
176
210
  // GIVEN
177
- const fakeArguments = [[]]
211
+ const fakeArguments = [[]];
178
212
 
179
213
  // WHEN
180
- testedEventsInterceptor.interceptOnPress(fakeArguments)
214
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
181
215
 
182
216
  // THEN
183
- expect(DdRum.addAction.mock.calls.length).toBe(0)
184
- })
217
+ expect(DdRum.addAction.mock.calls.length).toBe(0);
218
+ expect(InternalLog.log.mock.calls.length).toBe(1);
219
+ expect(InternalLog.log.mock.calls[0][0]).toBe(
220
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
221
+ );
222
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
223
+ });
185
224
 
186
225
  it('M do nothing W interceptOnPress { invalid arguments - undefined } ', async () => {
187
226
  // GIVEN
188
- const fakeArguments = undefined
227
+ const fakeArguments = undefined;
189
228
 
190
229
  // WHEN
191
- testedEventsInterceptor.interceptOnPress(fakeArguments)
230
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
192
231
 
193
232
  // THEN
194
- expect(DdRum.addAction.mock.calls.length).toBe(0)
195
- })
233
+ expect(DdRum.addAction.mock.calls.length).toBe(0);
234
+ expect(InternalLog.log.mock.calls.length).toBe(1);
235
+ expect(InternalLog.log.mock.calls[0][0]).toBe(
236
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
237
+ );
238
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
239
+ });
196
240
 
197
241
  it('M do nothing W interceptOnPress { invalid arguments - null } ', async () => {
198
242
  // GIVEN
199
- const fakeArguments = null
243
+ const fakeArguments = null;
200
244
 
201
245
  // WHEN
202
- testedEventsInterceptor.interceptOnPress(fakeArguments)
246
+ testedEventsInterceptor.interceptOnPress(fakeArguments);
203
247
 
204
248
  // THEN
205
- expect(DdRum.addAction.mock.calls.length).toBe(0)
206
- })
249
+ expect(DdRum.addAction.mock.calls.length).toBe(0);
250
+ expect(InternalLog.log.mock.calls.length).toBe(1);
251
+ expect(InternalLog.log.mock.calls[0][0]).toBe(
252
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
253
+ );
254
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
255
+ });
207
256
 
208
257
  it('M do nothing W interceptOnPress { invalid arguments - wrong object } ', async () => {
209
258
  // WHEN
210
- testedEventsInterceptor.interceptOnPress({ 'a': 'b' })
259
+ testedEventsInterceptor.interceptOnPress({ a: 'b' });
211
260
 
212
261
  // THEN
213
- expect(DdRum.addAction.mock.calls.length).toBe(0)
214
- })
262
+ expect(DdRum.addAction.mock.calls.length).toBe(0);
263
+ expect(InternalLog.log.mock.calls.length).toBe(1);
264
+ expect(InternalLog.log.mock.calls[0][0]).toBe(
265
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
266
+ );
267
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
268
+ });
215
269
 
216
270
  it('M do nothing W interceptOnPress { no arguments call } ', async () => {
217
271
  // WHEN
218
- testedEventsInterceptor.interceptOnPress()
272
+ testedEventsInterceptor.interceptOnPress();
219
273
 
220
274
  // THEN
221
- expect(DdRum.addAction.mock.calls.length).toBe(0)
222
- })
275
+ expect(DdRum.addAction.mock.calls.length).toBe(0);
276
+ expect(InternalLog.log.mock.calls.length).toBe(1);
277
+ expect(InternalLog.log.mock.calls[0][0]).toBe(
278
+ DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE
279
+ );
280
+ expect(InternalLog.log.mock.calls[0][1]).toBe(SdkVerbosity.WARN);
281
+ });