-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
qe.repository.ts
36 lines (35 loc) · 932 Bytes
/
qe.repository.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Repository } from '../core/repository';
export class QeRepository extends Repository {
public syncExperiments() {
return this.sync(this.client.state.experiments);
}
public async syncLoginExperiments() {
return this.sync(this.client.state.loginExperiments);
}
public async sync(experiments) {
let data;
try {
const uid = this.client.state.cookieUserId;
data = {
_csrftoken: this.client.state.cookieCsrfToken,
id: uid,
_uid: uid,
_uuid: this.client.state.uuid,
};
} catch {
data = {
id: this.client.state.uuid,
};
}
data = Object.assign(data, { experiments });
const { body } = await this.client.request.send({
method: 'POST',
url: '/api/v1/qe/sync/',
headers: {
'X-DEVICE-ID': this.client.state.uuid,
},
form: this.client.request.sign(data),
});
return body;
}
}