@grafana/faro-web-sdk 1.0.0-beta3 → 1.0.0-beta4

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 (107) hide show
  1. package/README.md +14 -6
  2. package/dist/bundle/faro-web-sdk.iife.js +1 -0
  3. package/dist/{cjs → types}/config/getWebInstrumentations.d.ts +0 -0
  4. package/dist/{cjs → types}/config/index.d.ts +0 -0
  5. package/dist/{cjs → types}/config/makeCoreConfig.d.ts +0 -0
  6. package/dist/{cjs → types}/config/types.d.ts +0 -0
  7. package/dist/{cjs → types}/consts.d.ts +0 -0
  8. package/dist/{cjs → types}/index.d.ts +0 -0
  9. package/dist/{cjs → types}/initialize.d.ts +0 -0
  10. package/dist/{cjs → types}/instrumentations/console/index.d.ts +0 -0
  11. package/dist/{cjs → types}/instrumentations/console/instrumentation.d.ts +1 -1
  12. package/dist/{cjs → types}/instrumentations/console/types.d.ts +0 -0
  13. package/dist/{cjs → types}/instrumentations/errors/const.d.ts +0 -0
  14. package/dist/{cjs → types}/instrumentations/errors/getErrorDetails.d.ts +0 -0
  15. package/dist/{cjs → types}/instrumentations/errors/getValueAndTypeFromMessage.d.ts +0 -0
  16. package/dist/{cjs → types}/instrumentations/errors/index.d.ts +0 -0
  17. package/dist/{esm → types}/instrumentations/errors/instrumentation.d.ts +1 -1
  18. package/dist/{cjs → types}/instrumentations/errors/registerOnerror.d.ts +0 -0
  19. package/dist/{cjs → types}/instrumentations/errors/registerOnunhandledrejection.d.ts +0 -0
  20. package/dist/{cjs → types}/instrumentations/errors/stackFrames/buildStackFrame.d.ts +0 -0
  21. package/dist/{cjs → types}/instrumentations/errors/stackFrames/const.d.ts +0 -0
  22. package/dist/{cjs → types}/instrumentations/errors/stackFrames/getDataFromSafariExtensions.d.ts +0 -0
  23. package/dist/{cjs → types}/instrumentations/errors/stackFrames/getStackFramesFromError.d.ts +0 -0
  24. package/dist/{cjs → types}/instrumentations/errors/stackFrames/index.d.ts +0 -0
  25. package/dist/{cjs → types}/instrumentations/errors/stackFrames/parseStacktrace.d.ts +0 -0
  26. package/dist/{cjs → types}/instrumentations/errors/types.d.ts +0 -0
  27. package/dist/{cjs → types}/instrumentations/index.d.ts +0 -0
  28. package/dist/{cjs → types}/instrumentations/session/index.d.ts +0 -0
  29. package/dist/{cjs → types}/instrumentations/session/instrumentation.d.ts +0 -0
  30. package/dist/{cjs → types}/instrumentations/webVitals/index.d.ts +0 -0
  31. package/dist/{esm → types}/instrumentations/webVitals/instrumentation.d.ts +1 -1
  32. package/dist/{cjs → types}/metas/browser/index.d.ts +0 -0
  33. package/dist/{cjs → types}/metas/browser/meta.d.ts +0 -0
  34. package/dist/{cjs → types}/metas/const.d.ts +0 -0
  35. package/dist/{cjs → types}/metas/index.d.ts +0 -0
  36. package/dist/{cjs → types}/metas/page/index.d.ts +0 -0
  37. package/dist/{cjs → types}/metas/page/meta.d.ts +0 -0
  38. package/dist/{cjs → types}/session.d.ts +0 -0
  39. package/dist/{cjs → types}/transports/console/index.d.ts +0 -0
  40. package/dist/{esm → types}/transports/console/transport.d.ts +1 -1
  41. package/dist/{cjs → types}/transports/console/types.d.ts +0 -0
  42. package/dist/{cjs → types}/transports/fetch/index.d.ts +0 -0
  43. package/dist/{cjs → types}/transports/fetch/transport.d.ts +1 -1
  44. package/dist/{cjs → types}/transports/fetch/types.d.ts +0 -0
  45. package/dist/{cjs → types}/transports/index.d.ts +0 -0
  46. package/package.json +20 -12
  47. package/dist/cjs/instrumentations/errors/instrumentation.d.ts +0 -6
  48. package/dist/cjs/instrumentations/errors/registerOnerror.test.d.ts +0 -1
  49. package/dist/cjs/instrumentations/errors/registerOnerror.test.js +0 -23
  50. package/dist/cjs/instrumentations/errors/registerOnerror.test.js.map +0 -1
  51. package/dist/cjs/instrumentations/session/instrumentation.test.d.ts +0 -1
  52. package/dist/cjs/instrumentations/session/instrumentation.test.js +0 -47
  53. package/dist/cjs/instrumentations/session/instrumentation.test.js.map +0 -1
  54. package/dist/cjs/instrumentations/webVitals/instrumentation.d.ts +0 -14
  55. package/dist/cjs/transports/console/transport.d.ts +0 -10
  56. package/dist/cjs/transports/fetch/transport.test.d.ts +0 -1
  57. package/dist/cjs/transports/fetch/transport.test.js +0 -193
  58. package/dist/cjs/transports/fetch/transport.test.js.map +0 -1
  59. package/dist/esm/config/getWebInstrumentations.d.ts +0 -3
  60. package/dist/esm/config/index.d.ts +0 -3
  61. package/dist/esm/config/makeCoreConfig.d.ts +0 -3
  62. package/dist/esm/config/types.d.ts +0 -9
  63. package/dist/esm/consts.d.ts +0 -1
  64. package/dist/esm/index.d.ts +0 -12
  65. package/dist/esm/initialize.d.ts +0 -3
  66. package/dist/esm/instrumentations/console/index.d.ts +0 -2
  67. package/dist/esm/instrumentations/console/instrumentation.d.ts +0 -10
  68. package/dist/esm/instrumentations/console/types.d.ts +0 -4
  69. package/dist/esm/instrumentations/errors/const.d.ts +0 -7
  70. package/dist/esm/instrumentations/errors/getErrorDetails.d.ts +0 -3
  71. package/dist/esm/instrumentations/errors/getValueAndTypeFromMessage.d.ts +0 -1
  72. package/dist/esm/instrumentations/errors/index.d.ts +0 -3
  73. package/dist/esm/instrumentations/errors/registerOnerror.d.ts +0 -2
  74. package/dist/esm/instrumentations/errors/registerOnerror.test.d.ts +0 -1
  75. package/dist/esm/instrumentations/errors/registerOnerror.test.js +0 -21
  76. package/dist/esm/instrumentations/errors/registerOnerror.test.js.map +0 -1
  77. package/dist/esm/instrumentations/errors/registerOnunhandledrejection.d.ts +0 -2
  78. package/dist/esm/instrumentations/errors/stackFrames/buildStackFrame.d.ts +0 -2
  79. package/dist/esm/instrumentations/errors/stackFrames/const.d.ts +0 -15
  80. package/dist/esm/instrumentations/errors/stackFrames/getDataFromSafariExtensions.d.ts +0 -1
  81. package/dist/esm/instrumentations/errors/stackFrames/getStackFramesFromError.d.ts +0 -2
  82. package/dist/esm/instrumentations/errors/stackFrames/index.d.ts +0 -4
  83. package/dist/esm/instrumentations/errors/stackFrames/parseStacktrace.d.ts +0 -2
  84. package/dist/esm/instrumentations/errors/types.d.ts +0 -8
  85. package/dist/esm/instrumentations/index.d.ts +0 -6
  86. package/dist/esm/instrumentations/session/index.d.ts +0 -1
  87. package/dist/esm/instrumentations/session/instrumentation.d.ts +0 -8
  88. package/dist/esm/instrumentations/session/instrumentation.test.d.ts +0 -1
  89. package/dist/esm/instrumentations/session/instrumentation.test.js +0 -45
  90. package/dist/esm/instrumentations/session/instrumentation.test.js.map +0 -1
  91. package/dist/esm/instrumentations/webVitals/index.d.ts +0 -1
  92. package/dist/esm/metas/browser/index.d.ts +0 -1
  93. package/dist/esm/metas/browser/meta.d.ts +0 -2
  94. package/dist/esm/metas/const.d.ts +0 -2
  95. package/dist/esm/metas/index.d.ts +0 -3
  96. package/dist/esm/metas/page/index.d.ts +0 -1
  97. package/dist/esm/metas/page/meta.d.ts +0 -2
  98. package/dist/esm/session.d.ts +0 -2
  99. package/dist/esm/transports/console/index.d.ts +0 -2
  100. package/dist/esm/transports/console/types.d.ts +0 -4
  101. package/dist/esm/transports/fetch/index.d.ts +0 -2
  102. package/dist/esm/transports/fetch/transport.d.ts +0 -16
  103. package/dist/esm/transports/fetch/transport.test.d.ts +0 -1
  104. package/dist/esm/transports/fetch/transport.test.js +0 -119
  105. package/dist/esm/transports/fetch/transport.test.js.map +0 -1
  106. package/dist/esm/transports/fetch/types.d.ts +0 -13
  107. package/dist/esm/transports/index.d.ts +0 -4
