Guest User

Untitled

a guest
Jan 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. # Problem
  2.  
  3. The Feed feature team needs to instrument an A/B test across many (if not most) template types simultaneously. If possible, we'd like to do this in a way that is extensible and flexible for similar use cases down the road.
  4.  
  5. # Proposal
  6.  
  7. Establish the notion of card template "versions", which are specified as a top-level prop to the `FeedCard` component.
  8.  
  9. ## `feed-card-templates/src/index.js`
  10. ```jsx-harmony
  11. const ComponentVersionsByTemplateType = {
  12. [CARD_TEMPLATE_TYPES.BASIC]: {
  13. v2: TemplateComponents.BasicTemplateV2,
  14. default: TemplateComponents.BasicTemplate,
  15. },
  16. [CARD_TEMPLATE_TYPES.CONTENT]: {
  17. v2: TemplateComponents.ContentTemplateV2,
  18. default: TemplateComponents.ContentTemplate,
  19. },
  20. // ...
  21. };
  22.  
  23. export const FeedCard = ({
  24. handleCardAction,
  25. handleCardDismiss,
  26. onFocusCard,
  27. template,
  28. templateVersion,
  29. }) => {
  30. if (!isCardTemplateSupported(template)) return null;
  31. const componentVersions = ComponentVersionsByTemplateType[template.template_type];
  32. const CardTemplateComponent = _.get(componentVersions, templateVersion) || _.get(componentVersions, 'default');
  33. // Raise error if no `CardTemplateComponent`
  34. return (
  35. <CardTemplateComponent
  36. templateFields={template.template_fields}
  37. handleCardAction={handleCardAction}
  38. handleCardDismiss={handleCardDismiss}
  39. onFocusCard={onFocusCard}
  40. />
  41. );
  42. };
  43. ```
  44.  
  45. ## A/B test configuration
  46. ```
  47. {
  48. testName: "simplify_feed_ui",
  49. variants: {
  50. 1000: {
  51. variantName: "Control",
  52. customData: {
  53. templateVersions: {
  54. BASIC_TEMPLATE: "default",
  55. CONTENT_TEMPLATE: "default",
  56. // ...
  57. }
  58. }
  59. },
  60. 1001: {
  61. variantName: "Simplified feed cards",
  62. customData: {
  63. templateVersions: {
  64. BASIC_TEMPLATE: "v2",
  65. CONTENT_TEMPLATE: "v2",
  66. // ...
  67. }
  68. }
  69. }
  70. },
  71. }
  72. ```
  73.  
  74. ## Open questions
  75. * "Versioning" is a weighty, powerful concept that is important to get right. We don't intend to address all of the aspects that may eventually become important for versioning feed cards, but we want to be sure to lay a flexible groundwork that doesn't limit our options down the road.
  76. * Would it make sense to establish a directory structure convention for template versions, e.g.:
  77. ```
  78. - components
  79. - basic-template
  80. - default.js
  81. - index.js
  82. - v2.js
  83. - v3.js
  84. ```
  85.  
  86. ## Other notes
  87. * Would probably make sense to include `templateVersion` on feed card impression/action tracking events.
  88.  
  89. ## Discarded alternatives
  90. * Mutate feed card data objects on the client according to A/B test membership
  91. * Requires mutating what _should_ be a canonical data object served by the BE
  92. * Pass `activeExperiments` as a prop to the `FeedCard` and allow the implementation to choose the corresponding implementation
  93. * Requires `feed-card-templates` to have knowledge of A/B tests
Add Comment
Please, Sign In to add comment