@sailfish-ai/sf-veritas 0.1.32 โ 0.1.33
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.
- package/README.md +125 -86
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,119 +1,158 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Sailfish's Backend Data Collector for JavaScript and TypeScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Sailfish's veritas library captures all of the data to enable engineers to properly debug issues.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Supported Frameworks
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
As of September 2025, we support [the most widely-used JS/TS backend frameworks](https://survey.stackoverflow.co/2025/technology#most-popular-technologies-webframe) and others (in both JavaScript and TypeScript):
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- Most-widely Used
|
|
10
|
+
- Node.js
|
|
11
|
+
- Next.js
|
|
12
|
+
- Express
|
|
13
|
+
- Angular
|
|
14
|
+
- NestJS
|
|
15
|
+
- NuxtJS
|
|
16
|
+
- Others
|
|
17
|
+
- Apollo Server
|
|
18
|
+
- Mercurius
|
|
19
|
+
- MeteorJS
|
|
20
|
+
- GraphQL over HTTP (formerly Express GraphQL)
|
|
10
21
|
|
|
11
|
-
|
|
12
|
-
// Add this to your .npmrc
|
|
13
|
-
@sailfishai:registry=https://us-npm.pkg.dev/sailfish-ai/sailfishai-npm/
|
|
14
|
-
```
|
|
22
|
+
## Installation
|
|
15
23
|
|
|
16
24
|
#### Install the Package
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
Install via your package manager; for reference, here is how you can install our package via `npm` and `yarn`:
|
|
27
|
+
|
|
28
|
+
```sh title="Install via npm"
|
|
29
|
+
npm install --save @sailfish-ai/sf-veritas
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```sh title="Install via yarn"
|
|
33
|
+
yarn add @sailfish-ai/sf-veritas
|
|
22
34
|
```
|
|
23
35
|
|
|
24
|
-
##
|
|
36
|
+
## Integration
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
Once you have installed the `sf-veritas` package, it's time to integrate it into your project.
|
|
27
39
|
|
|
28
|
-
|
|
40
|
+
### Arguments/Parameters
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
Below are the configuration parameters for `sf-veritas`. These options are passed as an object to the `setupInterceptors` function.
|
|
31
43
|
|
|
32
|
-
- `
|
|
44
|
+
- **`apiKey`**: `string`
|
|
33
45
|
|
|
34
|
-
-
|
|
46
|
+
- This can be seen and copied from your [Settings Configuration page](https://app.sailfishqa.com/settings/configuration) in the "Sailfish Configuration" section.
|
|
35
47
|
|
|
36
|
-
- `
|
|
48
|
+
- **`serviceIdentifier`**: `string`
|
|
37
49
|
|
|
38
|
-
-
|
|
50
|
+
- This identifies the service that is running.
|
|
51
|
+
- The value is extremely important because Sailfish uses the `serviceIdentifier` to link sevices to the location in code. Without this, Sailfish can have issues locating code and automatically fixing issues.
|
|
52
|
+
- e.g. **`gitOrg`/`gitRepo`/`pathToFile`**
|
|
39
53
|
|
|
40
|
-
- `
|
|
54
|
+
- **`serviceVersion`**: `string`
|
|
41
55
|
|
|
42
|
-
-
|
|
56
|
+
- This identifies the version of your service - this is a human-readable version and is not required.
|
|
57
|
+
|
|
58
|
+
- **`gitSha`**: `string`
|
|
43
59
|
|
|
44
|
-
-
|
|
60
|
+
- This is the Git SHA of your releases - populating this via this argument or an environment variable helps your team tie issues to code changes quickly.
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
- **`serviceAdditionalMetadata`**: `Record<string, string | number | boolean | null>`
|
|
63
|
+
|
|
64
|
+
- Add extra metadata such as cluster information or environment details.
|
|
47
65
|
|
|
48
|
-
- `
|
|
66
|
+
- **`domainsToNotPropagateHeadersTo`**: `string[]`
|
|
49
67
|
|
|
50
|
-
-
|
|
68
|
+
- Prevents adding tracing headers (`X-Sf3-Rid`) to certain domains.
|
|
69
|
+
- Supports wildcard characters, subdomains, and paths.
|
|
51
70
|
|
|
52
|
-
|
|
71
|
+
- **`nodeModulesToCollectLocalVariablesOn`**: `string[]` (_coming soon_)
|
|
72
|
+
- Specify packages or modules for capturing local variable values during errors or exceptions.
|
|
53
73
|
|
|
54
|
-
|
|
55
|
-
|
|
74
|
+
### Integration
|
|
75
|
+
|
|
76
|
+
To integrate and start, place the following into your application's entry point, **as early as possible**:
|
|
56
77
|
|
|
57
78
|
```ts title="JS/TS integration code"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
setupInterceptors({
|
|
84
|
-
apiKey: "test-api-key",
|
|
85
|
-
serviceIdentifier: "your-service-name",
|
|
86
|
-
serviceVersion: "1.0.0",
|
|
87
|
-
serviceAdditionalMetadata: {
|
|
88
|
-
environment: "production",
|
|
89
|
-
cluster: "east-coast",
|
|
90
|
-
},
|
|
91
|
-
domainsToNotPropagateHeadersTo: ["example.com"],
|
|
92
|
-
nodeModulesToCollectLocalVariablesOn: ["@your-org/your-package"],
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
console.log(
|
|
96
|
-
"[Instrumentation] Server-side interceptors initialized successfully.",
|
|
97
|
-
);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.error(
|
|
100
|
-
"[Instrumentation] Error importing setupInterceptors:",
|
|
101
|
-
error,
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
79
|
+
import { setupInterceptors } from "@sailfish-ai/sf-veritas";
|
|
80
|
+
|
|
81
|
+
setupInterceptors({
|
|
82
|
+
apiKey: "your-api-key",
|
|
83
|
+
serviceIdentifier: "<gitOrg>/<gitRepo>/<pathToFile>",
|
|
84
|
+
domainsToNotPropagateHeadersTo: ["example.com"],
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Features
|
|
89
|
+
|
|
90
|
+
#### Identify Users
|
|
91
|
+
|
|
92
|
+
You can also associate data (logs, exceptions, and network requests) with specific users using the identify method. This is particularly helpful for user-centric debugging.
|
|
93
|
+
|
|
94
|
+
#### Identify Signature
|
|
95
|
+
|
|
96
|
+
Here's the argument signature:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
type Identify = (
|
|
100
|
+
userId: string,
|
|
101
|
+
traits: Record<string, any>,
|
|
102
|
+
override: boolean,
|
|
103
|
+
) => void;
|
|
106
104
|
```
|
|
107
105
|
|
|
108
|
-
|
|
106
|
+
#### Identify Example
|
|
109
107
|
|
|
110
|
-
|
|
108
|
+
In order to identify, you will need to call the `identify` method. You can also force an override of stored values by setting the `override` argument to `true`.
|
|
109
|
+
|
|
110
|
+
```ts title="Link a user to a recording"
|
|
111
|
+
import { identify } from "@sailfish-ai/sf-veritas";
|
|
112
|
+
|
|
113
|
+
identify("user-123", { lastAction: "2024-11-18" });
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### Add or Update Metadata
|
|
117
|
+
|
|
118
|
+
In order to add or update metadata associated with specific users and the recordings, you can use the `addOrUpdateMetadata` method. This will associate all information with the recording by calling this method on any Node.js backend.
|
|
119
|
+
|
|
120
|
+
- **`userId`**: `string`
|
|
121
|
+
|
|
122
|
+
- This associates the logs (and recording, if there is an associated recording) with a specific user.
|
|
123
|
+
|
|
124
|
+
- **`traits`**: `Record<string, any>`
|
|
125
|
+
|
|
126
|
+
- This is a custom dictionary of traits to values for a specific user or customer. Everything is searchable!
|
|
127
|
+
|
|
128
|
+
- **`traitsJson`**: `string`
|
|
129
|
+
|
|
130
|
+
- This is a custom JSON, just like `traits`, but using the JSON format.
|
|
131
|
+
|
|
132
|
+
- **`override`**: `boolean`
|
|
133
|
+
- This tells whether any of the information we pass along should be overridden or not.
|
|
134
|
+
|
|
135
|
+
#### AddOrUpdateMetadata Signature
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
type AddOrUpdateMetadataFunction = (
|
|
139
|
+
userId: string,
|
|
140
|
+
traits: Record<string, any>,
|
|
141
|
+
override: boolean,
|
|
142
|
+
) => void;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Add/Update Metadata Example
|
|
146
|
+
|
|
147
|
+
```ts title="Add/Update Metadata for a recording"
|
|
148
|
+
import { addOrUpdateMetadata } from "@sailfish-ai/sf-veritas";
|
|
149
|
+
|
|
150
|
+
addOrUpdateMetadata("user-123", { birthday: "2000-01-01" }, true);
|
|
151
|
+
```
|
|
111
152
|
|
|
112
|
-
|
|
153
|
+
### Technical Details
|
|
113
154
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
| โ
With Package | 714.17 | 575.00 | 595.92 | 1000 |
|
|
117
|
-
| โ Without Package | 715.59 | 541.00 | 643.22 | 1000 |
|
|
155
|
+
- **Non-Blocking Execution**: All operations are executed in non-blocking, isolated threads, ensuring less than 20 ยตs of overhead.
|
|
156
|
+
- **Contextual Awareness**: Tracks context across threads, processes, and async tasks to associate logs with the correct sequence of events.
|
|
118
157
|
|
|
119
|
-
|
|
158
|
+
By following these steps, you can seamlessly integrate `sf-veritas` into your Node.js project and start capturing LEaPS (Logs, Exceptions, and Print Statements) effectively!
|