Skip to content

Commit 41de184

Browse files
authored
refactor: reduce bundle size via dead code removal and log shortening (#1439)
1 parent 93455c0 commit 41de184

52 files changed

Lines changed: 288 additions & 666 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/rules/conventions.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

.cursor/rules/pr-conventions.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
description: Conventions for pull request titles and body content
3+
alwaysApply: true
4+
---
5+
6+
# Pull Request Conventions
7+
8+
## PR Title
9+
10+
Use semantic/conventional commit prefixes in PR titles:
11+
12+
- `fix:` for bug fixes
13+
- `feat:` for new features
14+
- `chore:` for maintenance tasks (deps, CI, tooling)
15+
- `refactor:` for code restructuring without behavior changes
16+
- `docs:` for documentation-only changes
17+
- `test:` for test-only changes
18+
19+
Example: `fix: resolve notification grouping on Android 14`
20+
21+
## PR Body
22+
23+
Follow the repo's PR template at `.github/pull_request_template.md`. Every PR body must include:
24+
25+
1. **One Line Summary** (required)
26+
2. **Motivation** (required) explaining why the change is being made
27+
3. **Scope** (recommended) describing what is and isn't affected
28+
4. **Testing** section with manual and/or unit testing details
29+
5. **Affected code checklist** with relevant items checked
30+
6. **Checklist** sections confirmed
31+
32+
Remove the instructional header block (between `<!-- START -->` and `<!-- END -->`) before submitting.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@
7777
},
7878
{
7979
"path": "./build/releases/OneSignalSDK.page.es6.js",
80-
"limit": "43.69 kB",
80+
"limit": "41.94 kB",
8181
"gzip": true
8282
},
8383
{
8484
"path": "./build/releases/OneSignalSDK.sw.js",
85-
"limit": "12.701 kB",
85+
"limit": "12.272 kB",
8686
"gzip": true
8787
},
8888
{

src/core/executors/CustomEventOperationExecutor.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ export class CustomEventsOperationExecutor implements IOperationExecutor {
3434
}
3535

3636
async _execute(operations: Operation[]): Promise<ExecutionResponse> {
37-
Log._debug(
38-
`CustomEventsOperationExecutor(operations: ${JSON.stringify(
39-
operations,
40-
)})`,
41-
);
37+
Log._debug(`CustomEventOpExec(${JSON.stringify(operations)})`);
4238

4339
// TODO: each trackEvent is sent individually right now; may need to batch in the future
4440
const operation = operations[0];

src/core/executors/IdentityOperationExecutor.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ export class IdentityOperationExecutor implements IOperationExecutor {
4040
}
4141

4242
async _execute(operations: Operation[]): Promise<ExecutionResponse> {
43-
Log._debug(
44-
`IdentityOperationExecutor(operations: ${JSON.stringify(operations)})`,
45-
);
43+
Log._debug(`IdentityOpExec(${JSON.stringify(operations)})`);
4644

4745
const invalidOps = operations.filter(
4846
(op) =>

src/core/executors/LoginUserOperationExecutor.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ export class LoginUserOperationExecutor implements IOperationExecutor {
6161
}
6262

6363
async _execute(operations: Operation[]): Promise<ExecutionResponse> {
64-
Log._debug(
65-
`LoginUserOperationExecutor(operation: ${JSON.stringify(operations)})`,
66-
);
64+
Log._debug(`LoginUserOpExec(${JSON.stringify(operations)})`);
6765
const startingOp = operations[0];
6866

6967
if (startingOp instanceof LoginUserOperation)
@@ -121,13 +119,11 @@ export class LoginUserOperationExecutor implements IOperationExecutor {
121119
}
122120

123121
case ExecutionResult._FailConflict:
124-
Log._debug(`Handling 409 for externalId: ${loginUserOp._externalId}`);
122+
Log._debug(`409 conflict: ${loginUserOp._externalId}`);
125123
return this._createUser(loginUserOp, operations);
126124

127125
case ExecutionResult._FailNoretry:
128-
Log._error(
129-
`Recovering from SetAlias failure for externalId: ${loginUserOp._externalId}`,
130-
);
126+
Log._error(`SetAlias failed: ${loginUserOp._externalId}`);
131127
return this._createUser(loginUserOp, operations);
132128

133129
default:

src/core/executors/RefreshUserOperationExecutor.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ export class RefreshUserOperationExecutor implements IOperationExecutor {
5252
}
5353

5454
async _execute(operations: Operation[]): Promise<ExecutionResponse> {
55-
Log._debug(
56-
`RefreshUserOperationExecutor(operation: ${JSON.stringify(operations)})`,
57-
);
55+
Log._debug(`RefreshUserOpExec(${JSON.stringify(operations)})`);
5856

5957
if (operations.some((op) => !(op instanceof RefreshUserOperation)))
6058
throw new Error(

src/core/executors/SubscriptionOperationExecutor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class SubscriptionOperationExecutor implements IOperationExecutor {
5353
}
5454

5555
async _execute(operations: Operation[]): Promise<ExecutionResponse> {
56-
Log._debug(`SubscriptionOperationExecutor(operations: ${operations})`);
56+
Log._debug(`SubOpExec(${operations})`);
5757

5858
const startingOp = operations[0];
5959
if (startingOp instanceof CreateSubscriptionOperation)

src/core/executors/UpdateUserOperationExecutor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class UpdateUserOperationExecutor implements IOperationExecutor {
7878
}
7979

8080
async _execute(operations: Operation[]): Promise<ExecutionResponse> {
81-
Log._debug(`UpdateUserOperationExecutor(operation: ${operations})`);
81+
Log._debug(`UpdateUserOpExec(${operations})`);
8282

8383
const { appId, onesignalId, propertiesObject, refreshDeviceMetadata } =
8484
this._processOperations(operations);

src/core/modelRepo/OperationModelStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class OperationModelStore extends ModelStore<Operation> {
2727

2828
_create(jsonObject?: { name?: string } | null): Operation | null {
2929
if (jsonObject === null) {
30-
Log._error('null jsonObject sent to OperationModelStore.create');
30+
Log._error('null jsonObject in OpModelStore.create');
3131
return null;
3232
}
3333

@@ -96,7 +96,7 @@ export class OperationModelStore extends ModelStore<Operation> {
9696
} {
9797
const operationName = object?.name;
9898
if (!operationName) {
99-
Log._error("jsonObject must have 'name' attribute");
99+
Log._error("Missing 'name' attribute");
100100
return false;
101101
}
102102

0 commit comments

Comments
 (0)