Skip to content

Commit b290dd5

Browse files
committed
add sdk log auth header
1 parent 6e14913 commit b290dd5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/utils/logger.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ZalgoPromise } from '@krakenjs/zalgo-promise/src';
88
import { getGlobalUrl } from './global';
99
import { request } from './miscellaneous';
1010

11-
import { getLibraryVersion, getDisableSetCookie } from './sdk';
11+
import { getLibraryVersion, getDisableSetCookie, getClientId } from './sdk';
1212

1313
function generateLogPayload(account, { meta, events: bizEvents, tracking }) {
1414
const { deviceID, sessionID, integration_type, messaging_version } = meta.global ?? {};
@@ -212,3 +212,14 @@ logger.addTrackingBuilder(() => {
212212
timestamp: new Date().getTime()
213213
};
214214
});
215+
216+
logger.addHeaderBuilder(() => {
217+
if (__MESSAGES__.__TARGET__ === 'SDK') {
218+
const encodedClientId = btoa(getClientId());
219+
return {
220+
// Send authorization header with tracking event
221+
authorization: `Basic ${encodedClientId}`
222+
};
223+
}
224+
return null;
225+
});

src/utils/sdk.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export function getAccount() {
7171
return undefined;
7272
}
7373
}
74+
75+
export function getClientId() {
76+
return getClientID();
77+
}
78+
7479
export function getPageType() {
7580
if (__MESSAGES__.__TARGET__ === 'SDK') {
7681
return getSDKPageType();

0 commit comments

Comments
 (0)