Skip to content

Commit f8be05f

Browse files
authored
feat!: crash attributes (#143)
* feat!: crash attributes * chore: fix build * chore: add prettierrc * fix: add xml type * chore: fix test BREAKING CHANGE: removes md5, no longer used
1 parent c2125b1 commit f8be05f

File tree

6 files changed

+58
-40
lines changed

6 files changed

+58
-40
lines changed

.prettierrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"bracketSpacing": true,
5+
"trailingComma": "es5",
6+
"printWidth": 100,
7+
"tabWidth": 2,
8+
"useTabs": false,
9+
"endOfLine": "lf"
10+
}

spec/files/native/post-native-crash.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ export async function postNativeCrash(
3434
): Promise<PostCrashResponse> {
3535
const crashFile = await createUploadableFile('./spec/files/native/myConsoleCrasher.zip');
3636
const crashPostClient = new CrashPostClient(database);
37-
await delay(2000); // Prevent rate-limiting
37+
await delay(1000); // Prevent rate-limiting
3838
const postCrashResult = await crashPostClient.postCrash(
3939
application,
4040
version,
4141
CrashType.native,
4242
crashFile,
43-
'ebe24c1cd1a0912904658fa4fad2b539'
4443
);
4544
return postCrashResult.json();
4645
}

src/post/crash-post-client.e2e.ts

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
import { CrashPostClient, CrashType } from '@post';
2-
import { config } from '@spec/config';
32
import { createUploadableFile } from '@spec/files/create-bugsplat-file';
43
import { delay } from '../common/delay';
4+
import { config } from '@spec/config';
55

66
describe('CrashPostClient', () => {
7-
beforeEach(async () => delay(2000)); // Prevent rate-limiting
7+
beforeEach(async () => delay(1000)); // Prevent rate-limiting
88

9-
describe('postCrash', () => {
10-
it('should post crash to BugSplat and return 200', async () => {
11-
const application = 'myConsoleCrasher';
12-
const version = `${Math.random() * 1000000}`;
13-
const md5 = 'ebe24c1cd1a0912904658fa4fad2b539';
14-
const crashFile = await createUploadableFile('spec/files/native/myConsoleCrasher.zip');
15-
const crashPostClient = new CrashPostClient(config.database);
16-
const result = await crashPostClient.postCrash(
17-
application,
18-
version,
19-
CrashType.native,
20-
crashFile,
21-
md5
22-
);
23-
const json = await result.json();
9+
describe('postCrash', () => {
10+
it('should post crash to BugSplat and return 200', async () => {
11+
const application = 'myConsoleCrasher';
12+
const version = `${Math.random() * 1000000}`;
13+
const crashFile = await createUploadableFile('spec/files/native/myConsoleCrasher.zip');
14+
const crashPostClient = new CrashPostClient(config.database);
15+
const attributes = {
16+
test: 'test',
17+
};
18+
const result = await crashPostClient.postCrash(
19+
application,
20+
version,
21+
CrashType.native,
22+
crashFile,
23+
attributes
24+
);
25+
const json = await result.json();
2426

25-
expect(result.status).toEqual(200);
26-
expect(json.crashId).toBeGreaterThan(0);
27-
});
27+
expect(result.status).toEqual(200);
28+
expect(json.crashId).toBeGreaterThan(0);
2829
});
29-
});
30+
});
31+
});

