Skip to content

Commit

Permalink
fix(v3proxy): add send_guid endpoint (#1033)
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
kschelonka authored Jan 29, 2025
1 parent c943522 commit 69c8fe8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions servers/v3-proxy-api/src/routes/v3SendGuid.integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import request from 'supertest';
import { startServer } from '../server';
import { Server } from 'http';
import { Application } from 'express';
import { GraphQLClient } from 'graphql-request';

describe('v3/send_guid', () => {
let app: Application;
let server: Server;
let clientSpy;

beforeAll(async () => {
({ app, server } = await startServer(0));
// Response is unused so it doesn't matter what it returns
clientSpy = jest
.spyOn(GraphQLClient.prototype, 'request')
.mockResolvedValue(true);
});
afterAll(async () => {
clientSpy.mockRestore();
server.close();
jest.restoreAllMocks();
});
afterEach(() => jest.clearAllMocks());

it('Accepts actions without access token on POST', async () => {
const actions =
'%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';
const response = await request(app).post('/v3/send_guid').send({
consumer_key: 'test',
guid: 'test',
locale_lang: 'en-US',
actions,
});
const expected = {
status: 1,
action_results: [false],
action_errors: [
{
message: "Invalid Action: 'pv_wt'",
type: 'Bad request',
code: 130,
},
],
};
expect(response.body).toEqual(expected);
});
});
1 change: 1 addition & 0 deletions servers/v3-proxy-api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export async function startServer(port: number): Promise<{
app.use('/v3/add', v3AddRouter);
app.use('/v3/fetch', v3FetchRouter);
app.use('/v3/send', v3SendRouter);
app.use('/v3/send_guid', v3SendRouter);

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

Expand Down

0 comments on commit 69c8fe8

Please sign in to comment.