Storing this value in a global variable is brittle and error-prone, so we should avoid doing it. We previously discussed closing over a scope containing a value vs. propagating it through a long call chain, and we agreed that the former is better; but I didn't realize at the time that the scope you had in mind was the global scope, which all functions close over, and in which it is thus dangerous to store call-specific state.

So we should propagate the value through the call chain instead. But that doesn't mean we have to propagate it through the whole chain. We could instead retrieve receipts earlier, as soon as we identify the origin of an app. In the *addAppByTab* case, that happens early, as soon as, addAppByTabUrl(), so we would only need to pass the value to that one function. It happens later in the *addAppByDirectory* case, not until _updateApp(), which generates the xkey. But I don't see why we have to generate the xkey so late; we could move xkey generation up to addAppByDirectory(), in which case we would again only need to pass the value into one function.