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
6 changes: 5 additions & 1 deletion src/FSPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const FullStory = isTurboModuleEnabled
? require('./NativeFullStory').default
: NativeModules.FullStory;

const { startPage, endPage, updatePage } = FullStory;
const { startPage, endPage, updatePage } = FullStory || {
startPage: () => null,
endPage: () => null,
updatePage: () => null,
};

type UnknownObj = {
[key: string]: unknown | UnknownObj;
Expand Down
23 changes: 20 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const FullStory = isTurboModuleEnabled
? require('./NativeFullStory').default
: NativeModules.FullStory;

if (!FullStory) {
console.warn('FullStory: Native module not found. Falling back to stub implementations.');
}

const {
anonymize,
identify,
Expand All @@ -31,7 +35,20 @@ const {
restart,
log,
resetIdleTimer,
} = FullStory;
} = FullStory || {
anonymize: () => null,
identify: () => null,
setUserVars: () => null,
onReady: () => Promise.resolve({ replayStartUrl: '', replayNowUrl: '', sessionId: '' }),
getCurrentSession: () => Promise.resolve(''),
getCurrentSessionURL: () => Promise.resolve(''),
consent: () => null,
event: () => null,
shutdown: () => null,
restart: () => null,
log: () => null,
resetIdleTimer: () => null,
};

const FullStoryPrivate = isTurboModuleEnabled
? require('./NativeFullStoryPrivate').default
Expand Down Expand Up @@ -60,7 +77,7 @@ interface NativeCommands {
dataComponent: (viewRef: ComponentRef<FSComponentType>, dataElement: string) => void;
}

/*
/*
Calling these commands sequentially will *not* lead to an intermediate state where views
have incomplete attribute values. React's rendering phases protects against this race condition.
See DOC-1863 for more information.
Expand Down Expand Up @@ -98,7 +115,7 @@ type FSNativeElement = ComponentRef<FSComponentType> & {

// Shared wrapper for components without refs (most common case)
function sharedRefWrapper(element: FSNativeElement | null) {
if (element && isTurboModuleEnabled && Platform.OS === 'ios') {
if (element && isTurboModuleEnabled && Platform.OS === 'ios' && !Platform.isTV) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tvOS shouldn't be iOS (Apple treats them as separate platforms), but I guess it is because the issue implies that it is.

let currentProps: Record<keyof NativeCommands, string | object>;

if (getInternalInstanceHandleFromPublicInstance) {
Expand Down