chore: 🤖 Update session recording API (#243)
* chore: 🤖 Update session recording API * chore: 🤖 Update usage of scope id for targets * chore: 🤖 Update scope id usage for user in session recordings
This commit is contained in:
1 parent
308a393202
commit
0dee7b5a02
11 files changed
+89
-51
No files matched your search
@@ -19,16 +19,11 @@ export default class GeneratedSessionRecordingModel extends BaseModel {
|
||||
type;
|
||||
|
||||
@attr({
|
||||
description: 'The user who created the session.',
|
||||
description:
|
||||
'Contains the values of related fields at the time this Session Recording was created',
|
||||
readOnly: true,
|
||||
})
|
||||
user;
|
||||
|
||||
@attr({
|
||||
description: 'The target the session connected to.',
|
||||
readOnly: true,
|
||||
})
|
||||
target;
|
||||
create_time_values;
|
||||
|
||||
@attr('string', {
|
||||
description: 'The ID of the Session which this Session Recording recorded.',
|
||||
@@ -36,6 +31,13 @@ export default class GeneratedSessionRecordingModel extends BaseModel {
|
||||
})
|
||||
session_id;
|
||||
|
||||
@attr('string', {
|
||||
description:
|
||||
'The ID of the Storage Bucket for the Target of this Session Recording',
|
||||
readOnly: true,
|
||||
})
|
||||
storage_bucket_id;
|
||||
|
||||
@attr('string', {
|
||||
description:
|
||||
'The total number of bytes uploaded from the client in the Session.',
|
||||
|
||||
@@ -38,7 +38,10 @@ export default class SessionRecordingModel extends GeneratedSessionRecordingMode
|
||||
* @type {string}
|
||||
*/
|
||||
get targetScopeDisplayName() {
|
||||
return this.target?.scope?.name || this.target?.scope?.id;
|
||||
return (
|
||||
this.create_time_values?.target?.scope?.name ||
|
||||
this.create_time_values?.target?.scope?.id
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,6 +49,8 @@ export default class SessionRecordingModel extends GeneratedSessionRecordingMode
|
||||
* @type {string}
|
||||
*/
|
||||
get userDisplayName() {
|
||||
return this.user?.name || this.user?.id;
|
||||
return (
|
||||
this.create_time_values?.user?.name || this.create_time_values?.user?.id
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,12 @@ export default factory.extend({
|
||||
target.id = 'deleted_target';
|
||||
|
||||
sessionRecording.update({
|
||||
user: user.attrs,
|
||||
target: target.attrs,
|
||||
sessionId: session.id,
|
||||
storage_bucket_id: target.storage_bucket_id,
|
||||
create_time_values: {
|
||||
user: user.attrs,
|
||||
target: target.attrs,
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
@@ -52,9 +55,12 @@ export default factory.extend({
|
||||
);
|
||||
|
||||
sessionRecording.update({
|
||||
user: user.attrs,
|
||||
target: target.attrs,
|
||||
sessionId: session.id,
|
||||
storage_bucket_id: target.storage_bucket_id,
|
||||
create_time_values: {
|
||||
user: user.attrs,
|
||||
target: target.attrs,
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -26,18 +26,19 @@ export default ApplicationSerializer.extend({
|
||||
);
|
||||
});
|
||||
}
|
||||
if (model.user?.scopeId) {
|
||||
const scope = scopes.find(model.user.scopeId);
|
||||
json.user.scope = ScopeSerializer.prototype._hashForModel.apply(this, [
|
||||
scope,
|
||||
]);
|
||||
const userScopeId = model.create_time_values?.user?.scopeId;
|
||||
if (userScopeId) {
|
||||
const scope = scopes.find(userScopeId);
|
||||
json.create_time_values.user.scope =
|
||||
ScopeSerializer.prototype._hashForModel.apply(this, [scope]);
|
||||
}
|
||||
if (model.target?.scopeId) {
|
||||
const scope = scopes.find(model.target.scopeId);
|
||||
json.target.scope = ScopeSerializer.prototype._hashForModel.apply(this, [
|
||||
scope,
|
||||
]);
|
||||
const targetScopeId = model.create_time_values?.target?.scopeId;
|
||||
if (targetScopeId) {
|
||||
const scope = scopes.find(targetScopeId);
|
||||
json.create_time_values.target.scope =
|
||||
ScopeSerializer.prototype._hashForModel.apply(this, [scope]);
|
||||
}
|
||||
delete json.create_time_values?.target?.storage_bucket_id;
|
||||
|
||||
json.session_id = model.sessionId;
|
||||
return json;
|
||||
|
||||
@@ -84,13 +84,22 @@ module('Unit | Model | session-recording', function (hooks) {
|
||||
const fakeId = 's_123456789';
|
||||
|
||||
const modelA = store.createRecord('session-recording', {
|
||||
target: {
|
||||
scope: { name: fakeName, id: fakeId },
|
||||
create_time_values: {
|
||||
target: {
|
||||
scope: {
|
||||
name: fakeName,
|
||||
id: fakeId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const modelB = store.createRecord('session-recording', {
|
||||
target: {
|
||||
scope: { id: fakeId },
|
||||
create_time_values: {
|
||||
target: {
|
||||
scope: {
|
||||
id: fakeId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -105,11 +114,20 @@ module('Unit | Model | session-recording', function (hooks) {
|
||||
const fakeUserId = 'userid';
|
||||
|
||||
const userModelA = store.createRecord('session-recording', {
|
||||
user: { name: fakeUserName, id: fakeUserId },
|
||||
create_time_values: {
|
||||
user: {
|
||||
name: fakeUserName,
|
||||
id: fakeUserId,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const userModelB = store.createRecord('session-recording', {
|
||||
user: { id: fakeUserId },
|
||||
create_time_values: {
|
||||
user: {
|
||||
id: fakeUserId,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(userModelA.userDisplayName, fakeUserName);
|
||||
|
||||
Reference in new issue
Block a user