Skip to content

Commit

Permalink
Move backwards compatible fields to the shipper's implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Apr 12, 2022
1 parent 92d4f92 commit aeedc22
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
14 changes: 3 additions & 11 deletions packages/elastic-analytics/src/events/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,16 @@ export interface EventContext {
version?: string;
/**
* The name of the current page.
* @remarks We need to keep this for backwards compatibility because it was provided by previous implementations of FullStory.
*/
pageName?: string;
/**
* The current page.
* @remarks We need to keep this for backwards compatibility because it was provided by previous implementations of FullStory.
*/
page?: string;
/**
* The current application ID.
* @remarks We need to keep this for backwards compatibility because it was provided by previous implementations of FullStory.
*/
app_id?: string;
applicationId?: string;
/**
* The current entity ID.
* @remarks We need to keep this for backwards compatibility because it was provided by previous implementations of FullStory.
* The current entity ID (dashboard ID, visualization ID, etc.).
*/
ent_id?: string;
entityId?: string;
// TODO: Extend with known keys
[key: string]: unknown;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export class FullStoryShipper implements IShipper {

// Event-level context. At the moment, only the scope `page` is supported by FullStory for webapps.
if (Object.keys(nonUserContext).length) {
// Keeping these fields for backwards compatibility.
if (nonUserContext.applicationId) nonUserContext.app_id = nonUserContext.applicationId;
if (nonUserContext.entityId) nonUserContext.ent_id = nonUserContext.entityId;

this.initContext.logger.debug(
`Calling FS.setVars with context ${JSON.stringify(nonUserContext)}`
);
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/cloud/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ export class CloudPlugin implements Plugin<CloudSetup> {
// Update the current context every time it changes
map(({ name, page, id }) => ({
pageName: `${compact([name, page]).join(':')}`,
app_id: name ?? 'unknown',
applicationId: name ?? 'unknown',
page,
ent_id: id,
entityId: id,
}))
),
schema: {
Expand All @@ -343,11 +343,11 @@ export class CloudPlugin implements Plugin<CloudSetup> {
type: 'keyword',
_meta: { description: 'The current page', optional: true },
},
app_id: {
applicationId: {
type: 'keyword',
_meta: { description: 'The id of the current application' },
},
ent_id: {
entityId: {
type: 'keyword',
_meta: {
description:
Expand Down

0 comments on commit aeedc22

Please sign in to comment.