@upstash/redis 1.19.1 → 1.19.3
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 +3 -2
- package/esm/pkg/http.js +17 -9
- package/esm/pkg/redis.js +28 -0
- package/esm/platforms/cloudflare.js +6 -6
- package/esm/platforms/fastly.js +5 -0
- package/esm/platforms/node_with_fetch.js +10 -11
- package/esm/platforms/nodejs.js +10 -11
- package/esm/version.js +1 -1
- package/package.json +1 -1
- package/script/pkg/http.js +17 -9
- package/script/pkg/redis.js +28 -0
- package/script/platforms/cloudflare.js +6 -6
- package/script/platforms/fastly.js +5 -0
- package/script/platforms/node_with_fetch.js +10 -11
- package/script/platforms/nodejs.js +10 -11
- package/script/version.js +1 -1
- package/types/pkg/http.d.ts +2 -17
- package/types/pkg/redis.d.ts +7 -0
- package/types/pkg/types.d.ts +17 -0
- package/types/version.d.ts +1 -1
package/README.md
CHANGED
|
@@ -83,8 +83,9 @@ console.log(data)
|
|
|
83
83
|
|
|
84
84
|
## Troubleshooting
|
|
85
85
|
|
|
86
|
-
We have a
|
|
87
|
-
|
|
86
|
+
We have a
|
|
87
|
+
[dedicated page](https://docs.upstash.com/redis/sdks/javascriptsdk/troubleshooting)
|
|
88
|
+
for common problems. If you can't find a solution, please
|
|
88
89
|
[open an issue](https://github.com/upstash/upstash-redis/issues/new).
|
|
89
90
|
|
|
90
91
|
## Docs
|
package/esm/pkg/http.js
CHANGED
|
@@ -35,15 +35,6 @@ export class HttpClient {
|
|
|
35
35
|
"Content-Type": "application/json",
|
|
36
36
|
...config.headers,
|
|
37
37
|
};
|
|
38
|
-
if (config.telemetry?.runtime) {
|
|
39
|
-
this.headers["Upstash-Telemetry-Runtime"] = config.telemetry.runtime;
|
|
40
|
-
}
|
|
41
|
-
if (config.telemetry?.platform) {
|
|
42
|
-
this.headers["Upstash-Telemetry-Platform"] = config.telemetry.platform;
|
|
43
|
-
}
|
|
44
|
-
if (config.telemetry?.sdk) {
|
|
45
|
-
this.headers["Upstash-Telemetry-Sdk"] = config.telemetry.sdk;
|
|
46
|
-
}
|
|
47
38
|
if (this.options.responseEncoding === "base64") {
|
|
48
39
|
this.headers["Upstash-Encoding"] = "base64";
|
|
49
40
|
}
|
|
@@ -61,6 +52,23 @@ export class HttpClient {
|
|
|
61
52
|
};
|
|
62
53
|
}
|
|
63
54
|
}
|
|
55
|
+
mergeTelemetry(telemetry) {
|
|
56
|
+
function merge(obj, key, value) {
|
|
57
|
+
if (!value) {
|
|
58
|
+
return obj;
|
|
59
|
+
}
|
|
60
|
+
if (obj[key]) {
|
|
61
|
+
obj[key] = [obj[key], value].join(",");
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
obj[key] = value;
|
|
65
|
+
}
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Runtime", telemetry.runtime);
|
|
69
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Platform", telemetry.platform);
|
|
70
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Sdk", telemetry.sdk);
|
|
71
|
+
}
|
|
64
72
|
async request(req) {
|
|
65
73
|
const requestOptions = {
|
|
66
74
|
method: "POST",
|
package/esm/pkg/redis.js
CHANGED
|
@@ -31,6 +31,12 @@ export class Redis {
|
|
|
31
31
|
writable: true,
|
|
32
32
|
value: void 0
|
|
33
33
|
});
|
|
34
|
+
Object.defineProperty(this, "enableTelemetry", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: void 0
|
|
39
|
+
});
|
|
34
40
|
/**
|
|
35
41
|
* Wrap a new middleware around the HTTP client.
|
|
36
42
|
*/
|
|
@@ -43,6 +49,27 @@ export class Redis {
|
|
|
43
49
|
this.client.request = (req) => middleware(req, makeRequest);
|
|
44
50
|
}
|
|
45
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* Technically this is not private, we can hide it from intellisense by doing this
|
|
54
|
+
*/
|
|
55
|
+
Object.defineProperty(this, "addTelemetry", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: (telemetry) => {
|
|
60
|
+
if (!this.enableTelemetry) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
// @ts-ignore - The `Requester` interface does not know about this method but it will be there
|
|
65
|
+
// as long as the user uses the standard HttpClient
|
|
66
|
+
this.client.mergeTelemetry(telemetry);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// ignore
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
46
73
|
/**
|
|
47
74
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
48
75
|
*
|
|
@@ -1165,6 +1192,7 @@ export class Redis {
|
|
|
1165
1192
|
});
|
|
1166
1193
|
this.client = client;
|
|
1167
1194
|
this.opts = opts;
|
|
1195
|
+
this.enableTelemetry = opts?.enableTelemetry ?? true;
|
|
1168
1196
|
}
|
|
1169
1197
|
createScript(script) {
|
|
1170
1198
|
return new Script(this, script);
|
|
@@ -27,21 +27,21 @@ export class Redis extends core.Redis {
|
|
|
27
27
|
/\r|\n/.test(config.token)) {
|
|
28
28
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
29
29
|
}
|
|
30
|
-
const telemetry = {};
|
|
31
|
-
if (!env?.UPSTASH_DISABLE_TELEMETRY) {
|
|
32
|
-
telemetry.platform = "cloudflare";
|
|
33
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
34
|
-
}
|
|
35
30
|
const client = new HttpClient({
|
|
36
31
|
retry: config.retry,
|
|
37
32
|
baseUrl: config.url,
|
|
38
33
|
headers: { authorization: `Bearer ${config.token}` },
|
|
39
34
|
responseEncoding: config.responseEncoding,
|
|
40
|
-
telemetry,
|
|
41
35
|
});
|
|
42
36
|
super(client, {
|
|
37
|
+
enableTelemetry: !env?.UPSTASH_DISABLE_TELEMETRY,
|
|
43
38
|
automaticDeserialization: config.automaticDeserialization,
|
|
44
39
|
});
|
|
40
|
+
// This is only added of the user has not disabled telemetry
|
|
41
|
+
this.addTelemetry({
|
|
42
|
+
platform: "cloudflare",
|
|
43
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
44
|
+
});
|
|
45
45
|
}
|
|
46
46
|
/*
|
|
47
47
|
* Create a new Upstash Redis instance from environment variables on cloudflare.
|
package/esm/platforms/fastly.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as core from "../pkg/redis.js";
|
|
2
2
|
import { HttpClient } from "../pkg/http.js";
|
|
3
|
+
import { VERSION } from "../version.js";
|
|
3
4
|
/**
|
|
4
5
|
* Serverless redis client for upstash.
|
|
5
6
|
*/
|
|
@@ -37,5 +38,9 @@ export class Redis extends core.Redis {
|
|
|
37
38
|
super(client, {
|
|
38
39
|
automaticDeserialization: config.automaticDeserialization,
|
|
39
40
|
});
|
|
41
|
+
this.addTelemetry({
|
|
42
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
43
|
+
platform: "fastly",
|
|
44
|
+
});
|
|
40
45
|
}
|
|
41
46
|
}
|
|
@@ -35,26 +35,25 @@ export class Redis extends core.Redis {
|
|
|
35
35
|
/\r|\n/.test(configOrRequester.token)) {
|
|
36
36
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
37
37
|
}
|
|
38
|
-
const telemetry = {};
|
|
39
|
-
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
40
|
-
telemetry.runtime = `node@${process.version}`;
|
|
41
|
-
telemetry.platform = process.env.VERCEL
|
|
42
|
-
? "vercel"
|
|
43
|
-
: process.env.AWS_REGION
|
|
44
|
-
? "aws"
|
|
45
|
-
: "unknown";
|
|
46
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
47
|
-
}
|
|
48
38
|
const client = new HttpClient({
|
|
49
39
|
baseUrl: configOrRequester.url,
|
|
50
40
|
retry: configOrRequester.retry,
|
|
51
41
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
52
42
|
// agent: configOrRequester.agent,
|
|
53
43
|
responseEncoding: configOrRequester.responseEncoding,
|
|
54
|
-
telemetry,
|
|
55
44
|
});
|
|
56
45
|
super(client, {
|
|
57
46
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
47
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
48
|
+
});
|
|
49
|
+
this.addTelemetry({
|
|
50
|
+
runtime: `node@${process.version}`,
|
|
51
|
+
platform: process.env.VERCEL
|
|
52
|
+
? "vercel"
|
|
53
|
+
: process.env.AWS_REGION
|
|
54
|
+
? "aws"
|
|
55
|
+
: "unknown",
|
|
56
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
59
|
/**
|
package/esm/platforms/nodejs.js
CHANGED
|
@@ -29,26 +29,25 @@ export class Redis extends core.Redis {
|
|
|
29
29
|
/\r|\n/.test(configOrRequester.token)) {
|
|
30
30
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
31
31
|
}
|
|
32
|
-
const telemetry = {};
|
|
33
|
-
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
34
|
-
telemetry.runtime = `node@${process.version}`;
|
|
35
|
-
telemetry.platform = process.env.VERCEL
|
|
36
|
-
? "vercel"
|
|
37
|
-
: process.env.AWS_REGION
|
|
38
|
-
? "aws"
|
|
39
|
-
: "unknown";
|
|
40
|
-
telemetry.sdk = `@upstash/redis@${VERSION}`;
|
|
41
|
-
}
|
|
42
32
|
const client = new HttpClient({
|
|
43
33
|
baseUrl: configOrRequester.url,
|
|
44
34
|
retry: configOrRequester.retry,
|
|
45
35
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
46
36
|
agent: configOrRequester.agent,
|
|
47
37
|
responseEncoding: configOrRequester.responseEncoding,
|
|
48
|
-
telemetry,
|
|
49
38
|
});
|
|
50
39
|
super(client, {
|
|
51
40
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
41
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
42
|
+
});
|
|
43
|
+
this.addTelemetry({
|
|
44
|
+
runtime: `node@${process.version}`,
|
|
45
|
+
platform: process.env.VERCEL
|
|
46
|
+
? "vercel"
|
|
47
|
+
: process.env.AWS_REGION
|
|
48
|
+
? "aws"
|
|
49
|
+
: "unknown",
|
|
50
|
+
sdk: `@upstash/redis@${VERSION}`,
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
/**
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "v1.19.
|
|
1
|
+
export const VERSION = "v1.19.3";
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "./script/platforms/nodejs.js",
|
|
4
4
|
"types": "./types/platforms/nodejs.d.ts",
|
|
5
5
|
"name": "@upstash/redis",
|
|
6
|
-
"version": "v1.19.
|
|
6
|
+
"version": "v1.19.3",
|
|
7
7
|
"description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
package/script/pkg/http.js
CHANGED
|
@@ -38,15 +38,6 @@ class HttpClient {
|
|
|
38
38
|
"Content-Type": "application/json",
|
|
39
39
|
...config.headers,
|
|
40
40
|
};
|
|
41
|
-
if (config.telemetry?.runtime) {
|
|
42
|
-
this.headers["Upstash-Telemetry-Runtime"] = config.telemetry.runtime;
|
|
43
|
-
}
|
|
44
|
-
if (config.telemetry?.platform) {
|
|
45
|
-
this.headers["Upstash-Telemetry-Platform"] = config.telemetry.platform;
|
|
46
|
-
}
|
|
47
|
-
if (config.telemetry?.sdk) {
|
|
48
|
-
this.headers["Upstash-Telemetry-Sdk"] = config.telemetry.sdk;
|
|
49
|
-
}
|
|
50
41
|
if (this.options.responseEncoding === "base64") {
|
|
51
42
|
this.headers["Upstash-Encoding"] = "base64";
|
|
52
43
|
}
|
|
@@ -64,6 +55,23 @@ class HttpClient {
|
|
|
64
55
|
};
|
|
65
56
|
}
|
|
66
57
|
}
|
|
58
|
+
mergeTelemetry(telemetry) {
|
|
59
|
+
function merge(obj, key, value) {
|
|
60
|
+
if (!value) {
|
|
61
|
+
return obj;
|
|
62
|
+
}
|
|
63
|
+
if (obj[key]) {
|
|
64
|
+
obj[key] = [obj[key], value].join(",");
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
obj[key] = value;
|
|
68
|
+
}
|
|
69
|
+
return obj;
|
|
70
|
+
}
|
|
71
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Runtime", telemetry.runtime);
|
|
72
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Platform", telemetry.platform);
|
|
73
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Sdk", telemetry.sdk);
|
|
74
|
+
}
|
|
67
75
|
async request(req) {
|
|
68
76
|
const requestOptions = {
|
|
69
77
|
method: "POST",
|
package/script/pkg/redis.js
CHANGED
|
@@ -34,6 +34,12 @@ class Redis {
|
|
|
34
34
|
writable: true,
|
|
35
35
|
value: void 0
|
|
36
36
|
});
|
|
37
|
+
Object.defineProperty(this, "enableTelemetry", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
37
43
|
/**
|
|
38
44
|
* Wrap a new middleware around the HTTP client.
|
|
39
45
|
*/
|
|
@@ -46,6 +52,27 @@ class Redis {
|
|
|
46
52
|
this.client.request = (req) => middleware(req, makeRequest);
|
|
47
53
|
}
|
|
48
54
|
});
|
|
55
|
+
/**
|
|
56
|
+
* Technically this is not private, we can hide it from intellisense by doing this
|
|
57
|
+
*/
|
|
58
|
+
Object.defineProperty(this, "addTelemetry", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
value: (telemetry) => {
|
|
63
|
+
if (!this.enableTelemetry) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
// @ts-ignore - The `Requester` interface does not know about this method but it will be there
|
|
68
|
+
// as long as the user uses the standard HttpClient
|
|
69
|
+
this.client.mergeTelemetry(telemetry);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// ignore
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
49
76
|
/**
|
|
50
77
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
51
78
|
*
|
|
@@ -1168,6 +1195,7 @@ class Redis {
|
|
|
1168
1195
|
});
|
|
1169
1196
|
this.client = client;
|
|
1170
1197
|
this.opts = opts;
|
|
1198
|
+
this.enableTelemetry = opts?.enableTelemetry ?? true;
|
|
1171
1199
|
}
|
|
1172
1200
|
createScript(script) {
|
|
1173
1201
|
return new script_js_1.Script(this, script);
|
|
@@ -53,21 +53,21 @@ class Redis extends core.Redis {
|
|
|
53
53
|
/\r|\n/.test(config.token)) {
|
|
54
54
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
55
55
|
}
|
|
56
|
-
const telemetry = {};
|
|
57
|
-
if (!env?.UPSTASH_DISABLE_TELEMETRY) {
|
|
58
|
-
telemetry.platform = "cloudflare";
|
|
59
|
-
telemetry.sdk = `@upstash/redis@${version_js_1.VERSION}`;
|
|
60
|
-
}
|
|
61
56
|
const client = new http_js_1.HttpClient({
|
|
62
57
|
retry: config.retry,
|
|
63
58
|
baseUrl: config.url,
|
|
64
59
|
headers: { authorization: `Bearer ${config.token}` },
|
|
65
60
|
responseEncoding: config.responseEncoding,
|
|
66
|
-
telemetry,
|
|
67
61
|
});
|
|
68
62
|
super(client, {
|
|
63
|
+
enableTelemetry: !env?.UPSTASH_DISABLE_TELEMETRY,
|
|
69
64
|
automaticDeserialization: config.automaticDeserialization,
|
|
70
65
|
});
|
|
66
|
+
// This is only added of the user has not disabled telemetry
|
|
67
|
+
this.addTelemetry({
|
|
68
|
+
platform: "cloudflare",
|
|
69
|
+
sdk: `@upstash/redis@${version_js_1.VERSION}`,
|
|
70
|
+
});
|
|
71
71
|
}
|
|
72
72
|
/*
|
|
73
73
|
* Create a new Upstash Redis instance from environment variables on cloudflare.
|
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.Redis = void 0;
|
|
27
27
|
const core = __importStar(require("../pkg/redis.js"));
|
|
28
28
|
const http_js_1 = require("../pkg/http.js");
|
|
29
|
+
const version_js_1 = require("../version.js");
|
|
29
30
|
/**
|
|
30
31
|
* Serverless redis client for upstash.
|
|
31
32
|
*/
|
|
@@ -63,6 +64,10 @@ class Redis extends core.Redis {
|
|
|
63
64
|
super(client, {
|
|
64
65
|
automaticDeserialization: config.automaticDeserialization,
|
|
65
66
|
});
|
|
67
|
+
this.addTelemetry({
|
|
68
|
+
sdk: `@upstash/redis@${version_js_1.VERSION}`,
|
|
69
|
+
platform: "fastly",
|
|
70
|
+
});
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
73
|
exports.Redis = Redis;
|
|
@@ -61,26 +61,25 @@ class Redis extends core.Redis {
|
|
|
61
61
|
/\r|\n/.test(configOrRequester.token)) {
|
|
62
62
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
63
63
|
}
|
|
64
|
-
const telemetry = {};
|
|
65
|
-
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
66
|
-
telemetry.runtime = `node@${process.version}`;
|
|
67
|
-
telemetry.platform = process.env.VERCEL
|
|
68
|
-
? "vercel"
|
|
69
|
-
: process.env.AWS_REGION
|
|
70
|
-
? "aws"
|
|
71
|
-
: "unknown";
|
|
72
|
-
telemetry.sdk = `@upstash/redis@${version_js_1.VERSION}`;
|
|
73
|
-
}
|
|
74
64
|
const client = new http_js_1.HttpClient({
|
|
75
65
|
baseUrl: configOrRequester.url,
|
|
76
66
|
retry: configOrRequester.retry,
|
|
77
67
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
78
68
|
// agent: configOrRequester.agent,
|
|
79
69
|
responseEncoding: configOrRequester.responseEncoding,
|
|
80
|
-
telemetry,
|
|
81
70
|
});
|
|
82
71
|
super(client, {
|
|
83
72
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
73
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
74
|
+
});
|
|
75
|
+
this.addTelemetry({
|
|
76
|
+
runtime: `node@${process.version}`,
|
|
77
|
+
platform: process.env.VERCEL
|
|
78
|
+
? "vercel"
|
|
79
|
+
: process.env.AWS_REGION
|
|
80
|
+
? "aws"
|
|
81
|
+
: "unknown",
|
|
82
|
+
sdk: `@upstash/redis@${version_js_1.VERSION}`,
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
@@ -55,26 +55,25 @@ class Redis extends core.Redis {
|
|
|
55
55
|
/\r|\n/.test(configOrRequester.token)) {
|
|
56
56
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
57
57
|
}
|
|
58
|
-
const telemetry = {};
|
|
59
|
-
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
60
|
-
telemetry.runtime = `node@${process.version}`;
|
|
61
|
-
telemetry.platform = process.env.VERCEL
|
|
62
|
-
? "vercel"
|
|
63
|
-
: process.env.AWS_REGION
|
|
64
|
-
? "aws"
|
|
65
|
-
: "unknown";
|
|
66
|
-
telemetry.sdk = `@upstash/redis@${version_js_1.VERSION}`;
|
|
67
|
-
}
|
|
68
58
|
const client = new http_js_1.HttpClient({
|
|
69
59
|
baseUrl: configOrRequester.url,
|
|
70
60
|
retry: configOrRequester.retry,
|
|
71
61
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
72
62
|
agent: configOrRequester.agent,
|
|
73
63
|
responseEncoding: configOrRequester.responseEncoding,
|
|
74
|
-
telemetry,
|
|
75
64
|
});
|
|
76
65
|
super(client, {
|
|
77
66
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
67
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
68
|
+
});
|
|
69
|
+
this.addTelemetry({
|
|
70
|
+
runtime: `node@${process.version}`,
|
|
71
|
+
platform: process.env.VERCEL
|
|
72
|
+
? "vercel"
|
|
73
|
+
: process.env.AWS_REGION
|
|
74
|
+
? "aws"
|
|
75
|
+
: "unknown",
|
|
76
|
+
sdk: `@upstash/redis@${version_js_1.VERSION}`,
|
|
78
77
|
});
|
|
79
78
|
}
|
|
80
79
|
/**
|
package/script/version.js
CHANGED
package/types/pkg/http.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Telemetry } from "./types.js";
|
|
1
2
|
export declare type UpstashRequest = {
|
|
2
3
|
path?: string[];
|
|
3
4
|
/**
|
|
@@ -67,23 +68,6 @@ export declare type HttpClientConfig = {
|
|
|
67
68
|
options?: Options;
|
|
68
69
|
retry?: RetryConfig;
|
|
69
70
|
agent?: any;
|
|
70
|
-
telemetry?: {
|
|
71
|
-
/**
|
|
72
|
-
* Upstash-Telemetry-Sdk
|
|
73
|
-
* @example @upstash/redis@v1.1.1
|
|
74
|
-
*/
|
|
75
|
-
sdk?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Upstash-Telemetry-Platform
|
|
78
|
-
* @example cloudflare
|
|
79
|
-
*/
|
|
80
|
-
platform?: string;
|
|
81
|
-
/**
|
|
82
|
-
* Upstash-Telemetry-Runtime
|
|
83
|
-
* @example node@v18
|
|
84
|
-
*/
|
|
85
|
-
runtime?: string;
|
|
86
|
-
};
|
|
87
71
|
} & RequesterConfig;
|
|
88
72
|
export declare class HttpClient implements Requester {
|
|
89
73
|
baseUrl: string;
|
|
@@ -98,5 +82,6 @@ export declare class HttpClient implements Requester {
|
|
|
98
82
|
backoff: (retryCount: number) => number;
|
|
99
83
|
};
|
|
100
84
|
constructor(config: HttpClientConfig);
|
|
85
|
+
mergeTelemetry(telemetry: Telemetry): void;
|
|
101
86
|
request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>>;
|
|
102
87
|
}
|
package/types/pkg/redis.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Requester, UpstashRequest, UpstashResponse } from "./http.js";
|
|
|
3
3
|
import { Pipeline } from "./pipeline.js";
|
|
4
4
|
import type { CommandArgs } from "./types.js";
|
|
5
5
|
import { Script } from "./script.js";
|
|
6
|
+
import { Telemetry } from "./types.js";
|
|
6
7
|
export declare type RedisOptions = {
|
|
7
8
|
/**
|
|
8
9
|
* Automatically try to deserialize the returned data from upstash using `JSON.deserialize`
|
|
@@ -10,6 +11,7 @@ export declare type RedisOptions = {
|
|
|
10
11
|
* @default true
|
|
11
12
|
*/
|
|
12
13
|
automaticDeserialization?: boolean;
|
|
14
|
+
enableTelemetry?: boolean;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* Serverless redis client for upstash.
|
|
@@ -17,6 +19,7 @@ export declare type RedisOptions = {
|
|
|
17
19
|
export declare class Redis {
|
|
18
20
|
protected client: Requester;
|
|
19
21
|
protected opts?: CommandOptions<any, any>;
|
|
22
|
+
protected enableTelemetry: boolean;
|
|
20
23
|
/**
|
|
21
24
|
* Create a new redis client
|
|
22
25
|
*
|
|
@@ -33,6 +36,10 @@ export declare class Redis {
|
|
|
33
36
|
* Wrap a new middleware around the HTTP client.
|
|
34
37
|
*/
|
|
35
38
|
use: <TResult = unknown>(middleware: (r: UpstashRequest, next: <TResult_1 = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult_1>>) => Promise<UpstashResponse<TResult>>) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Technically this is not private, we can hide it from intellisense by doing this
|
|
41
|
+
*/
|
|
42
|
+
protected addTelemetry: (telemetry: Telemetry) => void;
|
|
36
43
|
createScript(script: string): Script;
|
|
37
44
|
/**
|
|
38
45
|
* Create a new pipeline that allows you to send requests in bulk.
|
package/types/pkg/types.d.ts
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
1
|
export declare type CommandArgs<TCommand extends new (...args: any) => any> = ConstructorParameters<TCommand>[0];
|
|
2
|
+
export declare type Telemetry = {
|
|
3
|
+
/**
|
|
4
|
+
* Upstash-Telemetry-Sdk
|
|
5
|
+
* @example @upstash/redis@v1.1.1
|
|
6
|
+
*/
|
|
7
|
+
sdk?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Upstash-Telemetry-Platform
|
|
10
|
+
* @example cloudflare
|
|
11
|
+
*/
|
|
12
|
+
platform?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Upstash-Telemetry-Runtime
|
|
15
|
+
* @example node@v18
|
|
16
|
+
*/
|
|
17
|
+
runtime?: string;
|
|
18
|
+
};
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "v1.19.
|
|
1
|
+
export declare const VERSION = "v1.19.3";
|