@@ -1,193 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var faro_core_1 = require("@grafana/faro-core");
40
- var transport_1 = require("./transport");
41
- var fetch = jest.fn(function () { return Promise.resolve({ status: 202 }); });
42
- global.fetch = fetch;
43
- var item = {
44
- type: faro_core_1.TransportItemType.LOG,
45
- payload: {
46
- context: {},
47
- level: faro_core_1.LogLevel.INFO,
48
- message: 'hi',
49
- timestamp: new Date().toISOString(),
50
- },
51
- meta: {},
52
- };
53
- describe('FetchTransport', function () {
54
- beforeEach(function () {
55
- fetch.mockClear();
56
- });
57
- it('will send event over fetch', function () {
58
- var transport = new transport_1.FetchTransport({
59
- url: 'http://example.com/collect',
60
- });
61
- transport.send(item);
62
- expect(fetch).toHaveBeenCalledTimes(1);
63
- expect(fetch).toHaveBeenCalledWith('http://example.com/collect', {
64
- body: JSON.stringify((0, faro_core_1.getTransportBody)(item)),
65
- headers: {
66
- 'Content-Type': 'application/json',
67
- },
68
- keepalive: true,
69
- method: 'POST',
70
- });
71
- });
72
- it('will not sending events if buffer size is exhausted', function () {
73
- var transport = new transport_1.FetchTransport({
74
- url: 'http://example.com/collect',
75
- bufferSize: 3,
76
- });
77
- for (var idx = 0; idx < 6; idx++) {
78
- transport.send(item);
79
- }
80
- expect(fetch).toHaveBeenCalledTimes(3);
81
- });
82
- it('will back off on 429 for default interval if no retry-after header present', function () { return __awaiter(void 0, void 0, void 0, function () {
83
- var now, transport;
84
- return __generator(this, function (_a) {
85
- switch (_a.label) {
86
- case 0:
87
- now = Date.now();
88
- transport = new transport_1.FetchTransport({
89
- url: 'http://example.com/collect',
90
- defaultRateLimitBackoffMs: 1000,
91
- getNow: function () { return now; },
92
- });
93
- fetch.mockImplementationOnce(function () {
94
- return Promise.resolve({
95
- status: 429,
96
- headers: {
97
- get: function () { return ''; },
98
- },
99
- });
100
- });
101
- return [4 /*yield*/, transport.send(item)];
102
- case 1:
103
- _a.sent();
104
- expect(fetch).toHaveBeenCalledTimes(1);
105
- return [4 /*yield*/, transport.send(item)];
106
- case 2:
107
- _a.sent();
108
- expect(fetch).toHaveBeenCalledTimes(1);
109
- now += 1001;
110
- return [4 /*yield*/, transport.send(item)];
111
- case 3:
112
- _a.sent();
113
- expect(fetch).toHaveBeenCalledTimes(2);
114
- return [2 /*return*/];
115
- }
116
- });
117
- }); });
118
- it('will back off on 429 for default interval if retry-after header present, with delay', function () { return __awaiter(void 0, void 0, void 0, function () {
119
- var now, transport;
120
- return __generator(this, function (_a) {
121
- switch (_a.label) {
122
- case 0:
123
- now = Date.now();
124
- transport = new transport_1.FetchTransport({
125
- url: 'http://example.com/collect',
126
- defaultRateLimitBackoffMs: 1000,
127
- getNow: function () { return now; },
128
- });
129
- fetch.mockImplementationOnce(function () {
130
- return Promise.resolve({
131
- status: 429,
132
- headers: {
133
- get: function () { return '2'; },
134
- },
135
- });
136
- });
137
- return [4 /*yield*/, transport.send(item)];
138
- case 1:
139
- _a.sent();
140
- expect(fetch).toHaveBeenCalledTimes(1);
141
- now += 1001;
142
- return [4 /*yield*/, transport.send(item)];
143
- case 2:
144
- _a.sent();
145
- expect(fetch).toHaveBeenCalledTimes(1);
146
- now += 1001;
147
- return [4 /*yield*/, transport.send(item)];
148
- case 3:
149
- _a.sent();
150
- expect(fetch).toHaveBeenCalledTimes(2);
151
- return [2 /*return*/];
152
- }
153
- });
154
- }); });
155
- it('will back off on 429 for default interval if retry-after header present, with delay', function () { return __awaiter(void 0, void 0, void 0, function () {
156
- var now, transport;
157
- return __generator(this, function (_a) {
158
- switch (_a.label) {
159
- case 0:
160
- now = Date.now();
161
- transport = new transport_1.FetchTransport({
162
- url: 'http://example.com/collect',
163
- defaultRateLimitBackoffMs: 1000,
164
- getNow: function () { return now; },
165
- });
166
- fetch.mockImplementationOnce(function () {
167
- return Promise.resolve({
168
- status: 429,
169
- headers: {
170
- get: function () { return new Date(now + 3000).toISOString(); },
171
- },
172
- });
173
- });
174
- return [4 /*yield*/, transport.send(item)];
175
- case 1:
176
- _a.sent();
177
- expect(fetch).toHaveBeenCalledTimes(1);
178
- now += 1001;
179
- return [4 /*yield*/, transport.send(item)];
180
- case 2:
181
- _a.sent();
182
- expect(fetch).toHaveBeenCalledTimes(1);
183
- now += 2001;
184
- return [4 /*yield*/, transport.send(item)];
185
- case 3:
186
- _a.sent();
187
- expect(fetch).toHaveBeenCalledTimes(2);
188
- return [2 /*return*/];
189
- }
190
- });
191
- }); });
192
- });
193
- //# sourceMappingURL=transport.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.test.js","sourceRoot":"","sources":["../../../../src/transports/fetch/transport.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA4G;AAE5G,yCAA6C;AAE7C,IAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,cAAM,OAAA,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAhC,CAAgC,CAAC,CAAC;AAE7D,MAAc,CAAC,KAAK,GAAG,KAAK,CAAC;AAE9B,IAAM,IAAI,GAA4B;IACpC,IAAI,EAAE,6BAAiB,CAAC,GAAG;IAC3B,OAAO,EAAE;QACP,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,oBAAQ,CAAC,IAAI;QACpB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC;IACD,IAAI,EAAE,EAAE;CACT,CAAC;AAEF,QAAQ,CAAC,gBAAgB,EAAE;IACzB,UAAU,CAAC;QACT,KAAK,CAAC,SAAS,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE;QAC/B,IAAM,SAAS,GAAG,IAAI,0BAAc,CAAC;YACnC,GAAG,EAAE,4BAA4B;SAClC,CAAC,CAAC;QAEH,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErB,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,4BAA4B,EAAE;YAC/D,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAA,4BAAgB,EAAC,IAAI,CAAC,CAAC;YAC5C,OAAO,EAA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qFAAqF,EAAE;;;;;oBACpF,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;oBAEf,SAAS,GAAG,IAAI,0BAAc,CAAC;wBACnC,GAAG,EAAE,4BAA4B;wBACjC,yBAAyB,EAAE,IAAI;wBAC/B,MAAM,EAAE,cAAM,OAAA,GAAG,EAAH,CAAG;qBAClB,CAAC,CAAC;oBAEH,KAAK,CAAC,sBAAsB,CAAC;wBAC3B,OAAA,OAAO,CAAC,OAAO,CAAC;4BACd,MAAM,EAAE,GAAG;4BACX,OAAO,EAAE;gCACP,GAAG,EAAE,cAAM,OAAA,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,EAAlC,CAAkC;6BAC9C;yBACF,CAAC;oBALF,CAKE,CACH,CAAC;oBAEF,qBAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA;;oBAA1B,SAA0B,CAAC;oBAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;oBAEvC,GAAG,IAAI,IAAI,CAAC;oBACZ,qBAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA;;oBAA1B,SAA0B,CAAC;oBAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;oBAEvC,GAAG,IAAI,IAAI,CAAC;oBACZ,qBAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA;;oBAA1B,SAA0B,CAAC;oBAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;;;;SACxC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { getTransportBody, LogEvent, LogLevel, TransportItem, TransportItemType } from '@grafana/faro-core';\n\nimport { FetchTransport } from './transport';\n\nconst fetch = jest.fn(() => Promise.resolve({ status: 202 }));\n\n(global as any).fetch = fetch;\n\nconst item: TransportItem<LogEvent> = {\n type: TransportItemType.LOG,\n payload: {\n context: {},\n level: LogLevel.INFO,\n message: 'hi',\n timestamp: new Date().toISOString(),\n },\n meta: {},\n};\n\ndescribe('FetchTransport', () => {\n beforeEach(() => {\n fetch.mockClear();\n });\n\n it('will send event over fetch', () => {\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n });\n\n transport.send(item);\n\n expect(fetch).toHaveBeenCalledTimes(1);\n expect(fetch).toHaveBeenCalledWith('http://example.com/collect', {\n body: JSON.stringify(getTransportBody(item)),\n headers: {\n 'Content-Type': 'application/json',\n },\n keepalive: true,\n method: 'POST',\n });\n });\n\n it('will not sending events if buffer size is exhausted', () => {\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n bufferSize: 3,\n });\n\n for (let idx = 0; idx < 6; idx++) {\n transport.send(item);\n }\n\n expect(fetch).toHaveBeenCalledTimes(3);\n });\n\n it('will back off on 429 for default interval if no retry-after header present', async () => {\n let now = Date.now();\n\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n defaultRateLimitBackoffMs: 1000,\n getNow: () => now,\n });\n\n fetch.mockImplementationOnce(() =>\n Promise.resolve({\n status: 429,\n headers: {\n get: () => '',\n },\n })\n );\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(2);\n });\n\n it('will back off on 429 for default interval if retry-after header present, with delay', async () => {\n let now = Date.now();\n\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n defaultRateLimitBackoffMs: 1000,\n getNow: () => now,\n });\n\n fetch.mockImplementationOnce(() =>\n Promise.resolve({\n status: 429,\n headers: {\n get: () => '2',\n },\n })\n );\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(2);\n });\n\n it('will back off on 429 for default interval if retry-after header present, with delay', async () => {\n let now = Date.now();\n\n const transport = new FetchTransport({\n url: 'http://example.com/collect',\n defaultRateLimitBackoffMs: 1000,\n getNow: () => now,\n });\n\n fetch.mockImplementationOnce(() =>\n Promise.resolve({\n status: 429,\n headers: {\n get: () => new Date(now + 3000).toISOString(),\n },\n })\n );\n\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 1001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(1);\n\n now += 2001;\n await transport.send(item);\n expect(fetch).toHaveBeenCalledTimes(2);\n });\n});\n\nexport {};\n"]}
@@ -1,3 +0,0 @@
1
- import type { Instrumentation } from '@grafana/faro-core';
2
- import type { GetWebInstrumentationsOptions } from './types';
3
- export declare function getWebInstrumentations(options?: GetWebInstrumentationsOptions): Instrumentation[];
@@ -1,3 +0,0 @@
1
- export { getWebInstrumentations } from './getWebInstrumentations';
2
- export { makeCoreConfig } from './makeCoreConfig';
3
- export type { BrowserConfig, GetWebInstrumentationsOptions } from './types';
@@ -1,3 +0,0 @@
1
- import type { Config } from '@grafana/faro-core';
2
- import type { BrowserConfig } from './types';
3
- export declare function makeCoreConfig(browserConfig: BrowserConfig): Config | undefined;
@@ -1,9 +0,0 @@
1
- import type { Config, LogLevel } from '@grafana/faro-core';
2
- export interface BrowserConfig extends Partial<Omit<Config, 'app' | 'parseStacktrace'>>, Pick<Config, 'app'> {
3
- url?: string;
4
- apiKey?: string;
5
- }
6
- export interface GetWebInstrumentationsOptions {
7
- captureConsole?: boolean;
8
- captureConsoleDisabledLevels?: LogLevel[];
9
- }
@@ -1 +0,0 @@
1
- export declare const defaultEventDomain = "browser";
@@ -1,12 +0,0 @@
1
- export { getWebInstrumentations, makeCoreConfig } from './config';
2
- export type { BrowserConfig } from './config';
3
- export { defaultEventDomain } from './consts';
4
- export { initializeFaro } from './initialize';
5
- export { buildStackFrame, ConsoleInstrumentation, ErrorsInstrumentation, getDataFromSafariExtensions, getStackFramesFromError, parseStacktrace, WebVitalsInstrumentation, } from './instrumentations';
6
- export type { ConsoleInstrumentationOptions, ErrorEvent, ExtendedPromiseRejectionEvent } from './instrumentations';
7
- export { browserMeta, defaultMetas, pageMeta } from './metas';
8
- export { createSession } from './session';
9
- export { ConsoleTransport, FetchTransport } from './transports';
10
- export type { ClockFn, ConsoleTransportOptions, FetchTransportOptions, FetchTransportRequestOptions, } from './transports';
11
- export { faro, allLogLevels, BaseExtension, BaseInstrumentation, BaseTransport, Conventions, createInternalLogger, createPromiseBuffer, deepEqual, defaultExceptionType, defaultGlobalObjectKey, defaultInternalLoggerLevel, defaultLogLevel, getCurrentTimestamp, getInternalFaroFromGlobalObject, getTransportBody, globalObject, internalGlobalObjectKey, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isInternalFaroOnGlobalObject, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, InternalLoggerLevel, LogLevel, noop, setInternalFaroOnGlobalObject, TransportItemType, transportItemTypeToBodyKey, VERSION, } from '@grafana/faro-core';
12
- export type { Faro, API, APIEvent, BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BeforeSendHook, BufferItem, Config, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, GlobalObject, Instrumentation, Instrumentations, InternalLogger, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, Meta, MetaAPI, MetaApp, MetaAttributes, MetaBrowser, MetaGetter, MetaItem, MetaPage, Metas, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, OTELApi, Patterns, PromiseBuffer, PromiseBufferOptions, PromiseProducer, PushErrorOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, Transport, TransportBody, TransportItem, TransportItemPayload, Transports, UnpatchedConsole, } from '@grafana/faro-core';
@@ -1,3 +0,0 @@
1
- import type { Faro } from '@grafana/faro-core';
2
- import type { BrowserConfig } from './config';
3
- export declare function initializeFaro(config: BrowserConfig): Faro;
@@ -1,2 +0,0 @@
1
- export { ConsoleInstrumentation } from './instrumentation';
2
- export type { ConsoleInstrumentationOptions } from './types';
@@ -1,10 +0,0 @@
1
- import { BaseInstrumentation, LogLevel } from '@grafana/faro-core';
2
- import type { ConsoleInstrumentationOptions } from './types';
3
- export declare class ConsoleInstrumentation extends BaseInstrumentation {
4
- private options;
5
- readonly name = "@grafana/faro-web-sdk:instrumentation-console";
6
- readonly version = "1.0.0-beta3";
7
- static defaultDisabledLevels: LogLevel[];
8
- constructor(options?: ConsoleInstrumentationOptions);
9
- initialize(): void;
10
- }
@@ -1,4 +0,0 @@
1
- import type { LogLevel } from '@grafana/faro-core';
2
- export interface ConsoleInstrumentationOptions {
3
- disabledLevels?: LogLevel[];
4
- }
@@ -1,7 +0,0 @@
1
- export declare const primitiveUnhandledValue = "Non-Error promise rejection captured with value:";
2
- export declare const primitiveUnhandledType = "UnhandledRejection";
3
- export declare const domErrorType = "DOMError";
4
- export declare const domExceptionType = "DOMException";
5
- export declare const objectEventValue = "Non-Error exception captured with keys:";
6
- export declare const unknownString = "?";
7
- export declare const valueTypeRegex: RegExp;
@@ -1,3 +0,0 @@
1
- import type { ExceptionStackFrame } from '@grafana/faro-core';
2
- import type { ErrorEvent } from './types';
3
- export declare function getErrorDetails(evt: ErrorEvent): [string | undefined, string | undefined, ExceptionStackFrame[]];
@@ -1 +0,0 @@
1
- export declare function getValueAndTypeFromMessage(message: string): [string, string];
@@ -1,3 +0,0 @@
1
- export { ErrorsInstrumentation } from './instrumentation';
2
- export { buildStackFrame, getDataFromSafariExtensions, getStackFramesFromError, parseStacktrace } from './stackFrames';
3
- export type { ErrorEvent, ExtendedPromiseRejectionEvent } from './types';
@@ -1,2 +0,0 @@
1
- import { Faro } from '@grafana/faro-core';
2
- export declare function registerOnerror(faro: Faro): void;
@@ -1,21 +0,0 @@
1
- import { mockConfig, MockTransport } from '@grafana/faro-core/src/testUtils';
2
- import { initializeFaro } from '../../initialize';
3
- import { registerOnerror } from './registerOnerror';
4
- describe('registerOnerror', () => {
5
- it('will preserve the old callback', () => {
6
- let called = false;
7
- window.onerror = () => {
8
- called = true;
9
- };
10
- const transport = new MockTransport();
11
- const config = mockConfig({
12
- transports: [transport],
13
- });
14
- const faro = initializeFaro(config);
15
- registerOnerror(faro);
16
- window.onerror('boo', 'some file', 10, 10, new Error('boo'));
17
- expect(called).toBe(true);
18
- expect(transport.items).toHaveLength(1);
19
- });
20
- });
21
- //# sourceMappingURL=registerOnerror.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registerOnerror.test.js","sourceRoot":"","sources":["../../../../src/instrumentations/errors/registerOnerror.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;YACpB,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,UAAU,CAAC;YACxB,UAAU,EAAE,CAAC,SAAS,CAAC;SACxB,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACpC,eAAe,CAAC,IAAI,CAAC,CAAC;QAEtB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { mockConfig, MockTransport } from '@grafana/faro-core/src/testUtils';\n\nimport { initializeFaro } from '../../initialize';\nimport { registerOnerror } from './registerOnerror';\n\ndescribe('registerOnerror', () => {\n it('will preserve the old callback', () => {\n let called = false;\n window.onerror = () => {\n called = true;\n };\n const transport = new MockTransport();\n const config = mockConfig({\n transports: [transport],\n });\n const faro = initializeFaro(config);\n registerOnerror(faro);\n\n window.onerror('boo', 'some file', 10, 10, new Error('boo'));\n expect(called).toBe(true);\n expect(transport.items).toHaveLength(1);\n });\n});\n\nexport {};\n"]}
@@ -1,2 +0,0 @@
1
- import { Faro } from '@grafana/faro-core';
2
- export declare function registerOnunhandledrejection(faro: Faro): void;
@@ -1,2 +0,0 @@
1
- import type { ExceptionStackFrame } from '@grafana/faro-core';
2
- export declare function buildStackFrame(filename: string | undefined, func: string | undefined, lineno: number | undefined, colno: number | undefined): ExceptionStackFrame;
@@ -1,15 +0,0 @@
1
- export declare const newLineString = "\n";
2
- export declare const evalString = "eval";
3
- export declare const unknownString = "?";
4
- export declare const atString = "@";
5
- export declare const webkitLineRegex: RegExp;
6
- export declare const webkitEvalRegex: RegExp;
7
- export declare const webkitEvalString = "eval";
8
- export declare const webkitAddressAtString = "address at ";
9
- export declare const webkitAddressAtStringLength: number;
10
- export declare const firefoxLineRegex: RegExp;
11
- export declare const firefoxEvalRegex: RegExp;
12
- export declare const firefoxEvalString = " > eval";
13
- export declare const safariExtensionString = "safari-extension";
14
- export declare const safariWebExtensionString = "safari-web-extension";
15
- export declare const reactMinifiedRegex: RegExp;
@@ -1 +0,0 @@
1
- export declare function getDataFromSafariExtensions(func: string | undefined, filename: string | undefined): [string | undefined, string | undefined];
@@ -1,2 +0,0 @@
1
- import type { ExceptionStackFrame, ExtendedError } from '@grafana/faro-core';
2
- export declare function getStackFramesFromError(error: ExtendedError): ExceptionStackFrame[];
@@ -1,4 +0,0 @@
1
- export { buildStackFrame } from './buildStackFrame';
2
- export { getDataFromSafariExtensions } from './getDataFromSafariExtensions';
3
- export { getStackFramesFromError } from './getStackFramesFromError';
4
- export { parseStacktrace } from './parseStacktrace';
@@ -1,2 +0,0 @@
1
- import type { ExtendedError, Stacktrace } from '@grafana/faro-core';
2
- export declare function parseStacktrace(error: ExtendedError): Stacktrace;
@@ -1,8 +0,0 @@
1
- export interface ExtendedPromiseRejectionEvent extends PromiseRejectionEvent {
2
- detail?: {
3
- reason: PromiseRejectionEvent['reason'];
4
- };
5
- }
6
- export type ErrorEvent = (Error | Event) & {
7
- error?: Error;
8
- };
@@ -1,6 +0,0 @@
1
- export { SessionInstrumentation } from './session';
2
- export { ConsoleInstrumentation } from './console';
3
- export type { ConsoleInstrumentationOptions } from './console';
4
- export { buildStackFrame, ErrorsInstrumentation, getDataFromSafariExtensions, getStackFramesFromError, parseStacktrace, } from './errors';
5
- export type { ErrorEvent, ExtendedPromiseRejectionEvent } from './errors';
6
- export { WebVitalsInstrumentation } from './webVitals';
@@ -1 +0,0 @@
1
- export { SessionInstrumentation } from './instrumentation';
@@ -1,8 +0,0 @@
1
- import { BaseInstrumentation } from '@grafana/faro-core';
2
- export declare class SessionInstrumentation extends BaseInstrumentation {
3
- readonly name = "@grafana/faro-web-sdk:instrumentation-session";
4
- readonly version: string;
5
- private notifiedSession;
6
- private sendSessionStartEvent;
7
- initialize(): void;
8
- }
@@ -1,45 +0,0 @@
1
- import { Conventions, initializeFaro } from '@grafana/faro-core';
2
- import { mockConfig, MockTransport } from '@grafana/faro-core/src/testUtils';
3
- import { createSession } from '../../session';
4
- import { SessionInstrumentation } from './instrumentation';
5
- describe('SessionInstrumentation', () => {
6
- it('will send session start event on initialize', () => {
7
- var _a, _b;
8
- const transport = new MockTransport();
9
- const session = createSession({ foo: 'bar' });
10
- const config = mockConfig({
11
- transports: [transport],
12
- instrumentations: [new SessionInstrumentation()],
13
- session,
14
- });
15
- initializeFaro(config);
16
- expect(transport.items).toHaveLength(1);
17
- const event = transport.items[0];
18
- expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);
19
- expect((_a = event.meta.session) === null || _a === void 0 ? void 0 : _a.attributes).toEqual({ foo: 'bar' });
20
- expect((_b = event.meta.session) === null || _b === void 0 ? void 0 : _b.id).toEqual(session.id);
21
- });
22
- it('will send session new start event if setSession is called.', () => {
23
- var _a, _b;
24
- const transport = new MockTransport();
25
- const session = createSession({ foo: 'bar' });
26
- const config = mockConfig({
27
- transports: [transport],
28
- instrumentations: [new SessionInstrumentation()],
29
- session,
30
- });
31
- const faro = initializeFaro(config);
32
- expect(transport.items).toHaveLength(1);
33
- let event = transport.items[0];
34
- expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);
35
- expect((_a = event.meta.session) === null || _a === void 0 ? void 0 : _a.id).toEqual(session.id);
36
- faro.metas.add({ user: { id: 'foo' } });
37
- expect(transport.items).toHaveLength(1);
38
- const newSession = createSession();
39
- faro.api.setSession(newSession);
40
- expect(transport.items).toHaveLength(2);
41
- event = transport.items[0];
42
- expect((_b = event.meta.session) === null || _b === void 0 ? void 0 : _b.id).toEqual(session.id);
43
- });
44
- });
45
- //# sourceMappingURL=instrumentation.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumentation.test.js","sourceRoot":"","sources":["../../../../src/instrumentations/session/instrumentation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,cAAc,EAAiB,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,a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fig, MockTransport } from '@grafana/faro-core/src/testUtils';\n\nimport { createSession } from '../../session';\nimport { SessionInstrumentation } from './instrumentation';\n\ndescribe('SessionInstrumentation', () => {\n it('will send session start event on initialize', () => {\n const transport = new MockTransport();\n const session = createSession({ foo: 'bar' });\n const config = mockConfig({\n transports: [transport],\n instrumentations: [new SessionInstrumentation()],\n session,\n });\n\n initializeFaro(config);\n\n expect(transport.items).toHaveLength(1);\n\n const event = transport.items[0]! as TransportItem<EventEvent>;\n expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);\n expect(event.meta.session?.attributes).toEqual({ foo: 'bar' });\n expect(event.meta.session?.id).toEqual(session.id);\n });\n\n it('will send session new start event if setSession is called.', () => {\n const transport = new MockTransport();\n const session = createSession({ foo: 'bar' });\n const config = mockConfig({\n transports: [transport],\n instrumentations: [new SessionInstrumentation()],\n session,\n });\n\n const faro = initializeFaro(config);\n\n expect(transport.items).toHaveLength(1);\n\n let event = transport.items[0]! as TransportItem<EventEvent>;\n expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);\n expect(event.meta.session?.id).toEqual(session.id);\n\n faro.metas.add({ user: { id: 'foo' } });\n expect(transport.items).toHaveLength(1);\n\n const newSession = createSession();\n faro.api.setSession(newSession);\n expect(transport.items).toHaveLength(2);\n\n event = transport.items[0]! as TransportItem<EventEvent>;\n expect(event.meta.session?.id).toEqual(session.id);\n });\n});\n\nexport {};\n"]}
@@ -1 +0,0 @@
1
- export { WebVitalsInstrumentation } from './instrumentation';
@@ -1 +0,0 @@
1
- export { browserMeta } from './meta';
@@ -1,2 +0,0 @@
1
- import type { Meta, MetaItem } from '@grafana/faro-core';
2
- export declare const browserMeta: MetaItem<Pick<Meta, 'browser'>>;
@@ -1,2 +0,0 @@
1
- import type { MetaItem } from '@grafana/faro-core';
2
- export declare const defaultMetas: MetaItem[];
@@ -1,3 +0,0 @@
1
- export { browserMeta } from './browser';
2
- export { defaultMetas } from './const';
3
- export { pageMeta } from './page';
@@ -1 +0,0 @@
1
- export { pageMeta } from './meta';
@@ -1,2 +0,0 @@
1
- import type { Meta, MetaItem } from '@grafana/faro-core';
2
- export declare const pageMeta: MetaItem<Pick<Meta, 'page'>>;
@@ -1,2 +0,0 @@
1
- import type { MetaSession } from '@grafana/faro-core';
2
- export declare function createSession(attributes?: MetaSession['attributes']): MetaSession;
@@ -1,2 +0,0 @@
1
- export { ConsoleTransport } from './transport';
2
- export type { ConsoleTransportOptions } from './types';
@@ -1,4 +0,0 @@
1
- import type { LogLevel } from '@grafana/faro-core';
2
- export interface ConsoleTransportOptions {
3
- level?: LogLevel;
4
- }
@@ -1,2 +0,0 @@
1
- export { FetchTransport } from './transport';
2
- export type { ClockFn, FetchTransportOptions, FetchTransportRequestOptions } from './types';
@@ -1,16 +0,0 @@
1
- import { BaseTransport, PromiseBuffer } from '@grafana/faro-core';
2
- import type { TransportItem } from '@grafana/faro-core';
3
- import type { FetchTransportOptions } from './types';
4
- export declare class FetchTransport extends BaseTransport {
5
- private options;
6
- readonly name = "@grafana/faro-web-sdk:transport-fetch";
7
- readonly version = "1.0.0-beta3";
8
- promiseBuffer: PromiseBuffer<Response | void>;
9
- private rateLimitBackoffMs;
10
- private getNow;
11
- private disabledUntil;
12
- constructor(options: FetchTransportOptions);
13
- send(item: TransportItem): Promise<void>;
14
- getIgnoreUrls(): Array<string | RegExp>;
15
- private getRetryAfterDate;
16
- }
@@ -1 +0,0 @@
1
- export {};