Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Status
colourGreen
titleAccurate

Code Block
languagejs
linenumberstrue
{
  "config": { // All clients listen here permanently
    "articleBaseUrl": "http://cloud-storage.com/articles/",
  },   "userslegalsUrl": {"http://impossible.am/legalstuff/",
    "user_id_01for7MW": { // Clients listen here permanently
      "usernamefacebookPage": "user", //
[default:null]       "emailfacebookGroup": "user@somewhere.com", // [default:null]
      "fitnessLevelinstagramUser": 10"",
// [default:10]       "fitnessBiasfaqsUrl": 1, // [default:1]
 ""
    },
    "createdforAfterburner": {
 987654345, // Unix timestamp (seconds) [default:0] "facebookPage": "",
      "maxImpactCreditfacebookGroup": 3, // [default:0]"",
      "impactCreditinstagramUser": 0.9"",
// [default:0]       "updatedICfaqsUrl": 987654345,""
// Unix timestamp (seconds) [default:0] }
  },
   "triggersFiredusers": {
"triggerId_01": true, "triggerId_02    "user_id_01": true{ }, // [default:null]Clients listen here   permanently
 "sessions": {         "for7MWusername": 2"user", // [default:0null]
 
      "forAfterburneremail": 0"user@somewhere.com", // [default:0]
      },null]
      "totalActivitiesfitnessLevel": 210, // [default:010]
      "totalActivities7MWfitnessBias": 1, // [default:01]
      "totalActivitiesAFcreated": 1987654345, // Unix timestamp (seconds) [default:0]
      "firstActivity7MWmaxImpactCredit": 9876543453, // Unix timestamp (seconds) [default:0]
      "impactCredit": 0.9, // [default:0]
      "firstActivityAFupdatedIC": 987654345, // Unix timestamp (seconds) [default:0]
    }   },
  "visibleWorkoutDefs": { // Workout defs that are visible to the user"triggersFired": { "triggerId_01": true, "triggerId_02": true }, // [default:null]
      "user_id_01sessions": {
        "for7MW": {2, // 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "wktdef1": {[default:0]
        "forAfterburner": 0 // [default:0]
      },
      "recommendedtotalActivities": "", // Not recommended, just visible2, // [default:null0]
	      "lockedtotalActivities7MW": true1, // Not[default:0]
available to user (unlocked via IAP and/or journey trigger) "totalActivitiesAF": 1, // [default:false0]
		    "lockString  "firstActivity7MW": "Finish 6 more workouts before Thurs 9th June"987654345, // DisplayedUnix totimestamp user(seconds) [default:null0]
          "MWIfirstActivityAF": 0.54987654345, // Unix timestamp (seconds) [default:0.5]
  
       "breakdowntimedNotifSeqVersion": {0, // Version of timed notif sequence user is on (server   "epoc": 0.1, // use) [default:0.25]
            "cardio"testMode": 0.1false, // [default:0.25]
            "metabolic": 0.1, //Puts the app in 'test mode' for this user [default:0.25false]
      "notifTokens": { // APN tokens for "strength": 0.1 //the user's devices [default:0.25null]
        "for7MW":  }
        },{ "apn_token": true }, // Where 'api_token' is the actual token string
        "wktdef2forAfterburner": { "apn_token": true }
      }
    "recommended}
  },
  "visibles": "You{
