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
      "for7MWusername": {"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 }
      },
    }
  },
  "forAfterburnervisibles": {
//   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": "activeDaysInWeeks",
	// [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
	{
              "actionsstress": [
		  {"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 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "strength": {
  	  "trigger01": {
	          "categorystress": "achievement"43,
	              "triggerTypemagnitudeProduct": "activeDaysInWeeks",
	0.6,
              "condition1halflifeProduct": 70.3, // 7 activities
	
              "condition2duration": 7, // in 7 days
	5678,
              "actionsvolume": 3456
[ 		  {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
		  {"actionType":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
	           },
      ] 	  }, 	  "trigger02epoc": {
	      "category": "education",
	        "triggerTypestress": "totalActivities"43,
	     "condition1": 10, // 10 activities 	    "condition2magnitudeProduct": 0.6,
  //  Not used 	    "actions": [ 		  {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}
	halflifeProduct": 0.3,
      ] 	  }     }"duration": 5678,
      },      "definitions": { 	"versionvolume": 1,3456
    "exerciseDefs": { // Clients listen here permanently for ChildAdded},
ChildChanged    and ChildRemoved       "exdef1metabolic": {
              "behaviourstress": 143,
              "titlemagnitudeProduct": "Cruches",0.6,
              "videohalflifeProduct": "01-Crunches.mp4"0.3,
        "image      "duration": "abs"5678,
        "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.","volume": 3456
            }
          },
          "muscleGroups": {
            "subtitleupper": "Target your abs for a balanced set of stomach muscles.",0.3, // [default: 0.3]
             "calPerSeclower": 50.3, // [default: 0.3]
     "skill": 0.2,
        "strengthcore": 0.7,
 4 // [default: 0.3]
      "cardio": 0.1,   }
     "epoc": 0.4,  }
      "metabolic": 0.4,}
    }
  },
  "upperafterburn": 0.5,{
    "user_id_01": { // Clients "core": 0.5,
listen here permanently
       "lowerstart": 0.5
      },345678987, // Unix timestamp (seconds) // [no default]
      "exdef2response": { // [default:null]
        "behaviourresolution": 1600, // Secs
        "titleepoc": "Squats"[0.6,0.5,0.3,0.2,0.1,0.0],
        "videocardio": "02-Squats.mp4"[0.6,0.5,0.3,0.2,0.1,0.0],
        "imagestrength": "abs"[0.6,0.5,0.3,0.2,0.1,0.0],
        "descmetabolic": "Squats are an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks.",[0.6,0.5,0.3,0.2,0.1,0.0]
      },
      "impactCredit": { // [default:null]
        "subtitleresolution": "Train your lower body and core.",600, // Secs
           "calPerSecfutureCredit": 40.9,
        "skillpending": [0.0,0.1,0.2,0.3,0.4,0.5]
        "strength": 0.6},
        "cardiomessages": 0.3,
        "epoc": 0.4,[ // Messages displayed below the radar chart [default:null]
         {"metabolict": 0.6,
        "upper": 0.5,"body":"Restoring body temperature", "detail": ""},
        {"coret": 0.5,
        "lower": 0.5120,"body":"Replenishing glycogen stores", "detail": "detail/glycogen"}
      }],
    },     "workoutDefsnotifications": {[ // Clients[default:null]
listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "wktdef1": {
        "type": 1 {"t":6000,"body":"Great workout! You're still burning calories and building strength."},
        {"titlet": "Aerobic",
        "image": "abs",14400,"body":"Fitness test unlocked! You're ready to take another fitness test."}
      ]
    "desc": "Aerobic Basic Movement"}
  },
  "timelineArticles": {
    "breakDurationuser_id_01": 5,
		"appStoreId: "workout01", // StoreKit product id
{ // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "article_id_01": {
        "in7MWdate": true4567890987, // For server useUnix timestamp (seconds) // [no default]
        "inAfterburnertitle": false"Post title", // For[no serverdefault]
use         "exercisesread": [false, // [default:true]
        {
    "location": "post/location.html", // [no default]
		"icon": "default", // [default:"default"]
        "idappMask": "exdef17MW,AF", // [default: all apps]
        "durationpromptRating": 20true // [default:false]
      }
 },   }
  },
   "definitions": {
    "routines": { // Clients listen here permanently  "id": "exdef2"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]
{             "idinAfterburner": "exdef4"false, // For server use [default:false]
        "durationlockedIn7MW": 5false, // For server use [default:false]
     },   "lockedInAfterburner": false, // For server use [default:false]
 {             "id": "exdef5",
 "video": "", // [default:null]
          "durationminFitnessLevel": 104, // [default:1]
        }"workoutDefs": { // [no default]
    ],
        "adaptiveStresswktdef1": {
            "strengthtype": 0.2,1, // [default:1]
            "cardiotitle": 0.9"Aerobic", // [no default]
       "metabolic": 0.6,    "image": "abs",      "epoc": 0.6// [default:"default"]
         },   "desc": "Aerobic Basic Movement", //  "muscleStress": {[default:null]
            "upperbreakDuration": 5, // 10,// [default:10]
            "lowerappStoreId7MW": 10,
   "workout01", // StoreKit product id [default:null]
      "core      "locked": 10false, // For server use [default:false]
			"MWI": 0.54,  }// [default:0.5]
      },       "wktdef2exercises": { [ // [no default]
          "type": 1,   {
     "title": "Thai Boxing",         "imageid": "absexdef1", // [no default]
     "desc": "Boxing With Kicking",           "breakDurationduration": 4,
		"appStoreId: "", 20 // StoreKit[no productdefault]
id         "in7MW": false, // For server use
        "inAfterburner": true, // For server use },
         "exercises": [       {
   {             "id": "exdef5exdef2",
                "duration": 15
              },
              {
                "id": "exdef3",
                "duration": 10
              },
              {
                "id": "exdef1exdef4",
                "duration": 5
              },
          ],    {
    "stress": {           "strengthid": 0.2,"exdef5",
                "cardioduration": 0.9,
10
         "metabolic": 0.6,    }
      "epoc": 0.6     ],
   },         "muscleStressadaptiveStress": {
              "upperstrength": 100.2, // [default:1]
        "lower      "cardio": 10,0.9, // [default:1]
              "coremetabolic": 100.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