Skip to content

Commit afe3a1a

Browse files
revert: hasIdentifyBeenCalled check and its tests (#462)
1 parent bbd8414 commit afe3a1a

File tree

2 files changed

+0
-59
lines changed

2 files changed

+0
-59
lines changed

src/analytics/SegmentAnalyticsService.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ class SegmentAnalyticsService {
157157
* @param {*} [traits]
158158
*/
159159
identifyAuthenticatedUser(userId, traits) {
160-
if (this.hasIdentifyBeenCalled) {
161-
return;
162-
}
163-
164160
if (!userId) {
165161
throw new Error('UserId is required for identifyAuthenticatedUser.');
166162
}
@@ -179,10 +175,6 @@ class SegmentAnalyticsService {
179175
* @returns {Promise} Promise that will resolve once the document readyState is complete
180176
*/
181177
identifyAnonymousUser(traits) { // eslint-disable-line no-unused-vars
182-
if (this.hasIdentifyBeenCalled) {
183-
return Promise.resolve();
184-
}
185-
186178
if (!this.segmentInitialized) {
187179
return Promise.resolve();
188180
}

src/analytics/interface.test.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -112,30 +112,6 @@ describe('Analytics', () => {
112112
expect(() => identifyAuthenticatedUser(null))
113113
.toThrowError(new Error('UserId is required for identifyAuthenticatedUser.'));
114114
});
115-
116-
it('should call segment identify once', () => {
117-
const testTraits = { anything: 'Yay!' };
118-
identifyAuthenticatedUser(testUserId, testTraits);
119-
identifyAuthenticatedUser(testUserId, testTraits);
120-
121-
expect(window.analytics.identify.mock.calls.length).toBe(1);
122-
});
123-
124-
it('should call segment identify if hasIdentifyBeenCalled is false', () => {
125-
const testTraits = { anything: 'Yay!' };
126-
service.hasIdentifyBeenCalled = false;
127-
identifyAuthenticatedUser(testUserId, testTraits);
128-
129-
expect(window.analytics.identify).toHaveBeenCalled();
130-
});
131-
132-
it('should not call segment identify if hasIdentifyBeenCalled is true', () => {
133-
const testTraits = { anything: 'Yay!' };
134-
service.hasIdentifyBeenCalled = true;
135-
identifyAuthenticatedUser(testUserId, testTraits);
136-
137-
expect(window.analytics.identify).not.toHaveBeenCalled();
138-
});
139115
});
140116

141117
describe('analytics identifyAnonymousUser', () => {
@@ -154,33 +130,6 @@ describe('Analytics', () => {
154130

155131
expect(window.analytics.reset.mock.calls.length).toBe(1);
156132
});
157-
158-
it('should call segment reset once', () => {
159-
window.analytics.user = () => ({ id: () => 1 });
160-
const testTraits = { anything: 'Yay!' };
161-
identifyAnonymousUser(testTraits);
162-
identifyAnonymousUser(testTraits);
163-
164-
expect(window.analytics.reset.mock.calls.length).toBe(1);
165-
});
166-
167-
it('should call segment reset if hasIdentifyBeenCalled is false', () => {
168-
window.analytics.user = () => ({ id: () => 2 });
169-
const testTraits = { anything: 'Yay!' };
170-
service.hasIdentifyBeenCalled = false;
171-
identifyAnonymousUser(testTraits);
172-
173-
expect(window.analytics.reset).toHaveBeenCalled();
174-
});
175-
176-
it('should not call segment reset if hasIdentifyBeenCalled is true', () => {
177-
window.analytics.user = () => ({ id: () => 3 });
178-
const testTraits = { anything: 'Yay!' };
179-
service.hasIdentifyBeenCalled = true;
180-
identifyAnonymousUser(testTraits);
181-
182-
expect(window.analytics.reset).not.toHaveBeenCalled();
183-
});
184133
});
185134

186135
function testSendPageAfterIdentify(identifyFunction) {

0 commit comments

Comments
 (0)