[LaunchDarkly] Unhashed deploymentId as userId (#159597)

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Alejandro Fernández Haro 2023-06-14 19:52:14 +02:00 committed by GitHub
parent 5776e97d9c
commit 4172236eb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 16 deletions

View file

@ -168,7 +168,7 @@ xpack.cloud_integrations.experiments.flag_overrides:
### How is my user identified?
The user is automatically identified during the `setup` phase. It currently uses a hash of the deployment ID, meaning all users accessing the same deployment will get the same values for the `getVariation` requests unless the A/B provider is explicitly configured to randomize it.
The user is automatically identified during the `setup` phase. It currently uses the ESS deployment ID, meaning all users accessing the same deployment will get the same values for the `getVariation` requests unless the A/B provider is explicitly configured to randomize it.
If you are curious of the data provided to the `identify` call, you can see that in the [`cloud` plugin](../../cloud).

View file

@ -131,7 +131,7 @@ describe('Cloud Experiments public plugin', () => {
isElasticStaff: true,
kibanaVersion: 'version',
trialEndDate: '2020-10-01T14:13:12.000Z',
userId: '1c2412b751f056aef6e340efa5637d137442d489a4b1e3117071e7c87f8523f2',
userId: 'mock-deployment-id',
});
});
});

View file

@ -9,7 +9,6 @@ import type { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from '@kb
import { get, has } from 'lodash';
import { duration } from 'moment';
import { concatMap } from 'rxjs';
import { Sha256 } from '@kbn/crypto-browser';
import type { CloudSetup, CloudStart } from '@kbn/cloud-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import { LaunchDarklyClient, type LaunchDarklyClientConfig } from './launch_darkly_client';
@ -78,9 +77,9 @@ export class CloudExperimentsPlugin
* @param deps {@link CloudExperimentsPluginSetupDeps}
*/
public setup(core: CoreSetup, deps: CloudExperimentsPluginSetupDeps) {
if (deps.cloud.isCloudEnabled && deps.cloud.cloudId && this.launchDarklyClient) {
if (deps.cloud.isCloudEnabled && deps.cloud.deploymentId && this.launchDarklyClient) {
this.metadataService.setup({
userId: sha256(deps.cloud.cloudId),
userId: deps.cloud.deploymentId,
kibanaVersion: this.kibanaVersion,
trialEndDate: deps.cloud.trialEndDate?.toISOString(),
isElasticStaff: deps.cloud.isElasticStaffOwned,
@ -156,7 +155,3 @@ export class CloudExperimentsPlugin
}
};
}
function sha256(str: string) {
return new Sha256().update(str, 'utf8').digest('hex');
}

View file

@ -116,7 +116,7 @@ describe('Cloud Experiments server plugin', () => {
).mock.instances[0];
advance(100); // Remove the debounceTime effect
expect(launchDarklyInstanceMock.updateUserMetadata).toHaveBeenCalledWith({
userId: '1c2412b751f056aef6e340efa5637d137442d489a4b1e3117071e7c87f8523f2',
userId: 'deployment-id',
kibanaVersion: coreMock.createPluginInitializerContext().env.packageInfo.version,
isElasticStaff: true,
trialEndDate: expect.any(String),

View file

@ -13,7 +13,6 @@ import type {
Logger,
} from '@kbn/core/server';
import { get, has } from 'lodash';
import { createSHA256Hash } from '@kbn/crypto';
import type { LogMeta } from '@kbn/logging';
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server';
import type { CloudSetup } from '@kbn/cloud-plugin/server';
@ -84,10 +83,10 @@ export class CloudExperimentsPlugin
}));
}
if (deps.cloud.isCloudEnabled && deps.cloud.cloudId) {
if (deps.cloud.isCloudEnabled && deps.cloud.deploymentId) {
this.metadataService.setup({
// We use the Cloud ID as the userId in the Cloud Experiments
userId: createSHA256Hash(deps.cloud.cloudId),
// We use the Cloud Deployment ID as the userId in the Cloud Experiments
userId: deps.cloud.deploymentId,
kibanaVersion: this.initializerContext.env.packageInfo.version,
trialEndDate: deps.cloud.trialEndDate?.toISOString(),
isElasticStaff: deps.cloud.isElasticStaffOwned,

View file

@ -15,9 +15,7 @@
"@kbn/data-views-plugin",
"@kbn/usage-collection-plugin",
"@kbn/cloud-plugin",
"@kbn/crypto-browser",
"@kbn/config-schema",
"@kbn/crypto",
"@kbn/logging",
"@kbn/logging-mocks",
"@kbn/utility-types",