Skip to content

Commit

Permalink
fix(insights): use internal find util method (#4580)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored Nov 17, 2020
1 parent 265ce53 commit 61b855b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/middlewares/createInsightsMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InsightsClient, InsightsClientMethod, Middleware } from '../types';
import { getInsightsAnonymousUserTokenInternal } from '../helpers';
import { warning, noop, getAppIdAndApiKey } from '../lib/utils';
import { warning, noop, getAppIdAndApiKey, find } from '../lib/utils';

export type InsightsEvent = {
insightsMethod?: InsightsClientMethod;
Expand Down Expand Up @@ -54,10 +54,10 @@ export const createInsightsMiddleware: CreateInsightsMiddleware = props => {
// we still want to read the token from the queue.
// Otherwise, the first search call will be fired without the token.
[, queuedUserToken] =
insightsClient.queue
.slice()
.reverse()
.find(([method]) => method === 'setUserToken') || [];
find(
insightsClient.queue.slice().reverse(),
([method]) => method === 'setUserToken'
) || [];
}
insightsClient('_get', '_userToken', (userToken: string) => {
// If user has called `aa('setUserToken', 'my-user-token')` before creating
Expand Down

0 comments on commit 61b855b

Please sign in to comment.