@remotion/licensing 4.0.375 → 4.0.377

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.
@@ -6,30 +6,44 @@ var registerUsageEvent = async ({
6
6
  succeeded,
7
7
  event
8
8
  }) => {
9
- const res = await fetch(`${HOST}/api/track/register-usage-point`, {
10
- method: "POST",
11
- body: JSON.stringify({
12
- event,
13
- apiKey,
14
- host,
15
- succeeded
16
- }),
17
- headers: {
18
- "Content-Type": "application/json"
9
+ const abortController = new AbortController;
10
+ const timeout = setTimeout(() => {
11
+ abortController.abort();
12
+ }, 1e4);
13
+ try {
14
+ const res = await fetch(`${HOST}/api/track/register-usage-point`, {
15
+ method: "POST",
16
+ body: JSON.stringify({
17
+ event,
18
+ apiKey,
19
+ host,
20
+ succeeded
21
+ }),
22
+ headers: {
23
+ "Content-Type": "application/json"
24
+ },
25
+ signal: abortController.signal
26
+ });
27
+ clearTimeout(timeout);
28
+ const json = await res.json();
29
+ if (json.success) {
30
+ return {
31
+ billable: json.billable,
32
+ classification: json.classification
33
+ };
19
34
  }
20
- });
21
- const json = await res.json();
22
- if (json.success) {
23
- return {
24
- billable: json.billable,
25
- classification: json.classification
26
- };
27
- }
28
- if (!res.ok) {
29
- throw new Error(json.error);
35
+ if (!res.ok) {
36
+ throw new Error(json.error);
37
+ }
38
+ const read = await res.json();
39
+ return read;
40
+ } catch (err) {
41
+ clearTimeout(timeout);
42
+ if (err instanceof Error && err.name === "AbortError") {
43
+ throw new Error("Request timed out after 10 seconds");
44
+ }
45
+ throw err;
30
46
  }
31
- const read = await res.json();
32
- return read;
33
47
  };
34
48
  // src/get-usage.ts
35
49
  var getUsage = async ({
@@ -3,29 +3,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerUsageEvent = exports.HOST = void 0;
4
4
  exports.HOST = 'https://www.remotion.pro';
5
5
  const registerUsageEvent = async ({ apiKey, host, succeeded, event, }) => {
6
- const res = await fetch(`${exports.HOST}/api/track/register-usage-point`, {
7
- method: 'POST',
8
- body: JSON.stringify({
9
- event,
10
- apiKey,
11
- host,
12
- succeeded,
13
- }),
14
- headers: {
15
- 'Content-Type': 'application/json',
16
- },
17
- });
18
- const json = (await res.json());
19
- if (json.success) {
20
- return {
21
- billable: json.billable,
22
- classification: json.classification,
23
- };
6
+ const abortController = new AbortController();
7
+ const timeout = setTimeout(() => {
8
+ abortController.abort();
9
+ }, 10000);
10
+ try {
11
+ const res = await fetch(`${exports.HOST}/api/track/register-usage-point`, {
12
+ method: 'POST',
13
+ body: JSON.stringify({
14
+ event,
15
+ apiKey,
16
+ host,
17
+ succeeded,
18
+ }),
19
+ headers: {
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ signal: abortController.signal,
23
+ });
24
+ clearTimeout(timeout);
25
+ const json = (await res.json());
26
+ if (json.success) {
27
+ return {
28
+ billable: json.billable,
29
+ classification: json.classification,
30
+ };
31
+ }
32
+ if (!res.ok) {
33
+ throw new Error(json.error);
34
+ }
35
+ const read = await res.json();
36
+ return read;
24
37
  }
25
- if (!res.ok) {
26
- throw new Error(json.error);
38
+ catch (err) {
39
+ clearTimeout(timeout);
40
+ if (err instanceof Error && err.name === 'AbortError') {
41
+ throw new Error('Request timed out after 10 seconds');
42
+ }
43
+ throw err;
27
44
  }
28
- const read = await res.json();
29
- return read;
30
45
  };
31
46
  exports.registerUsageEvent = registerUsageEvent;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/licensing"
4
4
  },
5
5
  "name": "@remotion/licensing",
6
- "version": "4.0.375",
6
+ "version": "4.0.377",
7
7
  "description": "Manage your Remotion.pro license",
8
8
  "main": "dist",
9
9
  "sideEffects": false,
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {},
26
26
  "devDependencies": {
27
- "@remotion/eslint-config-internal": "4.0.375",
27
+ "@remotion/eslint-config-internal": "4.0.377",
28
28
  "eslint": "9.19.0"
29
29
  },
30
30
  "homepage": "https://www.remotion.dev/docs/licensing"