Skip to content

Commit 69c8fe8

Browse files
authored
fix(v3proxy): add send_guid endpoint (#1033)
Routes to v3/send controller. For backwards-compatible Android requests, which are erroring out due to 404 when accessing Home while not logged in. This endpoint is just legacy analytics, so we will ignore the actions in the same way that we ignore them in v3/send (by returning false and an error in the response, but not a failure of the entire request. [POCkET-10932]
1 parent c943522 commit 69c8fe8

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import request from 'supertest';
2+
import { startServer } from '../server';
3+
import { Server } from 'http';
4+
import { Application } from 'express';
5+
import { GraphQLClient } from 'graphql-request';
6+
7+
describe('v3/send_guid', () => {
8+
let app: Application;
9+
let server: Server;
10+
let clientSpy;
11+
12+
beforeAll(async () => {
13+
({ app, server } = await startServer(0));
14+
// Response is unused so it doesn't matter what it returns
15+
clientSpy = jest
16+
.spyOn(GraphQLClient.prototype, 'request')
17+
.mockResolvedValue(true);
18+
});
19+
afterAll(async () => {
20+
clientSpy.mockRestore();
21+
server.close();
22+
jest.restoreAllMocks();
23+
});
24+
afterEach(() => jest.clearAllMocks());
25+
26+
it('Accepts actions without access token on POST', async () => {
27+
const actions =
28+
'%5B%7B%22action_identifier%22%3A%22referrer%22%2C%22page%22%3A%22installation%22%2C%22page_params%22%3A%22utm_source%3Dgoogle-play%26utm_medium%3Dorganic%22%2C%22section%22%3A%22core%22%2C%22time%22%3A1737985217%2C%22type_id%22%3A3%2C%22view%22%3A%22mobile%22%2C%22action%22%3A%22pv_wt%22%2C%22cxt_online%22%3A2%2C%22cxt_orient%22%3A1%2C%22sid%22%3A%221737985217%22%7D%5D';
29+
const response = await request(app).post('/v3/send_guid').send({
30+
consumer_key: 'test',
31+
guid: 'test',
32+
locale_lang: 'en-US',
33+
actions,
34+
});
35+
const expected = {
36+
status: 1,
37+
action_results: [false],
38+
action_errors: [
39+
{
40+
message: "Invalid Action: 'pv_wt'",
41+
type: 'Bad request',
42+
code: 130,
43+
},
44+
],
45+
};
46+
expect(response.body).toEqual(expected);
47+
});
48+
});

servers/v3-proxy-api/src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export async function startServer(port: number): Promise<{
5252
app.use('/v3/add', v3AddRouter);
5353
app.use('/v3/fetch', v3FetchRouter);
5454
app.use('/v3/send', v3SendRouter);
55+
app.use('/v3/send_guid', v3SendRouter);
5556

5657
// NOTE: we on purpose do not setup the sentry middleware in this service since it is a proxy and we log our own errors.
5758

0 commit comments

Comments
 (0)