@amplitude/analytics-core 0.2.4 → 0.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.
Files changed (160) hide show
  1. package/LICENSE +21 -0
  2. package/lib/cjs/config.d.ts +14 -15
  3. package/lib/cjs/config.d.ts.map +1 -1
  4. package/lib/cjs/config.js +38 -55
  5. package/lib/cjs/config.js.map +1 -1
  6. package/lib/cjs/core-client.d.ts +18 -12
  7. package/lib/cjs/core-client.d.ts.map +1 -1
  8. package/lib/cjs/core-client.js +87 -84
  9. package/lib/cjs/core-client.js.map +1 -1
  10. package/lib/cjs/event-bridge/event-bridge-channel.d.ts +10 -0
  11. package/lib/cjs/event-bridge/event-bridge-channel.d.ts.map +1 -0
  12. package/lib/cjs/event-bridge/event-bridge-channel.js +32 -0
  13. package/lib/cjs/event-bridge/event-bridge-channel.js.map +1 -0
  14. package/lib/cjs/event-bridge/event-bridge-container.d.ts +6 -0
  15. package/lib/cjs/event-bridge/event-bridge-container.d.ts.map +1 -0
  16. package/lib/cjs/event-bridge/event-bridge-container.js +17 -0
  17. package/lib/cjs/event-bridge/event-bridge-container.js.map +1 -0
  18. package/lib/cjs/event-bridge/event-bridge.d.ts +8 -0
  19. package/lib/cjs/event-bridge/event-bridge.d.ts.map +1 -0
  20. package/lib/cjs/event-bridge/event-bridge.js +23 -0
  21. package/lib/cjs/event-bridge/event-bridge.js.map +1 -0
  22. package/lib/cjs/event-bridge/event-channel.d.ts +5 -0
  23. package/lib/cjs/event-bridge/event-channel.d.ts.map +1 -0
  24. package/lib/cjs/event-bridge/event-channel.js +8 -0
  25. package/lib/cjs/event-bridge/event-channel.js.map +1 -0
  26. package/lib/cjs/event-bridge/event-receiver.d.ts +8 -0
  27. package/lib/cjs/event-bridge/event-receiver.d.ts.map +1 -0
  28. package/lib/cjs/event-bridge/event-receiver.js +27 -0
  29. package/lib/cjs/event-bridge/event-receiver.js.map +1 -0
  30. package/lib/cjs/index.d.ts +5 -3
  31. package/lib/cjs/index.d.ts.map +1 -1
  32. package/lib/cjs/index.js +12 -17
  33. package/lib/cjs/index.js.map +1 -1
  34. package/lib/cjs/messages.d.ts +1 -1
  35. package/lib/cjs/messages.d.ts.map +1 -1
  36. package/lib/cjs/messages.js +1 -1
  37. package/lib/cjs/messages.js.map +1 -1
  38. package/lib/cjs/plugins/destination.d.ts +2 -1
  39. package/lib/cjs/plugins/destination.d.ts.map +1 -1
  40. package/lib/cjs/plugins/destination.js +20 -6
  41. package/lib/cjs/plugins/destination.js.map +1 -1
  42. package/lib/cjs/storage/memory.d.ts +11 -0
  43. package/lib/cjs/storage/memory.d.ts.map +1 -0
  44. package/lib/cjs/storage/memory.js +29 -0
  45. package/lib/cjs/storage/memory.js.map +1 -0
  46. package/lib/cjs/timeline.d.ts +1 -0
  47. package/lib/cjs/timeline.d.ts.map +1 -1
  48. package/lib/cjs/timeline.js +16 -1
  49. package/lib/cjs/timeline.js.map +1 -1
  50. package/lib/cjs/transports/base.d.ts +7 -0
  51. package/lib/cjs/transports/base.d.ts.map +1 -0
  52. package/lib/cjs/transports/base.js +103 -0
  53. package/lib/cjs/transports/base.js.map +1 -0
  54. package/lib/cjs/utils/event-builder.d.ts +2 -2
  55. package/lib/cjs/utils/event-builder.d.ts.map +1 -1
  56. package/lib/cjs/utils/event-builder.js +3 -2
  57. package/lib/cjs/utils/event-builder.js.map +1 -1
  58. package/lib/cjs/utils/return-wrapper.d.ts +3 -0
  59. package/lib/cjs/utils/return-wrapper.d.ts.map +1 -0
  60. package/lib/cjs/utils/return-wrapper.js +16 -0
  61. package/lib/cjs/utils/return-wrapper.js.map +1 -0
  62. package/lib/cjs/utils/uuid.d.ts +10 -0
  63. package/lib/cjs/utils/uuid.d.ts.map +1 -0
  64. package/lib/cjs/utils/uuid.js +31 -0
  65. package/lib/cjs/utils/uuid.js.map +1 -0
  66. package/lib/cjs/utils/valid-properties.d.ts.map +1 -1
  67. package/lib/cjs/utils/valid-properties.js +5 -1
  68. package/lib/cjs/utils/valid-properties.js.map +1 -1
  69. package/lib/esm/config.d.ts +14 -15
  70. package/lib/esm/config.d.ts.map +1 -1
  71. package/lib/esm/config.js +25 -41
  72. package/lib/esm/config.js.map +1 -1
  73. package/lib/esm/core-client.d.ts +18 -12
  74. package/lib/esm/core-client.d.ts.map +1 -1
  75. package/lib/esm/core-client.js +87 -73
  76. package/lib/esm/core-client.js.map +1 -1
  77. package/lib/esm/event-bridge/event-bridge-channel.d.ts +10 -0
  78. package/lib/esm/event-bridge/event-bridge-channel.d.ts.map +1 -0
  79. package/lib/esm/event-bridge/event-bridge-channel.js +30 -0
  80. package/lib/esm/event-bridge/event-bridge-channel.js.map +1 -0
  81. package/lib/esm/event-bridge/event-bridge-container.d.ts +6 -0
  82. package/lib/esm/event-bridge/event-bridge-container.d.ts.map +1 -0
  83. package/lib/esm/event-bridge/event-bridge-container.js +15 -0
  84. package/lib/esm/event-bridge/event-bridge-container.js.map +1 -0
  85. package/lib/esm/event-bridge/event-bridge.d.ts +8 -0
  86. package/lib/esm/event-bridge/event-bridge.d.ts.map +1 -0
  87. package/lib/esm/event-bridge/event-bridge.js +21 -0
  88. package/lib/esm/event-bridge/event-bridge.js.map +1 -0
  89. package/lib/esm/event-bridge/event-channel.d.ts +5 -0
  90. package/lib/esm/event-bridge/event-channel.d.ts.map +1 -0
  91. package/lib/esm/event-bridge/event-channel.js +6 -0
  92. package/lib/esm/event-bridge/event-channel.js.map +1 -0
  93. package/lib/esm/event-bridge/event-receiver.d.ts +8 -0
  94. package/lib/esm/event-bridge/event-receiver.d.ts.map +1 -0
  95. package/lib/esm/event-bridge/event-receiver.js +25 -0
  96. package/lib/esm/event-bridge/event-receiver.js.map +1 -0
  97. package/lib/esm/index.d.ts +5 -3
  98. package/lib/esm/index.d.ts.map +1 -1
  99. package/lib/esm/index.js +5 -3
  100. package/lib/esm/index.js.map +1 -1
  101. package/lib/esm/messages.d.ts +1 -1
  102. package/lib/esm/messages.d.ts.map +1 -1
  103. package/lib/esm/messages.js +1 -1
  104. package/lib/esm/messages.js.map +1 -1
  105. package/lib/esm/plugins/destination.d.ts +2 -1
  106. package/lib/esm/plugins/destination.d.ts.map +1 -1
  107. package/lib/esm/plugins/destination.js +21 -7
  108. package/lib/esm/plugins/destination.js.map +1 -1
  109. package/lib/esm/storage/memory.d.ts +11 -0
  110. package/lib/esm/storage/memory.d.ts.map +1 -0
  111. package/lib/esm/storage/memory.js +27 -0
  112. package/lib/esm/storage/memory.js.map +1 -0
  113. package/lib/esm/timeline.d.ts +1 -0
  114. package/lib/esm/timeline.d.ts.map +1 -1
  115. package/lib/esm/timeline.js +14 -0
  116. package/lib/esm/timeline.js.map +1 -1
  117. package/lib/esm/transports/base.d.ts +7 -0
  118. package/lib/esm/transports/base.d.ts.map +1 -0
  119. package/lib/esm/transports/base.js +101 -0
  120. package/lib/esm/transports/base.js.map +1 -0
  121. package/lib/esm/utils/event-builder.d.ts +2 -2
  122. package/lib/esm/utils/event-builder.d.ts.map +1 -1
  123. package/lib/esm/utils/event-builder.js +3 -2
  124. package/lib/esm/utils/event-builder.js.map +1 -1
  125. package/lib/esm/utils/return-wrapper.d.ts +3 -0
  126. package/lib/esm/utils/return-wrapper.d.ts.map +1 -0
  127. package/lib/esm/utils/return-wrapper.js +13 -0
  128. package/lib/esm/utils/return-wrapper.js.map +1 -0
  129. package/lib/esm/utils/uuid.d.ts +10 -0
  130. package/lib/esm/utils/uuid.d.ts.map +1 -0
  131. package/lib/esm/utils/uuid.js +28 -0
  132. package/lib/esm/utils/uuid.js.map +1 -0
  133. package/lib/esm/utils/valid-properties.d.ts.map +1 -1
  134. package/lib/esm/utils/valid-properties.js +5 -1
  135. package/lib/esm/utils/valid-properties.js.map +1 -1
  136. package/package.json +3 -3
  137. package/lib/cjs/transports/http.d.ts +0 -5
  138. package/lib/cjs/transports/http.d.ts.map +0 -1
  139. package/lib/cjs/transports/http.js +0 -51
  140. package/lib/cjs/transports/http.js.map +0 -1
  141. package/lib/cjs/utils/response-builder.d.ts +0 -3
  142. package/lib/cjs/utils/response-builder.d.ts.map +0 -1
  143. package/lib/cjs/utils/response-builder.js +0 -74
  144. package/lib/cjs/utils/response-builder.js.map +0 -1
  145. package/lib/cjs/utils/status-builder.d.ts +0 -3
  146. package/lib/cjs/utils/status-builder.d.ts.map +0 -1
  147. package/lib/cjs/utils/status-builder.js +0 -26
  148. package/lib/cjs/utils/status-builder.js.map +0 -1
  149. package/lib/esm/transports/http.d.ts +0 -5
  150. package/lib/esm/transports/http.d.ts.map +0 -1
  151. package/lib/esm/transports/http.js +0 -49
  152. package/lib/esm/transports/http.js.map +0 -1
  153. package/lib/esm/utils/response-builder.d.ts +0 -3
  154. package/lib/esm/utils/response-builder.d.ts.map +0 -1
  155. package/lib/esm/utils/response-builder.js +0 -71
  156. package/lib/esm/utils/response-builder.js.map +0 -1
  157. package/lib/esm/utils/status-builder.d.ts +0 -3
  158. package/lib/esm/utils/status-builder.d.ts.map +0 -1
  159. package/lib/esm/utils/status-builder.js +0 -23
  160. package/lib/esm/utils/status-builder.js.map +0 -1
