Skip to content

Commit

Permalink
FullStory: Skip setup for Elasticians (elastic#171041)
Browse files Browse the repository at this point in the history
(cherry picked from commit 19da2d5)
  • Loading branch information
afharo committed Nov 13, 2023
1 parent c767ae2 commit 95db7d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ describe('Cloud Plugin', () => {
const setupPlugin = async ({
config = {},
isCloudEnabled = true,
isElasticStaffOwned = false,
}: {
config?: Partial<CloudFullStoryConfigType>;
isCloudEnabled?: boolean;
isElasticStaffOwned?: boolean;
}) => {
const initContext = coreMock.createPluginInitializerContext(config);

const plugin = new CloudFullStoryPlugin(initContext);

const coreSetup = coreMock.createSetup();

const cloud = { ...cloudMock.createSetup(), isCloudEnabled };
const cloud = { ...cloudMock.createSetup(), isCloudEnabled, isElasticStaffOwned };

plugin.setup(coreSetup, { cloud });

Expand Down Expand Up @@ -61,6 +63,15 @@ describe('Cloud Plugin', () => {
expect(coreSetup.analytics.registerShipper).not.toHaveBeenCalled();
});

it('does set up FullStory when isCloudEnabled=true but the deployment is owned by an Elastician', async () => {
const { coreSetup } = await setupPlugin({
config: { org_id: 'foo' },
isCloudEnabled: true,
isElasticStaffOwned: true,
});
expect(coreSetup.analytics.registerShipper).not.toHaveBeenCalled();
});

it('does not call initializeFullStory when org_id is undefined', async () => {
const { coreSetup } = await setupPlugin({ config: {} });
expect(coreSetup.analytics.registerShipper).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export class CloudFullStoryPlugin implements Plugin {

public setup(core: CoreSetup, { cloud }: CloudFullStorySetupDeps) {
if (cloud.isCloudEnabled) {
if (cloud.isElasticStaffOwned) {
this.initializerContext.logger
.get()
.info('Skipping FullStory setup for a Elastic-owned deployments');
return;
}
this.setupFullStory({ analytics: core.analytics, basePath: core.http.basePath }).catch((e) =>
// eslint-disable-next-line no-console
console.debug(`Error setting up FullStory: ${e.toString()}`)
Expand Down

0 comments on commit 95db7d6

Please sign in to comment.