src/post/crash-post-client.spec.ts

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Environment } from '@common';
1+
import { Environment, UploadableFile } from '@common';
22
import { CrashPostClient, CrashType } from '@post';
33
import { createFakeBugSplatApiClient } from '@spec/fakes/common/bugsplat-api-client';
44
import { createFakeFormData } from '@spec/fakes/common/form-data';
@@ -15,26 +15,29 @@ describe('CrashPostClient', () => {
1515
let fakeGetUploadUrlResponse;
1616
let s3ApiClient;
1717

18-
let application;
19-
let database;
20-
let file;
21-
let ipAddress;
22-
let md5;
23-
let type;
24-
let url;
25-
let version;
18+
let application: string;
19+
let attributes: Record<string, string>;
20+
let database: string;
21+
let file: UploadableFile;
22+
let ipAddress: string;
23+
let type: CrashType;
24+
let url: string;
25+
let version: string;
2626

2727
let result;
2828

2929
beforeEach(() => {
3030
database = 'pumpkin';
3131
application = 'spice';
32-
file = { name: 'pumpkin-spice-latte-recipe.txt', file: '🎃🌶☕️', size: 100 };
32+
attributes = {
33+
'test': 'test'
34+
};
35+
file = { name: 'pumpkin-spice-latte-recipe.txt', file: '🎃🌶☕️' as any, size: 100 };
3336
ipAddress = '127.0.0.1';
34-
md5 = '93aebd31ecc781f6574cc396a1e0c4d2';
3537
type = CrashType.native;
3638
url = 'https://cassies.coffee/yum';
3739
version = 'latte';
40+
3841
fakeFormData = createFakeFormData();
3942
fakeCommitS3UploadResponse = createFakeResponseBody(200);
4043
fakeGetUploadUrlResponse = createFakeResponseBody(200, { url });
@@ -59,7 +62,7 @@ describe('CrashPostClient', () => {
5962
version,
6063
type,
6164
file,
62-
md5
65+
attributes
6366
);
6467
});
6568

@@ -79,7 +82,7 @@ describe('CrashPostClient', () => {
7982
expect(fakeFormData.append).toHaveBeenCalledWith('crashType', type.name);
8083
expect(fakeFormData.append).toHaveBeenCalledWith('crashTypeId', `${type.id}`);
8184
expect(fakeFormData.append).toHaveBeenCalledWith('s3key', url);
82-
expect(fakeFormData.append).toHaveBeenCalledWith('md5', md5);
85+
expect(fakeFormData.append).toHaveBeenCalledWith('attributes', JSON.stringify(attributes));
8386
expect(bugsplatApiClient.fetch).toHaveBeenCalledWith(
8487
'/api/commitS3CrashUpload',
8588
jasmine.objectContaining({

src/post/crash-post-client.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class CrashPostClient {
2323
version: string,
2424
type: CrashType,
2525
file: UploadableFile,
26-
md5 = ''
26+
attributes?: Record<string, string>
2727
): Promise<BugSplatResponse<PostCrashResponse>> {
2828
const uploadUrl = await this.getCrashUploadUrl(
2929
this._database,
@@ -40,7 +40,7 @@ export class CrashPostClient {
4040
application,
4141
version,
4242
type,
43-
md5,
43+
attributes,
4444
this._processor
4545
);
4646
}
@@ -75,7 +75,7 @@ export class CrashPostClient {
7575
application: string,
7676
version: string,
7777
crashType: CrashType,
78-
md5: string,
78+
attributes?: Record<string, string>,
7979
processor?: string,
8080
): Promise<BugSplatResponse<PostCrashResponse>> {
8181
const route = '/api/commitS3CrashUpload';
@@ -86,7 +86,10 @@ export class CrashPostClient {
8686
formData.append('crashType', crashType.name);
8787
formData.append('crashTypeId', `${crashType.id}`);
8888
formData.append('s3key', s3Key);
89-
formData.append('md5', md5);
89+
90+
if (attributes) {
91+
formData.append('attributes', JSON.stringify(attributes));
92+
}
9093

9194
if (processor) {
9295
formData.append('processor', processor);

src/post/crash-type.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export class CrashType {
66
static readonly mac = new CrashType('macOS', 13);
77
static readonly ps4 = new CrashType('PlayStation 4', 28);
88
static readonly ps5 = new CrashType('PlayStation 5', 29);
9+
static readonly xml = new CrashType('Xml.Report', 21);
910
private constructor(public readonly name: string, public readonly id: number) { }
1011
}

0 commit comments

Comments
 (0)