@@ -1,74 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.buildResponse = void 0;
3
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
4
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- var analytics_types_1 = require("@amplitude/analytics-types");
7
- var status_builder_1 = require("./status-builder");
8
- var buildResponse = function (responseJSON) {
9
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
10
- if (typeof responseJSON !== 'object') {
11
- return null;
12
- }
13
- var statusCode = responseJSON.code || 0;
14
- var status = (0, status_builder_1.buildStatus)(statusCode);
15
- switch (status) {
16
- case analytics_types_1.Status.Success:
17
- return {
18
- status: status,
19
- statusCode: statusCode,
20
- body: {
21
- eventsIngested: (_a = responseJSON.events_ingested) !== null && _a !== void 0 ? _a : 0,
22
- payloadSizeBytes: (_b = responseJSON.payload_size_bytes) !== null && _b !== void 0 ? _b : 0,
23
- serverUploadTime: (_c = responseJSON.server_upload_time) !== null && _c !== void 0 ? _c : 0,
24
- },
25
- };
26
- case analytics_types_1.Status.Invalid:
27
- return {
28
- status: status,
29
- statusCode: statusCode,
30
- body: {
31
- error: (_d = responseJSON.error) !== null && _d !== void 0 ? _d : '',
32
- missingField: (_e = responseJSON.missing_field) !== null && _e !== void 0 ? _e : '',
33
- eventsWithInvalidFields: (_f = responseJSON.events_with_invalid_fields) !== null && _f !== void 0 ? _f : {},
34
- eventsWithMissingFields: (_g = responseJSON.events_with_missing_fields) !== null && _g !== void 0 ? _g : {},
35
- epsThreshold: (_h = responseJSON.eps_threshold) !== null && _h !== void 0 ? _h : 0,
36
- exceededDailyQuotaDevices: (_j = responseJSON.exceeded_daily_quota_devices) !== null && _j !== void 0 ? _j : {},
37
- silencedDevices: (_k = responseJSON.silenced_devices) !== null && _k !== void 0 ? _k : [],
38
- silencedEvents: (_l = responseJSON.silenced_events) !== null && _l !== void 0 ? _l : [],
39
- throttledDevices: (_m = responseJSON.throttled_devices) !== null && _m !== void 0 ? _m : {},
40
- throttledEvents: (_o = responseJSON.throttled_events) !== null && _o !== void 0 ? _o : [],
41
- },
42
- };
43
- case analytics_types_1.Status.PayloadTooLarge:
44
- return {
45
- status: status,
46
- statusCode: statusCode,
47
- body: {
48
- error: (_p = responseJSON.error) !== null && _p !== void 0 ? _p : '',
49
- },
50
- };
51
- case analytics_types_1.Status.RateLimit:
52
- return {
53
- status: status,
54
- statusCode: statusCode,
55
- body: {
56
- error: (_q = responseJSON.error) !== null && _q !== void 0 ? _q : '',
57
- epsThreshold: (_r = responseJSON.eps_threshold) !== null && _r !== void 0 ? _r : 0,
58
- throttledDevices: (_s = responseJSON.throttled_devices) !== null && _s !== void 0 ? _s : {},
59
- throttledUsers: (_t = responseJSON.throttled_users) !== null && _t !== void 0 ? _t : {},
60
- exceededDailyQuotaDevices: (_u = responseJSON.exceeded_daily_quota_devices) !== null && _u !== void 0 ? _u : {},
61
- exceededDailyQuotaUsers: (_v = responseJSON.exceeded_daily_quota_users) !== null && _v !== void 0 ? _v : {},
62
- throttledEvents: (_w = responseJSON.throttled_events) !== null && _w !== void 0 ? _w : [],
63
- },
64
- };
65
- case analytics_types_1.Status.Timeout:
66
- default:
67
- return {
68
- status: status,
69
- statusCode: statusCode,
70
- };
71
- }
72
- };
73
- exports.buildResponse = buildResponse;
74
- //# sourceMappingURL=response-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"response-builder.js","sourceRoot":"","sources":["../../../src/utils/response-builder.ts"],"names":[],"mappings":";;AAAA,0DAA0D;AAC1D,4DAA4D;AAC5D,sDAAsD;AACtD,8DAA8D;AAC9D,mDAA+C;AAExC,IAAM,aAAa,GAAG,UAAC,YAAiC;;IAC7D,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;QACpC,OAAO,IAAI,CAAC;KACb;IAED,IAAM,UAAU,GAAG,YAAY,CAAC,IAAI,IAAI,CAAC,CAAC;IAC1C,IAAM,MAAM,GAAG,IAAA,4BAAW,EAAC,UAAU,CAAC,CAAC;IAEvC,QAAQ,MAAM,EAAE;QACd,KAAK,wBAAM,CAAC,OAAO;YACjB,OAAO;gBACL,MAAM,QAAA;gBACN,UAAU,YAAA;gBACV,IAAI,EAAE;oBACJ,cAAc,EAAE,MAAA,YAAY,CAAC,eAAe,mCAAI,CAAC;oBACjD,gBAAgB,EAAE,MAAA,YAAY,CAAC,kBAAkB,mCAAI,CAAC;oBACtD,gBAAgB,EAAE,MAAA,YAAY,CAAC,kBAAkB,mCAAI,CAAC;iBACvD;aACF,CAAC;QAEJ,KAAK,wBAAM,CAAC,OAAO;YACjB,OAAO;gBACL,MAAM,QAAA;gBACN,UAAU,YAAA;gBACV,IAAI,EAAE;oBACJ,KAAK,EAAE,MAAA,YAAY,CAAC,KAAK,mCAAI,EAAE;oBAC/B,YAAY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rD;aACF,CAAC;QACJ,KAAK,wBAAM,CAAC,OAAO,CAAC;QACpB;YACE,OAAO;gBACL,MAAM,QAAA;gBACN,UAAU,YAAA;aACX,CAAC;KACL;AACH,CAAC,CAAC;AAlEW,QAAA,aAAa,iBAkExB","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport { Response, Status } from '@amplitude/analytics-types';\nimport { buildStatus } from './status-builder';\n\nexport const buildResponse = (responseJSON: Record<string, any>): Response | null => {\n if (typeof responseJSON !== 'object') {\n return null;\n }\n\n const statusCode = responseJSON.code || 0;\n const status = buildStatus(statusCode);\n\n switch (status) {\n case Status.Success:\n return {\n status,\n statusCode,\n body: {\n eventsIngested: responseJSON.events_ingested ?? 0,\n payloadSizeBytes: responseJSON.payload_size_bytes ?? 0,\n serverUploadTime: responseJSON.server_upload_time ?? 0,\n },\n };\n\n case Status.Invalid:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n missingField: responseJSON.missing_field ?? '',\n eventsWithInvalidFields: responseJSON.events_with_invalid_fields ?? {},\n eventsWithMissingFields: responseJSON.events_with_missing_fields ?? {},\n epsThreshold: responseJSON.eps_threshold ?? 0,\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n silencedDevices: responseJSON.silenced_devices ?? [],\n silencedEvents: responseJSON.silenced_events ?? [],\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.PayloadTooLarge:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n },\n };\n case Status.RateLimit:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n epsThreshold: responseJSON.eps_threshold ?? 0,\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledUsers: responseJSON.throttled_users ?? {},\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n exceededDailyQuotaUsers: responseJSON.exceeded_daily_quota_users ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.Timeout:\n default:\n return {\n status,\n statusCode,\n };\n }\n};\n"]}
@@ -1,3 +0,0 @@
1
- import { Status } from '@amplitude/analytics-types';
2
- export declare function buildStatus(code: number): Status;
3
- //# sourceMappingURL=status-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"status-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/status-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0BhD"}
@@ -1,26 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.buildStatus = void 0;
3
- var analytics_types_1 = require("@amplitude/analytics-types");
4
- function buildStatus(code) {
5
- if (code >= 200 && code < 300) {
6
- return analytics_types_1.Status.Success;
7
- }
8
- if (code === 429) {
9
- return analytics_types_1.Status.RateLimit;
10
- }
11
- if (code === 413) {
12
- return analytics_types_1.Status.PayloadTooLarge;
13
- }
14
- if (code === 408) {
15
- return analytics_types_1.Status.Timeout;
16
- }
17
- if (code >= 400 && code < 500) {
18
- return analytics_types_1.Status.Invalid;
19
- }
20
- if (code >= 500) {
21
- return analytics_types_1.Status.Failed;
22
- }
23
- return analytics_types_1.Status.Unknown;
24
- }
25
- exports.buildStatus = buildStatus;
26
- //# sourceMappingURL=status-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"status-builder.js","sourceRoot":"","sources":["../../../src/utils/status-builder.ts"],"names":[],"mappings":";;AAAA,8DAAoD;AAEpD,SAAgB,WAAW,CAAC,IAAY;IACtC,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,EAAE;QAC7B,OAAO,wBAAM,CAAC,OAAO,CAAC;KACvB;IAED,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,wBAAM,CAAC,SAAS,CAAC;KACzB;IAED,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,wBAAM,CAAC,eAAe,CAAC;KAC/B;IAED,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,wBAAM,CAAC,OAAO,CAAC;KACvB;IAED,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,EAAE;QAC7B,OAAO,wBAAM,CAAC,OAAO,CAAC;KACvB;IAED,IAAI,IAAI,IAAI,GAAG,EAAE;QACf,OAAO,wBAAM,CAAC,MAAM,CAAC;KACtB;IAED,OAAO,wBAAM,CAAC,OAAO,CAAC;AACxB,CAAC;AA1BD,kCA0BC","sourcesContent":["import { Status } from '@amplitude/analytics-types';\n\nexport function buildStatus(code: number): Status {\n if (code >= 200 && code < 300) {\n return Status.Success;\n }\n\n if (code === 429) {\n return Status.RateLimit;\n }\n\n if (code === 413) {\n return Status.PayloadTooLarge;\n }\n\n if (code === 408) {\n return Status.Timeout;\n }\n\n if (code >= 400 && code < 500) {\n return Status.Invalid;\n }\n\n if (code >= 500) {\n return Status.Failed;\n }\n\n return Status.Unknown;\n}\n"]}
@@ -1,5 +0,0 @@
1
- import { Payload, Response, Transport } from '@amplitude/analytics-types';
2
- export declare class Http implements Transport {
3
- send(serverUrl: string, payload: Payload): Promise<Response | null>;
4
- }
5
- //# sourceMappingURL=http.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/transports/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAI1E,qBAAa,IAAK,YAAW,SAAS;IACpC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAwCpE"}
@@ -1,49 +0,0 @@
1
- import * as http from 'http';
2
- import { buildResponse } from '../utils/response-builder';
3
- var Http = /** @class */ (function () {
4
- function Http() {
5
- }
6
- Http.prototype.send = function (serverUrl, payload) {
7
- var url = new URL(serverUrl);
8
- var requestPayload = JSON.stringify(payload);
9
- var options = {
10
- headers: {
11
- 'Content-Type': 'application/json',
12
- 'Content-Length': Buffer.byteLength(requestPayload),
13
- },
14
- hostname: url.hostname,
15
- method: 'POST',
16
- path: url.pathname,
17
- port: url.port,
18
- protocol: url.protocol,
19
- };
20
- return new Promise(function (resolve) {
21
- var req = http.request(options, function (res) {
22
- res.setEncoding('utf8');
23
- var responsePayload = '';
24
- res.on('data', function (chunk) {
25
- responsePayload += chunk;
26
- });
27
- res.on('end', function () {
28
- if (res.complete && responsePayload.length > 0) {
29
- try {
30
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
31
- var parsedResponsePayload = JSON.parse(responsePayload);
32
- var result = buildResponse(parsedResponsePayload);
33
- resolve(result);
34
- return;
35
- }
36
- catch (_a) {
37
- resolve(null);
38
- }
39
- }
40
- });
41
- });
42
- req.on('error', buildResponse);
43
- req.end(requestPayload);
44
- });
45
- };
46
- return Http;
47
- }());
48
- export { Http };
49
- //# sourceMappingURL=http.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/transports/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;IAAA;IAyCA,CAAC;IAxCC,mBAAI,GAAJ,UAAK,SAAiB,EAAE,OAAgB;QACtC,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;QAC/B,IAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAM,OAAO,GAAG;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC;aACpD;YACD,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,CAAC,QAAQ;YAClB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;QACF,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;YACzB,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,UAAC,GAAG;gBACpC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,IAAI,eAAe,GAAG,EAAE,CAAC;gBACzB,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,UAAC,KAAa;oBAC3B,eAAe,IAAI,KAAK,CAAC;gBAC3B,CAAC,CAAC,CAAC;gBAEH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE;oBACZ,IAAI,GAAG,CAAC,QAAQ,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;wBAC9C,IAAI;4BACF,mEAAmE;4BACnE,IAAM,qBAAqB,GAAwB,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;4BAC/E,IAAM,MAAM,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC;4BACpD,OAAO,CAAC,MAAM,CAAC,CAAC;4BAChB,OAAO;yBACR;wBAAC,WAAM;4BACN,OAAO,CAAC,IAAI,CAAC,CAAC;yBACf;qBACF;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YAC/B,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IACH,WAAC;AAAD,CAAC,AAzCD,IAyCC","sourcesContent":["import { Payload, Response, Transport } from '@amplitude/analytics-types';\nimport * as http from 'http';\nimport { buildResponse } from '../utils/response-builder';\n\nexport class Http implements Transport {\n send(serverUrl: string, payload: Payload): Promise<Response | null> {\n const url = new URL(serverUrl);\n const requestPayload = JSON.stringify(payload);\n const options = {\n headers: {\n 'Content-Type': 'application/json',\n 'Content-Length': Buffer.byteLength(requestPayload),\n },\n hostname: url.hostname,\n method: 'POST',\n path: url.pathname,\n port: url.port,\n protocol: url.protocol,\n };\n return new Promise((resolve) => {\n const req = http.request(options, (res) => {\n res.setEncoding('utf8');\n let responsePayload = '';\n res.on('data', (chunk: string) => {\n responsePayload += chunk;\n });\n\n res.on('end', () => {\n if (res.complete && responsePayload.length > 0) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const parsedResponsePayload: Record<string, any> = JSON.parse(responsePayload);\n const result = buildResponse(parsedResponsePayload);\n resolve(result);\n return;\n } catch {\n resolve(null);\n }\n }\n });\n });\n req.on('error', buildResponse);\n req.end(requestPayload);\n });\n }\n}\n"]}
@@ -1,3 +0,0 @@
1
- import { Response } from '@amplitude/analytics-types';
2
- export declare const buildResponse: (responseJSON: Record<string, any>) => Response | null;
3
- //# sourceMappingURL=response-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"response-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/response-builder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAU,MAAM,4BAA4B,CAAC;AAG9D,eAAO,MAAM,aAAa,iBAAkB,OAAO,MAAM,EAAE,GAAG,CAAC,KAAG,QAAQ,GAAG,IAkE5E,CAAC"}
@@ -1,71 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
3
- /* eslint-disable @typescript-eslint/no-unsafe-call */
4
- import { Status } from '@amplitude/analytics-types';
5
- import { buildStatus } from './status-builder';
6
- export var buildResponse = function (responseJSON) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
8
- if (typeof responseJSON !== 'object') {
9
- return null;
10
- }
11
- var statusCode = responseJSON.code || 0;
12
- var status = buildStatus(statusCode);
13
- switch (status) {
14
- case Status.Success:
15
- return {
16
- status: status,
17
- statusCode: statusCode,
18
- body: {
19
- eventsIngested: (_a = responseJSON.events_ingested) !== null && _a !== void 0 ? _a : 0,
20
- payloadSizeBytes: (_b = responseJSON.payload_size_bytes) !== null && _b !== void 0 ? _b : 0,
21
- serverUploadTime: (_c = responseJSON.server_upload_time) !== null && _c !== void 0 ? _c : 0,
22
- },
23
- };
24
- case Status.Invalid:
25
- return {
26
- status: status,
27
- statusCode: statusCode,
28
- body: {
29
- error: (_d = responseJSON.error) !== null && _d !== void 0 ? _d : '',
30
- missingField: (_e = responseJSON.missing_field) !== null && _e !== void 0 ? _e : '',
31
- eventsWithInvalidFields: (_f = responseJSON.events_with_invalid_fields) !== null && _f !== void 0 ? _f : {},
32
- eventsWithMissingFields: (_g = responseJSON.events_with_missing_fields) !== null && _g !== void 0 ? _g : {},
33
- epsThreshold: (_h = responseJSON.eps_threshold) !== null && _h !== void 0 ? _h : 0,
34
- exceededDailyQuotaDevices: (_j = responseJSON.exceeded_daily_quota_devices) !== null && _j !== void 0 ? _j : {},
35
- silencedDevices: (_k = responseJSON.silenced_devices) !== null && _k !== void 0 ? _k : [],
36
- silencedEvents: (_l = responseJSON.silenced_events) !== null && _l !== void 0 ? _l : [],
37
- throttledDevices: (_m = responseJSON.throttled_devices) !== null && _m !== void 0 ? _m : {},
38
- throttledEvents: (_o = responseJSON.throttled_events) !== null && _o !== void 0 ? _o : [],
39
- },
40
- };
41
- case Status.PayloadTooLarge:
42
- return {
43
- status: status,
44
- statusCode: statusCode,
45
- body: {
46
- error: (_p = responseJSON.error) !== null && _p !== void 0 ? _p : '',
47
- },
48
- };
49
- case Status.RateLimit:
50
- return {
51
- status: status,
52
- statusCode: statusCode,
53
- body: {
54
- error: (_q = responseJSON.error) !== null && _q !== void 0 ? _q : '',
55
- epsThreshold: (_r = responseJSON.eps_threshold) !== null && _r !== void 0 ? _r : 0,
56
- throttledDevices: (_s = responseJSON.throttled_devices) !== null && _s !== void 0 ? _s : {},
57
- throttledUsers: (_t = responseJSON.throttled_users) !== null && _t !== void 0 ? _t : {},
58
- exceededDailyQuotaDevices: (_u = responseJSON.exceeded_daily_quota_devices) !== null && _u !== void 0 ? _u : {},
59
- exceededDailyQuotaUsers: (_v = responseJSON.exceeded_daily_quota_users) !== null && _v !== void 0 ? _v : {},
60
- throttledEvents: (_w = responseJSON.throttled_events) !== null && _w !== void 0 ? _w : [],
61
- },
62
- };
63
- case Status.Timeout:
64
- default:
65
- return {
66
- status: status,
67
- statusCode: statusCode,
68
- };
69
- }
70
- };
71
- //# sourceMappingURL=response-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"response-builder.js","sourceRoot":"","sources":["../../../src/utils/response-builder.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,4DAA4D;AAC5D,sDAAsD;AACtD,OAAO,EAAY,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,CAAC,IAAM,aAAa,GAAG,UAAC,YAAiC;;IAC7D,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;QACpC,OAAO,IAAI,CAAC;KACb;IAED,IAAM,UAAU,GAAG,YAAY,CAAC,IAAI,IAAI,CAAC,CAAC;IAC1C,IAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAEvC,QAAQ,MAAM,EAAE;QACd,KAAK,MAAM,CAAC,OAAO;YACjB,OAAO;gBACL,MAAM,QAAA;gBACN,UAAU,YAAA;gBACV,IAAI,EAAE;oBACJ,cAAc,EAAE,MAAA,YAAY,CAAC,eAAe,mCAAI,CAAC;oBACjD,gBAAgB,EAAE,MAAA,YAAY,CAAC,kBAAkB,mCAAI,CAAC;oBACtD,gBAAgB,EAAE,MAAA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YAAY,CAAC,eAAe,mCAAI,EAAE;oBAClD,yBAAyB,EAAE,MAAA,YAAY,CAAC,4BAA4B,mCAAI,EAAE;oBAC1E,uBAAuB,EAAE,MAAA,YAAY,CAAC,0BAA0B,mCAAI,EAAE;oBACtE,eAAe,EAAE,MAAA,YAAY,CAAC,gBAAgB,mCAAI,EAAE;iBACrD;aACF,CAAC;QACJ,KAAK,MAAM,CAAC,OAAO,CAAC;QACpB;YACE,OAAO;gBACL,MAAM,QAAA;gBACN,UAAU,YAAA;aACX,CAAC;KACL;AACH,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport { Response, Status } from '@amplitude/analytics-types';\nimport { buildStatus } from './status-builder';\n\nexport const buildResponse = (responseJSON: Record<string, any>): Response | null => {\n if (typeof responseJSON !== 'object') {\n return null;\n }\n\n const statusCode = responseJSON.code || 0;\n const status = buildStatus(statusCode);\n\n switch (status) {\n case Status.Success:\n return {\n status,\n statusCode,\n body: {\n eventsIngested: responseJSON.events_ingested ?? 0,\n payloadSizeBytes: responseJSON.payload_size_bytes ?? 0,\n serverUploadTime: responseJSON.server_upload_time ?? 0,\n },\n };\n\n case Status.Invalid:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n missingField: responseJSON.missing_field ?? '',\n eventsWithInvalidFields: responseJSON.events_with_invalid_fields ?? {},\n eventsWithMissingFields: responseJSON.events_with_missing_fields ?? {},\n epsThreshold: responseJSON.eps_threshold ?? 0,\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n silencedDevices: responseJSON.silenced_devices ?? [],\n silencedEvents: responseJSON.silenced_events ?? [],\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.PayloadTooLarge:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n },\n };\n case Status.RateLimit:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n epsThreshold: responseJSON.eps_threshold ?? 0,\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledUsers: responseJSON.throttled_users ?? {},\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n exceededDailyQuotaUsers: responseJSON.exceeded_daily_quota_users ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.Timeout:\n default:\n return {\n status,\n statusCode,\n };\n }\n};\n"]}
@@ -1,3 +0,0 @@
1
- import { Status } from '@amplitude/analytics-types';
2
- export declare function buildStatus(code: number): Status;
3
- //# sourceMappingURL=status-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"status-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/status-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0BhD"}
@@ -1,23 +0,0 @@
1
- import { Status } from '@amplitude/analytics-types';
2
- export function buildStatus(code) {
3
- if (code >= 200 && code < 300) {
4
- return Status.Success;
5
- }
6
- if (code === 429) {
7
- return Status.RateLimit;
8
- }
9
- if (code === 413) {
10
- return Status.PayloadTooLarge;
11
- }
12
- if (code === 408) {
13
- return Status.Timeout;
14
- }
15
- if (code >= 400 && code < 500) {
16
- return Status.Invalid;
17
- }
18
- if (code >= 500) {
19
- return Status.Failed;
20
- }
21
- return Status.Unknown;
22
- }
23
- //# sourceMappingURL=status-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"status-builder.js","sourceRoot":"","sources":["../../../src/utils/status-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,EAAE;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC;KACvB;IAED,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,MAAM,CAAC,SAAS,CAAC;KACzB;IAED,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,MAAM,CAAC,eAAe,CAAC;KAC/B;IAED,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,MAAM,CAAC,OAAO,CAAC;KACvB;IAED,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,EAAE;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC;KACvB;IAED,IAAI,IAAI,IAAI,GAAG,EAAE;QACf,OAAO,MAAM,CAAC,MAAM,CAAC;KACtB;IAED,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC","sourcesContent":["import { Status } from '@amplitude/analytics-types';\n\nexport function buildStatus(code: number): Status {\n if (code >= 200 && code < 300) {\n return Status.Success;\n }\n\n if (code === 429) {\n return Status.RateLimit;\n }\n\n if (code === 413) {\n return Status.PayloadTooLarge;\n }\n\n if (code === 408) {\n return Status.Timeout;\n }\n\n if (code >= 400 && code < 500) {\n return Status.Invalid;\n }\n\n if (code >= 500) {\n return Status.Failed;\n }\n\n return Status.Unknown;\n}\n"]}