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)
      "maxImpactCreditfacebookGroup": 3"",
      "impactCreditinstagramUser": 0.9"",
      "updatedICfaqsUrl": 987654345,""
// Unix timestamp (seconds) }
  },
  "apnIdsusers": []{
    }
  },
  "visibleWorkoutDefs"user_id_01": { // WorkoutClients defslisten thathere arepermanently
visible to the user   "username":  "user_id_01":, { // [default:null]
      "visibleIn7MWemail": {"user@somewhere.com", // 7MW[default:null]
clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
 "fitnessLevel": 10, // [default:10]
       "wktdef1fitnessBias": {1, // [default:1]
        "recommendedcreated": ""987654345, // NotUnix recommended, just visible
	timestamp (seconds) [default:0]
      "lockedmaxImpactCredit": true3, // Not available to user (unlocked via IAP and/or journey trigger)
		  "lockString": "Finish 6 more workouts before Thurs 9th June"[default:0]
      "impactCredit": 0.9, // Displayed to user[default:0]
           "MWIupdatedIC": 0.54987654345, // Unix timestamp (seconds) [default:0]
      "breakdowntriggersFired": { "triggerId_01":            "epoc": 0.1,
  true, "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]
      "totalActivitiesAF": 1,  "recommended": "You need to work on your abs"// [default:0]
      "firstActivity7MW": 987654345, // RecommendedUnix andtimestamp reason for this to be shown to user
		(seconds) [default:0]
      "lockedfirstActivityAF": false987654345, // AvailableUnix totimestamp user
		  "lockString": "",(seconds) [default:0]
           "MWItimedNotifSeqVersion": 0.54, // Version of timed notif sequence user is on (server  "breakdown": {
   use) [default:0]
        "epoctestMode": 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[default:null]
        "for7MW": 0.1,
            "strength": 0.1{ "apn_token": true }, // Where 'api_token' is the actual token string
        "forAfterburner": { "apn_token": true  }
      }
 }   }
   },
  "visibles": {
    "visibleInAfterburnerworkoutDefs": { // AfterburnerWorkout clientsdefs listenthat hereare permanentlyvisible forto ChildAdded, ChildChanged and ChildRemoved
 the user
      "wktdef1user_id_01": { 
         "recommendedfor7MW": "",{ // 7MW Not recommended, just visible
	      "locked": false, // Available to user
		  "lockString": "",clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
          "wktdef1": {
            "MWIrecommended": 0.54"", // Not recommended, just visible // [default:null]
    "breakdown": {             "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": {
          "recommended": "You need to work on your abs""epoc": 0.1, // Recommended and reason for this to be shown to user
		  "locked": false[default:0.25]
              "cardio": 0.1, // Available to user
		  "lockString": "",[default:0.25]
                "MWI"metabolic": 0.541,           "breakdown": {// [default:0.25]
               "epocstrength": 0.1, // [default:0.25]
          "cardio": 0.1, }
           "metabolic": 0.1},
            "strengthwktdef2": 0.1{
          }  "recommended": "You need to work on your }abs", // Recommended and reason for this }to be shown to user
}   },   "workouts": {     "activitieslocked": {
 false, // Available to user
     "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved"lockString": "",
            "workout_id_01MWI": { // Clients post new activity to here with auto id, server listens
          "workoutDefId": "wktdef1",0.54,
            "breakdown": {
              "finishepoc": 9876543450.1,
// Unix timestamp (seconds)           "exertioncardio": 0.51,
              "finalHeartRateBPMmetabolic": 1600.1,
              "finalHeartRateDelaystrength": 0.1
//  Length of delay (in secs) after the workout before the HR}
was measured (0 if they didn't press the 'start again' button)}
        },
      }     },
    "results": {
      "user_id_01""forAfterburner": { // ClientsAfterburner clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
          "workout_id_01wktdef1": {
// Server posts workout results here           "workoutDefIdrecommended": "wktdef1", // Not recommended, just visible
  	        "finishlocked": 987654345false, // UnixAvailable timestampto (seconds)user
  	        "AWIlockString": 0.1,
          "responseDuration": 3456,"",
            "intensityMWI": 0.9,
          "responses": {54,
            "cardiobreakdown": {
              "stressepoc": 430.1,
              "magnitudeProductcardio": 0.61,
              "halflifeProductmetabolic": 0.31,
              "durationstrength": 5678,0.1
            }
 "volume": 3456
            },
            "strengthwktdef2": {
              "stressrecommended": 43,"You need to work on your abs", // Recommended and reason for this to be "magnitudeProduct": 0.6,
 shown to user
            "halflifeProductlocked": 0.3,
 false, // Available to user
            "durationlockString": 5678"",
              "volumeMWI": 0.54,
  3456          "breakdown": {
 },             "epoc": {0.1,
              "stresscardio": 430.1,
              "magnitudeProductmetabolic": 0.61,
              "halflifeProductstrength": 0.3,1
            }
  "duration": 5678,        }
        "volume":}
3456        }
    },
    "routines": {
      "metabolicuser_id_01": { 
        "for7MW": { // 7MW clients listen here permanently "stress": 43for ChildAdded, ChildChanged and ChildRemoved
           "magnitudeProductroutine_id_01": 0.6,{
              "halflifeProductlocked": 0.3true, // Not available to user (unlocked via IAP and/or journey     "duration": 5678,
 trigger) [default:false]
            "volumelockString": 3456"Finish 6 more workouts before Thurs 9th June" // Displayed to user [default:null]
}           },
          "muscleGroupsroutine_id_02": {
            "upperlocked": 0.3true,
            "lowerlockString": 0.3,
            "core": 0.4"" // No lock string, so only unlocked via IAP [default:null]
          },
        }  "routine_id_03": {
     }     }  "locked": }false, // Available
 "afterburn": {     "user_id_01": { // Clients listen here permanently"lockString": ""
      "start": 345678987, // Unix timestamp}
(seconds)       "response": { },
        "resolutionforAfterburner": 600,{ // Secs7MW clients listen here permanently for ChildAdded, ChildChanged and "epoc": [0.6,0.5,0.3,0.2,0.1,0.0],ChildRemoved
          "routine_id_03": {
            "cardiolocked": [0.6,0.5,0.3,0.2,0.1,0.0],false, // Available
            "strengthlockString": [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]       },
      "impactCredit": {}
    }
  },
  "resolutionworkouts": 600, // Secs
 {
    "activities": {
      "futureCredituser_id_01": 0.9,
        "pending": [0.0,0.1,0.2,0.3,0.4,0.5]
      },{ // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "messagesworkout_id_01": [{ // Messages displayed below the radar chart
  Clients post new activity to here with auto id, server listens
     {"t":0,"body":"Restoring body temperature", "detail     "workoutDefId": "wktdef1"}, // [no default]
      {"t":120,"body":"Replenishing glycogen stores", "detail": "detail/glycogen"}
      ],    "finish": 987654345, // Unix timestamp (seconds) [default:0]
          "notificationsiterations": [
        {"t":6000,"body":"Great workout! You're still burning calories and building strength."},1.5, // Number of times it was performed [default:1]
          {"texertion":14400,"body":"Fitness test unlocked! You're ready to take another fitness test."} 0.5, // [default:0.5]
          "finalHeartRateBPM": 160, // [default:140]
    }   },   "timelineArticlesfinalHeartRateDelay": {
    "user_id_01": {0, // ClientsLength listenof heredelay permanently(in forsecs) ChildAdded,after ChildChangedthe andworkout ChildRemovedbefore the HR was measured (0  "article_id_01": {
        "date": 4567890987,if they didn't press the 'start again' button) [default:0]
		  "app": "7MW" // Unix timestamp (seconds)
        "title": "Post title",Short code of the app the activity was performed in: 7MW, AF, etc [default:null]
        }
  "read": false,   }
     "location": "post/location.html",
		"icon": "default",
 },
    "results": {
      "appMaskuser_id_01": "7MW,AF"
      }
    }
  },
  "journeyTriggers: {
	"trigger01{ // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "workout_id_01": { 	// Server "category": "achievement",
	  "triggerType": "activitiesInDays",
	  "triggerValA": 7, // 7 activities
	  "triggerValB": 7posts workout results here
          "workoutDefId": "wktdef1", // in 7 days[no default]
          "appMaskfinish": "7MW,AF"987654345, 	//  "actions": [
		{"action":"post","articleId":"article_id_01","data":"e.g. url parameters"},
		{"action":"unlock","itemId":"workoutDef_id_01","articleId":"article_id_02","data":""}
	  ]
	},
	"trigger02": {
	  "category": "education",
	  "triggerType": "totalActivities",
	  "triggerValA": 10, // 10 activities
	  "triggerValB": 0, // Not usedUnix timestamp (seconds) // [no default]
          "AWI": 0.1, // [default:0.5]
          "responseDuration": 3456, // [default: 0]
          "intensity": 0.9, // [default:0.5]
		  "app": "7MW", // Short code of the app the activity was performed in: 7MW, AF, etc [no default]
          "responses": { // [no default]
            "appMaskcardio": "7MW,AF",
	{
              "actionsstress": [
		{"action":"post","articleId":"article_id_01","data":"e.g. url parameters"}
	  ]
	}
  },
  "definitions": {
	"version": 143,
              "magnitudeProduct": 0.6,
    "exerciseDefs": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
 "halflifeProduct": 0.3,
    "exdef1": {         "behaviourduration": 15678,
        "title      "volume": "Cruches",3456
        "video": "01-Crunches.mp4",      },
  "image": "abs",         "descstrength": "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.","stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "subtitleduration": "Target your abs for a balanced set of stomach muscles.",5678,
              "calPerSecvolume": 5,3456
        "skill": 0.2,   },
     "strength": 0.7,         "cardioepoc": 0.1, {
              "epocstress": 0.4,43,
              "metabolicmagnitudeProduct": 0.46,
              "upperhalflifeProduct": 0.53,
        "core      "duration": 0.5,5678,
              "lowervolume": 0.53456
            },
            "exdef2metabolic": {
        "behaviour      "stress": 143,
        "title      "magnitudeProduct": "Squats",0.6,
              "videohalflifeProduct": "02-Squats.mp4",0.3,
              "imageduration": "abs"5678,
        "desc      "volume": "Squats3456
  are an excellent exercise for training the lower body and core}
muscles, if done regularly they help to define thighs and buttocks."},
          "subtitlemuscleGroups": "Train{
your lower body and core.",         "calPerSecupper": 40.3, // [default: 0.3]
     "skill": 0.2,         "strengthlower": 0.63, // [default: 0.3]
     "cardio": 0.3,         "epoccore": 0.4,
  // [default: 0.3]
      "metabolic": 0.6,   }
     "upper": 0.5,  }
      "core": 0.5,}
    }
  },
  "lowerafterburn": {
0.5    "user_id_01": { // }Clients listen here permanently
 },     "workoutDefsstart": {345678987, // ClientsUnix listentimestamp here permanently for ChildAdded, ChildChanged and ChildRemoved(seconds) // [no default]
       "wktdef1response": { // [default:null]
        "typeresolution": 1600,         "title": "Aerobic",// Secs
         "imageepoc": "abs"[0.6,0.5,0.3,0.2,0.1,0.0],
        "desccardio": "Aerobic Basic Movement"[0.6,0.5,0.3,0.2,0.1,0.0],
        "breakDurationstrength": 5,
		"appStoreId: "workout01", // StoreKit product id[0.6,0.5,0.3,0.2,0.1,0.0],
           "in7MWmetabolic": true, // For server use
 [0.6,0.5,0.3,0.2,0.1,0.0]
      },
      "inAfterburnerimpactCredit": false,{ // For server use[default:null]
        "exercisesresolution": [600, // Secs
        {
   "futureCredit": 0.9,
        "idpending": "exdef1",[0.0,0.1,0.2,0.3,0.4,0.5]
      },
      "durationmessages": 20[ // Messages displayed below the radar chart [default:null]
  },           {
            "id{"t":0,"body":"Restoring body temperature", "detail": "exdef2"},
        {"t":120,"body":"Replenishing glycogen stores",  "durationdetail": 15"detail/glycogen"}
          }],
      "notifications": [ // [default:null]
{             "id": "exdef3",
   {"t":6000,"body":"Great workout! You're still burning calories and building strength."},
        "duration{"t":14400,"body":"Fitness 10test unlocked! You're ready to take another     },fitness test."}
      ]
   { }
  },
  "timelineArticles": {
    "user_id_01": "exdef4",
            "duration": 5
    { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "article_id_01": {
     },   "date": 4567890987, // Unix timestamp (seconds) //  {
   [no default]
        "idtitle": "exdef5Post title", // [no  default]
        "durationread": 10false, // [default:true]
        }
        ],
        "adaptiveStress": {
"location": "post/location.html", // [no default]
		"icon": "default", // [default:"default"]
         "strengthappMask": 0.2"7MW,AF", // [default: all apps]
        "cardiopromptRating": 0.9,
 true // [default:false]
      }
 "metabolic": 0.6,  }
  },
     "epocdefinitions": 0.6{
    "routines": { //  },
 Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "muscleStressroutine_id_01": {
 
        "uppertitle": 10,
  "The Wonder Routine", // [no default]
        "lowerimage": 10"wonder-routine", // [default:"default-routine"]
        "coredesc": 10"Big long description", // [default:null]
    }       }"appStoreId7MW": "routine01", // StoreKit product    "wktdef2": {id [default:null]
        "typein7MW": 1true, // For server use [default:false]
   "title": "Thai Boxing",   "inAfterburner": false, // For server use "image": "abs",[default:false]
        "desclockedIn7MW": "Boxing With Kicking",false, // For server use [default:false]
        "breakDurationlockedInAfterburner": 4false, 		"appStoreId: "", // For StoreKitserver product iduse [default:false]
        "in7MWvideo": false"", // For server use[default:null]
        "inAfterburnerminFitnessLevel": true4, // For[default:1]
server use         "exercisesworkoutDefs": { // [no default]
          "wktdef1": {
            "idtype": "exdef5"1, // [default:1]
            "durationtitle": 15
  "Aerobic", // [no default]
       },     "image": "abs", // [default:"default"]
  {             "iddesc": "exdef3Aerobic Basic Movement", // [default:null]
            "durationbreakDuration": 105, // // [default:10]
       },     "appStoreId7MW": "workout01", // StoreKit product id {[default:null]
            "idlocked": "exdef1"false, // For server use [default:false]
			"MWI": 0.54, // [default:0.5]
   "duration": 5        "exercises": [  }// [no default]
          ],    {
    "stress": {           "strengthid": 0.2"exdef1", // [no default]
       "cardio": 0.9,           "metabolicduration": 0.6,
20 // [no default]
         "epoc": 0.6    },
    },         "muscleStress": {
                "upperid": 10"exdef2",
          "lower": 10      "duration": 15
              },
          "core": 10   {
     }       }     }"id": "exdef3",
     }
}           "duration": 10
              },
              {
                "id": "exdef4",
                "duration": 5
              },
              {
                "id": "exdef5",
                "duration": 10
              }
            ],
            "adaptiveStress": {
              "strength": 0.2, // [default:1]
              "cardio": 0.9, // [default:1]
              "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