Skip to content

[BUG] TypeScript error with $opt_event_properties #303

@TwisterMc

Description

@TwisterMc

Is there an existing issue for this?

  • I have searched the existing issues

SDK Version

Source: https://docs.developers.optimizely.com/feature-experimentation/docs/usetrackevent-react

When you look at the example code it says:

  const [track] = useTrackEvent()

// Define event properties
  const properties = {
    "category": "shoes",
    "color": "red"
  };

  // Define tags including event properties
  const tags = {
    "revenue": 10000,
    "value": 100.00,
    "$opt_event_properties": properties
  };

  // Track event with tags
  track("signup-clicked", tags);

However, if you add that code to a TypeScript project, utilizing the useTrackEvent hook, it expects $opt_event_properties: properties to be a string.

Image

Current Behavior

Code is throwing a TypeScript error.

Expected Behavior

Code should not throw a TypeScript error.

Steps To Reproduce

  1. Paste the example code from https://docs.developers.optimizely.com/feature-experimentation/docs/usetrackevent-react into a TypeScript project.
  2. See error

React Framework

NextJS 13.5.6

Browsers impacted

No response

Link

No response

Logs

No response

Severity

No response

Workaround/Solution

No response

Recent Change

No response

Conflicts

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions