export function buildSchema()

in src/shippers/fullstory/src/get_properties_and_schema.ts [56:76]


export function buildSchema(context: object): FSSchema {
  return Object.fromEntries(
    Object.entries(context)
      // Discard any undefined values
      .map<[string, unknown]>(([key, value]) => {
        return Array.isArray(value) ? [key, value.filter((v) => typeof v !== 'undefined')] : [key, value];
      })
      // Discard reserved properties (no need to define them in the schema)
      .filter(([key]) => !FULLSTORY_RESERVED_PROPERTIES.includes(key))
      .filter(([, value]) => typeof value !== 'undefined' && (!Array.isArray(value) || value.length > 0))
      // Infer the type according to the FullStory specs
      .map(([key, value]) => {
        if (isRecord(value)) {
          return [key, buildSchema(value)];
        }
        const valueType = getFullStoryType(value);
        return [key, valueType];
      })
      .filter(([, value]) => typeof value !== 'undefined')
  );
}