need to work on your abs","workoutDefs": { // RecommendedWorkout anddefs reasonthat forare thisvisible to the user
be shown to user 		  "lockeduser_id_01": false,{ //
Available to    user 		  "lockStringfor7MW": "",{ // 7MW clients listen here permanently for ChildAdded, ChildChanged  "MWI": 0.54,and ChildRemoved
          "breakdownwktdef1": {
            "epocrecommended": 0.1"", // Not recommended, just visible        "cardio": 0.1,// [default:null]
            "metaboliclocked": 0.1true, // Not available to user (unlocked via IAP and/or journey trigger) [default:false]
 "strength": 0.1 	        "lockString": "Finish 6 }more workouts before Thurs 9th June", // Displayed to }user [default:null]
     },       "forAfterburnerMWI": {0.54, // Afterburner clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved[default:0.5]
            "wktdef1breakdown": {
              "recommendedepoc": ""0.1, // Not recommended, just visible
	[default:0.25]
              "lockedcardio": false0.1, // Available to user
		  "lockString": "",[default:0.25]
               "MWImetabolic": 0.541, // [default:0.25]
        "breakdown": {
            "epoc"strength": 0.1,
 // [default:0.25]
           "cardio": 0.1, }
          },
 "metabolic": 0.1,
            "strengthwktdef2": 0.1
          }
        },
        "wktdef2": {{
            "recommended": "You need to work on your abs", // Recommended and reason for this to be shown to user
		
            "locked": false, // Available to user
		
            "lockString": "",
            "MWI": 0.54,
            "breakdown": {
              "epoc": 0.1,
              "cardio": 0.1,
              "metabolic": 0.1,
              "strength": 0.1
          }  }
      }     }
 }     }   },
  "workouts": {     "activities": {
      "user_id_01forAfterburner": { // Afterburner Clientsclients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "workout_id_01  "wktdef1": { //
Clients post new activity to here with auto id, server listens           "workoutDefId"recommended": "wktdef1", // Not [no default]
recommended, just visible
  	        "finishlocked": 987654345false, // UnixAvailable timestamp (seconds) [default:0]to user
  	        "iterationslockString": 1.5, // Number of times it was performed [default:1]"",
            "exertionMWI": 0.554,
// [default:0.5]           "finalHeartRateBPMbreakdown": {
 160, // [default:140]           "finalHeartRateDelayepoc": 0.1,
//  Length of delay (in secs) after the workout before the HR was measured"cardio": (0 if they didn't press the 'start again' button) [default:0]
		  "app": "7MW" // Short code of the app the activity was performed in: 7MW, AF, etc [default:null].1,
              "metabolic": 0.1,
              "strength": 0.1
            }
      }     },
 
  "results": {       "user_id_01wktdef2": {
// Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved   "recommended": "You need to work on your "workout_id_01": {abs", // Server posts workout results here Recommended and reason for this to be shown to user
            "workoutDefIdlocked": "wktdef1"false, // [no default] Available to user
            "finishlockString": 987654345, // Unix timestamp (seconds) // [no default]"",
               "AWIMWI": 0.154,
// [default:0.5]
            "responseDurationbreakdown": {
3456, // [default: 0]           "intensityepoc": 0.91,
// [default:0.5] 		  "app": "7MW", // Short code of the app the activity was performed in"cardio": 7MW0.1,
AF, etc [no default]           "responsesmetabolic": { // [no default]0.1,
              "cardiostrength": {0.1
            }
 "stress": 43,        }
      "magnitudeProduct": 0.6, }
      }
      "halflifeProduct": 0.3},
    "routines": {
        "duration"user_id_01": 5678,
    { 
        "volumefor7MW": 3456{ // 7MW clients listen here permanently for ChildAdded, ChildChanged    },
 and ChildRemoved
          "strengthroutine_id_01": {

             "stresslocked": 43true, // Not available to user (unlocked via IAP and/or journey     "magnitudeProduct": 0.6,trigger) [default:false]
            "lockString": "Finish 6 "halflifeProduct": 0.3,
        more workouts before Thurs 9th June" // Displayed to user [default:null]
     "duration": 5678,    },
          "volumeroutine_id_02": {
3456            "locked": }true,
            "epoclockString": {"" // No lock string, so only unlocked via IAP [default:null]
     "stress": 43,    },
          "magnitudeProductroutine_id_03": 0.6,
{
             "halflifeProductlocked": 0.3false, // Available
            "durationlockString": 5678,""
            }
 "volume": 3456      },
      },  "forAfterburner": { // 7MW clients listen here permanently for ChildAdded, ChildChanged "metabolic": {
and ChildRemoved
             "stress"routine_id_03": 43,{
              "magnitudeProduct"locked": 0.6false, // Available
            "halflifeProductlockString": 0.3, ""
          }
        }
 "duration": 5678,    }
    }
  },
  "volumeworkouts": 3456{
    "activities": {
      }
          },
"user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
         "muscleGroupsworkout_id_01": { // Clients post new activity to here with auto id, server listens
          "upperworkoutDefId": 0.3"wktdef1", // [no default: 0.3]
 
          "lowerfinish": 0.3987654345, // Unix timestamp (seconds) [default: 0.3]

           "coreiterations": 01.45, // Number of times it was performed [default: 0.31]
          }
  "exertion": 0.5, // [default:0.5]
     }     "finalHeartRateBPM": 160,  }// [default:140]
    }   },   "afterburnfinalHeartRateDelay": {0, // Length of  "user_id_01": { // Clients listen here permanently
      "start": 345678987, // Unix timestamp (seconds) // [no default]
      "response": { //delay (in secs) after the workout before the HR was measured (0 if they didn't press the 'start again' button) [default:0]
		  "app": "7MW" // Short code of the app the activity was performed in: 7MW, AF, etc [default:null]
         "resolution": 600, // Secs}
      }
    },
    "epocresults": [0.6,0.5,0.3,0.2,0.1,0.0],{
        "cardio": [0.6,0.5,0.3,0.2,0.1,0.0],
        "strength": [0.6,0.5,0.3,0.2,0.1,0.0],"user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "metabolicworkout_id_01": [0.6,0.5,0.3,0.2,0.1,0.0]
   { // Server posts workout results here
   },       "impactCreditworkoutDefId": {"wktdef1", // [no default:null]
          "resolutionfinish": 600987654345, // SecsUnix timestamp (seconds) // [no default]
   "futureCredit": 0.9,         "pendingAWI": [0.0,0.1, // [default:0.2,0.3,0.4,0.5]
      },
      "messagesresponseDuration": [3456, // Messages displayed below the radar chart [default:null 0]
          {"tintensity": 0,"body":"Restoring body temperature", "detail.9, // [default:0.5]
		  "app": "7MW"}, // Short code of the app the activity was performed {"t":120,"body":"Replenishing glycogen stores", "detail": "detail/glycogen"}
  in: 7MW, AF, etc [no default]
   ],       "notificationsresponses": [{ // [no default:null]
            {"tcardio":6000,"body":"Great workout! You're still burning calories and building strength."}, {
              {"tstress":14400,"body":"Fitness test unlocked! You're ready to take another fitness test."} 43,
               ]
 "magnitudeProduct": 0.6,
  }   },   "timelineArticles": {     "user_id_01halflifeProduct": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved0.3,
               "article_id_01duration": {5678,
         "date": 4567890987, // Unix timestamp (seconds) // [no default] "volume": 3456
          "title": "Post title"},
//  [no default]         "readstrength": false, // [default:true]{
              "locationstress": "post/location.html", // [no default]
		"icon": "default", // [default:"default"]43,
              "appMaskmagnitudeProduct": "7MW,AF" // [default: all apps]0.6,
             } "halflifeProduct": 0.3,
  }   },   "definitions": {     "exerciseDefsduration": {5678,
// Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved       "exdef1volume": {3456
           "behaviour": 1},
 // [default:1]           "titleepoc": "Cruches", // [no default]{
              "videostress": "01-Crunches.mp4"43,
// [no default]              "imagemagnitudeProduct": "abs", // [default:"default"]0.6,
              "deschalflifeProduct": "A crunch begins with lying face up on the floor with knees bent. The movement begins by curling the shoulders towards the pelvis. The hands can be behind or beside the neck or crossed over the chest. Injury can be caused by pushing against the head or neck with hands.", // [default:null]0.3,
              "duration": 5678,
              "volume": 3456
            },
            "subtitlemetabolic": "Target{
your abs for a balanced set of stomach muscles.", // [default:null]    "stress": 43,
   "calPerSec": 5, // [default:0]         "skillmagnitudeProduct": 0.26,
  // [default:0.5]            "strengthhalflifeProduct": 0.73,
  // [default:0.5]            "cardioduration": 0.1, // [default:0.5]5678,
              "epocvolume": 0.4, // [default:0.5]3456
            }
          },
          "metabolicmuscleGroups": 0.4, // [default:0.5] {
            "upper": 0.53, // [default: 0.53]
            "corelower": 0.53, // [default: 0.53]
            "lowercore": 0.54 // [default: 0.53]
          },
      "exdef2": { }
      }
"behaviour": 1,   }
  },
  "titleafterburn": "Squats",{
    "user_id_01": { // Clients "video": "02-Squats.mp4",
listen here permanently
       "imagestart": "abs"345678987, // Unix timestamp (seconds) // [no default]
      "descresponse": "Squats{ are an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks."// [default:null]
        "resolution": 600, // Secs
        "epoc": [0.6,0.5,0.3,0.2,0.1,0.0],
        "subtitlecardio": "Train your lower body and core."[0.6,0.5,0.3,0.2,0.1,0.0],
        "calPerSecstrength": 4[0.6,0.5,0.3,0.2,0.1,0.0],
        "skillmetabolic": [0.6,0.5,0.3,0.2,0.1,0.0]
      },
      "strengthimpactCredit": 0.6,{ // [default:null]
        "cardioresolution": 0.3,
600, // Secs
        "epocfutureCredit": 0.49,
        "metabolicpending": [0.6,
 0,0.1,0.2,0.3,0.4,0.5]
      "upper": 0.5,
},
       "coremessages": 0.5,
        "lower": 0.5[ // Messages displayed below the radar chart [default:null]
       }
     {"t":0,"body":"Restoring body temperature", "detail": ""},
    "workoutDefs": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved {"t":120,"body":"Replenishing glycogen stores", "detail": "detail/glycogen"}
      ],
"wktdef1": {         "typenotifications": 1,[ // [default:1null]
        {"titlet": "Aerobic", // [no default]6000,"body":"Great workout! You're still burning calories and building strength."},
        {"imaget": 14400,"abs", // [defaultbody":"default"]Fitness test unlocked! You're ready to take another fitness "desc": "Aerobic Basic Movement", // [default:null]test."}
      ]
    }
  },
  "breakDurationtimelineArticles": {
5, // // [default:10]
		"appStoreId: "workout01", "user_id_01": { // StoreKitClients listen producthere id [default:null]
 permanently for ChildAdded, ChildChanged and ChildRemoved
      "in7MWarticle_id_01": true, // For server use [default:false]{
        "inAfterburnerdate": false4567890987, // Unix Fortimestamp server use(seconds) // [no default:false]
        "exercisestitle": ["Post title", // [no default]
        "read": false, {
   // [default:true]
        "idlocation": "exdef1post/location.html", // [no default]
     		"icon": "default", // [default:"default"]
        "durationappMask": 20"7MW,AF", // [no defaultdefault: all apps]
        "promptRating":  },true // [default:false]
      }
   { }
  },
  "definitions": {
    "idroutines": "exdef2",
      { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "durationroutine_id_01": 15{
          }"title": "The Wonder Routine", // [no default]
       { "image": "wonder-routine", // [default:"default-routine"]
        "iddesc": "exdef3Big long description",    // [default:null]
        "durationappStoreId7MW": 10
    "routine01", // StoreKit product id [default:null]
     },   "in7MW": true, // For server use [default:false]
 {             "id"inAfterburner": "exdef4"false, // For server use [default:false]
        "durationlockedIn7MW": 5false, // For server use [default:false]
     },   "lockedInAfterburner": false, // For server use [default:false]
 {             "id"video": "exdef5",    // [default:null]
        "durationminFitnessLevel": 104, // [default:1]
        }"workoutDefs": { // [no   default]
  ],         "adaptiveStresswktdef1": {
            "strengthtype": 0.21, // [default:1]
            "cardiotitle": 0.9"Aerobic", // [no default:1]
            "metabolicimage": 0.6"abs", // [default:1"default"]
            "epocdesc": 0.6 "Aerobic Basic Movement", // [default:1null]
        },     "breakDuration": 5, //  "muscleStress": {// [default:10]
            "upperappStoreId7MW": 10"workout01", // StoreKit product id [default:1null]
            "locked": false, // For server use [default:false]
			"lowerMWI": 100.54, // [default:10.5]
            "coreexercises": 10[ // [no default:1]
        }      {
},       "wktdef2": {         "typeid": 1"exdef1", // [no default]
     "title": "Thai Boxing",         "imageduration": "abs",
  20 // [no default]
     "desc": "Boxing With Kicking",      },
  "breakDuration": 4, 		"appStoreId: "", // StoreKit product id     {
   "in7MW": false, // For server use         "inAfterburnerid": true"exdef2",
 //    For server use         "exercisesduration": [15
          {    },
        "id": "exdef5",     {
       "duration": 15           },
"id": "exdef3",
         {             "id"duration": "exdef3",10
            "duration": 10 },
         },     {
     {             "id": "exdef1exdef4",
                "duration": 5
          }    },
    ],         "stress": {
          "strength": 0.2,     "id": "exdef5",
    "cardio": 0.9,           "metabolicduration": 10
0.6,           "epoc": 0.6  }
      },         "muscleStress": {],
            "upperadaptiveStress": 10, {
              "lowerstrength": 10,0.2, // [default:1]
              "corecardio": 10
 0.9, // [default:1]
       }       }
    },"metabolic": 0.6, // [default:1]
      "journeyTriggers: {       "forAfterburnerepoc": {0.6 // [default:1]
      "trigger01": {      },
            "categorymuscleStress": "achievement", {
              "triggerTypeupper": "activeDaysInWeeks"10, // [default:1]
              "condition1lower": 410, // [default:1]
 4 active days           "condition2core": 8,10 // every week for 8 weeks [default:1]
            }
       "actions": [  }
        }
 {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},   }
    },
    {"actionType":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
          ]"exerciseDefs": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "exdef1": {
},         "trigger02behaviour": {1, // [default:1]
        "categorytitle": "educationCruches", // [no default]
        "triggerTypevideo": "totalActivities01-Crunches.mp4", // [no default]
        "condition1image": 10"abs", // 10 activities
 [default:"default"]
        "condition2desc": 0, // Not used
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}
          ]
        }
      },
      "for7MW": {
        "trigger01": {
"A crunch begins with lying face up on the floor with knees bent. The movement begins by curling the shoulders towards the pelvis. The hands can be behind or beside the neck or crossed over the chest. Injury can be caused by pushing against the head or neck with hands.", // [default:null]
        "subtitle": "Target your abs for a balanced set of stomach muscles.", // [default:null]
         "categorycalPerSec": "achievement"5, // [default:0]
        "triggerTypeskill": "activeDaysInWeeks"0.2, // [default:0.5]
        "condition1strength": 40.7, // 4 active days[default:0.5]
            "condition2cardio": 80.1, // every week for 8 weeks[default:0.5]
              "actions": [
 "epoc": 0.4, // [default:0.5]
        "metabolic": 0.4, // [default:0.5]
          {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
   upper": 0.5, // [default:0.5]
        {"actionTypecore":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""} 0.5, // [default:0.5]
        "lower": 0.5, // [default:0.5]
        "needsHalfwaySwap": false // [default:false]
 
      },

       "trigger02exdef2": {
          "categorybehaviour": "education"1,
          "triggerTypetitle": "totalActivitiesSquats",
 
        "condition1video": 10, // 10 activities
 "02-Squats.mp4",
        "image": "abs",
        "condition2desc": 0, // Not used
          "actions": [
   "Squats are an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks.",
        {"actionTypesubtitle":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"} "Train your lower body and core.",
        "calPerSec": 4,
        "skill": 0.2,
        "strength": 0.6,
        "cardio": 0.3,
  ]      "epoc": 0.4,
   }     "metabolic": 0.6,
}     }   }
}"upper": 0.5,
        "core": 0.5,
        "lower": 0.5,
        "needsHalfwaySwap": true
      }
    },
    "journeyTriggers": {
      "forAfterburner": {
        "trigger01": {
          "category": "achievement",
          "triggerType": "activeDaysInWeeks",
          "condition1": 4, // 4 active days
          "condition2": 8, // every week for 8 weeks
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
            {"actionType":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
          ]
        },
        "trigger02": {
          "category": "education",
          "triggerType": "totalActivities",
          "condition1": 10, // 10 activities
          "condition2": 0, // Not used
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}
          ]
        }
      },
      "for7MW": {
        "trigger01": {
          "category": "achievement",
          "triggerType": "activeDaysInWeeks",
          "condition1": 4, // 4 active days
          "condition2": 8, // every week for 8 weeks
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
            {"actionType":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
          ]
        },
        "trigger02": {
          "category": "education",
          "triggerType": "totalActivities",
          "condition1": 10, // 10 activities
          "condition2": 0, // Not used
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}
          ]
        }
      }
    }
    "timedNotifs": {
      "forAfterburner": {
        "notif01": {
          "deltaHours": 24, // Delta after APN token reg that the notif is delivered [no default]
          "seqVersion": 0, // Sequence version to allow future updates without flooding existing users [default:0]
          "title": "Title of notification", // [default:""]
          "body": "Body of notification" // [no default]
        },
      },
      "for7MW": {
        "notif01": {
          "deltaHours": 24, 
          "seqVersion": 0, 
          "title": "Title of notification",
          "body": "Body of notification"
        },
      }
    }
  },
  "receipts": {
    "user_id_01": {
      "receipt_auto_id_01": {
        "receipt": "receipt_data", // Written by the client after an IAP purchase
        "validation": { // Written by the server after the receipt has been processed
          "validationDate": 3456789, // Timestamp [default:0]
          "isValid": true [default:false]
        }
      }
    }
  },
}

Client-Side Data Validation & Error Handling

We apply the following process to validate data on the client and to handle the errors appropriately:

SituationActions
  • Property is missing or is wrong type
  • Property has a default defined in the model schema.
  • Log error to crashlytics.
  • Handle silently and apply default value.
  • Property is missing or is wrong type
  • Property doesn't have a default defined.
  • Log error to crashlytics.
  • Throw exception (catch the exception according to object-specific rules, see below).
  • Entire object is missing
  • Log error to crashlytics.
  • Throw exception (catch the exception according to object-specific rules, see below).

Data Validation Exception Handling

EntityChecksAction
visibleWorkoutDef
  • Missing properties without defaults.
  • Missing or invalid workout definition.
Hide from user.
exerciseDefinition
  • Missing properties without defaults.
Tell user via alert view.
timelineArticle
  • Missing properties without defaults.
Hide from user.
activity
  • Missing properties without defaults.
Tell user via alert view.
result
  • Missing properties without defaults.
Tell user via alert view.
afterburn
  • Missing properties without defaults.
Tell user via alert view.
userN/A (all properties have defaults)None