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)       "maxImpactCredit": 3"facebookGroup": "",
      "impactCreditinstagramUser": 0.9"",
      "updatedICfaqsUrl": 987654345,""
// Unix timestamp (seconds) }
  },
  "triggersFiredusers": { "triggerId_01": true, "triggerId_02
    "user_id_01": true{ },// Clients listen here permanently
  "sessions": {         "for7MW"username": 2"user", // [default:null]
      "forAfterburneremail": 0
  "user@somewhere.com", // [default:null]
   },
      "totalActivitiesfitnessLevel": 210, // [default:10]
      "totalActivities7MWfitnessBias": 1,       "totalActivitiesAF": 1,// [default:1]
      "firstActivity7MWcreated": 987654345, // Unix timestamp (seconds) [default:0]
      "firstActivityAFmaxImpactCredit": 9876543453, // Unix[default:0]
timestamp (seconds)
    }
  },   "visibleWorkoutDefsimpactCredit": {0.9, // Workout defs that are visible to the user
    "user_id_01": { [default:0]
      "updatedIC": 987654345, // Unix timestamp (seconds) [default:0]
      "for7MWtriggersFired": { // 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
 "triggerId_01": true, "triggerId_02": true }, // [default:null]
      "wktdef1sessions": {

         "recommendedfor7MW": ""2, // Not recommended, just visible
	[default:0]
        "lockedforAfterburner": true,0 // Not available to user (unlocked via IAP and/or journey trigger)
		  "lockString": "Finish 6 more workouts before Thurs 9th June", // Displayed to user
   [default:0]
      },
      "totalActivities": 2, // [default:0]
      "totalActivities7MW": 1, // [default:0]
      "MWItotalActivitiesAF": 0.541,    // [default:0]
      "breakdownfirstActivity7MW": {987654345, // Unix timestamp (seconds) [default:0]
       "epocfirstActivityAF": 0.1987654345, // Unix timestamp (seconds) [default:0]
       "cardiotimedNotifSeqVersion": 0.1, // Version of timed notif sequence user is on (server   "metabolic": 0.1,
     use) [default:0]
      "strengthtestMode": 0.1
          }false, // Puts the app in 'test mode' for this user [default:false]
      "notifTokens": { },// APN tokens for the user's    "wktdef2": {devices [default:null]
        "for7MW":  { "recommendedapn_token": "Youtrue need}, to// work on your abs", // Recommended and reason for this to be shown to user
		  "locked": false, // Available to user
		  "lockString": "",Where 'api_token' is the actual token string
        "forAfterburner": { "apn_token": true }
      }
    }
  },
  "MWIvisibles": 0.54,
     {
    "breakdownworkoutDefs": { // Workout defs that are visible to the user
      "epocuser_id_01": 0.1,{ 
           "cardiofor7MW": 0.1,
            "metabolic": 0.1,
  { // 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
            "strengthwktdef1": 0.1{
          }  "recommended": "", // Not recommended, just visible }
// [default:null]
     },       "forAfterburnerlocked": {true, // AfterburnerNot clientsavailable listento hereuser permanently(unlocked for ChildAdded, ChildChangedvia IAP and/or ChildRemovedjourney trigger) [default:false]
  	    "wktdef1": {           "recommended"lockString": "",Finish //6 Notmore recommended,workouts justbefore visibleThurs 	      "locked": false9th June", // AvailableDisplayed to user 		  "lockString": "",[default:null]
            "MWI": 0.54, // [default:0.5]
            "breakdown": {
              "epoc": 0.1, // [default:0.25]
              "cardio": 0.1,    // [default:0.25]
              "metabolic": 0.1, // [default:0.25]
              "strength": 0.1 // [default:0.25]
            }
          },
          "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"forAfterburner": {       "user_id_01": { // ClientsAfterburner clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
          "workout_id_01wktdef1": { // Clients
post new activity to here with auto id, server listens           "workoutDefId"recommended": "wktdef1", // Not recommended, just visible
  	        "finishlocked": 987654345false, // UnixAvailable timestampto (seconds)user
  	        "iterationslockString": 1.5"",
// Number of times it was performed           "exertionMWI": 0.554,
            "finalHeartRateBPMbreakdown": {
   160,           "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)
		  "app": "7MW" // Short code of the app the activity was performed in: 7MW, AF, etc.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 "workout_id_01": { your abs", // ServerRecommended posts workout results hereand reason for this to be shown to user
            "workoutDefIdlocked": "wktdef1",false, // Available to user
            "finishlockString": 987654345, // Unix timestamp (seconds)"",
            "AWIMWI": 0.154,
            "responseDurationbreakdown": 3456,{
              "intensityepoc": 0.91,
		  "app": "7MW", // Short code of the app the activity was performed in"cardio": 7MW0.1,
  AF, etc           "responsesmetabolic": {0.1,
              "cardiostrength": {0.1
            }
    "stress": 43,     }
        }
"magnitudeProduct": 0.6,     }
    },
    "halflifeProductroutines": 0.3, {
      "user_id_01": { 
        "durationfor7MW": { 5678,// 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
    "volume      "routine_id_01": 3456{
            }"locked": true, // Not available to user (unlocked via IAP and/or journey   "strength": {
 trigger) [default:false]
            "stresslockString": 43,"Finish 6 more workouts before Thurs 9th June" // Displayed to user [default:null]
  "magnitudeProduct": 0.6,        },
          "halflifeProduct": 0.3,routine_id_02": {
              "durationlocked": 5678true,
            "lockString":  "volume": 3456
 " // No lock string, so only unlocked via IAP [default:null]
          },

           "epocroutine_id_03": {
              "stresslocked": 43false, // Available
            "magnitudeProductlockString": 0.6,""
          }
   "halflifeProduct": 0.3,      },
        "durationforAfterburner": 5678,{ // 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
   "volume": 3456             },"routine_id_03": {
            "metaboliclocked": {false, // Available
            "stresslockString": 43,""
          }
   "magnitudeProduct": 0.6,    }
      }
   "halflifeProduct": 0.3, }
  },
      "workouts": {
    "durationactivities": 5678,{
              "volume": 3456
   "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        }
          },"workout_id_01": { // Clients post new activity to here with auto id, server listens
          "muscleGroupsworkoutDefId": {
  "wktdef1", // [no default]
          "upperfinish": 0.3,
 987654345, // Unix timestamp (seconds) [default:0]
          "loweriterations": 01.35, // Number of times it was performed [default:1]
          "coreexertion": 0.45, // [default:0.5]
          }
  "finalHeartRateBPM": 160, // [default:140]
     }     "finalHeartRateDelay": 0, }// Length of delay (in }secs) after the },workout before the "afterburn": {
    "user_id_01": { // Clients listen here permanently
      "start": 345678987, // Unix timestamp (seconds)
      "response": {
  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 }
      }
   "epoc": [0.6,0.5,0.3,0.2,0.1,0.0],
  },
    "results": {
      "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
        "strength": [0.6,0.5,0.3,0.2,0.1,0.0],workout_id_01": { // Server posts workout results here
          "metabolicworkoutDefId": [0.6,0.5,0.3,0.2,0.1,0.0]
  "wktdef1", // [no default]
   },       "impactCreditfinish": {987654345, // Unix timestamp (seconds) // [no default]
 "resolution": 600, // Secs         "futureCreditAWI": 0.91,         "pending": [0.0,0.1,0.2,0.3,0.4,0.// [default:0.5]
      },       "messagesresponseDuration": [3456, // Messages displayed below the radar chart[default: 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]
       {"t":6000,"body":"Great workout! You're still burning calories and building strength."},     "cardio": {
               {"tstress":14400,"body":"Fitness test unlocked! You're ready to take another fitness test."}
   43,
              "magnitudeProduct": 0.6,
   ]     }   },   "timelineArticleshalflifeProduct": { 0.3,
       "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved"duration": 5678,
              "article_id_01volume": 3456
 {          "date": 4567890987},
// Unix timestamp (seconds)         "titlestrength": "Post title", {
              "readstress": false43,
        "location      "magnitudeProduct": "post/location.html",
		"icon": "default",0.6,
              "appMaskhalflifeProduct": "7MW,AF"0.3,
       }     }  "duration": },5678,
              "definitionsvolume": {3456
    "exerciseDefs": { // Clients listen here permanently for ChildAdded},
ChildChanged    and ChildRemoved       "exdef1epoc": {
        "behaviour      "stress": 1,43,
              "titlemagnitudeProduct": "Cruches"0.6,
        "video      "halflifeProduct": "01-Crunches.mp4",0.3,
              "imageduration": "abs"5678,
        "desc      "volume": "A3456
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.","metabolic": {
              "stress": 43,
              "subtitlemagnitudeProduct": "Target your abs for a balanced set of stomach muscles.",0.6,
              "calPerSechalflifeProduct": 5,0.3,
              "skillduration": 0.25678,
        "strength      "volume": 0.7,3456
         "cardio": 0.1,  }
      "epoc": 0.4,   },
          "metabolicmuscleGroups": 0.4, {
            "upper": 0.53, // [default: 0.3]
     "core": 0.5,         "lower": 0.5
3, // [default: 0.3]
     },       "exdef2core": {0.4 // [default: 0.3]
     "behaviour": 1,    }
    "title": "Squats",   }
     "video": "02-Squats.mp4", }
    }
  },
  "imageafterburn": "abs",{
        "desc"user_id_01": "Squats are an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks.",{ // Clients listen here permanently
      "start": 345678987, // Unix timestamp (seconds) // [no default]
         "subtitleresponse": "Train{ your lower body and core.",// [default:null]
           "calPerSecresolution": 4600, // Secs
        "skillepoc": [0.6,0.5,0.3,0.2,0.1,0.0],
        "strengthcardio": [0.6,0.5,0.3,0.2,0.1,0.0],
        "cardiostrength": [0.6,0.5,0.3,
0.2,0.1,0.0],
        "epocmetabolic": [0.4,
 6,0.5,0.3,0.2,0.1,0.0]
      },
      "metabolicimpactCredit": 0.6, { // [default:null]
        "upperresolution": 0.5600, // Secs
        "corefutureCredit": 0.59,
        "lowerpending": 0.5
      }[0.0,0.1,0.2,0.3,0.4,0.5]
      },
      "workoutDefsmessages": {[ // ClientsMessages listendisplayed herebelow permanentlythe forradar ChildAdded, ChildChanged and ChildRemovedchart [default:null]
        {"wktdef1t": {
        "type": 1,
        "title0,"body":"Restoring body temperature", "detail": "Aerobic"},
        {"imaget": "abs",
        "desc120,"body":"Replenishing glycogen stores", "detail": "Aerobic Basic Movement",detail/glycogen"}
      ],
    "breakDuration": 5, 		"notifications"appStoreId: "workout01",[ // StoreKit[default:null]
product id         "in7MW{"t":6000,"body":"Great true, // For server use
  workout! You're still burning calories and building strength."},
     "inAfterburner   {"t": false, // For server use
        "exercises": [14400,"body":"Fitness test unlocked! You're ready to take another fitness test."}
      ]
    {}
  },
  "timelineArticles":  {
    "user_id_01": "exdef1",
      { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "durationarticle_id_01": 20{
          }"date": 4567890987, // Unix timestamp (seconds) // [no default]
   {             "id"title": "exdef2Post title", // [no default]
         "durationread": 15
false, // [default:true]
         }"location": "post/location.html", // [no default]
		"icon": "default", // [default:"default"]
   {             "id"appMask": "exdef37MW,AF", // [default: all apps]
        "durationpromptRating": 10true // [default:false]
      }
 },   }
  },
  "definitions":  {
    "routines": { // Clients listen here permanently  "id": "exdef4"for ChildAdded, ChildChanged and ChildRemoved
         "duration"routine_id_01": {
5        "title": "The Wonder }Routine", // [no default]
       { "image": "wonder-routine", // [default:"default-routine"]
        "iddesc": "exdef5Big long description",    // [default:null]
        "durationappStoreId7MW": 10
    "routine01", // StoreKit product id [default:null]
     }   "in7MW": true, // For server use [default:false],
        "adaptiveStressinAfterburner": {false, // For server use [default:false]
        "strengthlockedIn7MW": 0.2false, // For server use [default:false]
        "cardiolockedInAfterburner": 0.9,
 false, // For server use [default:false]
        "metabolicvideo": 0.6"", // [default:null]
        "epocminFitnessLevel": 0.6
        },4, // [default:1]
        "muscleStressworkoutDefs": { // [no default]
          "upperwktdef1": {
10,            "lowertype": 101, // [default:1]
        "core": 10   "title": "Aerobic", // [no default]
 }       },       "wktdef2image": {
 "abs", // [default:"default"]
      "type": 1,         "titledesc": "ThaiAerobic Basic BoxingMovement", // [default:null]
      "image": "abs",      "breakDuration": 5, // // [default:10]
 "desc": "Boxing With Kicking",         "breakDurationappStoreId7MW": 4, 		"appStoreId: ""workout01", // StoreKit product id [default:null]
            "in7MWlocked": false, // For server use         "inAfterburner[default:false]
			"MWI": true0.54, // For server use [default:0.5]
            "exercises": [ // [no default]
              {
                "id": "exdef5exdef1", // [no default]
                "duration": 15 20 // [no default]
              },
              {
                "id": "exdef3exdef2",
                "duration": 1015
              },
              {
                "id": "exdef1exdef3",
                "duration": 510
          }    },
    ],          "stress": {{
                "strengthid": 0.2"exdef4",
          "cardio": 0.9,     "duration": 5
    "metabolic": 0.6,          },
"epoc": 0.6         },    {
    "muscleStress": {           "upperid": 10"exdef5",
          "lower": 10,     "duration": 10
    "core": 10         }
       }     }],
    "journeyTriggers: {       "forAfterburneradaptiveStress": {
        "trigger01      "strength": {
 0.2, // [default:1]
        "category": "achievement",     "cardio": 0.9, // [default:1]
  "triggerType": "activeDaysInWeeks",           "condition1metabolic": 40.6, // 4 active days[default:1]
              "condition2epoc": 8,0.6 // every[default:1]
week for 8 weeks         },
 "actions": [             {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},muscleStress": {
              {"actionTypeupper":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
  10, // [default:1]
        ]      "lower": 10, // [default:1]
 },             "trigger02core": {10 // [default:1]
          "category": "education", }
         "triggerType": "totalActivities", }
        }
 "condition1": 10, // 10 activities }
    },
    "condition2exerciseDefs": 0,{ // Not used
   Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "actionsexdef1": [{
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}"behaviour": 1, // [default:1]
        "title": "Cruches", // [no default]
        }
   "video": "01-Crunches.mp4", // [no default]
  },       "for7MWimage": {
        "trigger01": {"abs", // [default:"default"]
          "categorydesc": "achievement",A crunch begins with lying face up on the floor with "triggerType": "activeDaysInWeeks",
          "condition1": 4, // 4 active days
          "condition2": 8, // every week for 8 weeks
    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]
        "actionssubtitle": ["Target your abs for a balanced set of      {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
 stomach muscles.", // [default:null]
          {"actionTypecalPerSec":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
  5, // [default:0]
        ]
  "skill": 0.2, // [default:0.5]
     },         "trigger02"strength": {
 0.7, // [default:0.5]
        "categorycardio": "education"0.1, // [default:0.5]
        "triggerTypeepoc": "totalActivities"0.4, // [default:0.5]
        "condition1metabolic": 100.4, // 10 activities
[default:0.5]
         "condition2upper": 0.5, // Not used[default:0.5]
          "actionscore": [
  0.5, // [default:0.5]
         {"actionTypelower":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"} 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