Skip to content

Commit 2b671dd

Browse files
committed
turn comments
1 parent ba418b4 commit 2b671dd

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/mp-instance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export type IntegrationDelays = Dictionary<boolean>;
6767
// https://go.mparticle.com/work/SQDSDKS-6949
6868
export interface IMParticleWebSDKInstance extends MParticleWebSDK {
6969
// Private Properties
70-
_timer: ForegroundTimer;
70+
_timeOnSiteTimer: ForegroundTimer;
7171
_APIClient: IAPIClient;
7272
_Consent: IConsent;
7373
_CookieSyncManager: ICookieSyncManager;
@@ -151,7 +151,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
151151
}
152152
}
153153
this.init = function(apiKey, config) {
154-
self._timer = new ForegroundTimer(apiKey);
154+
self._timeOnSiteTimer = new ForegroundTimer(apiKey);
155155
if (!config) {
156156
console.warn(
157157
'You did not pass a config object to init(). mParticle will not initialize properly'

src/serverModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export default function ServerModel(
345345
event.data,
346346
event.name
347347
),
348-
// ActiveTimeOnSite: mpInstance._timer.getTimeInForeground(),
348+
// ActiveTimeOnSite: mpInstance._timeOnSiteTimer.getTimeInForeground(),
349349
SourceMessageId:
350350
event.sourceMessageId ||
351351
mpInstance._Helpers.generateUniqueId(),

src/sessionManager.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default function SessionManager(
132132
});
133133

134134
mpInstance._Store.nullifySession();
135-
mpInstance._timer.resetTimer();
135+
mpInstance._timeOnSiteTimer.resetTimer();
136136
return;
137137
}
138138

@@ -144,6 +144,8 @@ export default function SessionManager(
144144
mpInstance.Logger.verbose(
145145
Messages.InformationMessages.AbandonEndSession
146146
);
147+
mpInstance._timeOnSiteTimer.resetTimer();
148+
147149
return;
148150
}
149151

@@ -156,6 +158,8 @@ export default function SessionManager(
156158
mpInstance.Logger.verbose(
157159
Messages.InformationMessages.NoSessionToEnd
158160
);
161+
mpInstance._timeOnSiteTimer.resetTimer();
162+
159163
return;
160164
}
161165

@@ -182,7 +186,7 @@ export default function SessionManager(
182186
}
183187
}
184188

185-
mpInstance._timer.resetTimer();
189+
mpInstance._timeOnSiteTimer.resetTimer();
186190

187191
};
188192

test/jest/foregroundTimeTracker.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ describe('ForegroundTimeTracker', () => {
66
const mockStorageKey = `mp-time-${apiKey}`;
77

88
beforeEach(() => {
9+
// Although in Jest, document.hidden should be false by default, we force it to be this way
10+
// to ensure the page is in the foreground
911
Object.defineProperty(document, 'hidden', { value: false, configurable: true });
1012
jest.useFakeTimers();
1113
localStorage.clear();
@@ -16,7 +18,6 @@ describe('ForegroundTimeTracker', () => {
1618
jest.restoreAllMocks();
1719
});
1820

19-
// in Jest, document.hidden by default is false
2021
it('should initialize with correct localStorage key', () => {
2122
foregroundTimeTracker = new ForegroundTimeTracker(apiKey);
2223
expect(foregroundTimeTracker['localStorageName']).toBe(mockStorageKey);

0 commit comments

Comments
 (0)