Skip to content

#CX-23917 : Use pre-login API on JS sdk for pre-login metrics#4795

Closed
Hu4k3n wants to merge 3 commits intowebex:nextfrom
Hu4k3n:arsyam/CX-23917
Closed

#CX-23917 : Use pre-login API on JS sdk for pre-login metrics#4795
Hu4k3n wants to merge 3 commits intowebex:nextfrom
Hu4k3n:arsyam/CX-23917

Conversation

@Hu4k3n
Copy link
Copy Markdown

@Hu4k3n Hu4k3n commented Mar 23, 2026

COMPLETES

https://jira-eng-sjc12.cisco.com/jira/browse/CX-23917

This pull request addresses

< DESCRIBE THE CONTEXT OF THE ISSUE >
The keys for the business event schema were written wrong. this is fixing it as part of the pre login metrics story

by making the following changes

updating the buisiness event parameters
< DESCRIBE YOUR CHANGES >

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Make sure to have followed the contributing guidelines before submitting.

@Hu4k3n Hu4k3n requested review from a team as code owners March 23, 2026 09:51
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04a3ab1500

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +83 to +87
key: name,
client_timestamp: new Date().toISOString(),
context: this.getContext(),
timestamp: new Date().getTime(),
browserDetails: this.getBrowserDetails(),
...metadata,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent metadata from overriding reserved business fields

submitPreLoginEvent() treats metadata as caller-controlled input, but buildEvent() spreads it after key, client_timestamp, context, and browserDetails. In any JS caller (or TS caller using as any), values like metadata.key or metadata.client_timestamp will silently replace the SDK-generated fields, causing the event to be attributed to the wrong metric or to carry an invalid timestamp. This regression is new to the pre-login path because the old code only merged metadata into eventPayload.value.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0822ab70a8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

eventPayload: {
metricName,
browserDetails: this.getBrowserDetails(),
...metadata,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reserve originTime before spreading pre-login metadata

Because metadata is now copied directly onto eventPayload, a caller can pass metadata.originTime with any truthy scalar (this is valid under EventPayload). PreLoginMetricsBatcher.prepareRequest() later does item.eventPayload.originTime = item.eventPayload.originTime || {}; item.eventPayload.originTime.sent = ... in packages/@webex/internal-plugin-metrics/src/prelogin-metrics-batcher.ts, which will throw in module/strict mode when originTime is a string or boolean. Before this change, metadata stayed under eventPayload.value, so arbitrary metadata keys could not break batching.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the extra meta data not be inside 'value' anyway?

Maybe we should look at an existing prelogin metric from webex to check?

Comment thread packages/@webex/internal-plugin-metrics/src/metrics.types.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: efbe281bfd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

eventPayload: {
metricName,
browserDetails: this.getBrowserDetails(),
...metadata,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Block metadata.event from corrupting pre-login batch items

Spreading caller metadata directly into eventPayload lets a valid EventPayload like metadata.event = true escape into the batch item shape. In paired-device environments, prepareDiagnosticMetricItem() later writes item.eventPayload.event.pairingState/pairedDevice, which throws when event is a scalar, causing pre-login metric submission to fail for that request. Before this change, metadata stayed under eventPayload.value, so user metadata could not collide with the batcher’s internal event object.

Useful? React with 👍 / 👎.

@Hu4k3n Hu4k3n closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants