Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/services/__tests__/splitApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ describe('splitApi', () => {
splitApi.postMetricsUsage('fake-body');
assertHeaders(settings, fetchMock.mock.calls[8][1].headers);

expect(telemetryTrackerMock.trackHttp).toBeCalledTimes(9);
splitApi.fetchMyLargeSegments('userKey');
[url, { headers }] = fetchMock.mock.calls[9];
assertHeaders(settings, headers);
expect(url).toBe('sdk/myLargeSegments/userKey');

expect(telemetryTrackerMock.trackHttp).toBeCalledTimes(10);

telemetryTrackerMock.trackHttp.mockClear();
fetchMock.mockClear();
Expand Down
7 changes: 6 additions & 1 deletion src/services/splitApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { splitHttpClientFactory } from './splitHttpClient';
import { ISplitApi } from './types';
import { objectAssign } from '../utils/lang/objectAssign';
import { ITelemetryTracker } from '../trackers/types';
import { SPLITS, IMPRESSIONS, IMPRESSIONS_COUNT, EVENTS, TELEMETRY, TOKEN, SEGMENT, MY_SEGMENT } from '../utils/constants';
import { SPLITS, IMPRESSIONS, IMPRESSIONS_COUNT, EVENTS, TELEMETRY, TOKEN, SEGMENT, MY_SEGMENT, MY_LARGE_SEGMENT } from '../utils/constants';
import { ERROR_TOO_MANY_SETS } from '../logger/constants';

const noCacheHeaderOptions = { headers: { 'Cache-Control': 'no-cache' } };
Expand Down Expand Up @@ -78,6 +78,11 @@ export function splitApiFactory(
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(MY_SEGMENT));
},

fetchMyLargeSegments(userMatchingKey: string, noCache?: boolean) {
const url = `${urls.sdk}/myLargeSegments/${encodeURIComponent(userMatchingKey)}`;
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(MY_LARGE_SEGMENT));
},

/**
* Post events.
*
Expand Down
1 change: 1 addition & 0 deletions src/services/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface ISplitApi {
fetchSplitChanges: IFetchSplitChanges
fetchSegmentChanges: IFetchSegmentChanges
fetchMySegments: IFetchMySegments
fetchMyLargeSegments: IFetchMySegments
postEventsBulk: IPostEventsBulk
postUniqueKeysBulkCs: IPostUniqueKeysBulkCs
postUniqueKeysBulkSs: IPostUniqueKeysBulkSs
Expand Down
3 changes: 2 additions & 1 deletion src/sync/submitters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export type TELEMETRY = 'te';
export type TOKEN = 'to';
export type SEGMENT = 'se';
export type MY_SEGMENT = 'ms';
export type OperationType = SPLITS | IMPRESSIONS | IMPRESSIONS_COUNT | EVENTS | TELEMETRY | TOKEN | SEGMENT | MY_SEGMENT;
export type MY_LARGE_SEGMENT = 'mls';
export type OperationType = SPLITS | IMPRESSIONS | IMPRESSIONS_COUNT | EVENTS | TELEMETRY | TOKEN | SEGMENT | MY_SEGMENT | MY_LARGE_SEGMENT;

export type LastSync = Partial<Record<OperationType, number | undefined>>
export type HttpErrors = Partial<Record<OperationType, { [statusCode: string]: number }>>
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const TELEMETRY = 'te';
export const TOKEN = 'to';
export const SEGMENT = 'se';
export const MY_SEGMENT = 'ms';
export const MY_LARGE_SEGMENT = 'mls';

export const TREATMENT = 't';
export const TREATMENTS = 'ts';
Expand Down
Loading