Skip to content

🎥 Make videos programmatically with React

make isProduction mandatory

Jonny Burgerc7cd69ca9764
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index d789e93652..0ec95b169a 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -360,7 +360,7 @@ export const renderCommand = async ({
requestHandler: null,
isProduction:
parsedLambdaCli[BrowserSafeApis.options.isProductionKeyOption.cliFlag] ??
- null,
+ true,
});
const progressBar = CliInternals.createOverwriteableCliOutput({
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
index fcfd7d739e..dc377919e3 100644
--- a/packages/lambda/src/cli/commands/still.ts
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -292,7 +292,7 @@ export const stillCommand = async ({
mediaCacheSizeInBytes,
isProduction:
parsedLambdaCli[BrowserSafeApis.options.isProductionKeyOption.cliFlag] ??
- null,
+ true,
});
Log.info(
{indent: false, logLevel},
diff --git a/packages/lambda/src/test/integration/renders/old-version.test.ts b/packages/lambda/src/test/integration/renders/old-version.test.ts
index 8d7faf2868..c430f925e6 100644
--- a/packages/lambda/src/test/integration/renders/old-version.test.ts
+++ b/packages/lambda/src/test/integration/renders/old-version.test.ts
@@ -63,7 +63,7 @@ test(
licenseKey: null,
storageClass: null,
mediaCacheSizeInBytes: null,
- isProduction: null,
+ isProduction: true,
},
functionName: 'remotion-dev-render',
region: 'us-east-1',
diff --git a/packages/lambda/src/test/integration/webhooks.test.ts b/packages/lambda/src/test/integration/webhooks.test.ts
index 04f17ba856..e692990fdf 100644
--- a/packages/lambda/src/test/integration/webhooks.test.ts
+++ b/packages/lambda/src/test/integration/webhooks.test.ts
@@ -220,7 +220,7 @@ test(
metadata: null,
licenseKey: null,
storageClass: null,
- isProduction: null,
+ isProduction: true,
},
timeoutInTest: 1000,
requestHandler: null,
diff --git a/packages/licensing/src/get-usage.d.ts b/packages/licensing/src/get-usage.d.ts
new file mode 100644
index 0000000000..7398e8deae
--- /dev/null
+++ b/packages/licensing/src/get-usage.d.ts
@@ -0,0 +1,21 @@
+export type EventCount = {
+ billable: number;
+ failed: number;
+ development: number;
+};
+export type GetUsageApiResponse = {
+ success: true;
+ cloudRenders: EventCount;
+ webcodecConversions: EventCount;
+} | {
+ success: false;
+ error: string;
+};
+export type GetUsageResponse = {
+ cloudRenders: EventCount;
+ webcodecConversions: EventCount;
+};
+export declare const getUsage: ({ apiKey, since, }: {
+ apiKey: string;
+ since?: number | null | undefined;
+}) => Promise<GetUsageResponse>;
diff --git a/packages/licensing/src/index.d.ts b/packages/licensing/src/index.d.ts
new file mode 100644
index 0000000000..644740873b
--- /dev/null
+++ b/packages/licensing/src/index.d.ts
@@ -0,0 +1,16 @@
+export { UsageEventClassification as Classification, RegisterUsageEventResponse, registerUsageEvent, } from './register-usage-event';
+export { EventCount, GetUsageResponse, getUsage } from './get-usage';
+export declare const LicensingInternals: {
+ internalRegisterUsageEvent: ({ host, succeeded, event, isStill, isProduction, ...apiOrLicenseKey }: ({
+ host: string | null;
+ succeeded: boolean;
+ event: "cloud-render" | "webcodec-conversion";
+ } & ({
+ apiKey: string | null;
+ } | {
+ licenseKey: string | null;
+ })) & {
+ isStill: boolean;
+ isProduction: boolean;
+ }) => Promise<import("./register-usage-event").RegisterUsageEventResponse>;
+};
diff --git a/packages/licensing/src/index.ts b/packages/licensing/src/index.ts
index c09446839e..d3c437d824 100644
--- a/packages/licensing/src/index.ts
+++ b/packages/licensing/src/index.ts
@@ -1,3 +1,5 @@
+import { internalRegisterUsageEvent } from './register-usage-event';
+
export {
UsageEventClassification as Classification,
RegisterUsageEventResponse,
@@ -5,3 +7,7 @@ export {
} from './register-usage-event';
export {EventCount, GetUsageResponse, getUsage} from './get-usage';
+
+export const LicensingInternals = {
+ internalRegisterUsageEvent
+}
\ No newline at end of file
diff --git a/packages/licensing/src/is-network-error.d.ts b/packages/licensing/src/is-network-error.d.ts
new file mode 100644
index 0000000000..c3d05bc997
--- /dev/null
+++ b/packages/licensing/src/is-network-error.d.ts
@@ -0,0 +1 @@
+export declare function isNetworkError(error: Error): boolean;
diff --git a/packages/licensing/src/register-usage-event.d.ts b/packages/licensing/src/register-usage-event.d.ts
new file mode 100644
index 0000000000..66167e60b0
--- /dev/null
+++ b/packages/licensing/src/register-usage-event.d.ts
@@ -0,0 +1,34 @@
+export declare const HOST = "https://www.remotion.pro";
+import type { NoReactInternals } from 'remotion/no-react';
+export declare const exponentialBackoffMs: (attempt: number) => number;
+export declare const sleep: (ms: number) => Promise<void>;
+export type RegisterUsageEventResponse = {
+ billable: boolean;
+ classification: UsageEventClassification;
+};
+type UsageEventType = 'webcodec-conversion' | 'cloud-render';
+export type UsageEventClassification = 'billable' | 'development' | 'failed';
+type EitherApiKeyOrLicenseKey = true extends typeof NoReactInternals.ENABLE_V5_BREAKING_CHANGES ? {
+ licenseKey: string | null;
+} : {
+ /**
+ * @deprecated Use `licenseKey` instead
+ */
+ apiKey: string | null;
+} | {
+ licenseKey: string | null;
+};
+type RegisterUsageEventMandatoryOptions = {
+ host: string | null;
+ succeeded: boolean;
+ event: UsageEventType;
+} & EitherApiKeyOrLicenseKey;
+type OptionalRegisterUsageEventOptional = {
+ isStill: boolean;
+ isProduction: boolean;
+};
+type InternalRegisterUsageEventOptions = RegisterUsageEventMandatoryOptions & OptionalRegisterUsageEventOptional;
+type RegisterUsageEventOptions = RegisterUsageEventMandatoryOptions & Partial<OptionalRegisterUsageEventOptional>;
+export declare const internalRegisterUsageEvent: ({ host, succeeded, event, isStill, isProduction, ...apiOrLicenseKey }: InternalRegisterUsageEventOptions) => Promise<RegisterUsageEventResponse>;
+export declare const registerUsageEvent: (options: RegisterUsageEventOptions) => Promise<RegisterUsageEventResponse>;
+export {};
diff --git a/packages/licensing/src/register-usage-event.ts b/packages/licensing/src/register-usage-event.ts
index 2eee75ef71..f487e1fa7f 100644
--- a/packages/licensing/src/register-usage-event.ts
+++ b/packages/licensing/src/register-usage-event.ts
@@ -50,20 +50,32 @@ type EitherApiKeyOrLicenseKey =
licenseKey: string | null;
};
-export const registerUsageEvent = async ({
+type RegisterUsageEventMandatoryOptions = {
+ host: string | null;
+ succeeded: boolean;
+ event: UsageEventType;
+} & EitherApiKeyOrLicenseKey;
+
+type OptionalRegisterUsageEventOptional = {
+ isStill: boolean;
+ isProduction: boolean;
+};
+
+
+type InternalRegisterUsageEventOptions = RegisterUsageEventMandatoryOptions &
+ OptionalRegisterUsageEventOptional;
+
+type RegisterUsageEventOptions = RegisterUsageEventMandatoryOptions &
+ Partial<OptionalRegisterUsageEventOptional>;
+
+export const internalRegisterUsageEvent = async ({
host,
succeeded,
event,
isStill,
isProduction,
...apiOrLicenseKey
-}: {
- host: string | null;
- succeeded: boolean;
- event: UsageEventType;
- isStill?: boolean;
- isProduction?: boolean;
-} & EitherApiKeyOrLicenseKey): Promise<RegisterUsageEventResponse> => {
+}: InternalRegisterUsageEventOptions): Promise<RegisterUsageEventResponse> => {
const apiKey = 'apiKey' in apiOrLicenseKey ? apiOrLicenseKey.apiKey : null;
const licenseKey =
'licenseKey' in apiOrLicenseKey ? apiOrLicenseKey.licenseKey : null;
@@ -140,3 +152,13 @@ export const registerUsageEvent = async ({
throw lastError;
};
+
+export const registerUsageEvent = (
+ options: RegisterUsageEventOptions,
+): Promise<RegisterUsageEventResponse> => {
+ return internalRegisterUsageEvent({
+ ...options,
+ isStill: options.isStill ?? false,
+ isProduction: options.isProduction ?? true,
+ });
+};
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 1bf3da6565..dc69ab5e52 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -1,4 +1,4 @@
-import {registerUsageEvent} from '@remotion/licensing';
+import {LicensingInternals} from '@remotion/licensing';
import type {ExecaChildProcess} from 'execa';
import fs from 'node:fs';
import os from 'node:os';
@@ -834,12 +834,13 @@ const internalRenderMediaRaw = ({
return;
}
- registerUsageEvent({
+ LicensingInternals.internalRegisterUsageEvent({
event: 'cloud-render',
host: null,
succeeded: true,
licenseKey: licenseKey ?? null,
- isProduction: isProduction ?? undefined,
+ isProduction: isProduction ?? true,
+ isStill: false,
})
.then(() => {
Log.verbose({indent, logLevel}, 'Usage event sent successfully');
diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.ts
index 04bbaacb5c..e889559151 100644
--- a/packages/renderer/src/render-still.ts
+++ b/packages/renderer/src/render-still.ts
@@ -1,4 +1,4 @@
-import {registerUsageEvent} from '@remotion/licensing';
+import {LicensingInternals, } from '@remotion/licensing';
import fs, {statSync} from 'node:fs';
import path from 'node:path';
import type {_InternalTypes} from 'remotion';
@@ -426,13 +426,14 @@ const internalRenderStillRaw = (
return;
}
- registerUsageEvent({
+ LicensingInternals.internalRegisterUsageEvent({
licenseKey: options.licenseKey ?? options.apiKey ?? null,
event: 'cloud-render',
host: null,
succeeded: true,
isStill: true,
- isProduction: options.isProduction ?? undefined,
+ isProduction: options.isProduction ?? true,
+
})
.then(() => {
Log.verbose(options, 'Usage event sent successfully');
diff --git a/packages/serverless-client/src/constants.ts b/packages/serverless-client/src/constants.ts
index 98e8328c61..ee86b34353 100644
--- a/packages/serverless-client/src/constants.ts
+++ b/packages/serverless-client/src/constants.ts
@@ -221,7 +221,7 @@ export type ServerlessPayloads<Provider extends CloudProvider> = {
metadata: Record<string, string> | null;
licenseKey: string | null;
storageClass: Provider['storageClass'] | null;
- isProduction: boolean | null;
+ isProduction: boolean;
};
status: ServerlessStatusPayload<Provider>;
renderer: {
diff --git a/packages/serverless/src/handlers/launch.ts b/packages/serverless/src/handlers/launch.ts
index 72dd8d7c2b..17e7e15398 100644
--- a/packages/serverless/src/handlers/launch.ts
+++ b/packages/serverless/src/handlers/launch.ts
@@ -725,12 +725,12 @@ export const launchHandler = async <Provider extends CloudProvider>({
});
clearTimeout(webhookDueToTimeout);
- sendTelemetryEvent(
- params.licenseKey ?? null,
- params.logLevel,
- null,
- params.isProduction,
- );
+ sendTelemetryEvent({
+ licenseKey: params.licenseKey ?? null,
+ logLevel: params.logLevel,
+ isStill: false,
+ isProduction: params.isProduction ?? true,
+ });
if (!params.webhook || webhookInvoked) {
return;
diff --git a/packages/serverless/src/handlers/send-telemetry-event.ts b/packages/serverless/src/handlers/send-telemetry-event.ts
index 2b38dea230..dba42b29dd 100644
--- a/packages/serverless/src/handlers/send-telemetry-event.ts
+++ b/packages/serverless/src/handlers/send-telemetry-event.ts
@@ -1,26 +1,31 @@
-import {registerUsageEvent} from '@remotion/licensing';
+import {LicensingInternals} from '@remotion/licensing';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-export const sendTelemetryEvent = async (
- licenseKey: string | null,
- logLevel: LogLevel,
- isStill: boolean | null,
- isProduction: boolean | null,
-) => {
+export const sendTelemetryEvent = async ({
+ licenseKey,
+ logLevel,
+ isStill,
+ isProduction,
+}: {
+ licenseKey: string | null;
+ logLevel: LogLevel;
+ isStill: boolean;
+ isProduction: boolean;
+}) => {
if (licenseKey === null) {
return Promise.resolve();
}
try {
// https://www.remotion.dev/docs/licensing
- await registerUsageEvent({
+ await LicensingInternals.internalRegisterUsageEvent({
licenseKey,
event: 'cloud-render',
host: null,
succeeded: true,
- isStill: isStill ?? undefined,
- isProduction: isProduction ?? undefined,
+ isStill,
+ isProduction,
});
RenderInternals.Log.info({indent: false, logLevel}, 'Telemetry event sent');
} catch (err) {
diff --git a/packages/serverless/src/handlers/start.ts b/packages/serverless/src/handlers/start.ts
index 2713dd24ba..1f43ac71c2 100644
--- a/packages/serverless/src/handlers/start.ts
+++ b/packages/serverless/src/handlers/start.ts
@@ -129,7 +129,7 @@ export const startHandler = async <Provider extends CloudProvider>({
offthreadVideoThreads: params.offthreadVideoThreads,
storageClass: params.storageClass,
mediaCacheSizeInBytes: params.mediaCacheSizeInBytes,
- isProduction: params.isProduction,
+ isProduction: params.isProduction ?? true,
};
await providerSpecifics.callFunctionAsync({
diff --git a/packages/serverless/src/handlers/still.ts b/packages/serverless/src/handlers/still.ts
index 14f5fb356a..0f3fbedc2f 100644
--- a/packages/serverless/src/handlers/still.ts
+++ b/packages/serverless/src/handlers/still.ts
@@ -364,12 +364,12 @@ const innerStillHandler = async <Provider extends CloudProvider>(
forcePathStyle: params.forcePathStyle,
}),
server.closeServer(true),
- sendTelemetryEvent(
- params.licenseKey ?? params.apiKey,
- params.logLevel,
- true,
- null,
- ),
+ sendTelemetryEvent({
+ licenseKey: params.licenseKey ?? params.apiKey,
+ logLevel: params.logLevel,
+ isStill: true,
+ isProduction: params.isProduction ?? true,
+ }),
]);
const estimatedPrice = providerSpecifics.estimatePrice({
diff --git a/packages/web-renderer/src/render-media-on-web.tsx b/packages/web-renderer/src/render-media-on-web.tsx
index 58e73d70d6..8496957470 100644
--- a/packages/web-renderer/src/render-media-on-web.tsx
+++ b/packages/web-renderer/src/render-media-on-web.tsx
@@ -465,7 +465,7 @@ const internalRenderMediaOnWeb = async <
licenseKey: licenseKey ?? null,
succeeded: true,
apiName: 'renderMediaOnWeb',
- isStill: null,
+ isStill: false,
isProduction: null,
});
@@ -486,7 +486,7 @@ const internalRenderMediaOnWeb = async <
licenseKey: licenseKey ?? null,
succeeded: true,
apiName: 'renderMediaOnWeb',
- isStill: null,
+ isStill: false,
isProduction: null,
});
@@ -508,7 +508,7 @@ const internalRenderMediaOnWeb = async <
succeeded: false,
licenseKey: licenseKey ?? null,
apiName: 'renderMediaOnWeb',
- isStill: null,
+ isStill: false,
isProduction: null,
}).catch((err2) => {
Internals.Log.error(
diff --git a/packages/web-renderer/src/send-telemetry-event.ts b/packages/web-renderer/src/send-telemetry-event.ts
index 02d08bcf31..7e1b4edd75 100644
--- a/packages/web-renderer/src/send-telemetry-event.ts
+++ b/packages/web-renderer/src/send-telemetry-event.ts
@@ -1,4 +1,4 @@
-import {registerUsageEvent} from '@remotion/licensing';
+import {LicensingInternals} from '@remotion/licensing';
import {Internals} from 'remotion';
export const sendUsageEvent = async ({
@@ -11,8 +11,8 @@ export const sendUsageEvent = async ({
licenseKey: string | null;
succeeded: boolean;
apiName: string;
- isStill: boolean | null;
- isProduction: boolean | null;
+ isStill: boolean;
+ isProduction: boolean;
}) => {
const host =
typeof window === 'undefined'
@@ -31,12 +31,12 @@ export const sendUsageEvent = async ({
);
}
- await registerUsageEvent({
+ await LicensingInternals.internalRegisterUsageEvent({
licenseKey: licenseKey === 'free-license' ? null : licenseKey,
event: 'webcodec-conversion',
host,
succeeded,
- isStill: isStill ?? undefined,
- isProduction: isProduction ?? undefined,
+ isStill,
+ isProduction,
});
};