@hawk.so/types 0.1.31 → 0.1.32-rc.2

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.
@@ -3,10 +3,10 @@ import { AffectedUser } from './affectedUser';
3
3
  import { EventAddons } from './addons';
4
4
  import { Json } from '../../utils';
5
5
  /**
6
- * Information about event
6
+ * Information about event (Payload of the event)
7
7
  * That object will be send as 'payload' to the Collector
8
8
  */
9
- export interface EventData<CatcherAddons extends EventAddons> {
9
+ export interface EventData<Addons extends EventAddons> {
10
10
  /**
11
11
  * Event title
12
12
  */
@@ -23,7 +23,7 @@ export interface EventData<CatcherAddons extends EventAddons> {
23
23
  /**
24
24
  * Catcher-specific information
25
25
  */
26
- addons?: CatcherAddons | string;
26
+ addons?: Addons | string;
27
27
  /**
28
28
  * Current release (aka version, revision) of an application
29
29
  */
@@ -45,18 +45,12 @@ export interface EventData<CatcherAddons extends EventAddons> {
45
45
  * Event accepted and processed by Collector.
46
46
  * It sets the timestamp to the event payload.
47
47
  */
48
- export interface EventDataAccepted<EventAddons> extends EventData<EventAddons> {
49
- /**
50
- * Occurrence time
51
- * Unix timestamp in seconds (example: 1567009247.576)
52
- * (Set by the Collector)
53
- */
54
- timestamp: number;
48
+ export interface EventDataAccepted<Addons extends EventAddons> extends EventData<Addons> {
55
49
  }
56
50
  /**
57
51
  * Event data with decoded unsafe fields
58
52
  */
59
- export interface DecodedEventData<EventAddons> extends EventDataAccepted<EventAddons> {
53
+ export interface DecodedEventData<Addons extends EventAddons> extends EventDataAccepted<Addons> {
60
54
  /**
61
55
  * Decoded context
62
56
  */
@@ -64,7 +58,7 @@ export interface DecodedEventData<EventAddons> extends EventDataAccepted<EventAd
64
58
  /**
65
59
  * Decoded addons
66
60
  */
67
- addons?: EventAddons;
61
+ addons?: Addons;
68
62
  }
69
63
  /**
70
64
  * Event data with encoded unsafe fields
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Interface representing the structure of log CatcherMessage payload.
3
+ * This interface is for payload of the CatcherMessages with CatcherType 'logs/*'.
4
+ */
5
+ export interface LogData {
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Interface representing the structure of performance CatcherMessage payload.
3
+ * This interface is for payload of the CatcherMessages with CatcherType 'performance'.
4
+ */
5
+ export interface PerformanceData {
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +1,42 @@
1
- import { EventData } from "../base/event/event";
2
- import { EventAddons } from "../base/event/addons";
1
+ import { EventData } from '../base/event/event';
2
+ import { LogData } from '../base/log/log';
3
+ import { PerformanceData } from '../base/performance/performance';
4
+ import type { JavaScriptAddons, PhpAddons, NodeJSAddons, GoAddons, PythonAddons } from '../base/event/addons';
3
5
  /**
4
- * Structure describing a message sending by Catcher
6
+ * Type that represents all supported Catcher message types for events
5
7
  */
6
- export default interface CatcherMessage<CatcherAddons extends EventAddons> {
8
+ declare type ErrorsCatcherType = 'errors/javascript' | 'errors/php' | 'errors/nodejs' | 'errors/go' | 'errors/python';
9
+ /**
10
+ * Type that represents all supported Catcher message types for logs
11
+ * @todo implement log catcher types
12
+ */
13
+ declare type LogsCatcherType = 'logs/javascript';
14
+ /**
15
+ * Type that represents all supported Catcher message types for metrics
16
+ * @todo implement performance catcher types
17
+ */
18
+ declare type MetricsCatcherType = 'performance';
19
+ /**
20
+ * Union type that represents all supported Catcher message types
21
+ */
22
+ declare type CatcherMessageType = ErrorsCatcherType | LogsCatcherType | MetricsCatcherType;
23
+ /**
24
+ * Type that represents the payload of a Catcher message based on its type
25
+ */
26
+ declare type CatcherMessagePayload<Type extends CatcherMessageType> = {
27
+ 'errors/javascript': EventData<JavaScriptAddons>;
28
+ 'errors/php': EventData<PhpAddons>;
29
+ 'errors/nodejs': EventData<NodeJSAddons>;
30
+ 'errors/go': EventData<GoAddons>;
31
+ 'errors/python': EventData<PythonAddons>;
32
+ 'logs/javascript': LogData;
33
+ 'performance': PerformanceData;
34
+ }[Type];
35
+ /**
36
+ * Interface that represents a message sent by a Catcher
37
+ * It calculates the type of the payload based on the Catcher type
38
+ */
39
+ export interface CatcherMessage<Type extends CatcherMessageType> {
7
40
  /**
8
41
  * User project's Integration Token
9
42
  */
@@ -11,9 +44,25 @@ export default interface CatcherMessage<CatcherAddons extends EventAddons> {
11
44
  /**
12
45
  * Hawk Catcher name
13
46
  */
14
- catcherType: string;
47
+ catcherType: Type;
15
48
  /**
16
49
  * All information about the event
17
50
  */
18
- payload: EventData<CatcherAddons>;
51
+ payload: CatcherMessagePayload<Type>;
19
52
  }
53
+ /**
54
+ * Type that represents a Catcher message accepted by the collector
55
+ * It omits the token field and adds projectId and timestamp
56
+ */
57
+ export declare type CatcherMessageAccepted<Type extends CatcherMessageType> = Omit<CatcherMessage<Type>, 'token'> & {
58
+ /**
59
+ * Id of the project that sent the message
60
+ */
61
+ projectId: string;
62
+ /**
63
+ * Timestamp of when the message was accepted by the collector
64
+ * This is the current time in milliseconds since the Unix epoch
65
+ */
66
+ timestamp: number;
67
+ };
68
+ export {};
@@ -34,6 +34,12 @@ export interface GroupedEventDBScheme {
34
34
  * Array of users who visited this event
35
35
  */
36
36
  visitedBy: UserDBScheme[];
37
+ /**
38
+ * Occurrence time
39
+ * Unix timestamp in seconds (example: 1567009247.576)
40
+ * (Set by the Collector)
41
+ */
42
+ timestamp: number;
37
43
  }
38
44
  /**
39
45
  * Grouped event with decoded event data
@@ -11,10 +11,21 @@ export interface RepetitionDBScheme {
11
11
  */
12
12
  groupHash: string;
13
13
  /**
14
+ * @deprecated, use delta instead
14
15
  * And any of EventDataAccepted field with diff
15
16
  * except fields that used in groupHash
16
17
  */
17
- payload: EventDataAccepted<EventAddons>;
18
+ payload?: EventDataAccepted<EventAddons>;
19
+ /**
20
+ * Delta between original event and repetition
21
+ */
22
+ delta?: string;
23
+ /**
24
+ * Occurrence time
25
+ * Unix timestamp in seconds (example: 1567009247.576)
26
+ * (Set by the Collector)
27
+ */
28
+ timestamp: number;
18
29
  }
19
30
  /**
20
31
  * Repetition with decoded event data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hawk.so/types",
3
- "version": "0.1.31",
3
+ "version": "0.1.32-rc.2",
4
4
  "description": "TypeScript definitions for Hawk",
5
5
  "types": "build/index.d.ts",
6
6
  "main": "build/index.js",
@@ -4,10 +4,10 @@ import { EventAddons } from './addons';
4
4
  import { Json } from '../../utils';
5
5
 
6
6
  /**
7
- * Information about event
8
- * That object will be send as 'payload' to the Collector
7
+ * Information about event (Payload of the event)
8
+ * That object will be sent as 'payload' from the Collector to the workers
9
9
  */
10
- export interface EventData<CatcherAddons extends EventAddons> {
10
+ export interface EventData<Addons extends EventAddons> {
11
11
  /**
12
12
  * Event title
13
13
  */
@@ -27,7 +27,7 @@ export interface EventData<CatcherAddons extends EventAddons> {
27
27
  /**
28
28
  * Catcher-specific information
29
29
  */
30
- addons?: CatcherAddons | string;
30
+ addons?: Addons;
31
31
 
32
32
  /**
33
33
  * Current release (aka version, revision) of an application
@@ -50,47 +50,32 @@ export interface EventData<CatcherAddons extends EventAddons> {
50
50
  catcherVersion?: string;
51
51
  }
52
52
 
53
- /**
54
- * Event accepted and processed by Collector.
55
- * It sets the timestamp to the event payload.
56
- */
57
- export interface EventDataAccepted<EventAddons> extends EventData<EventAddons> {
58
- /**
59
- * Occurrence time
60
- * Unix timestamp in seconds (example: 1567009247.576)
61
- * (Set by the Collector)
62
- */
63
- timestamp: number;
64
- }
65
-
66
-
67
53
  /**
68
54
  * Event data with decoded unsafe fields
69
55
  */
70
- export interface DecodedEventData<EventAddons> extends EventDataAccepted<EventAddons> {
56
+ export interface DecodedEventData<Addons extends EventAddons> extends EventData<Addons> {
71
57
  /**
72
- * Decoded context
58
+ * Json parsed context string
73
59
  */
74
60
  context?: EventContext;
75
61
 
76
62
  /**
77
- * Decoded addons
63
+ * Json parsed addons string
78
64
  */
79
- addons?: EventAddons;
65
+ addons?: Addons;
80
66
  }
81
67
 
82
68
  /**
83
69
  * Event data with encoded unsafe fields
84
- *
85
70
  */
86
- export interface EncodedEventData extends EventDataAccepted<EventAddons> {
71
+ export interface EncodedEventData extends EventData<EventAddons> {
87
72
  /**
88
- * Encoded context
73
+ * Stringified context object
89
74
  */
90
75
  context?: string;
91
76
 
92
77
  /**
93
- * Encoded addons
78
+ * Stringified addons object
94
79
  */
95
80
  addons?: string;
96
81
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Interface representing the structure of performance CatcherMessage payload.
3
+ * This interface is for payload of the CatcherMessages with CatcherType 'performance'.
4
+ */
5
+ export interface PerformanceData {}
@@ -1,10 +1,46 @@
1
- import { EventData } from "../base/event/event";
2
- import { EventAddons } from "../base/event/addons";
1
+ import { EventData } from '../base/event/event';
2
+ import { PerformanceData } from '../base/performance/performance';
3
+
4
+ import type {
5
+ JavaScriptAddons,
6
+ PhpAddons,
7
+ NodeJSAddons,
8
+ GoAddons,
9
+ PythonAddons
10
+ } from '../base/event/addons';
11
+
12
+ /**
13
+ * Type that represents all supported Catcher message types for events
14
+ */
15
+ type ErrorsCatcherType = 'errors/javascript' | 'errors/php' | 'errors/nodejs' | 'errors/go' | 'errors/python';
3
16
 
4
17
  /**
5
- * Structure describing a message sending by Catcher
18
+ * Type that represents all supported Catcher message types for performance
6
19
  */
7
- export default interface CatcherMessage<CatcherAddons extends EventAddons> {
20
+ type MetricsCatcherType = 'performance';
21
+
22
+ /**
23
+ * Union type that represents all supported Catcher message types
24
+ */
25
+ type CatcherMessageType = ErrorsCatcherType | MetricsCatcherType;
26
+
27
+ /**
28
+ * Type that represents the payload of a Catcher message based on its type
29
+ */
30
+ type CatcherMessagePayload<Type extends CatcherMessageType> = {
31
+ 'errors/javascript': EventData<JavaScriptAddons>;
32
+ 'errors/php': EventData<PhpAddons>;
33
+ 'errors/nodejs': EventData<NodeJSAddons>;
34
+ 'errors/go': EventData<GoAddons>;
35
+ 'errors/python': EventData<PythonAddons>;
36
+ 'performance': PerformanceData;
37
+ }[Type];
38
+
39
+ /**
40
+ * Interface that represents a message sent by a Catcher
41
+ * It calculates the type of the payload based on the Catcher type
42
+ */
43
+ export interface CatcherMessage<Type extends CatcherMessageType> {
8
44
  /**
9
45
  * User project's Integration Token
10
46
  */
@@ -13,10 +49,27 @@ export default interface CatcherMessage<CatcherAddons extends EventAddons> {
13
49
  /**
14
50
  * Hawk Catcher name
15
51
  */
16
- catcherType: string;
52
+ catcherType: Type;
17
53
 
18
54
  /**
19
55
  * All information about the event
20
56
  */
21
- payload: EventData<CatcherAddons>;
57
+ payload: CatcherMessagePayload<Type>;
22
58
  }
59
+
60
+ /**
61
+ * Type that represents a Catcher message accepted by the collector
62
+ * It omits the token field and adds projectId and timestamp
63
+ */
64
+ export type CatcherMessageAccepted<Type extends CatcherMessageType> = Omit<CatcherMessage<Type>, 'token'> & {
65
+ /**
66
+ * Id of the project that sent the message
67
+ */
68
+ projectId: string;
69
+
70
+ /**
71
+ * Timestamp of when the message was accepted by the collector
72
+ * This is the current time in milliseconds since the Unix epoch
73
+ */
74
+ timestamp: number;
75
+ };
@@ -1,5 +1,5 @@
1
1
  import { ObjectId } from "mongodb";
2
- import { DecodedEventData, EncodedEventData, EventDataAccepted } from "../base/event/event";
2
+ import { DecodedEventData, EncodedEventData, EventData } from "../base/event/event";
3
3
  import { UserDBScheme } from "./user";
4
4
  import { EventAddons } from '../base/event/addons';
5
5
 
@@ -30,7 +30,7 @@ export interface GroupedEventDBScheme {
30
30
  /**
31
31
  * Event data
32
32
  */
33
- payload: EventDataAccepted<EventAddons>;
33
+ payload: EventData<EventAddons>;
34
34
 
35
35
  /**
36
36
  * How many users catch this error
@@ -41,6 +41,13 @@ export interface GroupedEventDBScheme {
41
41
  * Array of users who visited this event
42
42
  */
43
43
  visitedBy: UserDBScheme[];
44
+
45
+ /**
46
+ * Occurrence time
47
+ * Unix timestamp in seconds (example: 1567009247.576)
48
+ * (created by the Collector)
49
+ */
50
+ timestamp: number;
44
51
  }
45
52
 
46
53
  /**
@@ -1,5 +1,5 @@
1
1
  import { ObjectId } from "mongodb";
2
- import { DecodedEventData, EncodedEventData, EventDataAccepted } from '../base/event/event';
2
+ import { DecodedEventData, EncodedEventData, EventData } from '../base/event/event';
3
3
  import { EventAddons } from '../base/event/addons';
4
4
 
5
5
  export interface RepetitionDBScheme {
@@ -14,10 +14,23 @@ export interface RepetitionDBScheme {
14
14
  groupHash: string;
15
15
 
16
16
  /**
17
- * And any of EventDataAccepted field with diff
17
+ * @deprecated, use delta instead
18
+ * And any of EventData field with diff
18
19
  * except fields that used in groupHash
19
20
  */
20
- payload: EventDataAccepted<EventAddons>;
21
+ payload?: EventData<EventAddons>;
22
+
23
+ /**
24
+ * Delta between original event and repetition
25
+ */
26
+ delta?: string,
27
+
28
+ /**
29
+ * Occurrence time
30
+ * Unix timestamp in seconds (example: 1567009247.576)
31
+ * (created by the Collector)
32
+ */
33
+ timestamp: number;
21
34
  }
22
35
 
23
36
  /**