Skip to content

Commit

Permalink
quick fix (#2342)
Browse files Browse the repository at this point in the history
  • Loading branch information
Karlie-777 committed May 7, 2024
1 parent 8d2c416 commit df11b4c
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 238 deletions.
9 changes: 9 additions & 0 deletions channels/1ds-post-js/src/HttpManager.ts
Expand Up @@ -331,6 +331,15 @@ export class HttpManager {
}

_self.getOfflineRequestDetails = () => {
try {
// get current url without paramter
let payload = _serializer && _serializer.createPayload(0, false, false, false, SendRequestReason.NormalSchedule, EventSendType.Batched);
return _buildRequestDetails(payload, _useHeaders);

} catch(e) {
// eslint-disable-next-line no-empty
}

return null;
}

Expand Down
10 changes: 7 additions & 3 deletions channels/1ds-post-js/src/PostChannel.ts
Expand Up @@ -6,8 +6,8 @@
import dynamicProto from "@microsoft/dynamicproto-js";
import {
BaseTelemetryPlugin, EventLatencyValue, EventSendType, EventsDiscardedReason, IAppInsightsCore, IChannelControls, IConfigDefaults,
IExtendedConfiguration, IInternalOfflineSupport, IPayloadData, IPlugin, IProcessTelemetryContext, IProcessTelemetryUnloadContext,
ITelemetryItem, ITelemetryUnloadState, IUnloadHook, NotificationManager, SendRequestReason, _eInternalMessageId, _throwInternal,
IExtendedConfiguration, IInternalOfflineSupport, IPlugin, IProcessTelemetryContext, IProcessTelemetryUnloadContext, ITelemetryItem,
ITelemetryUnloadState, IUnloadHook, NotificationManager, SendRequestReason, _eInternalMessageId, _throwInternal,
addPageHideEventListener, addPageShowEventListener, addPageUnloadEventListener, arrForEach, createProcessTelemetryContext,
createUniqueNamespace, doPerf, eLoggingSeverity, getWindow, isChromium, isGreaterThanZero, isNumber, mergeEvtNamespace, objForEachKey,
onConfigChange, optimizeObject, proxyFunctions, removePageHideEventListener, removePageShowEventListener, removePageUnloadEventListener,
Expand Down Expand Up @@ -239,7 +239,11 @@ export class PostChannel extends BaseTelemetryPlugin implements IChannelControls
if (_httpManager) {
return {
getUrl: () => {
return details.url
if (details) {
return details.url

}
return null;
},
serialize: _serialize,
batch: _batch,
Expand Down
3 changes: 2 additions & 1 deletion channels/1ds-post-js/test/Unit/src/HttpManagerTest.ts
Expand Up @@ -222,7 +222,8 @@ export class HttpManagerTest extends AITestClass {
QUnit.assert.equal(evtStr, `{"name":"testEvent","iKey":"o:testKey","data":{"baseData":{}}}`,"Event should be serialized");

QUnit.assert.ok(manager.getOfflineRequestDetails, "request details function should exist");
QUnit.assert.equal(manager.getOfflineRequestDetails(), null, "request details function should return null for 1ds");
QUnit.assert.ok(manager.getOfflineRequestDetails(), "request details should set");
QUnit.assert.equal(manager.getOfflineRequestDetails().url, "testEndpoint?cors=true&content-type=application/x-json-stream&w=0", "details url should be set");
let details = manager.createOneDSPayload([evt]);
let headers = details.headers || {};
let apiKey = headers["apikey"];
Expand Down
3 changes: 3 additions & 0 deletions channels/1ds-post-js/test/Unit/src/PostChannelTest.ts
Expand Up @@ -302,6 +302,9 @@ export class PostChannelTest extends AITestClass {
let eventStr = offlineSupport.serialize(event);
let expectedStr = `{"name":"testEvent","iKey":"o:testIkey","data":{"baseData":{}}}`;
QUnit.assert.equal(eventStr, expectedStr, "get expected string");

let url = offlineSupport.getUrl();
QUnit.assert.equal(url, "https://testEndpoint?cors=true&content-type=application/x-json-stream&w=0", "get expected url string");

QUnit.assert.ok(offlineSupport.batch, "batch should exit");
let batch = offlineSupport.batch([expectedStr, expectedStr]);
Expand Down

0 comments on commit df11b4c

Please sign in to comment.