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"",
      "updatedICfaqsUrl": 987654345,""
// Unix timestamp (seconds) }
  },
  "triggersFiredusers": { "triggerId_01": true, "triggerId_02
    "user_id_01": true{ },// Clients listen     "sessions": {
here permanently
       "for7MWusername": 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 timestamp (seconds)
    }[default:0]
   },   "visibleWorkoutDefsimpactCredit": {0.9, // Workout[default:0]
defs that are visible to the user
    "user_id_01": {"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]
      "testMode": false, // Puts the  "strength": 0.1
   app in 'test mode' for this user [default:false]
      }"notifTokens": { // APN tokens for the user's  },devices [default:null]
        "wktdef2for7MW": { "apn_token": true }, // Where 'api_token' is the actual token string
 "recommended": "You need to work on your abs"forAfterburner",: // Recommended and reason for this to be shown to user
		  "locked": false, // Available to user
		  "lockString": "",{ "apn_token": true }
      }
    }
  },
  "visibles": {
    "workoutDefs": { // Workout defs that "MWI": 0.54,
   are visible to the user
      "breakdownuser_id_01": { 
           "epocfor7MW": 0.1,
      { // 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
          "cardiowktdef1": 0.1,{
            "metabolicrecommended": 0.1"", // Not recommended, just visible // [default:null]
     "strength": 0.1      "locked": true, // Not available }to user (unlocked via IAP and/or journey trigger) [default:false]
}  	     },       "forAfterburnerlockString": {"Finish //6 Afterburnermore clientsworkouts listenbefore hereThurs permanently for ChildAdded9th June", ChildChanged// andDisplayed ChildRemovedto user  [default:null]
     "wktdef1": {           "recommendedMWI": ""0.54, // Not recommended, just visible
	 [default:0.5]
            "lockedbreakdown": false,{
// Available to user 		  "lockString": "",           "MWI"epoc": 0.541, // [default:0.25]
        "breakdown": {             "epoc"cardio": 0.1,             "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": {
      "user_id_01forAfterburner": { // Afterburner Clientsclients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "workout_id_01  "wktdef1": {
// Clients post new activity to here with auto id, server listens
          "workoutDefIdrecommended": "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
            }
          },
    },      "resultswktdef2": {
      "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved      "recommended": "You need to work on your abs", // Recommended and reason for this to be shown to user
            "workout_id_01locked": {false, // ServerAvailable poststo workoutuser
results here           "workoutDefIdlockString": "wktdef1",
            "finishMWI": 9876543450.54,
// Unix timestamp (seconds)           "AWIbreakdown": 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,  }
      }
    },
"magnitudeProduct": 0.6,
              "halflifeProduct"routines": 0.3,{
              "duration"user_id_01": 5678,{ 
             "volumefor7MW": 3456{ // 7MW clients listen here permanently for ChildAdded, ChildChanged    },
 and ChildRemoved
          "strengthroutine_id_01": {
              "stresslocked": 43true, // Not available to user (unlocked via IAP and/or journey     "magnitudeProduct": 0.6,trigger) [default:false]
               "halflifeProductlockString": 0.3,
              "duration": 5678,"Finish 6 more workouts before Thurs 9th June" // Displayed to user [default:null]
          },
          "volumeroutine_id_02": 3456{
            }"locked": true,
            "epoclockString": {"" // No lock string, so only unlocked via IAP [default:null]
     "stress": 43,    },
          "magnitudeProductroutine_id_03": 0.6,{
              "halflifeProductlocked": 0.3false, // Available
            "durationlockString": 5678,""
          }
        },
   "volume": 3456    "forAfterburner": { // 7MW clients listen here permanently for }ChildAdded, ChildChanged and ChildRemoved
          "metabolicroutine_id_03": {
              "stresslocked": 43false, // Available
            "magnitudeProductlockString": 0.6,""
          }
   "halflifeProduct": 0.3,    }
      }
   "duration": 5678, }
  },
  "workouts": {
       "volumeactivities": 3456{
      "user_id_01": { // Clients listen here }permanently for ChildAdded, ChildChanged        },
 and ChildRemoved
        "muscleGroupsworkout_id_01": { // Clients post new activity to here with     "upper": 0.3auto id, server listens
          "lowerworkoutDefId": 0.3"wktdef1", // [no default]
          "corefinish": 0.4
    987654345, // Unix timestamp (seconds) [default:0]
     }     "iterations": 1.5, // Number }of times it was    }performed [default:1]
    }   },   "afterburnexertion": {
    "user_id_01": { // Clients listen here permanently0.5, // [default:0.5]
          "startfinalHeartRateBPM": 345678987160, // Unix timestamp (seconds) [default:140]
          "responsefinalHeartRateDelay": 0, {// Length of delay (in secs) after the workout "resolution": 600, // Secs
        "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],
        "strength": [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]
 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]
        }
      }
    },

     "impactCreditresults": {
        "resolution"user_id_01": 600,{ // SecsClients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
"futureCredit": 0.9,         "pending": [0.0,0.1,0.2,0.3,0.4,0.5]
  "workout_id_01": { // Server posts workout results here
   },       "messagesworkoutDefId": ["wktdef1", // Messages[no displayeddefault]
below the radar chart         {"tfinish":0,"body":"Restoring body temperature", "detail": ""},
 987654345, // Unix timestamp (seconds) // [no default]
       {"t":120,"body":"Replenishing glycogen stores", "detailAWI": "detail/glycogen"}
 0.1, // [default:0.5]
     ],       "notificationsresponseDuration": 3456, // [default: 0]
         { "tintensity":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.9, // [default:0.5]
		  "app": "7MW", // Short code of the app the activity was performed in: 7MW, AF, etc [no default]
          "responses": ]{ // [no default]
 }   },   "timelineArticles": {     "user_id_01cardio": {
// Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved       "article_id_01stress": { 43,
              "datemagnitudeProduct": 45678909870.6,
//   Unix timestamp (seconds)         "titlehalflifeProduct": "Post title"0.3,
        "read": false,      "duration": 5678,
  "location": "post/location.html", 		"icon": "default",         "appMaskvolume": "7MW,AF"3456
       }     },
  },    "journeyTriggers: {     "forAfterburnerstrength": {

 	  "trigger01": { 	    "category": "achievement", 	    "triggerTypestress": "activeDaysInWeeks"43,
	    "condition1": 4, // 4 active days 	    "condition2magnitudeProduct": 80.6,
// every week for 8 weeks 	    "actions": [ 		  {"actionTypehalflifeProduct":"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"}
	    ]
	  }
    } 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "epoc": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "metabolic": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            }
          },
  "definitions": { 	"version": 1,     "exerciseDefsmuscleGroups": {
// Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved   "upper": 0.3, //  "exdef1": {[default: 0.3]
            "behaviourlower": 10.3, // [default: 0.3]
     "title": "Cruches",      "core": 0.4  "video"// [default: "01-Crunches.mp4",0.3]
        "image": "abs", }
       "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.",
        "subtitle": "Target your abs for a balanced set of stomach muscles.", }
      }
    }
  },
  "afterburn": {
    "user_id_01": { // Clients listen here permanently
      "start": 345678987, // Unix timestamp (seconds) // [no default]
      "response": { // [default:null]
         "calPerSecresolution": 5600, // Secs
        "skillepoc": [0.6,0.5,0.3,0.2,
        "strength": 0.7,0.1,0.0],
        "cardio": [0.1,6,0.5,0.3,0.2,0.1,0.0],
        "epocstrength": 0.4[0.6,0.5,0.3,0.2,0.1,0.0],
        "metabolic": [0.6,0.5,0.3,0.4,2,0.1,0.0]
        "upper": 0.5,
},
       "coreimpactCredit": 0.5,{ // [default:null]
        "lowerresolution": 0.5
 600, // Secs
    },       "exdef2futureCredit": {0.9,
        "behaviourpending": [0.0,0.1,0.2,0.3,0.4,0.5]
        "title": "Squats",
 },
      "videomessages": "02-Squats.mp4",
        "image": "abs",[ // Messages displayed below the radar chart [default:null]
        {"t":0,"body":"Restoring body temperature"desc, "detail": ""Squats},
are an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks." {"t":120,"body":"Replenishing glycogen stores", "detail": "detail/glycogen"}
      ],
        "subtitle"notifications": "Train[ your lower body and core.",// [default:null]
           {"calPerSect": 4,
        "skill": 0.26000,"body":"Great workout! You're still burning calories and building strength."},
        {"strengtht": 0.6,
        "cardio": 0.3,
 14400,"body":"Fitness test unlocked! You're ready to take another fitness test."}
      ]
    }
 "epoc": 0.4 },
  "timelineArticles": {
    "metabolicuser_id_01": 0.6,
        "upper": 0.5,
 { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "corearticle_id_01": 0.5,{
        "lowerdate": 0.5
      }4567890987, // Unix timestamp (seconds) // [no default]
    },
    "workoutDefstitle": { "Post title", // Clients[no listendefault]
here permanently for ChildAdded, ChildChanged and ChildRemoved  "read": false,    "wktdef1": {// [default:true]
         "typelocation": 1"post/location.html", // [no       "titledefault]
		"icon": "Aerobicdefault", // [default:"default"]
        "imageappMask": "abs7MW,AF",         "desc": "Aerobic Basic Movement",// [default: all apps]
         "breakDurationpromptRating": 5,
		"appStoreId: "workout01",true // StoreKit[default:false]
product id     }
   "in7MW": true, // For server use
   }
  },
  "definitions": {
     "inAfterburnerroutines": false,{ // ForClients listen serverhere usepermanently for ChildAdded, ChildChanged and ChildRemoved
   "exercises   "routine_id_01": [{
        "title": "The {Wonder Routine", // [no default]
        "idimage": "exdef1wonder-routine",    // [default:"default-routine"]
        "durationdesc": 20"Big long description", // [default:null]
      },  "appStoreId7MW": "routine01", // StoreKit product id [default:null]
  {      "in7MW": true, // For server use [default:false]
"id        "inAfterburner": "exdef2"false, // For server use [default:false]
        "durationlockedIn7MW": 15false, // For server use [default:false]
     },   "lockedInAfterburner": false, // For server use  [default:false]
{             "idvideo": "exdef3", // [default:null]
          "durationminFitnessLevel": 104, // [default:1]
        },
          {
 "workoutDefs": { // [no default]
          "idwktdef1": "exdef4",{
            "durationtype": 51, // [default:1]
        },    "title": "Aerobic", // [no  default]
 {             "idimage": "exdef5abs", // [default:"default"]
            "durationdesc": 10"Aerobic Basic Movement", // [default:null]
      }         ]"breakDuration": 5, //   // [default:10]
    "adaptiveStress": {           "strengthappStoreId7MW": 0.2"workout01", // StoreKit product        "cardio": 0.9,id [default:null]
            "metaboliclocked": 0.6false, // For server use       "epoc[default:false]
			"MWI": 0.654,    // [default:0.5]
    },         "muscleStressexercises": {[ // [no default]
       "upper": 10,      {
    "lower": 10,           "coreid": 10
     "exdef1", // [no default]
  }       },       "wktdef2duration": {20 // [no default]
     "type": 1,        },
"title": "Thai Boxing",         "image": "abs",  {
      "desc": "Boxing With Kicking",         "breakDuration": 4,
		"appStoreId"id": "exdef2",
// StoreKit product id         "in7MW": false, // For server use"duration": 15
       "inAfterburner": true, // For server use  },
      "exercises": [       {
   {             "id": "exdef5exdef3",
            "    "duration": 10
  15            },
              {
                "id": "exdef3exdef4",
                "duration": 105
              },
              {
                "id": "exdef1exdef5",
                "duration": 510
              }
            ],
            "stressadaptiveStress": {
              "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