Skip to content

Commit 248012e

Browse files
ahorowitz123claude
andauthored
feat(content-preview): forward monitoring dimensions (#4542)
* feat(content-preview): forward monitoring dimensions to Preview Accept accessPattern, previewMode, sharedLinkAuth as props on ContentPreview and pass them through to the underlying Preview library so emitted metric/error events are tagged for the monitoring dashboard. PREVIEW-225 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(content-preview): forward preload/prefetch status to Preview Accepts two new optional props on ContentPreview — prefetchStatus and preloadStatus — and threads them into previewOptions so box-content-preview can tag emitted load/error/outcome events. PREVIEW-225 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * revert(content-preview): stop forwarding preload/prefetch status box-content-preview now derives both signals internally. The wrapper no longer accepts these props. PREVIEW-225 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(content-preview): forward preloadStatus to Preview Wrapper accepts preloadStatus prop and threads it into previewOptions so box-content-preview can tag emitted load/error/outcome events. PREVIEW-225 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * style(content-preview): sort new Props alphabetically Addresses PR comment: merge the 4 new monitoring-dimension props into alphabetical order with the existing Props type members. PREVIEW-225 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent aa05a39 commit 248012e

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

src/elements/content-preview/ContentPreview.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type StartAt = {
8585
};
8686

8787
type Props = {
88+
accessPattern?: 'file_list' | 'direct_link' | 'shared_link',
8889
advancedContentInsights: {
8990
isActive: boolean,
9091
ownerEId: number,
@@ -126,13 +127,16 @@ type Props = {
126127
onLoad: Function,
127128
onNavigate: Function,
128129
onVersionChange: VersionChangeCallback,
130+
preloadStatus?: 'hit' | 'miss',
129131
previewExperiences?: {
130132
[name: string]: TargetingApi,
131133
},
132134
previewLibraryVersion: string,
135+
previewMode?: 'default' | 'shared_file' | 'shared_folder' | 'editable_shared_file' | 'inline_feed',
133136
requestInterceptor?: Function,
134137
responseInterceptor?: Function,
135138
sharedLink?: string,
139+
sharedLinkAuth?: 'logged_in' | 'logged_out' | 'na',
136140
sharedLinkPassword?: string,
137141
showAnnotations?: boolean,
138142
showAnnotationsControls?: boolean,
@@ -899,6 +903,7 @@ class ContentPreview extends React.PureComponent<Props, State> {
899903
*/
900904
loadPreview = async (): Promise<void> => {
901905
const {
906+
accessPattern,
902907
advancedContentInsights, // will be removed once preview package will be updated to utilize feature flip for ACI
903908
annotatorState: { activeAnnotationId } = {},
904909
renderCustomPreview,
@@ -909,7 +914,10 @@ class ContentPreview extends React.PureComponent<Props, State> {
909914
onAnnotatorEvent,
910915
onAnnotator,
911916
onContentInsightsEventReport,
917+
preloadStatus,
912918
previewExperiences,
919+
previewMode,
920+
sharedLinkAuth,
913921
showAnnotationsControls,
914922
token: tokenOrTokenFunction,
915923
...rest
@@ -951,6 +959,7 @@ class ContentPreview extends React.PureComponent<Props, State> {
951959
}
952960

953961
const previewOptions = {
962+
accessPattern,
954963
advancedContentInsights, // will be removed once preview package will be updated to utilize feature flip for ACI
955964
container: `#${this.id} .bcpr-content`,
956965
enableBoundingBoxHighlights,
@@ -960,6 +969,9 @@ class ContentPreview extends React.PureComponent<Props, State> {
960969
header: 'none',
961970
headerElement: `#${this.id} .bcpr-PreviewHeader`,
962971
experiences: previewExperiences,
972+
preloadStatus,
973+
previewMode,
974+
sharedLinkAuth,
963975
showAnnotations: this.canViewAnnotations(),
964976
showAnnotationsControls,
965977
showDownload: this.canDownload(),

src/elements/content-preview/__tests__/ContentPreview.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,41 @@ describe('elements/content-preview/ContentPreview', () => {
385385
);
386386
});
387387

388+
test('should forward host-supplied monitoring dimensions to preview options', async () => {
389+
const wrapper = getWrapper({
390+
...props,
391+
accessPattern: 'file_list',
392+
preloadStatus: 'hit',
393+
previewMode: 'default',
394+
sharedLinkAuth: 'na',
395+
});
396+
wrapper.setState({ file });
397+
const instance = wrapper.instance();
398+
await instance.loadPreview();
399+
expect(instance.preview.show).toHaveBeenCalledWith(
400+
file.id,
401+
expect.any(Function),
402+
expect.objectContaining({
403+
accessPattern: 'file_list',
404+
preloadStatus: 'hit',
405+
previewMode: 'default',
406+
sharedLinkAuth: 'na',
407+
}),
408+
);
409+
});
410+
411+
test('should pass monitoring dimensions as undefined when host omits them', async () => {
412+
const wrapper = getWrapper(props);
413+
wrapper.setState({ file });
414+
const instance = wrapper.instance();
415+
await instance.loadPreview();
416+
const options = instance.preview.show.mock.calls[0][2];
417+
expect(options.accessPattern).toBeUndefined();
418+
expect(options.preloadStatus).toBeUndefined();
419+
expect(options.previewMode).toBeUndefined();
420+
expect(options.sharedLinkAuth).toBeUndefined();
421+
});
422+
388423
test('should call preview show with file version params if provided', async () => {
389424
const wrapper = getWrapper(props);
390425
wrapper.setState({

0 commit comments

Comments
 (0)