import analytics
This commit is contained in:
parent
ce3b4cd817
commit
63ccc49ce2
|
@ -127,16 +127,14 @@ export class ImportComponent {
|
||||||
const importResult = await importer.parse(fileContents);
|
const importResult = await importer.parse(fileContents);
|
||||||
if (importResult.success) {
|
if (importResult.success) {
|
||||||
if (importResult.folders.length === 0 && importResult.ciphers.length === 0) {
|
if (importResult.folders.length === 0 && importResult.ciphers.length === 0) {
|
||||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
this.error(this.i18nService.t('importNothingError'));
|
||||||
this.i18nService.t('importNothingError'));
|
|
||||||
return;
|
return;
|
||||||
} else if (importResult.ciphers.length > 0) {
|
} else if (importResult.ciphers.length > 0) {
|
||||||
const halfway = Math.floor(importResult.ciphers.length / 2);
|
const halfway = Math.floor(importResult.ciphers.length / 2);
|
||||||
const last = importResult.ciphers.length - 1;
|
const last = importResult.ciphers.length - 1;
|
||||||
if (this.badData(importResult.ciphers[0]) && this.badData(importResult.ciphers[halfway]) &&
|
if (this.badData(importResult.ciphers[0]) && this.badData(importResult.ciphers[halfway]) &&
|
||||||
this.badData(importResult.ciphers[last])) {
|
this.badData(importResult.ciphers[last])) {
|
||||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
this.error(this.i18nService.t('importFormatError'));
|
||||||
this.i18nService.t('importFormatError'));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,12 +154,15 @@ export class ImportComponent {
|
||||||
try {
|
try {
|
||||||
this.formPromise = this.apiService.postImportCiphers(request);
|
this.formPromise = this.apiService.postImportCiphers(request);
|
||||||
await this.formPromise;
|
await this.formPromise;
|
||||||
|
this.analytics.eventTrack.next({
|
||||||
|
action: 'Imported Data',
|
||||||
|
properties: { label: this.format },
|
||||||
|
});
|
||||||
this.toasterService.popAsync('success', null, this.i18nService.t('importSuccess'));
|
this.toasterService.popAsync('success', null, this.i18nService.t('importSuccess'));
|
||||||
this.router.navigate(['vault']);
|
this.router.navigate(['vault']);
|
||||||
} catch { }
|
} catch { }
|
||||||
} else {
|
} else {
|
||||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
this.error(this.i18nService.t('importFormatError'));
|
||||||
this.i18nService.t('importFormatError'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +178,14 @@ export class ImportComponent {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private error(errorMessage: string) {
|
||||||
|
this.analytics.eventTrack.next({
|
||||||
|
action: 'Import Data Failed',
|
||||||
|
properties: { label: this.format },
|
||||||
|
});
|
||||||
|
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
private getFileContents(file: File): Promise<string> {
|
private getFileContents(file: File): Promise<string> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
|
|
Loading…
Reference in New Issue