Skip to content
Open
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
14 changes: 13 additions & 1 deletion src/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ZalgoPromise } from '@krakenjs/zalgo-promise/src';
import { getGlobalUrl } from './global';
import { request } from './miscellaneous';

import { getLibraryVersion, getDisableSetCookie } from './sdk';
import { getLibraryVersion, getDisableSetCookie, getClientId } from './sdk';

function generateLogPayload(account, { meta, events: bizEvents, tracking }) {
const { deviceID, sessionID, integration_type, messaging_version } = meta.global ?? {};
Expand Down Expand Up @@ -173,6 +173,18 @@ export const logger = Logger({
? `${url}?disableSetCookie=true&features=disable-set-cookie`
: url;

// Send authorization header with tracking event
if (__MESSAGES__.__TARGET__ === 'SDK') {
const encodedClientId = btoa(getClientId());
// eslint-disable-next-line no-param-reassign
headers.Authorization = `Basic ${encodedClientId}`;
}
if (__MESSAGES__.__TARGET__ === 'STANDALONE' || __MESSAGES__.__TARGET__ === 'STANDALONE_MODAL') {
const encodedPayerId = btoa(trimmedMeta['1'].account);
// eslint-disable-next-line no-param-reassign
headers.Authorization = `Basic ${encodedPayerId}`;
}

return ZalgoPromise.all(
translateLogData(trimmedLog).map(data => {
return request(method, urlWithCookieParams, {
Expand Down
9 changes: 9 additions & 0 deletions src/utils/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ export function getAccount() {
return undefined;
}
}

export function getClientId() {
if (__MESSAGES__.__TARGET__ === 'SDK') {
return getClientID();
} else {
return undefined;
}
}

export function getPageType() {
if (__MESSAGES__.__TARGET__ === 'SDK') {
return getSDKPageType();
Expand Down
Loading