How to see AuditEvent collection in for my app in Atlas

I want to integrate Event Library for iOS App. I have enabled the Event Recording and set Default Event Configuration. Now I was expecting AuditEvent Collection in my Atlas. So I looked all over the Atlas but could not find the collection AuditEvent. I following this tutorial to integrate the Event Library.
Please help me in finding the AuditEvent in my Atlas. Thanks in Advance.

Hey Adityha - what tutorial were you following to integrate the Event Library? Is there a link I can check out to see what you were doing?

Without more information, it’s hard to say what the issue might be. Here are a few things you could check out:

  • Do you have Development Mode enabled in your Device Sync configuration? That must be enabled to automatically create the AuditEvent collection - otherwise, you’d need to create this collection manually. If Development Mode is enabled, the AuditEvent collection should appear in the database you specify in your Device Sync configuration - but only when you successfully Sync some AuditEvent objects.
  • What version of the Realm Swift SDK are you using? There were a couple of releases where the Events API had an issue - that issue has been resolved in v10.37.2 or higher. If you’re trying to use one of the versions where the Events API has an issue, no events are getting created.
  • Are you holding the connection open long enough to Sync the event objects? If you’re testing the Events API in unit/integration tests, the Sync connection could close before the objects get a chance to sync. When I’m testing Events, I add a sleep() delay to keep the test open/hold open the Sync connection long enough for the objects to Sync.

Hopefully one of these things helps solve your issue. Otherwise, let us know what tutorial you’re trying to follow so we can try to spot the issue.

Hi Dachary_Carey,
Thanks for your replay. I was following the tutorial [https://www.mongodb.com/docs/realm/sdk/swift/sync/event-library/](https://Event Library Tutorial)…

  1. I have made development mode On.
  2. I could not find the Version of SDK but I have added it my Project via adding swift Package manager and used “Up to next major version”.
    Now my question was where I can see the AuditEvent collection in Atlasstrong text. My syncing is working fine and its bidirectional. I was looking to integrate the Event Library SDK and followed the tutorial https://www.mongodb.com/docs/realm/sdk/swift/sync/event-library/. but was unable to find the AuditEvent collection. Could you please share some screenshots or path so that I can understand where it is appearing. Thanks in Advance.

If you’re using Xcode you should be able to see the version of the SDK you’ve currently got installed under Package Dependencies in the Project navigator. It should give you a version number that would look something like:
> Realm 10.38.0
> RealmDatabase 13.9.0

If you’re using the default configuration and your Realm version is between 10.26.0 and 10.37.2, or if you’re not using the default configuration but are using async open and your realm version is 10.37.2, you should update to the latest version and try running your code again. You can update just the Realm package by right-clicking Realm in the Package Dependencies and selecting Update Package, or you can update all of your project’s dependencies from File > Packages > Update to Latest Package Versions.

The AuditEvent collection should appear in Atlas. If you go to your Atlas project where you’ve got your App Services App set up, and select the Data Services tab, then select Collections and open the development database you’re using in your Device Sync configuration. After you successfully sync some AuditEvent objects, you will see the collection in your development database, and when you open the collection, you should see AuditEvent objects.

Hi Dachary_Carey,
I have checked and found that I using below versions of Realm.
> Realm 10.38.0
> RealmDatabase 13.9.0
But I still can not see AuditEvent collection in under Data Services tab. I’m using below code for enabling recoding and configuratin:

To enable event recording, set the Event.Configuration property on the Realm.Configuration

let eventSyncUser = try await app.login(credentials: Credentials.anonymous)
var config = user.configuration(partitionValue: "Some partition value")
config.eventConfiguration = EventConfiguration(metadata: ["username": "Jason Bourne"], syncUser: eventSyncUser, partitionPrefix: "event-")

But still I can not see the AuditEvent collection under DataServices tab in Atlas. I’m attaching some screenshots for your reference.

. also I want to add that I’m using free version M0 of Atlas sync.

The example code you’re using from the documentation has an arbitrary partitionValue and EventConfiguration which may not match how your App Services app is configured.

  • In your Device Sync configuration, are you using Partition-Based Sync or Flexible Sync? What rules are you using for data access?
  • In your App Services logs, do you see any error messages when you try to write to the synced realm?
  • Are you able to confirm that the objects you’re writing to the synced realm are syncing? If you’re creating Task or Note objects in the app where you’re trying to use the Event Library, do you see those objects synced in Atlas?

Hi,
1.I’m using Flexible Sync for sync.
2. No error message while writing or syncing the data.
3. Yes, In my case I was able to sync the Task and Notes and sync was working perfectly fine.
I Integrated this Event Library before adding Subscription.
Could you please share a sample code so that I can understand, what mistake I have done.

Ahh, then it sounds like the user configuration you posted above isn’t getting used at all.

This example from the docs initializes a Sync configuration for Partition-Based Sync:

let eventSyncUser = try await app.login(credentials: Credentials.anonymous)
var config = user.configuration(partitionValue: "Some partition value")
config.eventConfiguration = EventConfiguration(metadata: ["username": "Jason Bourne"], syncUser: eventSyncUser, partitionPrefix: "event-")

If you’re using Flexible Sync successfully, then this configuration isn’t getting used at all. This EventLibrary configuration example builds on the example in the docs of opening a Synced Realm for Partition-Based Sync. If you’re using Flexible Sync and the objects are syncing, you’ve probably got something like this configuration somewhere else in your codebase:

var config = user.flexibleSyncConfiguration()

The .flexibleSyncConfiguration() opens a realm for Flexible Sync, and the .configuration(partitionValue: [YOUR PARTITION VALUE]) from the Event Library example opens a realm for Partition-Based Sync. Those two things don’t work together. If your App Services App uses Flexible Sync and you are successfully syncing objects, then the Partition-Based Sync config you’ve pasted here isn’t getting used at all and that’s why you’re not seeing the AuditEvent collection in Atlas.

I’ve just confirmed with the Product team that the Event Library does not work with Flexible Sync, so this functionality isn’t currently supported.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.