Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions apps/docs/solutions/esign/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ Complete eSign component API
```
</ParamField>

<ParamField path="telemetry" type="object">
Telemetry configuration. Enabled by default with `source: 'esign'` metadata. See [Telemetry](/resources/telemetry) for details.

<Expandable title="properties">
<ParamField path="enabled" type="boolean" default="true">
Enable or disable telemetry
</ParamField>
<ParamField path="metadata" type="Record<string, any>">
Custom metadata merged with the default `{ source: 'esign' }`
</ParamField>
</Expandable>
</ParamField>

<ParamField path="licenseKey" type="string">
License key for SuperDoc. Passed directly to the underlying SuperDoc instance.
</ParamField>

<ParamField path="isDisabled" type="boolean">
Disable all interactions
</ParamField>
Expand Down
29 changes: 29 additions & 0 deletions apps/docs/solutions/esign/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,35 @@ Style the component to match your brand.
/>
```

## Telemetry

Telemetry is enabled by default with `source: 'esign'` metadata. You can override or extend the defaults:

```jsx
<SuperDocESign
telemetry={{ enabled: true, metadata: { source: "my-app", environment: "production" } }}
// ... other props
/>
```

To disable telemetry:

```jsx
<SuperDocESign telemetry={{ enabled: false }} />
```

For more details on how telemetry works, see the [Telemetry](/resources/telemetry) page.

## License key

Pass your license key to activate commercial features:

```jsx
<SuperDocESign licenseKey="your-license-key" />
```

The key is forwarded to the underlying SuperDoc instance.

## Complete example

```jsx
Expand Down
1 change: 1 addition & 0 deletions packages/esign/demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export function App() {
<SuperDocESign
ref={esignRef}
eventId={eventId}
telemetry={{ enabled: true, metadata: { source: 'esign-demo' } }}
document={{
source: documentSource,
mode: 'full',
Expand Down
24 changes: 22 additions & 2 deletions packages/esign/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef, useState, useEffect, useCallback, forwardRef, useImperativeHandle } from 'react';
import { useRef, useState, useEffect, useCallback, useMemo, forwardRef, useImperativeHandle } from 'react';
import type { SuperDoc } from 'superdoc';
import type * as Types from './types';
import { textToImageDataUrl } from './utils/signature';
Expand All @@ -22,6 +22,8 @@
onStateChange,
onFieldChange,
onFieldsDiscovered,
telemetry,
licenseKey,
isDisabled = false,
className,
style,
Expand Down Expand Up @@ -57,7 +59,7 @@

// Handle table fields
if (field.type === 'table' && Array.isArray(field.value)) {
const helpers = (editor.helpers as any)?.structuredContentCommands;

Check warning on line 62 in packages/esign/src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
const tables = helpers?.getStructuredContentTablesById?.(field.id, editor.state) || [];

if (tables.length) {
Expand Down Expand Up @@ -86,7 +88,7 @@
}

// Append new rows after row 0 (copies style from row 0)
(editor.commands as any)?.appendRowsToStructuredContentTable?.({

Check warning on line 91 in packages/esign/src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
id: field.id,
rows: field.value,
copyRowStyle: true,
Expand Down Expand Up @@ -138,7 +140,7 @@
});

const discovered: Types.FieldInfo[] = tags
.map(({ node }: any) => ({

Check warning on line 143 in packages/esign/src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
id: node.attrs.id,
label: node.attrs.label,
value: configValues.get(node.attrs.id) ?? node.textContent ?? '',
Expand Down Expand Up @@ -178,7 +180,7 @@
...event,
timestamp: new Date().toISOString(),
};
const auditMock = (globalThis as any)?.__SUPERDOC_AUDIT_MOCK__;

Check warning on line 183 in packages/esign/src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
if (auditMock) {
auditMock(auditEvent);
}
Expand All @@ -188,6 +190,14 @@
return nextTrail;
};

const stableTelemetry = useMemo(
() => ({
enabled: telemetry?.enabled ?? true,
metadata: { source: 'esign', ...telemetry?.metadata },
}),
[telemetry?.enabled, JSON.stringify(telemetry?.metadata)],

Check warning on line 198 in packages/esign/src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

React Hook useMemo has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked

Check warning on line 198 in packages/esign/src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

React Hook useMemo has a missing dependency: 'telemetry?.metadata'. Either include it or remove the dependency array
);

// Initialize SuperDoc - uses abort pattern to handle React 18 Strict Mode
// which intentionally double-invokes effects to help identify cleanup issues
useEffect(() => {
Expand All @@ -212,6 +222,8 @@
viewOptions: {
layout: document.viewOptions?.layout ?? (document.layoutMode === 'responsive' ? 'web' : 'print'),
},
telemetry: stableTelemetry,
...(licenseKey && { licenseKey }),
onReady: () => {
// Guard callback execution if cleanup already ran
if (aborted) return;
Expand All @@ -238,7 +250,15 @@
superdocRef.current = null;
};
// Use primitives to avoid re-init on every render when object references change
}, [document.source, document.mode, document.layoutMode, document.viewOptions?.layout, discoverAndApplyFields]);
}, [
document.source,
document.mode,
document.layoutMode,
document.viewOptions?.layout,
discoverAndApplyFields,
stableTelemetry,
licenseKey,
]);

useEffect(() => {
if (!document.validation?.scroll?.required || !isReady) return;
Expand Down
6 changes: 6 additions & 0 deletions packages/esign/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export interface SuperDocESignProps {
onFieldChange?: (field: FieldChange) => void;
onFieldsDiscovered?: (fields: FieldInfo[]) => void;

/** Telemetry configuration for SuperDoc */
telemetry?: { enabled: boolean; metadata?: Record<string, any> };

/** License key for SuperDoc */
licenseKey?: string;

isDisabled?: boolean;
className?: string;
style?: React.CSSProperties;
Expand Down
Loading