23
const endpointHealthUrl = 'https://mobile.events.data.microsoft.com/ping';
24
25
>
async function getClient(instrumentationKey: string, addInternalFlag?: boolean, xhrOverride?: IXHROverride): Promise<IAppInsightsCore> {
1dsAppender.ts
26
>
// eslint-disable-next-line local/code-amd-node-module
27
>
const oneDs = isWeb ? await importAMDNodeModule<typeof import('@microsoft/1ds-core-js')>('@microsoft/1ds-core-js', 'bundle/ms.core.min.js') : await import('@microsoft/1ds-core-js');
28
>
// eslint-disable-next-line local/code-amd-node-module
29
>
const postPlugin = isWeb ? await importAMDNodeModule<typeof import('@microsoft/1ds-post-js')>('@microsoft/1ds-post-js', 'bundle/ms.post.min.js') : await import('@microsoft/1ds-post-js');
30
>
31
>
const appInsightsCore = new oneDs.AppInsightsCore();
32
>
const collectorChannelPlugin: PostChannel = new postPlugin.PostChannel();
33
>
// Configure the app insights core to send to collector++ and disable logging of debug info
34
>
const coreConfig: IExtendedConfiguration = {
35
>
instrumentationKey,
36
>
endpointUrl,
37
>
loggingLevelTelemetry: 0,
38
>
loggingLevelConsole: 0,
39
>
disableCookiesUsage: true,
40
>
disableDbgExt: true,
41
>
disableInstrumentationKeyValidation: true,
42
>
channels: [[
43
>
collectorChannelPlugin
44
>
]]
45
>
};
46
>
47
>
if (xhrOverride) {
48
>
coreConfig.extensionConfig = {};
49
>
// Configure the channel to use a XHR Request override since it's not available in node
50
>
const channelConfig: IChannelConfiguration = {
51
>
alwaysUseXhrOverride: true,
52
>
ignoreMc1Ms0CookieProcessing: true,
53
>
httpXHROverride: xhrOverride
54
>
};
55
>
coreConfig.extensionConfig[collectorChannelPlugin.identifier] = channelConfig;
56
>
}
57
>
58
>
appInsightsCore.initialize(coreConfig, []);
59
>
60
>
appInsightsCore.addTelemetryInitializer((envelope) => {
61
// Opt the user out of 1DS data sharing
62
envelope['ext'] = envelope['ext'] ?? {};