Squid.getInstance constructor

Squid.getInstance({
  1. required AppId appId,
  2. required SupportedSquidRegion region,
  3. ApiKey? apiKey,
  4. EnvironmentId? environmentId,
  5. SquidDeveloperId? squidDeveloperId,
  6. MessageNotificationWrapper? messageNotificationWrapper,
  7. Map<IntegrationId, String>? apiServerUrlOverrideMapping,
})

Enables debug logging for the Squid Client SDK. Returns the global Squid instance with the given options, creating a new Squid instance if one with the same options does not exist.

Implementation

factory Squid.getInstance({
  /// The application ID that is used to identify the application in Squid.
  /// The ID can be found in the Squid Cloud Console.
  required AppId appId,

  /// The application API key, using the API key can be used to bypass security
  /// rules and other restrictions. The API key can be found in the
  /// Squid Cloud Console.
  required SupportedSquidRegion region,

  /// The region that the application is running in. This is used to determine
  /// the URL of the Squid Cloud API.
  ApiKey? apiKey,

  /// The environment ID to work with, if not specified the default
  /// environment (prod) will be used.
  EnvironmentId? environmentId,

  ///The user ID of the developer that runs the environment locally.
  SquidDeveloperId? squidDeveloperId,

  /// A function that can be used to wrap messages coming from Squid to the
  /// application. This is useful for different frameworks that need to wrap
  /// messages in order to detect changes (like Angular).
  MessageNotificationWrapper? messageNotificationWrapper,

  /// A list of API endpoints that can be used for overriding the default API
  /// endpoints for the different integrations. This is useful for APIs that
  /// have multiple base urls hosted in different regions.
  Map<IntegrationId, String>? apiServerUrlOverrideMapping,
}) {
  final options = SquidOptions(
      appId: appId,
      region: region,
      apiKey: apiKey,
      environmentId: environmentId,
      squidDeveloperId: squidDeveloperId,
      messageNotificationWrapper: messageNotificationWrapper,
      apiServerUrlOverrideMapping: apiServerUrlOverrideMapping);
  if (_instances.containsKey(options)) {
    return _instances[options]!;
  }
  final instance = Squid(options);
  _instances[options] = instance;
  return instance;
}