Skip to content

Commit 2130b0f

Browse files
committed
address merge conflict with size optimization changes
1 parent 450ce08 commit 2130b0f

13 files changed

Lines changed: 106 additions & 40 deletions

File tree

__test__/support/environment/TestEnvironmentHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export const createPushSub = ({
139139
const pushSubscription = new SubscriptionModel();
140140
pushSubscription.initializeFromJson({
141141
device_model: '',
142-
device_os: 56,
142+
device_os: '56',
143143
enabled: true,
144144
id,
145145
notification_types: NotificationType.Subscribed,

src/core/executors/CustomEventOperationExecutor.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import Environment from 'src/shared/helpers/Environment';
1+
import {
2+
getDeviceModel,
3+
getDeviceOS,
4+
getSubscriptionType,
5+
} from 'src/shared/environment';
26
import {
37
getResponseStatusType,
48
ResponseStatusType,
@@ -25,9 +29,9 @@ export class CustomEventsOperationExecutor implements IOperationExecutor {
2529
private get eventMetadata(): ICustomEventMetadata {
2630
return {
2731
sdk: VERSION,
28-
device_model: Environment.getDeviceModel(),
29-
device_os: Environment.getDeviceOS(),
30-
type: Environment.getSubscriptionType(),
32+
device_model: getDeviceModel(),
33+
device_os: getDeviceOS(),
34+
type: getSubscriptionType(),
3135
};
3236
}
3337

src/core/models/SubscriptionModel.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Environment from 'src/shared/helpers/Environment';
1+
import { getDeviceModel, getDeviceOS } from 'src/shared/environment';
2+
import { VERSION } from 'src/shared/utils/EnvVariables';
23
import type { ISubscription } from '../types/api';
34
import {
45
type NotificationTypeValue,
@@ -27,9 +28,9 @@ type ISubscriptionModel = Pick<
2728
export class SubscriptionModel extends Model<ISubscriptionModel> {
2829
constructor() {
2930
super();
30-
this.sdk = Environment.version();
31-
this.device_model = Environment.getDeviceModel();
32-
this.device_os = Environment.getDeviceOS();
31+
this.sdk = VERSION;
32+
this.device_model = getDeviceModel();
33+
this.device_os = getDeviceOS();
3334
}
3435

3536
/**
@@ -96,10 +97,10 @@ export class SubscriptionModel extends Model<ISubscriptionModel> {
9697
this.setProperty('device_model', value);
9798
}
9899

99-
get device_os(): number | undefined {
100+
get device_os(): string | undefined {
100101
return this.getProperty('device_os');
101102
}
102-
set device_os(value: number | undefined) {
103+
set device_os(value: string | undefined) {
103104
this.setProperty('device_os', value);
104105
}
105106

src/core/operations/BaseFullSubscriptionOperation.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Environment from 'src/shared/helpers/Environment';
1+
import { getDeviceModel, getDeviceOS } from 'src/shared/environment';
2+
import { VERSION } from 'src/shared/utils/EnvVariables';
23
import type { ICreateUserSubscription } from '../types/api';
34
import {
45
type NotificationTypeValue,
@@ -28,9 +29,9 @@ export abstract class BaseFullSubscriptionOperation extends BaseSubscriptionOper
2829
super(operationName, appId, onesignalId);
2930

3031
if (subscription) {
31-
this.sdk = Environment.version();
32-
this.device_model = Environment.getDeviceModel();
33-
this.device_os = Environment.getDeviceOS();
32+
this.sdk = VERSION;
33+
this.device_model = getDeviceModel();
34+
this.device_os = getDeviceOS();
3435
this.enabled = subscription.enabled;
3536
this.notification_types = subscription.notification_types;
3637
this.subscriptionId = subscription.subscriptionId;
@@ -104,10 +105,10 @@ export abstract class BaseFullSubscriptionOperation extends BaseSubscriptionOper
104105
/**
105106
* The device OS version
106107
*/
107-
get device_os(): number | undefined {
108+
get device_os(): string | undefined {
108109
return this.getProperty('device_os');
109110
}
110-
protected set device_os(value: number | undefined) {
111+
protected set device_os(value: string | undefined) {
111112
this.setProperty('device_os', value);
112113
}
113114

src/core/operations/TrackEventOperation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { IDManager } from 'src/shared/managers/IDManager';
22
import { OPERATION_NAME } from '../constants';
3-
import { ICustomEvent } from '../types/customEvents';
3+
import type { ICustomEvent } from '../types/customEvents';
44
import {
55
GroupComparisonType,
6-
GroupComparisonValue,
76
Operation,
7+
type GroupComparisonValue,
88
} from './Operation';
99

1010
type OperationProps = {

src/core/types/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface ICreateUserIdentity {
3535
export interface ICreateUserSubscription {
3636
// app_version?: string; // For Mobile
3737
device_model?: string;
38-
device_os?: number;
38+
device_os?: string;
3939
enabled?: boolean;
4040
notification_types?: NotificationTypeValue;
4141
// rooted?: boolean; // For Android

src/core/types/customEvents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface ICustomEventController {
1111

1212
export interface ICustomEventMetadata {
1313
device_model: string;
14-
device_os: number;
14+
device_os: string;
1515
sdk: string;
1616
type: SubscriptionTypeValue;
1717
}

src/onesignal/OneSignal.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ describe('OneSignal', () => {
197197
id: DUMMY_SUBSCRIPTION_ID_2,
198198
token: 'test@test.com',
199199
type: 'Email',
200-
device_os: 56,
200+
device_os: '56',
201201
device_model: '',
202202
sdk: __VERSION__,
203203
enabled: true,
@@ -290,7 +290,7 @@ describe('OneSignal', () => {
290290
id: DUMMY_SUBSCRIPTION_ID_3,
291291
token: sms,
292292
type: 'SMS',
293-
device_os: 56,
293+
device_os: '56',
294294
device_model: '',
295295
sdk: __VERSION__,
296296
},

src/page/userModel/FuturePushSubscriptionRecord.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import type {
33
SubscriptionTypeValue,
44
} from 'src/core/types/subscription';
55
import { NotificationType } from 'src/core/types/subscription';
6+
import {
7+
getDeviceModel,
8+
getDeviceOS,
9+
getSubscriptionType,
10+
} from 'src/shared/environment';
611
import { RawPushSubscription } from 'src/shared/models/RawPushSubscription';
7-
import Environment from '../../shared/helpers/Environment';
12+
import { VERSION } from 'src/shared/utils/EnvVariables';
813
import type { Serializable } from '../models/Serializable';
914

1015
export default class FuturePushSubscriptionRecord implements Serializable {
@@ -14,18 +19,18 @@ export default class FuturePushSubscriptionRecord implements Serializable {
1419
readonly notificationTypes?: NotificationTypeValue;
1520
readonly sdk: string;
1621
readonly deviceModel: string;
17-
readonly deviceOs: number;
22+
readonly deviceOs: string;
1823
readonly webAuth?: string;
1924
readonly webp256?: string;
2025

2126
constructor(rawPushSubscription: RawPushSubscription) {
2227
this.token = this._getToken(rawPushSubscription);
23-
this.type = Environment.getSubscriptionType();
28+
this.type = getSubscriptionType();
2429
this.enabled = true;
2530
this.notificationTypes = NotificationType.Subscribed;
26-
this.sdk = Environment.version();
27-
this.deviceModel = Environment.getDeviceModel();
28-
this.deviceOs = Environment.getDeviceOS();
31+
this.sdk = VERSION;
32+
this.deviceModel = getDeviceModel();
33+
this.deviceOs = getDeviceOS();
2934
this.webAuth = rawPushSubscription.w3cAuth;
3035
this.webp256 = rawPushSubscription.w3cP256dh;
3136
}

src/shared/api/OneSignalApiSW.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { NotificationType } from 'src/core/types/subscription';
33
import AliasPair from '../../core/requestService/AliasPair';
44
import { RequestService } from '../../core/requestService/RequestService';
55
import type { OutcomeRequestData } from '../../page/models/OutcomeRequestData';
6+
import type { ServerAppConfig } from '../config';
67
import Utils from '../context/Utils';
7-
import Environment from '../helpers/Environment';
8+
import { getSubscriptionType } from '../environment';
89
import Log from '../libraries/Log';
9-
import type { ServerAppConfig } from '../models/AppConfig';
1010
import type { DeliveryPlatformKindValue } from '../models/DeliveryPlatformKind';
1111
import {
1212
OutcomeAttributionType,
@@ -111,7 +111,7 @@ export class OneSignalApiSW {
111111
notification_ids: attribution.notificationIds,
112112
subscription: {
113113
id: subscriptionId,
114-
type: Environment.getSubscriptionType(),
114+
type: getSubscriptionType(),
115115
},
116116
onesignal_id: onesignalId,
117117
};

0 commit comments

Comments
 (0)