SEOmatic: Change type of mainEntity With SEOmatic I want to be able to dynamically change the type of my mainEntity, which defaults to &quot;Webpage&quot; and in some cases I want to change it to &quot;Event&quot;
In an older project I did this:
{% do seomatic.jsonLd.get('mainEntityOfPage').type('Event') %}

But if I dump the mainEntity again, nothing has changed:
{% dd seomatic.jsonLd.get('mainEntityOfPage') %}

It's still a nystudio107\seomatic\models\jsonld\WebPage#1
How can I achieve this?
I'm using Craft 3.4.30 with Seomatic 3.3.35
So you can't just change the type of the mainEntityOfPage because there's a unique PHP class for each schema.org type.
What I would typically recommend here is that you set up the mappings via Content SEO (which lets you set up a different mainEntityOfPage per entry type) or you use the SEO Settings field to allow for per-entry changing of the mainEntityOfPage.
But if you really want to do it dynamically via Twig, you can. You just need to create a new object.
{% do seomatic.jsonLd.create({
    'key': 'mainEntityOfPage',
    'type': 'Whatever',
{# fill in other properties here #}
}) %}