Skip to content

batch fs properties into single native command#144

Open
RyanCommits wants to merge 1 commit intomasterfrom
ryanwang/batch-native-commands
Open

batch fs properties into single native command#144
RyanCommits wants to merge 1 commit intomasterfrom
ryanwang/batch-native-commands

Conversation

@RyanCommits
Copy link
Contributor

@RyanCommits RyanCommits commented Jan 28, 2026

VAL-9554

Overview

This refactoring changes from multiple individual native calls (one per property) to a single batched call. It attempts to reduce race conditions with React Native's rendering scheduler for the new architecture.

Copy link
Contributor

@martin-fs martin-fs left a comment

Choose a reason for hiding this comment

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

LGTM but please add another check for robustness.

}
if (props[@"dataComponent"]) {
set_dataComponent(props[@"dataComponent"], self);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a warning for any unrecognized props? Previously we always had a fallthrough. I assume if the commandName is setBatchProperties we don't want to fallthrough.

Easiest way to do this: count the handled props and compare that count to the total count in the dictionary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Creating a warning probably isn't worth it. We control the command call, so extra props wouldn't be expected. For the count to work, we'd have to get 7 prop types and above. Normally components wouldn't have all 6 fullstory attributes anyway, so we'd miss the warning if there was 1 or 2 extra props with 4 or less fullstory attributes.

@RyanCommits RyanCommits force-pushed the ryanwang/batch-native-commands branch from 4d522ec to 2db5247 Compare February 5, 2026 22:44
Comment on lines +378 to +399
if ([commandName isEqualToString:@"setBatchProperties"]) {
// Batched properties command - applies all properties in a single call
// to reduce race conditions with React Native's rendering scheduler
NSDictionary *props = args[0];
if (props[@"fsAttribute"]) {
set_fsAttribute(props[@"fsAttribute"], self);
}
if (props[@"fsClass"]) {
set_fsClass(props[@"fsClass"], self);
}
if (props[@"fsTagName"]) {
set_fsTagName(props[@"fsTagName"], self);
}
if (props[@"dataElement"]) {
set_dataElement(props[@"dataElement"], self);
}
if (props[@"dataSourceFile"]) {
set_dataSourceFile(props[@"dataSourceFile"], self);
}
if (props[@"dataComponent"]) {
set_dataComponent(props[@"dataComponent"], self);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ([commandName isEqualToString:@"setBatchProperties"]) {
// Batched properties command - applies all properties in a single call
// to reduce race conditions with React Native's rendering scheduler
NSDictionary *props = args[0];
if (props[@"fsAttribute"]) {
set_fsAttribute(props[@"fsAttribute"], self);
}
if (props[@"fsClass"]) {
set_fsClass(props[@"fsClass"], self);
}
if (props[@"fsTagName"]) {
set_fsTagName(props[@"fsTagName"], self);
}
if (props[@"dataElement"]) {
set_dataElement(props[@"dataElement"], self);
}
if (props[@"dataSourceFile"]) {
set_dataSourceFile(props[@"dataSourceFile"], self);
}
if (props[@"dataComponent"]) {
set_dataComponent(props[@"dataComponent"], self);
}
if ([commandName isEqualToString:@"setBatchProperties"]) {
NSUInteger commandCount = 0;
// Batched properties command - applies all properties in a single call
// to reduce race conditions with React Native's rendering scheduler
NSDictionary *props = args[0];
if (props[@"fsAttribute"]) {
set_fsAttribute(props[@"fsAttribute"], self);
commandCount++;
}
if (props[@"fsClass"]) {
set_fsClass(props[@"fsClass"], self);
commandCount++;
}
if (props[@"fsTagName"]) {
set_fsTagName(props[@"fsTagName"], self);
commandCount++;
}
if (props[@"dataElement"]) {
set_dataElement(props[@"dataElement"], self);
commandCount++;
}
if (props[@"dataSourceFile"]) {
set_dataSourceFile(props[@"dataSourceFile"], self);
commandCount++;
}
if (props[@"dataComponent"]) {
set_dataComponent(props[@"dataComponent"], self);
commandCount++;
}
if (props.count != commandCount) {
NSLog(@"FullStory: WARNING: Unrecognized command found in batch property command keys %@", [props allKeys]);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants