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"facebookPage": "",
      "usernamefacebookGroup": "user",
      "emailinstagramUser": "user@somewhere.com",
      "fitnessLevelfaqsUrl": ""
  10,  },
    "fitnessBiasforAfterburner": 1,{
      "createdfacebookPage": 987654345"",
// Unix timestamp (seconds)      "facebookGroup": "maxImpactCredit": 3,
      "impactCreditinstagramUser": 0.9,
      "updatedIC": 987654345, // Unix timestamp (seconds)
      "triggersFiredfaqsUrl": ["triggerId_01","triggerId_02"]
    }
  },
  "visibleWorkoutDefsusers": { // Workout defs that are visible to the user
    "user_id_01": { // Clients listen here permanently
      "visibleIn7MWusername": {"user", // 7MW[default:null]
clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
  "email": "user@somewhere.com", // [default:null]
      "wktdef1fitnessLevel": {10,    // [default:10]
      "recommendedfitnessBias": ""1, // Not recommended, just visible
	[default:1]
      "lockedcreated": true987654345, // NotUnix availabletimestamp to user (unlocked via IAP and/or journey trigger)
		  "lockString": "Finish 6 more workouts before Thurs 9th June"(seconds) [default:0]
      "maxImpactCredit": 3, // Displayed to user[default:0]
           "MWIimpactCredit": 0.549,    // [default:0]
      "breakdownupdatedIC": {987654345, // Unix timestamp (seconds) [default:0]
      "triggersFired": { "epoctriggerId_01": 0.1true, "triggerId_02": true },   // [default:null]
      "cardiosessions": 0.1,{
            "metabolicfor7MW": 0.12, // [default:0]
          "strengthforAfterburner": 0.1 // [default:0]
        },
        }"totalActivities": 2, // [default:0]
      "wktdef2totalActivities7MW": {1, // [default:0]
        "recommendedtotalActivitiesAF": "You need to work on your abs"1, // [default:0]
      "firstActivity7MW": 987654345, // RecommendedUnix andtimestamp reason for this to be shown to user
		  "locked": false(seconds) [default:0]
      "firstActivityAF": 987654345, // AvailableUnix totimestamp user
		  "lockString": "",(seconds) [default:0]
          "MWItimedNotifSeqVersion": 0.54, // Version of timed notif sequence user is on (server  "breakdown": {use) [default:0]
            "epoc"testMode": 0.1false, // Puts the app in 'test mode' for this user [default:false]
 "cardio": 0.1,    "notifTokens": { // APN tokens for the user's devices "metabolic": 0.1,
[default:null]
           "strengthfor7MW": 0.1
          }{ "apn_token": true }, // Where 'api_token' is the actual token string
        "forAfterburner": { "apn_token": true }
      },
    }
  },
  "visibleInAfterburnervisibles": {
//   Afterburner clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
 "workoutDefs": { // Workout defs that are visible to the user
      "wktdef1user_id_01": { 
         "recommendedfor7MW": "",{ // 7MW Notclients recommended,listen justhere visiblepermanently 	for ChildAdded, ChildChanged and ChildRemoved
 "locked": false, // Available to user
		         "lockStringwktdef1": "",{
            "MWIrecommended": 0.54"", // Not recommended, just visible      "breakdown": {// [default:null]
             "epoclocked": 0.1true, // Not available to user (unlocked via IAP and/or journey   "cardio": 0.1,
 trigger) [default:false]
  	           "metaboliclockString": 0.1,
            "strength": 0.1"Finish 6 more workouts before Thurs 9th June", // Displayed to user [default:null]
           } "MWI": 0.54, // [default:0.5]
    },         "wktdef2breakdown": {
              "recommendedepoc": "You need to work on your abs", // Recommended and reason for this to be shown to user
		  "locked": false0.1, // [default:0.25]
              "cardio": 0.1, // Available to user
		  "lockString": "",[default:0.25]
              "MWImetabolic": 0.541, // [default:0.25]
        "breakdown": {     "strength": 0.1 // [default:0.25]
      "epoc": 0.1,     }
       "cardio": 0.1,  },
          "metabolicwktdef2": 0.1,{
            "strengthrecommended": 0.1
          }
 "You need to work on your abs", // Recommended and reason for this to be shown to user
      }       }
    }"locked": false, // Available to user
   },   "workouts": {     "activitieslockString": {"",
      "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved"MWI": 0.54,
            "workout_id_01breakdown": {
// Clients post new activity to here with auto id, server listens        "epoc": 0.1,
  "workoutDefId": "wktdef1",           "finishcardio": 9876543450.1,
// Unix timestamp (seconds)           "exertionmetabolic": 0.51,
              "finalHeartRateBPMstrength": 160,0.1
            }
"finalHeartRateDelay": 0, // Length of delay (in secs) after the workout before the HR was measured (0 if they didn't press the 'start again' button)
		  "app": "7MW" // Short code of the app the activity was performed in: 7MW, AF, etc          }
        },
        "forAfterburner": { // Afterburner clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
          "wktdef1": }{
      }
    },     "resultsrecommended": {
      "user_id_01": {", // ClientsNot listenrecommended, herejust permanentlyvisible
for ChildAdded, ChildChanged and ChildRemoved
 	        "workout_id_01locked": {false, // ServerAvailable poststo workoutuser
results here 	          "workoutDefIdlockString": "wktdef1",
            "finishMWI": 9876543450.54,
//  Unix timestamp (seconds)        "breakdown": {
 "AWI": 0.1,             "responseDurationepoc": 34560.1,
              "intensitycardio": 0.91,
		  "app": "7MW", // Short code of the app the activity was performed in"metabolic": 7MW0.1,
AF,   etc           "responsesstrength": {0.1
            "cardio":}
{          },
    "stress": 43,     "wktdef2": {
            "magnitudeProductrecommended": 0.6,
              "halflifeProduct": 0.3,
"You need to work on your abs", // Recommended and reason for this to be shown to user
             "durationlocked": 5678false, // Available to user
            "volumelockString": 3456"",
             }"MWI": 0.54,
            "strengthbreakdown": {
              "stressepoc": 430.1,
              "magnitudeProductcardio": 0.61,
              "halflifeProductmetabolic": 0.31,
              "durationstrength": 5678,0.1
            }
 "volume": 3456        }
    },    }
      }
 "epoc": {  },
    "routines": {
      "stressuser_id_01": 43,{ 
        "for7MW": { // 7MW clients  "magnitudeProduct": 0.6,
  listen here permanently for ChildAdded, ChildChanged and ChildRemoved
           "halflifeProductroutine_id_01": 0.3,
 {
            "durationlocked": 5678true, // Not available to user (unlocked via IAP and/or journey trigger) [default:false]
  "volume": 3456         "lockString": "Finish 6 more },workouts before Thurs 9th June" // Displayed to user [default:null]
     "metabolic": {    },
          "stressroutine_id_02": 43,{
              "magnitudeProductlocked": 0.6true,
              "halflifeProductlockString": 0.3,
        "" // No lock string, so only unlocked via IAP [default:null]
     "duration": 5678,    },
          "volumeroutine_id_03": 3456{
            }
  "locked": false, // Available
       },     "lockString": ""
    "muscleGroups": {     }
       "upper": 0.3,
  },
          "lowerforAfterburner": 0.3,
            "core": 0.4{ // 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
          "routine_id_03": {
 }         }  "locked": false, // Available
 }     }   },   "afterburnlockString": {""
    "user_id_01": { // Clients listen here permanently}
      "start": 345678987, //}
Unix timestamp (seconds)    }
  "response": { }
    },
  "resolutionworkouts": 600, // Secs
 {
    "activities": {
      "epoc": [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],user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "strengthworkout_id_01": [0.6,0.5,0.3,0.2,0.1,0.0],
        "metabolic": [0.6,0.5,0.3,0.2,0.1,0.0]
  { // Clients post new activity to here with auto id, server listens
    },      "workoutDefId": "impactCredit": {wktdef1", // [no default]
          "resolutionfinish": 600987654345, // Secs
Unix timestamp (seconds) [default:0]
          "futureCredititerations": 01.95, // Number of times it was   "pending": [0.0,0.1,0.2,0.3,0.4,0.5]
performed [default:1]
     },       "messagesexertion": [0.5, // Messages displayed below the radar chart[default:0.5]
            {"tfinalHeartRateBPM":0,"body":"Restoring body temperature", "detail": ""}, 160, // [default:140]
          {"t":120,"body"finalHeartRateDelay":"Replenishing glycogen stores", "detail": "detail/glycogen"}
      ],
      "notifications": [
        {"t":6000,"body":"Great workout! You're still burning calories and building strength."},
        {"t":14400,"body":"Fitness test unlocked! You're ready to take another fitness test." 0, // Length of 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]
        }
      ]}
    }
,
 },   "timelineArticlesresults": {
      "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "articleworkout_id_01": { // Server posts workout results here
  "date        "workoutDefId": 4567890987"wktdef1", // [no Unixdefault]
timestamp (seconds)         "titlefinish": "Post title"987654345, // Unix timestamp (seconds) // [no default]
 "read": false,         "locationAWI": "post/location.html",
		"icon": "default",0.1, // [default:0.5]
          "appMaskresponseDuration": "7MW3456,AF" // [default: 0]
   }     }   }"intensity": 0.9,   "journeyTriggers: {
    "forAfterburner": {
  	  "trigger01": {
	    "category": "achievement",
	    "triggerType": "activeDaysInPeriod",
	// [default:0.5]
		  "app": "7MW", // Short code of the app the activity was performed in: 7MW, AF, etc [no default]
          "condition1responses": 7,{ // 7 activities
	[no default]
            "condition2cardio": 7, // in 7 days{
              "appMaskstress": "7MW,AF",
	43,
          "actions": [ 		  {"actionTypemagnitudeProduct":"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 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "strength": {
              "stress": 43,
              "appMaskmagnitudeProduct": "7MW,AF"0.6,
	    "actions": [ 		  {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}
	      "halflifeProduct": 0.3,
      ] 	  }     }"duration": 5678,
    "for7MW": {        	  "trigger01volume": {3456
 	    "category": "achievement", 	    "triggerType": "activeDaysInPeriod" },
	     "condition1": 7, // 7 activities
	       "epoc": {
              "condition2stress": 743,
//   in 7 days         "appMaskmagnitudeProduct": "7MW,AF",
	0.6,
              "actionshalflifeProduct": [
		  {"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 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "metabolic": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "appMaskhalflifeProduct": "7MW,AF",
	0.3,
          "actions": [ 		  {"actionTypeduration":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}
	 5678,
   ] 	  }     }   },
  "definitionsvolume": {3456
	"version": 1,     "exerciseDefs": { // Clients listen here permanently}
for ChildAdded, ChildChanged and ChildRemoved      },
"exdef1": {         "behaviourmuscleGroups": 1, {
            "titleupper": "Cruches"0.3, // [default: 0.3]
     "video       "lower": "01-Crunches.mp4"0.3, // [default: 0.3]
     "image": "abs",      "core": 0.4  "desc": "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: 0.3]
          }
        }
      }
    }
  },
  "afterburn": {
    "user_id_01": { // Clients listen here permanently
       "subtitlestart": "Target your abs for a balanced set of stomach muscles.",345678987, // Unix timestamp (seconds) // [no default]
      "response": {   "calPerSec": 5,// [default:null]
         "skillresolution": 0.2,600, // Secs
        "strengthepoc": [0.76,0.5,0.3,0.2,0.1,0.0],
        "cardio": [0.6,0.5,0.3,0.2,0.1,0.0],
        "epocstrength": [0.4,
6,0.5,0.3,0.2,0.1,0.0],
        "metabolic": [0.4,6,0.5,0.3,0.2,0.1,0.0]
      },
      "upperimpactCredit": 0.5, { // [default:null]
        "coreresolution": 0.5,600, // Secs
        "lowerfutureCredit": 0.59,
      },  "pending": [0.0,0.1,0.2,0.3,0.4,0.5]
   "exdef2": {  },
      "behaviourmessages": 1,[ // Messages displayed below the radar   "title": "Squats",chart [default:null]
        {"videot": "02-Squats.mp4",
        "image0,"body":"Restoring body temperature", "detail": "abs"},
        "desc{"t":120,"body": "SquatsReplenishing areglycogen an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks.",stores", "detail": "detail/glycogen"}
      ],
      "notifications": [ // [default:null]
        "subtitle{"t":6000,"body": "Train your lower body"Great workout! You're still burning calories and corebuilding strength."},
        {"calPerSect": 4,
        "skill": 0.2,
 14400,"body":"Fitness test unlocked! You're ready to take another fitness test."}
      ]
    }
 "strength": 0.6 },
  "timelineArticles": {
    "cardiouser_id_01": 0.3,
        "epoc": 0.4,{ // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "metabolic"article_id_01": 0.6,{
        "upperdate": 0.54567890987, // Unix timestamp (seconds) //    "core": 0.5,[no default]
         "lowertitle": 0.5
      }"Post title", // [no default]
      },     "workoutDefsread": {false, // Clients[default:true]
listen here permanently for ChildAdded, ChildChanged and ChildRemoved "location": "post/location.html", // [no default]
 		"wktdef1icon": {
        "type": 1,"default", // [default:"default"]
         "titleappMask": "Aerobic7MW,AF", // [default: all apps]
        "imagepromptRating": "abs",
 true // [default:false]
      "desc": "Aerobic Basic Movement",}
    }
  },
   "breakDurationdefinitions": 5,
		"appStoreId: "workout01", {
    "routines": { // StoreKitClients productlisten idhere permanently for ChildAdded, ChildChanged and ChildRemoved
  "in7MW": true, // For server use "routine_id_01": {
        "inAfterburnertitle": false "The Wonder Routine", // For server use[no default]
        "exercisesimage": [
    "wonder-routine", // [default:"default-routine"]
     {   "desc": "Big long description", // [default:null]
        "idappStoreId7MW": "exdef1routine01", // StoreKit product id [default:null]
        "durationin7MW": 20true, // For server use [default:false]
     },   "inAfterburner": false, // For server use [default:false]
 {       "lockedIn7MW": false, // For server use "id": "exdef2",
    [default:false]
        "lockedInAfterburner": false, // For server use [default:false]
        "durationvideo": 15"", // [default:null]
        }"minFitnessLevel": 4, // [default:1]
        "workoutDefs": { // [no default]
          "idwktdef1": "exdef3",{
            "durationtype": 101, // [default:1]
        },    "title": "Aerobic", // [no   default]
{             "idimage": "exdef4abs", // [default:"default"]
            "durationdesc": 5"Aerobic Basic Movement", // [default:null]
      },      "breakDuration": 5, //   {// [default:10]
            "idappStoreId7MW": "exdef5workout01", // StoreKit product id [default:null]
       "duration": 10           }
    "locked": false, // For server use [default:false]
			"MWI": 0.54, // [default:0.5]
   ],         "adaptiveStressexercises": {[ // [no default]
       "strength": 0.2,      {
    "cardio": 0.9,           "metabolicid": 0.6"exdef1", // [no default]
       "epoc": 0.6         },
   "duration": 20 // [no default]
    "muscleStress": {         },
 "upper": 10,           "lower": 10, {
          "core": 10     "id": "exdef2",
  }       },       "wktdef2duration": 15
    {         "type": 1},
        "title": "Thai Boxing",      {
      "image": "abs",         "descid": "Boxing With Kicking",exdef3",
             "breakDuration": 4, 		"appStoreId: "duration",: //10
StoreKit product id         "in7MW": false, // For},
server use         "inAfterburner": true, // For server{
use         "exercises": [      "id": "exdef4",
   {             "idduration": "exdef5",5
            "duration": 15   },
       },       {
   {             "id": "exdef3exdef5",
                "duration": 10
          },    }
      {             "id": "exdef1"],
            "durationadaptiveStress": 5{
          }    "strength": 0.2,    ],// [default:1]
        "stress": {
          "strengthcardio": 0.29,      // [default:1]
    "cardio": 0.9,           "metabolic": 0.6, // [default:1]
              "epoc": 0.6 // [default:1]
            },
            "muscleStress": {
              "upper": 10, // [default:1]
              "lower": 10, // [default:1]
              "core": 10 // [default:1]
            }
          }
        }
      }
    },
    "exerciseDefs": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "exdef1": {
        "behaviour": 1, // [default:1]
        "title": "Cruches", // [no default]
        "video": "01-Crunches.mp4", // [no default]
        "image": "abs", // [default:"default"]
        "desc": "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]
        "calPerSec": 5, // [default:0]
        "skill": 0.2, // [default:0.5]
        "strength": 0.7, // [default:0.5]
        "cardio": 0.1, // [default:0.5]
        "epoc": 0.4, // [default:0.5]
        "metabolic": 0.4, // [default:0.5]
        "upper": 0.5, // [default:0.5]
        "core": 0.5, // [default:0.5]
        "lower": 0.5, // [default:0.5]
        "needsHalfwaySwap": false // [default:false]
      },
      "exdef2": {
        "behaviour": 1,
        "title": "Squats",
        "video": "02-Squats.mp4",
        "image": "abs",
        "desc": "Squats are an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks.",
        "subtitle": "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