Skip to content

Commit 7fb0749

Browse files
committed
Append this._storageSuffix (which includes API key) to unsentKey before storing in AsyncStorage
Currently, when saving events to AsyncStorage, we we are only using unsentKey as the identifier. This can cause events from multiple projects to get mixed up. By appending this._storageSuffix, we are adding more specificity to keep unsent events within the correct project scope.
1 parent e609a65 commit 7fb0749

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/amplitude-client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o
168168
if (AsyncStorage) {
169169
Promise.all([
170170
AsyncStorage.getItem(this._storageSuffix),
171-
AsyncStorage.getItem(this.options.unsentKey),
171+
AsyncStorage.getItem(this.options.unsentKey + this._storageSuffix),
172172
AsyncStorage.getItem(this.options.unsentIdentifyKey),
173173
]).then((values) => {
174174
if (values[0]) {
@@ -702,7 +702,7 @@ AmplitudeClient.prototype._saveReferrer = function _saveReferrer(referrer) {
702702
AmplitudeClient.prototype.saveEvents = function saveEvents() {
703703
try {
704704
if (AsyncStorage) {
705-
AsyncStorage.setItem(this.options.unsentKey, JSON.stringify(this._unsentEvents));
705+
AsyncStorage.setItem(this.options.unsentKey + this._storageSuffix, JSON.stringify(this._unsentEvents));
706706
} else {
707707
this._setInStorage(localStorage, this.options.unsentKey, JSON.stringify(this._unsentEvents));
708708
}

0 commit comments

Comments
 (0)