feat(profile): Add API endpoints for ecosystem_anon_id #5364
Conversation
|
I'll take a more detailed look, but this seems broadly as I expected Could we please also include this field in the response from |
| ecosystemAnonId: Joi.string().required(), | ||
| }, | ||
| }, | ||
| handler: async function ecosystemAnonIdPost(req) { |
rfk
May 19, 2020
Member
Ideally, clients would be able to If-Match or If-Unmodified-Since on this post, for the case when we're filling in a placeholder anon id and we don't want two clients to race in setting it.
Ideally, clients would be able to If-Match or If-Unmodified-Since on this post, for the case when we're filling in a placeholder anon id and we don't want two clients to race in setting it.
jaredhirsch
May 20, 2020
Author
Member
Sounds good. I've added a note to #4325, since I can't test the ETag is checked against the If-Match value until the DB returns an actual response.
Sounds good. I've added a note to #4325, since I can't test the ETag is checked against the If-Match value until the DB returns an actual response.
|
To clarify, is the idea that we'll land and ship just the API surface in this bug, and plumb in the actual storing in a followup? |
Yes, exactly. I'm hoping to unblock desktop client work by starting with the API, then I'll work downwards. |
|
Thanks for taking a look! I'll fixup the bits you mentioned tomorrow morning and ping you for a followup |
I think this should work now, as I've added |
| } | ||
| ``` | ||
|
|
||
| Returns a `204 No Content` if there is no ecosystem_anon_id for the user. |
vbudhram
May 21, 2020
Contributor
I'm cool with this, I've seen other endpoints return 200 and an empty response.
I'm cool with this, I've seen other endpoints return 200 and an empty response.
| @@ -23,6 +23,7 @@ module.exports = { | |||
| }, | |||
| response: { | |||
| schema: { | |||
| ecosystemAnonId: Joi.string().optional(), | |||
vbudhram
May 21, 2020
Contributor
nit: Update docs
nit: Update docs
| var tok = token(); | ||
|
|
||
| describe('GET', function() { | ||
| xit('should return an ecosystem_anon_id', function() {}); |
vbudhram
May 21, 2020
Contributor
TIL xit
TIL xit
| @@ -765,6 +767,28 @@ describe('api', function() { | |||
| assertSecurityHeaders(res); | |||
| }); | |||
| }); | |||
|
|
|||
| it('should omit `ecosystem_anon_id` if not returned by auth-server', () => { | |||
vbudhram
May 21, 2020
Contributor
In the auth-server I've been slowly updating the test code to use async/await since it makes things a little easier to read.
In the auth-server I've been slowly updating the test code to use async/await since it makes things a little easier to read.
jaredhirsch
May 21, 2020
Author
Member
oh, nice! yeah, I was just trying to follow the existing style in the files, but I'll start converting to async/await 👍
oh, nice! yeah, I was just trying to follow the existing style in the files, but I'll start converting to async/await
| const uid = req.auth.credentials.user; | ||
| logger.info('activityEvent', { event: 'ecosystemAnonId.post', uid: uid }); | ||
|
|
||
| return req.server.methods.profileCache.drop(uid).then(() => { |
vladikoff
May 21, 2020
Contributor
could this just use await ? We've been slowly converting the routes
could this just use await ? We've been slowly converting the routes
jaredhirsch
May 21, 2020
Author
Member
yeah, definitely
yeah, definitely
|
A belated r+ here, but thanks for pushing this through first! |
The ecosystem_anon_id work for AET (Jira epic FXA-880) started from the API used by desktop code, in order to unblock that work, which can be done in parallel. This new identifier is eventually going to be part of the core profile fields stored in the auth server DB, which means there will be changes in mysql, auth-db, auth-server, and profile-server. The initial no-op profile-server API implementation landed as #5364. This change moves one step further down the stack, updating the profile-server API handler from a no-op to an actual call into the _core_profile, and adding a deceptively simple change to the auth server that allows an ecosystemAnonId field to be passed through from auth-db. Future commits will integrate this new field into the auth-db and eventually into mysql.
Starting off the AET work with an API that will need to agree with changes that ride the trains into desktop. This ecosystem_anon_id field isn't yet persisted in the core profile fields in the auth DB, that's a different bug. Not 100% sure I'm logging correctly. Still need to add tests to api.js.